Fix para los items que no caen
This commit is contained in:
1 parent
5012879591
commit
e1e29f02f1
9 files changed
+233
-65
No files matched your search
+58
-12
@@ -1,14 +1,18 @@
|
||||
extends Node2D
|
||||
|
||||
## Android test course: 17 stations / 17 different guaranteed items.
|
||||
## Encounters are configured in the scene, not spawned by code, so designers can
|
||||
## freely move a station or switch its drop in the Godot inspector.
|
||||
## Encounters are configured in the scene, not spawned by code.
|
||||
## This laboratory intentionally owns fixed drops: each death is observed from
|
||||
## the actual is_dead state, even when a died signal is missed.
|
||||
|
||||
signal level_completed
|
||||
|
||||
const TEST_ITEM_COUNT: int = 17
|
||||
const LEVEL_WIDTH: int = 8500
|
||||
const FINISH_RESTART_SECONDS: float = 8.0
|
||||
const LAB_BUILD: String = "LAB DROPS v2"
|
||||
const CONTROL_ITEM_ID: StringName = &"lab_control"
|
||||
const PICKUP_SCENE: PackedScene = preload("res://pickups/pickup.tscn")
|
||||
|
||||
@onready var player: Node2D = $Player
|
||||
@onready var test_enemies: Node2D = $TestEnemies
|
||||
@@ -17,11 +21,17 @@ const FINISH_RESTART_SECONDS: float = 8.0
|
||||
|
||||
var collected_items: Dictionary = {} # PickupData.id -> true; count each only once
|
||||
var defeated_enemies: int = 0
|
||||
var death_signals: int = 0
|
||||
var spawned_drops: int = 0
|
||||
var _processed_deaths: Dictionary = {} # enemy instance id -> true
|
||||
var showing_victory: bool = false
|
||||
var victory_timer: float = 0.0
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
# These two markers distinguish an actually loaded script from an old APK.
|
||||
status_label.text = "%s: script iniciado" % LAB_BUILD
|
||||
print("%s: Level01 script iniciado" % LAB_BUILD)
|
||||
finish_message.visible = false
|
||||
# Player Camera2D sets its own provisional limit (4000) in _ready.
|
||||
# Override it here, after child _ready, for the long Android route.
|
||||
@@ -32,15 +42,22 @@ func _ready() -> void:
|
||||
$DeathZone.body_entered.connect(_on_death_entered)
|
||||
player.connect(&"pickup_collected", _on_pickup_collected)
|
||||
for enemy in test_enemies.get_children():
|
||||
# Catch missing scene overrides as soon as the level starts rather than
|
||||
# silently falling back to the normal random drop table.
|
||||
# The laboratory, not Walker, owns the fixed drop. Only this level sets
|
||||
# the flag: normal enemies still generate their usual random drops.
|
||||
enemy.set("drops_handled_by_level", true)
|
||||
if enemy.get("guaranteed_drop") == null:
|
||||
push_error("%s has no guaranteed_drop assigned." % enemy.name)
|
||||
enemy.died.connect(_on_station_enemy_died)
|
||||
if enemy.has_signal(&"died"):
|
||||
enemy.connect(&"died", _on_station_enemy_died)
|
||||
else:
|
||||
push_error("%s no expone la senal died" % enemy.name)
|
||||
_update_status()
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
# Do not depend on the died signal to count KOs or create the object.
|
||||
# A transition to is_dead can only be processed once per enemy.
|
||||
_process_station_deaths()
|
||||
if showing_victory:
|
||||
victory_timer += delta
|
||||
if victory_timer >= FINISH_RESTART_SECONDS:
|
||||
@@ -65,21 +82,50 @@ func _update_status() -> void:
|
||||
next_item = data.display_name
|
||||
break
|
||||
|
||||
# Two independent counters reveal whether an object failed to spawn or
|
||||
# simply got collected. Useful for diagnosing drops on an Android APK.
|
||||
# S is the number of died signals received. KOs come from is_dead,
|
||||
# not signals. A difference between them pinpoints a signal problem.
|
||||
var loose_drops: int = get_tree().get_nodes_in_group("pickup").size()
|
||||
status_label.text = "LAB: %02d/%02d objetos | %02d KOs\nDROPS EN SUELO: %02d\nSIGUIENTE: %s" % [
|
||||
collected_items.size(), TEST_ITEM_COUNT, defeated_enemies,
|
||||
loose_drops, next_item
|
||||
status_label.text = "%s | %02d/%02d objetos\nKOs: %02d | Senales: %02d | Creados: %02d | Suelo: %02d\nSIGUIENTE: %s" % [
|
||||
LAB_BUILD, collected_items.size(), TEST_ITEM_COUNT,
|
||||
defeated_enemies, death_signals, spawned_drops, loose_drops, next_item
|
||||
]
|
||||
|
||||
|
||||
func _process_station_deaths() -> void:
|
||||
for enemy in test_enemies.get_children():
|
||||
if not bool(enemy.get("is_dead")):
|
||||
continue
|
||||
var instance_id: int = enemy.get_instance_id()
|
||||
if _processed_deaths.has(instance_id):
|
||||
continue
|
||||
_processed_deaths[instance_id] = true
|
||||
defeated_enemies += 1
|
||||
|
||||
var data: PickupData = enemy.get("guaranteed_drop") as PickupData
|
||||
if data == null:
|
||||
push_error("%s: %s ha muerto sin objeto asignado" % [LAB_BUILD, enemy.name])
|
||||
continue
|
||||
|
||||
# Adding an Area2D during a physics step is unsafe. Set position and
|
||||
# data before adding it, then defer its entry into the scene tree.
|
||||
var pickup: Pickup = PICKUP_SCENE.instantiate() as Pickup
|
||||
pickup.pickup_data = data
|
||||
pickup.position = to_local(enemy.global_position + Vector2(34.0, -12.0))
|
||||
call_deferred("add_child", pickup)
|
||||
spawned_drops += 1
|
||||
print("%s: KO %s -> %s" % [LAB_BUILD, enemy.name, data.display_name])
|
||||
|
||||
|
||||
func _on_station_enemy_died() -> void:
|
||||
defeated_enemies += 1
|
||||
_update_status()
|
||||
# Diagnostic counter only; the actual reward is managed above.
|
||||
death_signals += 1
|
||||
|
||||
|
||||
func _on_pickup_collected(data: PickupData) -> void:
|
||||
# The extra pickup at the start checks rendering and collection independently
|
||||
# of enemy deaths. It is not one of the 17 rewards.
|
||||
if data.id == CONTROL_ITEM_ID:
|
||||
return
|
||||
# A heal at full HP or a charge item with a full meter isn't consumed and
|
||||
# doesn't count. The object remains on the floor for later collection.
|
||||
collected_items[data.id] = true
|
||||
|
||||
+17
-2
@@ -1,8 +1,10 @@
|
||||
[gd_scene load_steps=31 format=3]
|
||||
[gd_scene load_steps=33 format=3]
|
||||
|
||||
[ext_resource type="PackedScene" path="res://player/player.tscn" id="1_player"]
|
||||
[ext_resource type="PackedScene" path="res://ui/mobile_controls/mobile_controls.tscn" id="2_mobile"]
|
||||
[ext_resource type="Script" path="res://levels/level_01.gd" id="3_level"]
|
||||
[ext_resource type="PackedScene" path="res://pickups/pickup.tscn" id="4_pickup"]
|
||||
[ext_resource type="Resource" path="res://pickups/data/lab_control.tres" id="lab_control"]
|
||||
[ext_resource type="PackedScene" path="res://enemies/variants/roadie.tscn" id="v0"]
|
||||
[ext_resource type="PackedScene" path="res://enemies/variants/pogo_fan.tscn" id="v1"]
|
||||
[ext_resource type="PackedScene" path="res://enemies/variants/feedback_tech.tscn" id="v2"]
|
||||
@@ -85,6 +87,19 @@ position = Vector2(140, 557)
|
||||
show_debug_hitboxes = false
|
||||
special_radius = 290.0
|
||||
|
||||
[node name="ControlPickup" parent="." instance=ExtResource("4_pickup")]
|
||||
position = Vector2(270, 548)
|
||||
pickup_data = ExtResource("lab_control")
|
||||
|
||||
[node name="ControlSign" type="Label" parent="."]
|
||||
offset_left = 173.0
|
||||
offset_top = 461.0
|
||||
offset_right = 368.0
|
||||
offset_bottom = 500.0
|
||||
text = "CONTROL: objeto SIN matar"
|
||||
horizontal_alignment = 1
|
||||
theme_override_font_sizes/font_size = 11
|
||||
|
||||
[node name="TestEnemies" type="Node2D" parent="."]
|
||||
|
||||
[node name="Station01" parent="TestEnemies" instance=ExtResource("v0")]
|
||||
@@ -419,7 +434,7 @@ theme_override_colors/font_shadow_color = Color(0.02, 0.02, 0.02, 0.95)
|
||||
theme_override_constants/shadow_offset_x = 2
|
||||
theme_override_constants/shadow_offset_y = 2
|
||||
theme_override_font_sizes/font_size = 17
|
||||
text = "LAB THRASH 00 / 17"
|
||||
text = "LAB DROPS v2: script SIN iniciar"
|
||||
horizontal_alignment = 2
|
||||
|
||||
[node name="FinishMessage" type="Label" parent="TestHUD/Overlay"]
|
||||
|
||||
Reference in new issue
Block a user