Add diamond collection and a level-clear door

The three diamonds and both doors were painted as tiles in TerrainBase, which cannot act as pickups or triggers. Replaced them with real prefabs that reuse the same atlas tiles (diamond = (7,3), doors = (10,6) and (11,5)) and erase their placeholder tile on ready. Collecting all three diamonds unlocks the door; touching it fades to black, pauses the tree and shows the level-clear screen with a next-level button (currently reloads the level, as there is only one). HUD now shows the diamond count.
This commit is contained in:
2026-10-07 21:04:58 +08:00
parent f67bd94605
commit 7c78a088a0
10 changed files with 335 additions and 12 deletions
+15
View File
@@ -60,6 +60,10 @@ var hurt_count: int = 0
var health: int = 3
## 身上的回血道具数量(捡到的小球)
var heal_items: int = 0
## 已收集的钻石数量
var diamonds: int = 0
## 关卡里钻石总数(开场自动数一遍)
var diamond_total: int = 0
## 无敌盾剩余时间,给 HUD 显示用
var shield_left: float = 0.0
## 生命值归零后进入死亡状态:不能操作,交给死亡界面
@@ -84,6 +88,12 @@ func _ready() -> void:
_measure_feet_offset()
_spawn_point = global_position
health = max_health
# 等一帧再数钻石,确保关卡里所有钻石节点都已经 _ready
_count_diamond_total.call_deferred()
func _count_diamond_total() -> void:
diamond_total = get_tree().get_nodes_in_group("diamond").size()
func _physics_process(delta: float) -> void:
@@ -182,6 +192,11 @@ func add_heal_item() -> void:
heal_items += 1
## 由钻石调用
func add_diamond() -> void:
diamonds += 1
## 按 Z:消耗一个回血道具,回一颗心并获得无敌盾
func use_heal_item() -> bool:
if is_dead or heal_items <= 0: