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
+26
View File
@@ -0,0 +1,26 @@
extends Area2D
## 钻石:走过去自动收集,集齐后碰门过关
@export var erase_placeholder_tile: bool = true
func _ready() -> void:
body_entered.connect(_on_body_entered)
if erase_placeholder_tile:
_erase_placeholder_tile()
func _on_body_entered(body: Node2D) -> void:
if body.has_method("add_diamond"):
body.add_diamond()
queue_free()
func _erase_placeholder_tile() -> void:
var root: Node = owner if owner != null else get_parent()
if root == null:
return
for layer in root.find_children("*", "TileMapLayer", true, false):
var cell: Vector2i = layer.local_to_map(layer.to_local(global_position))
if layer.get_cell_source_id(cell) != -1:
layer.erase_cell(cell)