Merge remote-tracking branch 'origin/demo'

This commit is contained in:
cakipaul 2025-07-31 04:01:02 +08:00
commit e829c28660
8 changed files with 116 additions and 59 deletions

View File

@ -22,10 +22,12 @@ var archive: AssembledArchive:
# emit signal
archive_loaded.emit()
GlobalConfigManager.print_global_info()
print("use archive ", archive.resource_path)
print("[Archive] use archive ", archive.resource_path)
archive.event_stage["release_stage"] = GlobalConfig.RELEASE_STAGE
print_rich("[color=brown] release_stage = %s[/color]" % GlobalConfig.RELEASE_STAGE)
else:
print("[Archive] unload archive")
var archives_dict: Dictionary[int, AssembledArchive] = {}
var archives_notes_dict: Dictionary[int, String] = {}

View File

@ -257,6 +257,16 @@ func disable_prop_item(prop_key: String) -> void:
printerr("disable_prop_item PropHud node not found")
# 临时禁用 prop, 延迟写入(真正 disable_prop_item 的时候写入)
func disable_prop_item_temp(prop_key: String) -> void:
var prop_hud = get_prop_hud()
if prop_hud:
print("[prop] disable_prop_item_temp prop:", prop_key)
prop_hud.disable_prop_item_temp(prop_key)
else:
printerr("disable_prop_item_temp PropHud node not found")
func pop_os_with_str(translation_key: String) -> void:
var player = get_player() as MainPlayer
if player:
@ -338,6 +348,8 @@ func pop_chapter_notification(id: int) -> void:
func checkout_index_page(transition := true) -> void:
# 保存后,渐隐切换场景
ArchiveManager.save_all()
# 移除 archive
ArchiveManager.archive = null
if transition:
var ground_loader = get_ground_loader() as GroundLoader
if ground_loader:

View File

@ -53,6 +53,7 @@ debug_note = "出来就不能回来了"
portal_name = "1"
target_scene = "c02_s12"
target_portal = "left"
status = "opened"
[node name="Ambush猫咪敲门互动2" parent="Ground/DeployLayer" index="3" instance=ExtResource("8_m6dyn")]
position = Vector2(106, 6)

View File

@ -10,10 +10,10 @@ extends Node2D
@export var trun_back_detect_x := 150
# 抓取范围,优先 catch_front 播放 猪头怪抓盒子猫
# 其次 catch_nearby 播放 猪头怪抓盒子猫后段
@export var catch_front_x_range := Vector2(55 - 3, 55 + 3)
@export var catch_nearby_x_range := Vector2(-10, 55)
var catch_front_x_range := Vector2(55 - 3, 55 + 3)
var catch_nearby_x_range := Vector2(-10, 55)
# 观测范围,在观测范围内进入盒子仍旧会被抓
@export var watching_x := 180
var watching_x := 80
# 允许被抓后重开游戏
var allow_restart_game := true
@ -50,6 +50,7 @@ func _on_ground_ready():
var archive = ArchiveManager.archive as AssembledArchive
var portal = archive.entrance_portal
var chasing_started = ArchiveManager.get_global_value(&"c02_boxcat_chasing_started", false)
# 盒子猫二楼 c02_s13
if archive.current_scene == "c02_s13":
# 开始追逐后,禁用二楼两只
if chasing_started and not transfer_mode:
@ -89,8 +90,8 @@ func _on_ground_ready():
global_position.x = portal_node.global_position.x
# 禁用传送过来的 portal 3s
_disable_portal_a_few_seconds(portal_node)
# 3 秒后传送
Util.timer(1.0, _do_transfer)
# 2.5 秒后传送
Util.timer(2.5, _do_transfer)
if GlobalConfig.DEBUG:
print("猪头怪 Transfer to: " + portal)
else:
@ -126,10 +127,10 @@ func toggle_footstep_sfx(play := true):
footstep_timer.stop()
# 禁用传送过来的 portal 3s
# 禁用传送过来的 portal 4s
func _disable_portal_a_few_seconds(portal_node: Portal2D):
portal_node.enabled = false
await create_tween().tween_interval(3.0).finished
await create_tween().tween_interval(4.0).finished
portal_node.enabled = true
@ -183,6 +184,8 @@ func do_catch(front: bool):
SceneManager.unlock_player()
# 等待动画播放后秒,再检查是否允许重开游戏
if allow_restart_game:
# 重置追击状态
ArchiveManager.set_global_entry(&"c02_boxcat_chasing_started", false)
SceneManager.get_ground_loader().transition_to_scene("c02_s12", "left")

