优化道具获取检视界面的ux逻辑(与balloon同时退出);ground 场景下 debug 时直接通过 main 场景启动
This commit is contained in:
parent
5e0183a8a4
commit
eaa51620e1
@ -78,8 +78,9 @@ func check_autosave_options():
|
||||
autosave_timer.start()
|
||||
if GlobalConfig.DEBUG:
|
||||
print(
|
||||
"check_autosave_options:",
|
||||
"check_autosave_option: ",
|
||||
GlobalConfigManager.config.auto_save_enabled,
|
||||
" wait_time=",
|
||||
autosave_timer.wait_time
|
||||
)
|
||||
|
||||
|
@ -28,11 +28,6 @@ func get_ground() -> Ground2D:
|
||||
var loader = get_ground_loader()
|
||||
if loader:
|
||||
return loader.ground
|
||||
# 在 editor 编辑时,ground 在 Section 节点下
|
||||
var root = get_node("/root")
|
||||
for child in root.get_children():
|
||||
if child.name.begins_with("S0") or child.name.begins_with("S1"):
|
||||
return child.get_node_or_null("Ground") as Ground2D
|
||||
return null
|
||||
|
||||
|
||||
@ -73,7 +68,7 @@ func focus_player() -> void:
|
||||
ground.focus_player()
|
||||
|
||||
|
||||
func focus_player_and_reset_zoom(duration := .5) -> void:
|
||||
func focus_player_and_reset_zoom(duration := 1) -> void:
|
||||
var marker = get_camera_marker()
|
||||
if marker:
|
||||
marker.tween_zoom(1.0, duration).tween_callback(focus_player)
|
||||
@ -152,35 +147,9 @@ func pop_debug_dialog_info(character: String, content: String):
|
||||
|
||||
#### Prop ####
|
||||
|
||||
var hud_path = ""
|
||||
|
||||
|
||||
func get_prop_hud() -> PropHud:
|
||||
var hud = get_node_or_null("/root/Main/UILayer/PropHUD") as PropHud
|
||||
if hud:
|
||||
return hud
|
||||
if hud_path:
|
||||
hud = get_node_or_null(hud_path) as PropHud
|
||||
if hud:
|
||||
return hud
|
||||
else:
|
||||
hud_path = ""
|
||||
# 如果在 debug 模式从其他场景启动,没有 HUD 但又要获取,就新建 hud 放进场景
|
||||
var ground = get_ground()
|
||||
if ground:
|
||||
var parent = ground.get_parent()
|
||||
if parent:
|
||||
var layer = CanvasLayer.new()
|
||||
layer.layer = GlobalConfig.CANVAS_LAYER_UI
|
||||
layer.name = "UILayer"
|
||||
hud = preload("res://scene/prop/prop_hud.tscn").instantiate()
|
||||
hud.name = "PropHUD"
|
||||
layer.add_child(hud)
|
||||
hud.inventory = ArchiveManager.archive.prop_inventory
|
||||
parent.call_deferred("add_child", layer)
|
||||
hud_path = str(parent.get_path()) + "/UILayer/PropHUD"
|
||||
print("New HUD path:", hud_path)
|
||||
return hud
|
||||
return get_node_or_null("/root/Main/UILayer/PropHUD") as PropHud
|
||||
|
||||
|
||||
func get_current_prop(must_selected: bool) -> String:
|
||||
|
@ -1,5 +1,7 @@
|
||||
extends CanvasLayer
|
||||
|
||||
signal manually_skipped_line
|
||||
|
||||
@export var force_locale :String:
|
||||
set(val):
|
||||
force_locale = val
|
||||
@ -46,10 +48,6 @@ var dialogue_line: DialogueLine:
|
||||
if not is_node_ready():
|
||||
await ready
|
||||
dialogue_line = next_dialogue_line
|
||||
# 如果是「音效: ...」,且不是 debug 模式,则直接跳过
|
||||
if dialogue_line.character == "音效" and not GlobalConfig.DEBUG:
|
||||
next(dialogue_line.next_id)
|
||||
return
|
||||
character_label.visible = not dialogue_line.character.is_empty()
|
||||
character_label.text = tr(dialogue_line.character, "dialogue")
|
||||
#主要角色颜色
|
||||
@ -127,6 +125,9 @@ var dialogue_line: DialogueLine:
|
||||
next(next_dialogue_line.next_id)
|
||||
# var time = next_dialogue_line.text.length() * 0.2 if next_dialogue_line.time == "auto" else next_dialogue_line.time.to_float()
|
||||
# await get_tree().create_timer(time).timeout
|
||||
# 如果当前 line 运行结束,则 queue free 释放资源
|
||||
if dialogue_line == next_dialogue_line:
|
||||
queue_free()
|
||||
|
||||
func _ready() -> void:
|
||||
layer = GlobalConfig.CANVAS_LAYER_DIALOG
|
||||
@ -162,10 +163,6 @@ func _setup_content_text() -> void:
|
||||
dialogue_line.text = text
|
||||
|
||||
|
||||
func _unhandled_input(_event: InputEvent) -> void:
|
||||
# Only the balloon is allowed to handle input while it's showing
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
func _notification(what: int) -> void:
|
||||
# Detect a change of locale and update the current dialogue line to show the new language
|
||||
if what == NOTIFICATION_TRANSLATION_CHANGED and is_instance_valid(dialogue_label):
|
||||
@ -196,10 +193,16 @@ func _on_mutated(_mutation: Dictionary) -> void:
|
||||
balloon.hide()
|
||||
)
|
||||
|
||||
|
||||
# func _unhandled_input(_event: InputEvent) -> void:
|
||||
# # Only the balloon is allowed to handle input while it's showing
|
||||
# get_viewport().set_input_as_handled()
|
||||
|
||||
|
||||
func _on_balloon_gui_input(event: InputEvent) -> void:
|
||||
# See if we need to skip typing of the dialogue
|
||||
if dialogue_label.is_typing:
|
||||
if event.is_action_pressed("interact"):
|
||||
if event.is_action_pressed("interact") or event.is_action_pressed("cancel"):
|
||||
dialogue_label.skip_typing()
|
||||
get_viewport().set_input_as_handled()
|
||||
return
|
||||
@ -208,15 +211,17 @@ func _on_balloon_gui_input(event: InputEvent) -> void:
|
||||
if dialogue_line.responses.size() > 0: return
|
||||
|
||||
# When there are no response options the balloon itself is the clickable thing
|
||||
get_viewport().set_input_as_handled()
|
||||
# get_viewport().set_input_as_handled()
|
||||
|
||||
#if event is InputEventMouseButton and event.is_pressed() and event.button_index == MOUSE_BUTTON_LEFT:
|
||||
#next(dialogue_line.next_id)
|
||||
#elif event.is_action_pressed(next_action) and get_viewport().gui_get_focus_owner() == balloon:
|
||||
#next(dialogue_line.next_id)
|
||||
|
||||
if event.is_action_pressed("interact"):
|
||||
if event.is_action_pressed("interact") or event.is_action_pressed("cancel"):
|
||||
# if event.is_action_pressed("interact") and get_viewport().gui_get_focus_owner() == balloon:
|
||||
get_viewport().set_input_as_handled()
|
||||
manually_skipped_line.emit()
|
||||
next(dialogue_line.next_id)
|
||||
|
||||
func _on_responses_menu_response_selected(response: DialogueResponse) -> void:
|
||||
|
@ -127,6 +127,7 @@ clip_contents = false
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 0
|
||||
mouse_filter = 2
|
||||
theme_override_colors/font_shadow_color = Color(0.306923, 0.306923, 0.306923, 0.388235)
|
||||
theme_override_constants/shadow_offset_y = 1
|
||||
theme_override_constants/shadow_offset_x = 1
|
||||
@ -154,13 +155,14 @@ mouse_filter = 2
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 8
|
||||
mouse_filter = 2
|
||||
theme_override_constants/separation = 2
|
||||
script = ExtResource("4_4netn")
|
||||
response_template = NodePath("ResponseExample")
|
||||
|
||||
[node name="ResponseExample" type="Button" parent="Balloon/Responses/ResponsesMenu"]
|
||||
layout_mode = 2
|
||||
mouse_filter = 1
|
||||
mouse_filter = 2
|
||||
text = "Response example"
|
||||
|
||||
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
|
||||
|
@ -89,7 +89,6 @@ func _show_os(res, title):
|
||||
|
||||
func _show_balloon(res, title):
|
||||
# SceneManager.focus_node(self)
|
||||
# SceneManager.get_camera_marker().tween_zoom(1.1, 1.5)
|
||||
DialogueManager.show_dialogue_balloon(res, title)
|
||||
# TODO note viewing animation
|
||||
SceneManager.freeze_player(0)
|
||||
|
@ -18,10 +18,10 @@ class_name CameraFocusMarker extends Marker2D
|
||||
# @export var limit_bottom := 158.0
|
||||
@export var limit_top := 0
|
||||
@export var limit_bottom := 316.0
|
||||
@export var zoom_ratio := 1.0
|
||||
|
||||
@onready var target = %Target as Node2D
|
||||
|
||||
var zoom_ratio := 1.0
|
||||
var zoom_tween: Tween
|
||||
|
||||
|
||||
|
@ -2,6 +2,8 @@
|
||||
class_name Ground2D extends Node2D
|
||||
|
||||
@export var scene_name := ""
|
||||
# 用于在 debug 时态下,指定进入的 portal
|
||||
@export_enum("left", "right", "1", "2", "3", "4", "5", "6", "7", "8", "9") var default_portal := "left"
|
||||
@export_group("Player", "player_")
|
||||
@export var player_y_fixed := true
|
||||
@export var player_y := 70:
|
||||
@ -44,23 +46,38 @@ const FOOTSTEP_AUDIO = {
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
foreground.layer = GlobalConfig.CANVAS_LAYER_FG
|
||||
_reset_player_positon()
|
||||
# 仅在编辑器中调试时,通过 main 场景启动
|
||||
if GlobalConfig.DEBUG and (not Engine.is_editor_hint()) and (not get_parent() is GroundLoader):
|
||||
call_deferred("_restart_from_main")
|
||||
return
|
||||
# 检查 scene_name 是否合法
|
||||
scene_name = scene_name.strip_edges()
|
||||
if not scene_name or scene_name.length() != 7:
|
||||
printerr("scene_name is not valid")
|
||||
return
|
||||
_reset_player_positon()
|
||||
if Engine.is_editor_hint():
|
||||
return
|
||||
# 如果 debug 模式下不通过 GroundLoader 启动,读取 palyer 位置
|
||||
if GlobalConfig.DEBUG and not get_parent() is GroundLoader:
|
||||
player.global_position.x = ArchiveManager.archive.player_global_position_x
|
||||
foreground.layer = GlobalConfig.CANVAS_LAYER_FG
|
||||
_set_camera_and_player_boundary()
|
||||
_load_footstep_audio()
|
||||
focus_player()
|
||||
# %ColorRectTop.visible = true
|
||||
# %ColorRectBottom.visible = true
|
||||
# 如果 debug 模式下不通过 GroundLoader 启动,则插入到 main 以下
|
||||
|
||||
|
||||
func _restart_from_main():
|
||||
var main = load("res://scene/main.tscn").instantiate()
|
||||
# if not main.is_node_ready():
|
||||
# await main.ready
|
||||
var ground_loader = main.get_node("./GroundLoader") as GroundLoader
|
||||
ground_loader.ignore_archive = false
|
||||
ground_loader.archive_scene = scene_name
|
||||
ground_loader.archive_portal = default_portal
|
||||
# ground_loader.transition_to_scene(scene_name, default_portal, true)
|
||||
get_node("/root").add_child(main)
|
||||
get_parent().queue_free()
|
||||
|
||||
|
||||
func _enter_tree() -> void:
|
||||
@ -126,3 +143,13 @@ func focus_node(node: CanvasItem) -> void:
|
||||
|
||||
func focus_player() -> void:
|
||||
focus_node(player)
|
||||
|
||||
|
||||
func move_player_to_portal(portal_name := default_portal) -> void:
|
||||
var portal_node = get_node_or_null("DeployLayer/portal_" + portal_name) as Node2D
|
||||
if portal_node:
|
||||
player.global_position.x = portal_node.global_position.x
|
||||
if GlobalConfig.DEBUG:
|
||||
print("move player to portal:", portal_name, portal_node.global_position)
|
||||
else:
|
||||
printerr(scene_name + " portal not found: " + portal_name)
|
||||
|
@ -16,6 +16,7 @@ func _ready() -> void:
|
||||
|
||||
[node name="Ground" type="Node2D"]
|
||||
script = ExtResource("1_0vrlo")
|
||||
default_portal = "left"
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
|
||||
|
@ -10,6 +10,7 @@ class_name GroundLoader extends Node2D
|
||||
debug_reload = false
|
||||
if is_node_ready() and current_scene and entrance_portal:
|
||||
transition_to_scene(current_scene, entrance_portal, true)
|
||||
# 强制覆盖 archive 记录
|
||||
@export var archive_scene := ""
|
||||
@export var archive_portal := ""
|
||||
|
||||
@ -32,7 +33,9 @@ func _ready() -> void:
|
||||
mask.color.a = 0.0
|
||||
# grounds
|
||||
_read_grounds()
|
||||
# ground = get_node_or_null("Ground")
|
||||
ground = get_node_or_null("Ground") as Ground2D
|
||||
if ground:
|
||||
ground.queue_free()
|
||||
# load save
|
||||
if not ignore_archive:
|
||||
_load_save()
|
||||
@ -62,14 +65,14 @@ func _load_save():
|
||||
archive_scene = ArchiveManager.archive.current_scene
|
||||
if ArchiveManager.archive.entrance_portal:
|
||||
archive_portal = ArchiveManager.archive.entrance_portal
|
||||
# 使用 archive 所记录的场景
|
||||
if archive_scene and archive_portal:
|
||||
# 强制覆盖 archive 记录
|
||||
if archive_scene or archive_portal:
|
||||
current_scene = archive_scene
|
||||
entrance_portal = archive_portal
|
||||
|
||||
|
||||
func _toggle_mask(display: bool, _immediately: bool) -> Tween:
|
||||
var tween = get_tree().create_tween()
|
||||
var tween = create_tween()
|
||||
if display:
|
||||
tween.tween_property(mask, "color:a", 1.0, 0.3).set_trans(Tween.TRANS_CUBIC)
|
||||
display_mask_time = Time.get_ticks_msec()
|
||||
@ -90,6 +93,7 @@ func transition_to_scene(scene_name: String, portal: String, immediately: bool)
|
||||
current_scene = scene_name
|
||||
entrance_portal = portal
|
||||
# 优先更新 archive,使 ground 可以访问自己的 current_scene 键值
|
||||
if not Engine.is_editor_hint():
|
||||
_update_archive()
|
||||
# 转场效果,在 _load_ground_node 之前播放
|
||||
var tween = _toggle_mask(true, immediately)
|
||||
@ -99,28 +103,20 @@ func transition_to_scene(scene_name: String, portal: String, immediately: bool)
|
||||
print("Scene not found: " + scene_name)
|
||||
|
||||
|
||||
func _update_player_position():
|
||||
if ignore_archive or Engine.is_editor_hint():
|
||||
return
|
||||
var player = SceneManager.get_player() as MainPlayer
|
||||
if player and ArchiveManager.archive:
|
||||
# if GlobalConfig.DEBUG:
|
||||
# print("update player position", ArchiveManager.archive.player_global_position)
|
||||
if ArchiveManager.archive.player_global_position_x >= 0:
|
||||
player.global_position.x = ArchiveManager.archive.player_global_position_x
|
||||
player.set_facing_direction(ArchiveManager.archive.player_direction)
|
||||
func _update_archive():
|
||||
ArchiveManager.archive.current_scene = current_scene
|
||||
ArchiveManager.archive.entrance_portal = entrance_portal
|
||||
archive_scene = current_scene
|
||||
archive_portal = entrance_portal
|
||||
|
||||
|
||||
func _do_transition(scene_name: String):
|
||||
# SceneManager.freeze_player(0)
|
||||
var ground_node = _load_ground_node(scene_name)
|
||||
if ground == ground_node:
|
||||
return
|
||||
if ground:
|
||||
# 提前移除,防止命名冲突
|
||||
remove_child(ground)
|
||||
# 不需要释放,因为会缓存,在 ground_node_cache 中释放
|
||||
# ground.queue_free()
|
||||
ground.queue_free()
|
||||
var ground_node = _load_ground_node(scene_name)
|
||||
# 先设置 ground,再添加到场景中
|
||||
# 因为 ground 在 enter_tree 时会用到 SceneManager 的方法
|
||||
# 其中间接用到了 GroundLoader 的 ground
|
||||
@ -135,30 +131,26 @@ func _do_transition(scene_name: String):
|
||||
func _add_ground():
|
||||
ground.name = "Ground"
|
||||
add_child(ground)
|
||||
if not Engine.is_editor_hint():
|
||||
var portal_node = ground.get_node_or_null("DeployLayer/portal_" + entrance_portal) as Node2D
|
||||
if portal_node:
|
||||
var player = SceneManager.get_player()
|
||||
if player:
|
||||
# player.global_position.x = -20.0
|
||||
player.global_position.x = portal_node.global_position.x
|
||||
if GlobalConfig.DEBUG:
|
||||
print("move player to portal:", entrance_portal, portal_node.global_position)
|
||||
else:
|
||||
printerr(current_scene + " portal not found: " + entrance_portal)
|
||||
# 更新玩家位置
|
||||
if first_entered and not Engine.is_editor_hint():
|
||||
_update_player_position()
|
||||
_update_player_position_from_archive()
|
||||
elif not Engine.is_editor_hint():
|
||||
# move player to portal
|
||||
ground.move_player_to_portal(entrance_portal)
|
||||
first_entered = false
|
||||
# SceneManager.release_player()
|
||||
|
||||
|
||||
func _update_archive():
|
||||
if not Engine.is_editor_hint() and ArchiveManager.archive:
|
||||
ArchiveManager.archive.current_scene = current_scene
|
||||
ArchiveManager.archive.entrance_portal = entrance_portal
|
||||
archive_scene = current_scene
|
||||
archive_portal = entrance_portal
|
||||
func _update_player_position_from_archive():
|
||||
if ignore_archive or Engine.is_editor_hint():
|
||||
return
|
||||
var player = SceneManager.get_player() as MainPlayer
|
||||
if player and ArchiveManager.archive:
|
||||
# if GlobalConfig.DEBUG:
|
||||
# print("update player position", ArchiveManager.archive.player_global_position)
|
||||
if ArchiveManager.archive.player_global_position_x >= 0:
|
||||
player.global_position.x = ArchiveManager.archive.player_global_position_x
|
||||
player.set_facing_direction(ArchiveManager.archive.player_direction)
|
||||
|
||||
|
||||
func _load_ground_node(scene_name: String) -> Node2D:
|
||||
|
@ -7,6 +7,7 @@ script = ExtResource("1_6mjre")
|
||||
|
||||
[node name="MaskLayer" type="CanvasLayer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layer = 11
|
||||
|
||||
[node name="Mask" type="ColorRect" parent="MaskLayer"]
|
||||
unique_name_in_owner = true
|
||||
|
@ -197,38 +197,38 @@ tracks/13/keys = {
|
||||
tracks/14/type = "value"
|
||||
tracks/14/imported = false
|
||||
tracks/14/enabled = true
|
||||
tracks/14/path = NodePath("Camera2D:zoom")
|
||||
tracks/14/path = NodePath("DeployLayer/oneshot纸片/Sign:display_sign")
|
||||
tracks/14/interp = 1
|
||||
tracks/14/loop_wrap = true
|
||||
tracks/14/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Vector2(1, 1)]
|
||||
"update": 1,
|
||||
"values": [true]
|
||||
}
|
||||
tracks/15/type = "value"
|
||||
tracks/15/imported = false
|
||||
tracks/15/enabled = true
|
||||
tracks/15/path = NodePath("DeployLayer/oneshot纸片/Sign:display_sign")
|
||||
tracks/15/path = NodePath("DeployLayer/oneshot纸片/Sign:position")
|
||||
tracks/15/interp = 1
|
||||
tracks/15/loop_wrap = true
|
||||
tracks/15/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [true]
|
||||
"update": 0,
|
||||
"values": [Vector2(3, -4)]
|
||||
}
|
||||
tracks/16/type = "value"
|
||||
tracks/16/imported = false
|
||||
tracks/16/enabled = true
|
||||
tracks/16/path = NodePath("DeployLayer/oneshot纸片/Sign:position")
|
||||
tracks/16/path = NodePath("MainPlayer/CameraFocusMarker:zoom_ratio")
|
||||
tracks/16/interp = 1
|
||||
tracks/16/loop_wrap = true
|
||||
tracks/16/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Vector2(3, -4)]
|
||||
"values": [1.0]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_7k2c8"]
|
||||
@ -462,7 +462,7 @@ tracks/8/path = NodePath("MainPlayer/CameraFocusMarker:position")
|
||||
tracks/8/interp = 1
|
||||
tracks/8/loop_wrap = true
|
||||
tracks/8/keys = {
|
||||
"times": PackedFloat32Array(0, 0.46, 3.98, 4.38),
|
||||
"times": PackedFloat32Array(0, 0.5, 3.98, 4.38),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(0, 0), Vector2(0, 10), Vector2(0, 10), Vector2(0, 0)]
|
||||
@ -470,14 +470,14 @@ tracks/8/keys = {
|
||||
tracks/9/type = "value"
|
||||
tracks/9/imported = false
|
||||
tracks/9/enabled = true
|
||||
tracks/9/path = NodePath("Camera2D:zoom")
|
||||
tracks/9/path = NodePath("MainPlayer/CameraFocusMarker:zoom_ratio")
|
||||
tracks/9/interp = 1
|
||||
tracks/9/loop_wrap = true
|
||||
tracks/9/keys = {
|
||||
"times": PackedFloat32Array(0.3, 0.7, 3.92, 4.38),
|
||||
"times": PackedFloat32Array(0.02, 0.54, 3.96, 4.38),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(1, 1), Vector2(1.5, 1.5), Vector2(1.5, 1.5), Vector2(1, 1)]
|
||||
"values": [1.0, 1.5, 1.5, 1.0]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_ocf0o"]
|
||||
@ -712,7 +712,6 @@ height = 50.0
|
||||
|
||||
[node name="MainPlayer" parent="Ground" index="5"]
|
||||
character = "小小蝶"
|
||||
running_locked = true
|
||||
|
||||
[node name="FGSprite2D" parent="Ground/ParallaxForeground/FGParallaxLayer" index="0"]
|
||||
position = Vector2(21, 39)
|
||||
|
@ -8,7 +8,7 @@
|
||||
[ext_resource type="Texture2D" uid="uid://c40gmvqw3vd88" path="res://asset/art/scene/c01/s06_孤儿院长廊围墙/l_长廊光.png" id="4_6ffae"]
|
||||
[ext_resource type="SpriteFrames" uid="uid://cemn2bnebsfko" path="res://asset/art/scene/c01/s06_孤儿院长廊围墙/全局参考.gif" id="4_8hecq"]
|
||||
[ext_resource type="Texture2D" uid="uid://bllt2wycchkp2" path="res://asset/art/scene/c01/s06_孤儿院长廊围墙/e_红柱子.png" id="4_dtycx"]
|
||||
[ext_resource type="Script" path="res://scene/tool/autoplay_animated_sprite.gd" id="5_ailfs"]
|
||||
[ext_resource type="Script" path="res://scene/ground/script/general/autoplay_animated_sprite.gd" id="6_4o4lo"]
|
||||
|
||||
[node name="S06" type="Node2D"]
|
||||
metadata/_edit_horizontal_guides_ = [158.0, 88.0]
|
||||
@ -43,19 +43,19 @@ immediately = false
|
||||
position = Vector2(547.5, 0.5)
|
||||
sprite_frames = ExtResource("2_l4axy")
|
||||
animation = &"男孩跑动-右"
|
||||
script = ExtResource("5_ailfs")
|
||||
script = ExtResource("6_4o4lo")
|
||||
|
||||
[node name="跷跷板" type="AnimatedSprite2D" parent="Ground/DeployLayer" index="3"]
|
||||
position = Vector2(1358.5, -0.5)
|
||||
sprite_frames = ExtResource("2_l4axy")
|
||||
animation = &"跷跷板"
|
||||
script = ExtResource("5_ailfs")
|
||||
script = ExtResource("6_4o4lo")
|
||||
|
||||
[node name="秋千" type="AnimatedSprite2D" parent="Ground/DeployLayer" index="4"]
|
||||
position = Vector2(1241.5, -0.5)
|
||||
sprite_frames = ExtResource("2_l4axy")
|
||||
animation = &"秋千"
|
||||
script = ExtResource("5_ailfs")
|
||||
script = ExtResource("6_4o4lo")
|
||||
|
||||
[node name="PointLight2D" type="PointLight2D" parent="Ground/AmbientLayer" index="0"]
|
||||
energy = 0.6
|
||||
@ -77,37 +77,37 @@ offset = Vector2(0, -153)
|
||||
position = Vector2(377.5, -1.5)
|
||||
sprite_frames = ExtResource("2_l4axy")
|
||||
animation = &"中蓝衣小孩呼吸"
|
||||
script = ExtResource("5_ailfs")
|
||||
script = ExtResource("6_4o4lo")
|
||||
|
||||
[node name="群众2" type="AnimatedSprite2D" parent="Ground/ParallaxForeground/BGParallaxLayer" index="2"]
|
||||
position = Vector2(408.5, 0.5)
|
||||
sprite_frames = ExtResource("2_l4axy")
|
||||
animation = &"右绿衣男孩呼吸"
|
||||
script = ExtResource("5_ailfs")
|
||||
script = ExtResource("6_4o4lo")
|
||||
|
||||
[node name="群众3" type="AnimatedSprite2D" parent="Ground/ParallaxForeground/BGParallaxLayer" index="3"]
|
||||
position = Vector2(269.5, -1.5)
|
||||
sprite_frames = ExtResource("2_l4axy")
|
||||
animation = &"左2黄衣男呼吸"
|
||||
script = ExtResource("5_ailfs")
|
||||
script = ExtResource("6_4o4lo")
|
||||
|
||||
[node name="群众4" type="AnimatedSprite2D" parent="Ground/ParallaxForeground/BGParallaxLayer" index="4"]
|
||||
position = Vector2(426.5, -0.5)
|
||||
sprite_frames = ExtResource("2_l4axy")
|
||||
animation = &"左一绿衣男呼吸"
|
||||
script = ExtResource("5_ailfs")
|
||||
script = ExtResource("6_4o4lo")
|
||||
|
||||
[node name="红衣姑娘" type="AnimatedSprite2D" parent="Ground/ParallaxForeground/BGParallaxLayer" index="5"]
|
||||
position = Vector2(333.5, -1.5)
|
||||
sprite_frames = ExtResource("2_l4axy")
|
||||
animation = &"红衣姑娘呼吸"
|
||||
script = ExtResource("5_ailfs")
|
||||
script = ExtResource("6_4o4lo")
|
||||
|
||||
[node name="院长" type="AnimatedSprite2D" parent="Ground/ParallaxForeground/BGParallaxLayer" index="6"]
|
||||
position = Vector2(301.5, -1.5)
|
||||
sprite_frames = ExtResource("2_l4axy")
|
||||
animation = &"院长呼吸"
|
||||
script = ExtResource("5_ailfs")
|
||||
script = ExtResource("6_4o4lo")
|
||||
|
||||
[node name="FGSprite2D" parent="Ground/ParallaxForeground/FGParallaxLayer" index="0"]
|
||||
texture = null
|
||||
|
@ -42,7 +42,7 @@ position = Vector2(629, 2)
|
||||
|
||||
[node name="Npc" parent="Ground/DeployLayer" index="2" instance=ExtResource("2_r5smg")]
|
||||
position = Vector2(465, 23)
|
||||
frame_progress = 0.514003
|
||||
frame_progress = 0.649558
|
||||
character_name = "张胖子"
|
||||
dialogue_title = "张胖子_01"
|
||||
|
||||
|
11
scene/ground/script/general/animated_sprite_state_machine.gd
Normal file
11
scene/ground/script/general/animated_sprite_state_machine.gd
Normal file
@ -0,0 +1,11 @@
|
||||
extends AnimatedSprite2D
|
||||
|
||||
var animation_state_dict = {
|
||||
}
|
||||
|
||||
func _ready() -> void:
|
||||
if animation:
|
||||
play(animation)
|
||||
|
||||
|
||||
|
6
scene/ground/script/general/state_action_res.gd
Normal file
6
scene/ground/script/general/state_action_res.gd
Normal file
@ -0,0 +1,6 @@
|
||||
class_name StateActionConfigResource extends Resource
|
||||
|
||||
@export var action_name := ""
|
||||
@export var animation_begin := ""
|
||||
@export var animation_mid := ""
|
||||
@export var animation_end := ""
|
@ -66,7 +66,7 @@ func _ready() -> void:
|
||||
|
||||
|
||||
func _enter_tree() -> void:
|
||||
if is_node_ready():
|
||||
if is_node_ready() and not Engine.is_editor_hint():
|
||||
_check_character_status()
|
||||
|
||||
|
||||
|
@ -27,6 +27,7 @@ modulate_color = Color(0.996078, 0.92549, 0.85098, 0.733333)
|
||||
[node name="MainPlayer" type="CharacterBody2D"]
|
||||
collision_mask = 2
|
||||
script = ExtResource("1_3a78y")
|
||||
running_locked = true
|
||||
metadata/_edit_vertical_guides_ = [-120.0]
|
||||
metadata/_edit_horizontal_guides_ = [-9.0]
|
||||
|
||||
|
@ -295,18 +295,13 @@ func enable_prop_item(prop_key: String) -> void:
|
||||
var inspector = SceneManager.get_inspector()
|
||||
if inspector:
|
||||
var inspect_path = items_dict[prop_key].inspect_path
|
||||
var prop_title = tr(prop_key)
|
||||
if inspect_path:
|
||||
var texture = load(inspect_path) as Texture2D
|
||||
inspector.pop_prop_inspection(texture)
|
||||
inspector.pop_prop_inspection(prop_title, texture)
|
||||
else:
|
||||
var texture = cached_inventory_textures[prop_key]
|
||||
inspector.pop_prop_inspection(texture, true)
|
||||
var prop_title = tr(prop_key)
|
||||
var obtain_str = tr("ui_获得")
|
||||
var text = "~ " + prop_key + "\n" + obtain_str + ": " + prop_title
|
||||
text += "[#item][ID:" + prop_title + "]\n=> END"
|
||||
var prop_res = DialogueManager.create_resource_from_text(text)
|
||||
DialogueManager.show_dialogue_balloon(prop_res, prop_key)
|
||||
inspector.pop_prop_inspection(prop_title, texture, true)
|
||||
|
||||
|
||||
func disable_prop_item(prop_key: String) -> void:
|
||||
|
@ -4,7 +4,7 @@ class_name PropInspector extends CanvasLayer
|
||||
enum { STATUS_HIDDEN, STATUS_INSPECTING_PROP, STATUS_INSPECTING_COVER, STATUS_INSPECTING_NOTES }
|
||||
|
||||
# must be connected to
|
||||
signal quit
|
||||
signal quit_and_hidden
|
||||
|
||||
@onready var prop_bg = %PropBG as TextureRect
|
||||
@onready var origin_texture = %OriginPropTexture as TextureRect
|
||||
@ -12,7 +12,6 @@ signal quit
|
||||
@onready var content_label = %ContentLabel as Label
|
||||
@onready var tip_label = %TipLabel as Label
|
||||
|
||||
|
||||
var tip_cover = "Q: " + tr("ui_退出") + " " + "E: " + tr("ui_阅读")
|
||||
var tip_notes = "Q: " + tr("ui_退出") + " " + "E: " + tr("ui_收起")
|
||||
var texture_cover: Texture2D
|
||||
@ -57,6 +56,7 @@ func _post_hide():
|
||||
content_label.text = ""
|
||||
tip_label.text = tip_cover
|
||||
visible = false
|
||||
quit_and_hidden.emit()
|
||||
|
||||
|
||||
func _blink_label(init := true):
|
||||
@ -87,7 +87,7 @@ func pop_standard_inspection(cover_texture, notes_texture, inspection_note):
|
||||
_blink_label()
|
||||
|
||||
|
||||
func pop_prop_inspection(cover_texture: Texture2D, use_default_bg := false):
|
||||
func pop_prop_inspection(prop_title: String, cover_texture: Texture2D, use_default_bg := false):
|
||||
if status != STATUS_HIDDEN:
|
||||
_hide()
|
||||
if not cover_texture:
|
||||
@ -108,6 +108,16 @@ func pop_prop_inspection(cover_texture: Texture2D, use_default_bg := false):
|
||||
tween.tween_property(full_texture, "modulate:a", 1.0, 0.15)
|
||||
content_label.text = ""
|
||||
tip_label.text = ""
|
||||
|
||||
# 显示道具获得提示
|
||||
var obtain_str = tr("ui_获得")
|
||||
var text = "~ title\n" + obtain_str + ": " + prop_title
|
||||
text += "[#item][ID:" + prop_title + "]\n=> END"
|
||||
var prop_res = DialogueManager.create_resource_from_text(text)
|
||||
var balloon = preload("res://scene/dialog/balloon.tscn").instantiate()
|
||||
# 手动跳过的同时隐藏
|
||||
balloon.manually_skipped_line.connect(_hide)
|
||||
DialogueManager.show_dialogue_balloon_scene(balloon, prop_res, "title")
|
||||
SceneManager.freeze_player(0)
|
||||
|
||||
|
||||
@ -117,7 +127,6 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("cancel"):
|
||||
get_viewport().set_input_as_handled()
|
||||
_hide()
|
||||
quit.emit()
|
||||
if event.is_action_pressed("interact"):
|
||||
get_viewport().set_input_as_handled()
|
||||
# STATUS_INSPECTING_COVER 与 STATUS_INSPECTING_NOTES 之间互相切换
|
||||
@ -140,4 +149,3 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
# STATUS_INSPECTING_PROP 直接退出
|
||||
elif status == STATUS_INSPECTING_PROP:
|
||||
_hide()
|
||||
quit.emit()
|
||||
|
@ -1,17 +0,0 @@
|
||||
extends Object
|
||||
class_name ResourceUtils
|
||||
|
||||
# # remove editor's cache
|
||||
# func remove_editor_cache(resource: Resource) -> void:
|
||||
# if Engine.is_editor_hint():
|
||||
# (resource)
|
||||
|
||||
|
||||
static func remove_editor_cache(name: String) -> void:
|
||||
pass
|
||||
# var dir = DirAccess.open("res://.godot/editor")
|
||||
# for file in dir.get_files():
|
||||
# if file.get_basename().begins_with(name):
|
||||
# DirAccess.remove_absolute("res://.godot/editor/" + file)
|
||||
# print("Removed editor cache: ", file)
|
||||
# break
|
Loading…
Reference in New Issue
Block a user