View File

@ -51,12 +51,11 @@ func intro():
func intro_finished():
SceneManager.disable_prop_item("prop_弹珠")
# 老虎钳 - 弹珠交换功能结束
EventManager.set_stage_if_greater(&"handnote_c02_hand_exchange", 2)
SceneManager.disable_prop_item_temp("prop_弹珠")
# SceneManager.disable_prop_item("prop_弹珠")
# 0:默认 1:寻找弹珠(老虎钳可以换弹珠) 2:给出弹珠 3:游戏结束(小猫纸片) 4:游戏结束(小猫离开)
# 放入弹珠,开始游戏
EventManager.set_stage(&"c02_ball_game_stage", 2)
# EventManager.set_stage(&"c02_ball_game_stage", 2)
var ball = pivot.get_child(0) as RigidBody2D
ball.angular_velocity = 20
animation_player.play("give_ball")
@ -255,6 +254,8 @@ func game_win() -> void:
animation_player.stop()
# 0:默认 1:寻找弹珠(老虎钳可以换弹珠) 2:给出弹珠 3:游戏结束(小猫纸片) 4:游戏结束(小猫离开)
EventManager.set_stage(&"c02_ball_game_stage", 3)
# 老虎钳 - 弹珠交换功能结束
EventManager.set_stage_if_greater(&"handnote_c02_hand_exchange", 2)
$"Sfx结尾小孩跑_耳鸣".global_play()
Util.shake_layer(self, 2.0)
# 弹珠雨

View File

@ -54,7 +54,7 @@ const HUD_FADE_DURATION = 0.3
var prop_containers: Array[CenterContainer] = []
var items_dict := {}
# 从配置文件加载 prop items
var item_config_res = preload("uid://b1vwhxctfhl5d") #item_description.dialogue
var item_config_res = preload("uid://b1vwhxctfhl5d") #item_description.dialogue
var path_prefix = "res://asset/art/prop/"
var cached_inventory_textures := {}
@ -97,18 +97,15 @@ func _ready() -> void:
display_prop.gui_input.connect(_on_prop_gui_input.bind(-1))
_load_items_config_to_dict("ImportantPropItems")
_load_items_config_to_dict("PropItems")
_reload_cache_and_realign_display()
_reload_all()
# 存档更新时,从存档加载 prop
ArchiveManager.archive_loaded.connect(_reload_all)
selecting_bg.modulate.a = 0.0
prop_scroll.scroll_horizontal = PROP_CONTAINER_X
props_bag_scroll.scroll_horizontal = 0.0
props_bag_scroll.custom_minimum_size.x = 0.0
# 存档更新时,从存档加载 prop
ArchiveManager.archive_loaded.connect(_reload_cache_and_realign_display)
# tween timer
timer.wait_time = display_time
timer.one_shot = true
@ -128,9 +125,17 @@ func _ready() -> void:
func _notification(what: int) -> void:
if what == NOTIFICATION_TRANSLATION_CHANGED and is_node_ready():
_load_items_config_to_dict("ImportantPropItems")
_load_items_config_to_dict("PropItems")
_reload_cache_and_realign_display()
_reload_all()
func _reload_all() -> void:
inventory = ArchiveManager.archive.prop_inventory
if inventory:
# 刷新 inventory 的 virtual回到 index 再进游戏时inventory 的 virtual 应该刷新)
inventory.virtual_enabled_items(true, true)
_load_items_config_to_dict("ImportantPropItems")
_load_items_config_to_dict("PropItems")
_reload_cache_and_realign_display()
func _load_items_config_to_dict(title: String):
@ -218,22 +223,24 @@ func _load_texture_cache() -> void:
if not inventory:
return
var virtual_items = inventory.virtual_enabled_items()
# 移除无效纹理
var keys_to_remove = []
for k in cached_inventory_textures:
if not k in inventory.enabled_items:
if not k in virtual_items:
keys_to_remove.append(k)
for k in keys_to_remove:
cached_inventory_textures.erase(k)
# 加载新纹理
for key in inventory.enabled_items:
for key in virtual_items:
if cached_inventory_textures.has(key):
continue
if not items_dict.has(key):
inventory.disable_item(key)
inventory.disable_item_tmp(key)
virtual_items = inventory.virtual_enabled_items()
printerr(
"PropHud _load_texture_cache: key not found in items_dict:", key, ". remove item."
)
@ -251,18 +258,15 @@ func _load_texture_cache() -> void:
print("Cache load prop texture key=", key)
cached_inventory_textures[key] = texture
# wrap index
if inventory.enabled_items.size() > 0:
inventory.current_index = wrapi(inventory.current_index, 0, inventory.enabled_items.size())
func _update_prop_display_with_texture():
if not inventory:
return
var virtual_items = inventory.virtual_enabled_items()
var key = ""
# 在没有道具时,展示空手 placeholder
if inventory.enabled_items.is_empty():
if virtual_items.is_empty():
display_prop.texture_normal = placeholder_texture
display_prop.size = Vector2(PROP_CONTROL_X, PROP_CONTROL_X)
display_prop.scale = Vector2(1.0, 1.0)
@ -284,9 +288,9 @@ func _update_prop_display_with_texture():
_update_select_mark()
# bag更新
for i in range(inventory.enabled_items.size()):
var id = wrapi(i, 0, inventory.enabled_items.size())
var k = inventory.enabled_items[id]
for i in range(virtual_items.size()):
var id = wrapi(i, 0, virtual_items.size())
var k = virtual_items[id]
var container = prop_containers[i]
var button = container.get_child(0).get_child(0) as TextureButton
_display_texture_by_key(button, k)
@ -300,7 +304,7 @@ func _update_select_mark():
if not is_instance_valid(select_mark):
select_mark = TextureRect.new()
select_mark.custom_minimum_size = Vector2(PROP_CONTAINER_X, PROP_CONTAINER_X)
# select_mark
# res://asset/art/ui/hud/select_mark.png
select_mark.texture = preload("uid://c0gjes4a8ou3b")
else:
var parent = select_mark.get_parent()
@ -380,10 +384,10 @@ func _on_prop_gui_input(event: InputEvent, id: int) -> void:
func _on_prop_inspected(id := 0) -> void:
if locked:
return
var virtual_items = inventory.virtual_enabled_items()
var prop_key = ""
if id >= 0 and id < inventory.enabled_items.size():
prop_key = inventory.enabled_items[id]
if id >= 0 and id < virtual_items.size():
prop_key = virtual_items[id]
else:
prop_key = inventory.current_item_key()
@ -404,7 +408,8 @@ func _on_prop_pressed(id := 0) -> void:
focus_mode = FOCUS_ALL
grab_focus()
if id >= 0 and id < inventory.enabled_items.size():
var virtual_items = inventory.virtual_enabled_items()
if id >= 0 and id < virtual_items.size():
inventory.current_index = id
_update_prop_display_with_texture()
@ -589,13 +594,9 @@ func inspect_item(prop_key: String, display_obtained := true, as_important_item
if as_important_item:
var content = get_item_description(prop_key)
var wide = len(content) > 150
inspector.pop_standard_inspection(
texture, null, content, false, wide
)
inspector.pop_standard_inspection(texture, null, content, false, wide)
else:
inspector.pop_prop_inspection(
prop_key, texture, display_obtained
)
inspector.pop_prop_inspection(prop_key, texture, display_obtained)
func disable_prop_item(prop_key: String) -> void:
@ -605,16 +606,25 @@ func disable_prop_item(prop_key: String) -> void:
_reload_cache_and_realign_display()
# 临时禁用 prop, 延迟写入(真正 disable_prop_item 的时候写入)
func disable_prop_item_temp(prop_key: String) -> void:
if not inventory or not prop_key:
return
inventory.disable_item_temp(prop_key)
_reload_cache_and_realign_display()
func _align_container_size() -> void:
if not inventory:
return
var virtual_items = inventory.virtual_enabled_items()
# 添加新容器
while inventory.enabled_items.size() > prop_containers.size():
while virtual_items.size() > prop_containers.size():
append_prop_container()
# 删除多余容器
while inventory.enabled_items.size() < prop_containers.size():
while virtual_items.size() < prop_containers.size():
remove_prop_container()
if displaying:

View File

@ -120,6 +120,7 @@ func pop_standard_inspection(
content_label.text = inspection_note.replace("{br}", "\n").strip_edges()
var tween = create_tween()
tween.tween_property(full_texture, "modulate:a", 1.0, 0.15)
tween.parallel().tween_property(prop_bg, "modulate:a", 1.0, 0.15)
tip_label.text = tip_cover
_blink_label()

View File

@ -7,10 +7,11 @@ signal current_item_changed(prop_key: String)
@export var current_index := 0:
set(val):
if current_index != val:
val = wrapi(val, 0, enabled_items.size())
# virtual id
val = wrapi(val, 0, virtual_items.size())
current_index = val
if enabled_items.size() > 0:
current_item_changed.emit(enabled_items[current_index])
if virtual_items.size() > 0:
current_item_changed.emit(virtual_items[current_index])
else:
current_item_changed.emit("")
# 重要物品,不可丢弃,在背包可见
@ -22,8 +23,11 @@ signal current_item_changed(prop_key: String)
@export var xdie_enabled_items := [] as Array[String]
@export var xxdie_enabled_items := [] as Array[String]
@export var xxxdie_enabled_items := [] as Array[String]
var enabled_items := [] as Array[String]
var enabled_items: Array[String]
var virtual_items: Array[String]
# virtual
var disabled_tmp_props := [] as Array[String]
func checkout(character: String):
# @export_enum("吕萍", "吕萍爬行", "吕萍带小猫", "吕萍推柜子", "小小蝶", "盒子猫", "小小小蝶") var character := "吕萍":
@ -35,6 +39,7 @@ func checkout(character: String):
enabled_items = xdie_enabled_items
else:
enabled_items = default_enabled_items
virtual_items = virtual_enabled_items(true)
func enable_important_item(prop_key: String) -> void:
@ -44,34 +49,56 @@ func enable_important_item(prop_key: String) -> void:
func has_prop(prop_key: String) -> bool:
return enabled_items.has(prop_key)
if not virtual_items.has(prop_key):
return false
return not disabled_tmp_props.has(prop_key)
# return current virtual item key
func current_item_key() -> String:
if enabled_items.size() == 0:
if virtual_items.is_empty():
return ""
return enabled_items[current_index]
current_index = wrapi(current_index, 0, virtual_items.size())
return virtual_items[current_index]
func enable_item(prop_key: String, inspect := true) -> void:
# 重复 enable 无负面影响
if not enabled_items.has(prop_key):
enabled_items.append(prop_key)
# 如果 inspect, 则直接选中为当前条目
if inspect:
current_index = enabled_items.find(prop_key)
current_index = virtual_items.find(prop_key)
# 消除临时禁用
disabled_tmp_props.erase(prop_key)
virtual_items = virtual_enabled_items(true)
func disable_item(prop_key: String) -> void:
disabled_tmp_props.erase(prop_key)
virtual_items = virtual_enabled_items(true)
# if enabled_items.has(prop_key):
enabled_items.erase(prop_key)
# wrap index
current_index = clampi(current_index, 0, enabled_items.size())
current_index = clampi(current_index, 0, virtual_items.size())
func disable_item_temp(prop_key: String) -> void:
disabled_tmp_props.append(prop_key)
virtual_items = virtual_enabled_items(true)
# return true if the index changed
func index_wrap_add(delta: int) -> bool:
func index_wrap_add(delta: int) -> void:
# auto wrapped in setter
current_index += delta
return not enabled_items.is_empty()
current_index = wrapi(current_index + delta, 0, virtual_items.size())
func virtual_enabled_items(refresh := false, clear_tmps := false) -> Array[String]:
if clear_tmps:
disabled_tmp_props.clear()
if refresh:
virtual_items = enabled_items.duplicate()
for k in disabled_tmp_props:
virtual_items.erase(k)
return virtual_items