♻️REFACTOR: Mejoras en la viabilidad para desarrollo
This commit is contained in:
1 parent
5aba6c7b47
commit
fd0118d964
98 files changed
+5985
-3024
No files matched your search
@@ -0,0 +1,140 @@
|
||||
[gd_scene load_steps=19 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://levels/level_root.gd" id="level"]
|
||||
[ext_resource type="PackedScene" path="res://player/player.tscn" id="player"]
|
||||
[ext_resource type="PackedScene" path="res://ui/mobile_controls/mobile_controls.tscn" id="mobile"]
|
||||
[ext_resource type="PackedScene" path="res://world/backgrounds/city_background.tscn" id="background"]
|
||||
[ext_resource type="PackedScene" path="res://world/terrain/ground.tscn" id="ground"]
|
||||
[ext_resource type="PackedScene" path="res://world/terrain/wall.tscn" id="wall"]
|
||||
[ext_resource type="PackedScene" path="res://world/signs/sign_post.tscn" id="sign"]
|
||||
[ext_resource type="PackedScene" path="res://world/terrain/platform.tscn" id="platform"]
|
||||
[ext_resource type="PackedScene" path="res://world/props/barrel.tscn" id="barrel"]
|
||||
[ext_resource type="PackedScene" path="res://world/props/crate.tscn" id="crate"]
|
||||
[ext_resource type="PackedScene" path="res://world/props/streetlamp.tscn" id="lamp"]
|
||||
[ext_resource type="PackedScene" path="res://world/props/bench.tscn" id="bench"]
|
||||
[ext_resource type="PackedScene" path="res://world/props/traffic_cone.tscn" id="cone"]
|
||||
[ext_resource type="PackedScene" path="res://world/props/trash_bin.tscn" id="bin"]
|
||||
[ext_resource type="PackedScene" path="res://world/props/rock.tscn" id="rock"]
|
||||
[ext_resource type="PackedScene" path="res://world/props/facade_01.tscn" id="facade"]
|
||||
[ext_resource type="PackedScene" path="res://world/signs/text_label.tscn" id="label"]
|
||||
[ext_resource type="PackedScene" path="res://pickups/variants/coffee.tscn" id="coffee"]
|
||||
|
||||
[node name="SceneryCatalog" type="Node2D"]
|
||||
texture_filter = 1
|
||||
script = ExtResource("level")
|
||||
camera_bounds = Rect2(0, 0, 3800, 1280)
|
||||
|
||||
[node name="CityBackground" parent="." instance=ExtResource("background")]
|
||||
|
||||
[node name="World" type="Node2D" parent="."]
|
||||
|
||||
[node name="Ground" parent="World" instance=ExtResource("ground")]
|
||||
position = Vector2(1900, 1030)
|
||||
dimensions = Vector2(3800, 260)
|
||||
|
||||
[node name="LeftBoundary" parent="World" instance=ExtResource("wall")]
|
||||
position = Vector2(0, 500)
|
||||
dimensions = Vector2(48, 1000)
|
||||
|
||||
[node name="RightBoundary" parent="World" instance=ExtResource("wall")]
|
||||
position = Vector2(3800, 500)
|
||||
dimensions = Vector2(48, 1000)
|
||||
|
||||
[node name="Scenery" type="Node2D" parent="."]
|
||||
|
||||
[node name="Signs" type="Node2D" parent="."]
|
||||
|
||||
[node name="Welcome" parent="Signs" instance=ExtResource("sign")]
|
||||
position = Vector2(330, 900)
|
||||
text = "CATALOGO JUGABLE\nA/D: mover | W: saltar\nAvanza a la derecha"
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource("player")]
|
||||
position = Vector2(160, 874)
|
||||
|
||||
[node name="Enemies" type="Node2D" parent="."]
|
||||
|
||||
[node name="Items" type="Node2D" parent="."]
|
||||
|
||||
[node name="Triggers" type="Node2D" parent="."]
|
||||
|
||||
[node name="MobileControls" parent="." instance=ExtResource("mobile")]
|
||||
|
||||
|
||||
[node name="SolidBarrel" parent="Scenery" instance=ExtResource("barrel")]
|
||||
position = Vector2(670, 900)
|
||||
collision_enabled = true
|
||||
preview_collision = true
|
||||
|
||||
[node name="BackgroundBarrel" parent="Scenery" instance=ExtResource("barrel")]
|
||||
position = Vector2(1050, 900)
|
||||
collision_enabled = false
|
||||
draw_layer = -2
|
||||
|
||||
[node name="ForegroundBarrel" parent="Scenery" instance=ExtResource("barrel")]
|
||||
position = Vector2(1420, 900)
|
||||
collision_enabled = false
|
||||
draw_layer = 10
|
||||
|
||||
[node name="Crate" parent="Scenery" instance=ExtResource("crate")]
|
||||
position = Vector2(1770, 900)
|
||||
|
||||
[node name="Bench" parent="Scenery" instance=ExtResource("bench")]
|
||||
position = Vector2(2030, 900)
|
||||
|
||||
[node name="Lamp" parent="Scenery" instance=ExtResource("lamp")]
|
||||
position = Vector2(2200, 900)
|
||||
|
||||
[node name="Cone" parent="Scenery" instance=ExtResource("cone")]
|
||||
position = Vector2(2320, 900)
|
||||
|
||||
[node name="TrashBin" parent="Scenery" instance=ExtResource("bin")]
|
||||
position = Vector2(2470, 900)
|
||||
|
||||
[node name="Rock" parent="Scenery" instance=ExtResource("rock")]
|
||||
position = Vector2(2630, 900)
|
||||
|
||||
[node name="Facade" parent="Scenery" instance=ExtResource("facade")]
|
||||
position = Vector2(2100, 900)
|
||||
|
||||
[node name="FirstPlatform" parent="World" instance=ExtResource("platform")]
|
||||
position = Vector2(2910, 770)
|
||||
dimensions = Vector2(240, 20)
|
||||
|
||||
[node name="SecondPlatform" parent="World" instance=ExtResource("platform")]
|
||||
position = Vector2(3180, 650)
|
||||
dimensions = Vector2(240, 20)
|
||||
|
||||
[node name="Coffee" parent="Items" instance=ExtResource("coffee")]
|
||||
position = Vector2(3180, 620)
|
||||
|
||||
[node name="SolidLabel" parent="Signs" instance=ExtResource("label")]
|
||||
offset_left = 560.0
|
||||
offset_top = 690.0
|
||||
offset_right = 800.0
|
||||
offset_bottom = 750.0
|
||||
text = "SOLIDO\nHay que saltarlo"
|
||||
|
||||
[node name="BackLabel" parent="Signs" instance=ExtResource("label")]
|
||||
offset_left = 930.0
|
||||
offset_top = 690.0
|
||||
offset_right = 1190.0
|
||||
offset_bottom = 750.0
|
||||
text = "SIN COLISION\nPasas por delante"
|
||||
|
||||
[node name="FrontLabel" parent="Signs" instance=ExtResource("label")]
|
||||
offset_left = 1300.0
|
||||
offset_top = 690.0
|
||||
offset_right = 1560.0
|
||||
offset_bottom = 750.0
|
||||
text = "SIN COLISION\nPasas por detras"
|
||||
|
||||
[node name="PlatformLabel" parent="Signs" instance=ExtResource("label")]
|
||||
offset_left = 2800.0
|
||||
offset_top = 490.0
|
||||
offset_right = 3300.0
|
||||
offset_bottom = 550.0
|
||||
text = "PLATAFORMAS ONE WAY\nSe atraviesan desde abajo"
|
||||
|
||||
[node name="EndSign" parent="Signs" instance=ExtResource("sign")]
|
||||
position = Vector2(3520, 900)
|
||||
text = "COPIA ESTAS PIEZAS\na tu propio nivel\nCtrl+C / Ctrl+V"
|
||||
+32
-49
@@ -1,14 +1,13 @@
|
||||
extends Node2D
|
||||
@tool
|
||||
extends LevelRoot
|
||||
|
||||
## Android test course: 17 stations / 17 different guaranteed items.
|
||||
## 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.
|
||||
## Laboratorio Android: 17 estaciones y 17 objetos garantizados distintos.
|
||||
## Los encuentros se colocan en la escena. Este nivel observa is_dead
|
||||
## y gestiona sus propias recompensas aunque no reciba alguna senal died.
|
||||
|
||||
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 v4"
|
||||
const CONTROL_ITEM_ID: StringName = &"lab_control"
|
||||
@@ -19,33 +18,32 @@ const PICKUP_SCENE: PackedScene = preload("res://pickups/pickup.tscn")
|
||||
@onready var status_label: Label = $TestHUD/Overlay/Status
|
||||
@onready var finish_message: Label = $TestHUD/Overlay/FinishMessage
|
||||
|
||||
var collected_items: Dictionary = {} # PickupData.id -> true; count each only once
|
||||
var collected_items: Dictionary = {} # PickupData.id -> true; cuenta cada objeto una sola vez.
|
||||
var defeated_enemies: int = 0
|
||||
var death_signals: int = 0
|
||||
var spawned_drops: int = 0
|
||||
var _processed_deaths: Dictionary = {} # enemy instance id -> true
|
||||
var _processed_deaths: Dictionary = {} # Identificador de instancia enemiga -> muerte ya procesada.
|
||||
var showing_victory: bool = false
|
||||
var victory_timer: float = 0.0
|
||||
|
||||
|
||||
## Configura las estaciones sin alterar las recompensas del resto de niveles.
|
||||
func _ready() -> void:
|
||||
# These two markers distinguish an actually loaded script from an old APK.
|
||||
super._ready()
|
||||
if Engine.is_editor_hint():
|
||||
return
|
||||
# Estos marcadores distinguen la version cargada de una instalacion antigua del 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.
|
||||
var camera: Camera2D = player.get_node("Camera2D") as Camera2D
|
||||
camera.limit_right = LEVEL_WIDTH
|
||||
|
||||
$FinishZone.body_entered.connect(_on_finish_entered)
|
||||
$DeathZone.body_entered.connect(_on_death_entered)
|
||||
player.connect(&"pickup_collected", _on_pickup_collected)
|
||||
for enemy in test_enemies.get_children():
|
||||
# Keep item-testing stations isolated despite the stronger game profiles.
|
||||
# Mantiene aisladas las estaciones aunque las variantes normales persigan a mayor distancia.
|
||||
enemy.set("chase_radius", 135.0)
|
||||
# The laboratory, not Walker, owns the fixed drop. Only this level sets
|
||||
# the flag: normal enemies still generate their usual random drops.
|
||||
# Solo el laboratorio asume la recompensa fija; los enemigos normales conservan sus propios drops.
|
||||
enemy.set("drops_handled_by_level", true)
|
||||
if enemy.get("guaranteed_drop") == null:
|
||||
push_error("%s has no guaranteed_drop assigned." % enemy.name)
|
||||
@@ -56,9 +54,12 @@ func _ready() -> void:
|
||||
_update_status()
|
||||
|
||||
|
||||
## Observa muertes y actualiza el diagnostico; tras completar, cuenta hasta reiniciar.
|
||||
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.
|
||||
super._process(delta)
|
||||
if Engine.is_editor_hint():
|
||||
return
|
||||
# El recuento y las recompensas no dependen de died. Cada muerte se procesa una sola vez.
|
||||
_process_station_deaths()
|
||||
if showing_victory:
|
||||
victory_timer += delta
|
||||
@@ -69,9 +70,9 @@ func _process(delta: float) -> void:
|
||||
_update_status()
|
||||
|
||||
|
||||
## Muestra progreso, estado de drops y siguiente recompensa.
|
||||
func _update_status() -> void:
|
||||
# Each station has one enemy and an assigned pickup. Look ahead to the first
|
||||
# living enemy so the player knows what to expect without opening a menu.
|
||||
# Busca la primera estacion viva por delante para anticipar su recompensa en el HUD.
|
||||
var next_item: String = "FIN DEL RECORRIDO"
|
||||
for enemy in test_enemies.get_children():
|
||||
if bool(enemy.get("is_dead")):
|
||||
@@ -84,8 +85,7 @@ func _update_status() -> void:
|
||||
next_item = data.display_name
|
||||
break
|
||||
|
||||
# S is the number of died signals received. KOs come from is_dead,
|
||||
# not signals. A difference between them pinpoints a signal problem.
|
||||
# Compara senales con muertes reales: una diferencia permite diagnosticar senales perdidas.
|
||||
var loose_drops: int = get_tree().get_nodes_in_group("pickup").size()
|
||||
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,
|
||||
@@ -93,6 +93,7 @@ func _update_status() -> void:
|
||||
]
|
||||
|
||||
|
||||
## Convierte cada nueva muerte en un unico objeto garantizado.
|
||||
func _process_station_deaths() -> void:
|
||||
for enemy in test_enemies.get_children():
|
||||
if not bool(enemy.get("is_dead")):
|
||||
@@ -108,8 +109,8 @@ func _process_station_deaths() -> void:
|
||||
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.
|
||||
# Prepara posicion y datos antes de diferir la entrada al arbol.
|
||||
# No se debe anadir un Area2D durante la resolucion de contactos fisicos.
|
||||
var pickup: Pickup = PICKUP_SCENE.instantiate() as Pickup
|
||||
pickup.pickup_data = data
|
||||
pickup.collection_delay_seconds = Pickup.DROP_COLLECTION_DELAY_SECONDS
|
||||
@@ -119,22 +120,23 @@ func _process_station_deaths() -> void:
|
||||
print("%s: KO %s -> %s" % [LAB_BUILD, enemy.name, data.display_name])
|
||||
|
||||
|
||||
## Cuenta senales para compararlas con las muertes observadas.
|
||||
func _on_station_enemy_died() -> void:
|
||||
# Diagnostic counter only; the actual reward is managed above.
|
||||
# Contador diagnostico; la recompensa se procesa por separado al observar is_dead.
|
||||
death_signals += 1
|
||||
|
||||
|
||||
## Cuenta identificadores distintos de recompensas realmente aplicadas.
|
||||
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.
|
||||
# El objeto inicial verifica imagen y recogida sin matar enemigos; no cuenta entre las 17 recompensas.
|
||||
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.
|
||||
# Una curacion con vida llena o carga ya completa no consume el objeto ni aumenta el recuento.
|
||||
collected_items[data.id] = true
|
||||
_update_status()
|
||||
|
||||
|
||||
## Completa el laboratorio al entrar el jugador en la meta.
|
||||
func _on_finish_entered(body: Node2D) -> void:
|
||||
if body != player or showing_victory:
|
||||
return
|
||||
@@ -146,26 +148,7 @@ func _on_finish_entered(body: Node2D) -> void:
|
||||
finish_message.visible = true
|
||||
|
||||
|
||||
## Aplica el comportamiento original del area de caida del laboratorio.
|
||||
func _on_death_entered(body: Node2D) -> void:
|
||||
if body == player and body.has_method("take_damage"):
|
||||
body.take_damage(9999, body.global_position)
|
||||
|
||||
|
||||
func _draw() -> void:
|
||||
# Temporary coloured geometry; collision shapes are the single source of
|
||||
# truth for position and dimensions, so the visuals cannot desynchronise.
|
||||
for child in $World.get_children():
|
||||
if not child is CollisionShape2D:
|
||||
continue
|
||||
var collision: CollisionShape2D = child as CollisionShape2D
|
||||
var rectangle: RectangleShape2D = collision.shape as RectangleShape2D
|
||||
if rectangle == null:
|
||||
continue
|
||||
var color: Color = Color(0.32, 0.57, 0.79)
|
||||
if collision.name == "Floor":
|
||||
color = Color(0.20, 0.40, 0.25)
|
||||
elif collision.name.begins_with("High"):
|
||||
color = Color(0.68, 0.39, 0.76)
|
||||
var rect: Rect2 = Rect2(collision.position - rectangle.size / 2.0, rectangle.size)
|
||||
draw_rect(rect, color, true)
|
||||
draw_rect(rect, Color(0.93, 0.94, 1.0, 0.6), false, 2.0)
|
||||
+55
-29
@@ -1,42 +1,61 @@
|
||||
[gd_scene load_steps=33 format=3]
|
||||
[gd_scene load_steps=31 format=3]
|
||||
|
||||
[ext_resource type="PackedScene" path="res://world/terrain/solid_block.tscn" id="kit_solid_block"]
|
||||
|
||||
[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"]
|
||||
|
||||
[ext_resource type="PackedScene" path="res://enemies/variants/backstage_guard.tscn" id="v3"]
|
||||
|
||||
[ext_resource type="PackedScene" path="res://enemies/variants/rival_guitarist.tscn" id="v4"]
|
||||
|
||||
[ext_resource type="Resource" path="res://pickups/data/pua_apocalipsis.tres" id="item_0"]
|
||||
|
||||
[ext_resource type="Resource" path="res://pickups/data/beer.tres" id="item_1"]
|
||||
|
||||
[ext_resource type="Resource" path="res://pickups/data/coffee.tres" id="item_2"]
|
||||
|
||||
[ext_resource type="Resource" path="res://pickups/data/casete_demo.tres" id="item_3"]
|
||||
|
||||
[ext_resource type="Resource" path="res://pickups/data/bocata_roadie.tres" id="item_4"]
|
||||
|
||||
[ext_resource type="Resource" path="res://pickups/data/lata_feedback.tres" id="item_5"]
|
||||
|
||||
[ext_resource type="Resource" path="res://pickups/data/pedal_distorsion.tres" id="item_6"]
|
||||
|
||||
[ext_resource type="Resource" path="res://pickups/data/setlist_fin.tres" id="item_7"]
|
||||
|
||||
[ext_resource type="Resource" path="res://pickups/data/pizza_post_bolo.tres" id="item_8"]
|
||||
|
||||
[ext_resource type="Resource" path="res://pickups/data/cuerda_titanio.tres" id="item_9"]
|
||||
|
||||
[ext_resource type="Resource" path="res://pickups/data/cinta_americana.tres" id="item_10"]
|
||||
|
||||
[ext_resource type="Resource" path="res://pickups/data/tapones_tecnico.tres" id="item_11"]
|
||||
|
||||
[ext_resource type="Resource" path="res://pickups/data/tupper_bateria.tres" id="item_12"]
|
||||
|
||||
[ext_resource type="Resource" path="res://pickups/data/botas_doble_bombo.tres" id="item_13"]
|
||||
|
||||
[ext_resource type="Resource" path="res://pickups/data/muelles_stage.tres" id="item_14"]
|
||||
|
||||
[ext_resource type="Resource" path="res://pickups/data/baqueta_sismica.tres" id="item_15"]
|
||||
|
||||
[ext_resource type="Resource" path="res://pickups/data/amplificador_11.tres" id="item_16"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="FloorShape"]
|
||||
size = Vector2(8500, 40)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="StepShape"]
|
||||
size = Vector2(240, 20)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="HighShape"]
|
||||
size = Vector2(180, 16)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="FinishShape"]
|
||||
size = Vector2(70, 200)
|
||||
|
||||
@@ -45,42 +64,49 @@ size = Vector2(9000, 170)
|
||||
|
||||
[node name="Level01" type="Node2D"]
|
||||
script = ExtResource("3_level")
|
||||
camera_bounds = Rect2(0, 0, 8500, 2500)
|
||||
|
||||
[node name="World" type="StaticBody2D" parent="."]
|
||||
collision_layer = 1
|
||||
collision_mask = 0
|
||||
[node name="World" type="Node2D" parent="."]
|
||||
|
||||
[node name="Floor" type="CollisionShape2D" parent="World"]
|
||||
[node name="Floor" parent="World" instance=ExtResource("kit_solid_block")]
|
||||
position = Vector2(4250, 620)
|
||||
shape = SubResource("FloorShape")
|
||||
dimensions = Vector2(8500, 40)
|
||||
fill_color = Color(0.20, 0.40, 0.25, 1)
|
||||
|
||||
[node name="Step1" type="CollisionShape2D" parent="World"]
|
||||
[node name="Step1" parent="World" instance=ExtResource("kit_solid_block")]
|
||||
position = Vector2(1530, 455)
|
||||
shape = SubResource("StepShape")
|
||||
dimensions = Vector2(240, 20)
|
||||
fill_color = Color(0.32, 0.57, 0.79, 1)
|
||||
|
||||
[node name="High1" type="CollisionShape2D" parent="World"]
|
||||
[node name="High1" parent="World" instance=ExtResource("kit_solid_block")]
|
||||
position = Vector2(1690, 291)
|
||||
shape = SubResource("HighShape")
|
||||
dimensions = Vector2(180, 16)
|
||||
fill_color = Color(0.68, 0.39, 0.76, 1)
|
||||
|
||||
[node name="Step2" type="CollisionShape2D" parent="World"]
|
||||
[node name="Step2" parent="World" instance=ExtResource("kit_solid_block")]
|
||||
position = Vector2(3370, 485)
|
||||
shape = SubResource("StepShape")
|
||||
dimensions = Vector2(240, 20)
|
||||
fill_color = Color(0.32, 0.57, 0.79, 1)
|
||||
|
||||
[node name="High2" type="CollisionShape2D" parent="World"]
|
||||
[node name="High2" parent="World" instance=ExtResource("kit_solid_block")]
|
||||
position = Vector2(3520, 338)
|
||||
shape = SubResource("HighShape")
|
||||
dimensions = Vector2(180, 16)
|
||||
fill_color = Color(0.68, 0.39, 0.76, 1)
|
||||
|
||||
[node name="Step3" type="CollisionShape2D" parent="World"]
|
||||
[node name="Step3" parent="World" instance=ExtResource("kit_solid_block")]
|
||||
position = Vector2(5600, 455)
|
||||
shape = SubResource("StepShape")
|
||||
dimensions = Vector2(240, 20)
|
||||
fill_color = Color(0.32, 0.57, 0.79, 1)
|
||||
|
||||
[node name="High3" type="CollisionShape2D" parent="World"]
|
||||
[node name="High3" parent="World" instance=ExtResource("kit_solid_block")]
|
||||
position = Vector2(5750, 291)
|
||||
shape = SubResource("HighShape")
|
||||
dimensions = Vector2(180, 16)
|
||||
fill_color = Color(0.68, 0.39, 0.76, 1)
|
||||
|
||||
[node name="Step4" type="CollisionShape2D" parent="World"]
|
||||
[node name="Step4" parent="World" instance=ExtResource("kit_solid_block")]
|
||||
position = Vector2(6890, 485)
|
||||
shape = SubResource("StepShape")
|
||||
dimensions = Vector2(240, 20)
|
||||
fill_color = Color(0.32, 0.57, 0.79, 1)
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource("1_player")]
|
||||
position = Vector2(140, 557)
|
||||
|
||||
+15
-46
@@ -1,22 +1,15 @@
|
||||
extends Node2D
|
||||
@tool
|
||||
extends LevelRoot
|
||||
|
||||
## Alpha de campo: recorrido urbano con suelo a distintas alturas, plataformas,
|
||||
## grupos de enemigos y objetos opcionales. Las posiciones y colisiones se editan
|
||||
## en level_02.tscn; este script solo dibuja las superficies y gestiona la meta.
|
||||
## en level_02.tscn; este script solo gestiona el progreso y la meta.
|
||||
## No interviene en los drops: los Walker usan su sistema habitual.
|
||||
|
||||
signal level_completed
|
||||
|
||||
const WORLD_WIDTH: int = 11000
|
||||
const FINISH_RESTART_SECONDS: float = 9.0
|
||||
|
||||
# El dibujo utiliza directamente los CollisionShape2D del escenario. Así no
|
||||
# hay una segunda lista de coordenadas visuales que pueda desincronizarse.
|
||||
const ASPHALT: Texture2D = preload("res://assets/city/asphalt.png")
|
||||
const CURB: Texture2D = preload("res://assets/city/curb.png")
|
||||
const WALKWAY: Texture2D = preload("res://assets/city/walkway.png")
|
||||
const BARRIER: Texture2D = preload("res://assets/city/barrier.png")
|
||||
|
||||
@onready var player: CharacterBody2D = $Player
|
||||
@onready var enemies: Node2D = $Enemies
|
||||
@onready var status_label: Label = $LevelHUD/Overlay/Status
|
||||
@@ -27,15 +20,11 @@ var completed: bool = false
|
||||
var _finish_timer: float = 0.0
|
||||
|
||||
|
||||
## Conecta meta y derrotas; LevelRoot aplica los limites de camara.
|
||||
func _ready() -> void:
|
||||
# Camera2D configura un límite provisional de 4000 en su propio _ready().
|
||||
# El nivel lo sustituye después de que el jugador haya entrado en el árbol.
|
||||
var camera: Camera2D = player.get_node("Camera2D") as Camera2D
|
||||
camera.limit_left = 0
|
||||
camera.limit_top = 0
|
||||
camera.limit_right = WORLD_WIDTH
|
||||
camera.limit_bottom = 1280
|
||||
|
||||
super._ready()
|
||||
if Engine.is_editor_hint():
|
||||
return
|
||||
$FinishZone.body_entered.connect(_on_finish_entered)
|
||||
finish_message.visible = false
|
||||
for enemy: Node in enemies.get_children():
|
||||
@@ -44,7 +33,11 @@ func _ready() -> void:
|
||||
_update_status()
|
||||
|
||||
|
||||
## Actualiza el progreso o espera el reinicio tras completar la calle.
|
||||
func _process(delta: float) -> void:
|
||||
super._process(delta)
|
||||
if Engine.is_editor_hint():
|
||||
return
|
||||
if completed:
|
||||
_finish_timer += delta
|
||||
if _finish_timer >= FINISH_RESTART_SECONDS:
|
||||
@@ -53,17 +46,20 @@ func _process(delta: float) -> void:
|
||||
_update_status()
|
||||
|
||||
|
||||
## Incrementa el contador de enemigos derrotados.
|
||||
func _on_enemy_died() -> void:
|
||||
defeated_enemies += 1
|
||||
|
||||
|
||||
## Calcula el sector segun los limites editables del nivel.
|
||||
func _update_status() -> void:
|
||||
var sector: int = clampi(int(player.global_position.x / (WORLD_WIDTH / 8.0)) + 1, 1, 8)
|
||||
var sector: int = clampi(int((player.position.x - camera_bounds.position.x) / (camera_bounds.size.x / 8.0)) + 1, 1, 8)
|
||||
status_label.text = "CALLE DEL FEEDBACK %02d/08\nKOs: %02d/%02d" % [
|
||||
sector, defeated_enemies, enemies.get_child_count()
|
||||
]
|
||||
|
||||
|
||||
## Muestra el resultado una sola vez al alcanzar la meta.
|
||||
func _on_finish_entered(body: Node2D) -> void:
|
||||
if body != player or completed:
|
||||
return
|
||||
@@ -73,30 +69,3 @@ func _on_finish_entered(body: Node2D) -> void:
|
||||
defeated_enemies, enemies.get_child_count()
|
||||
]
|
||||
finish_message.visible = true
|
||||
|
||||
|
||||
func _draw() -> void:
|
||||
# Tiling GPU: dos pequeños PNG para miles de unidades de calle.
|
||||
for collision: CollisionShape2D in $World/Ground.get_children():
|
||||
var bounds: Rect2 = _collision_rect(collision)
|
||||
if bounds.has_area():
|
||||
draw_texture_rect(ASPHALT, bounds, true)
|
||||
draw_texture_rect(CURB, Rect2(bounds.position.x, bounds.position.y, bounds.size.x, 24), true)
|
||||
|
||||
# Plataformas de una sola dirección: se atraviesan desde abajo, se aterriza
|
||||
# sobre ellas desde arriba y un segundo salto abre rutas opcionales.
|
||||
for collision: CollisionShape2D in $World/Walkways.get_children():
|
||||
var bounds: Rect2 = _collision_rect(collision)
|
||||
if bounds.has_area():
|
||||
draw_texture_rect(WALKWAY, bounds, true)
|
||||
|
||||
# Barreras visibles y sólidas; el jugador no puede abandonar el mapa.
|
||||
for wall_x: float in [0.0, WORLD_WIDTH - 48.0]:
|
||||
draw_texture_rect(BARRIER, Rect2(wall_x, 280.0, 48.0, 820.0), true)
|
||||
|
||||
|
||||
func _collision_rect(collision: CollisionShape2D) -> Rect2:
|
||||
var shape: RectangleShape2D = collision.shape as RectangleShape2D
|
||||
if shape == null:
|
||||
return Rect2()
|
||||
return Rect2(collision.position - shape.size * 0.5, shape.size)
|
||||
+205
-495
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,84 @@
|
||||
@tool
|
||||
class_name LevelRoot
|
||||
extends Node2D
|
||||
|
||||
## Infraestructura minima de un escenario, no un sistema de eventos.
|
||||
## La plantilla contiene Player, terreno, decoracion, enemigos y controles.
|
||||
## Los niveles con reglas propias pueden heredar y llamar a super en sus callbacks.
|
||||
|
||||
@export_category("Level")
|
||||
## Limites locales de camara. El rectangulo se puede ver antes de ejecutar el juego.
|
||||
@export var camera_bounds: Rect2 = Rect2(0.0, 0.0, 2400.0, 1280.0):
|
||||
set(value):
|
||||
camera_bounds = Rect2(value.position, Vector2(maxf(value.size.x, 1.0), maxf(value.size.y, 1.0)))
|
||||
queue_redraw()
|
||||
## Recuperacion al caer fuera del mapa. No depende de escudos o invulnerabilidad.
|
||||
@export var reset_after_fall: bool = true:
|
||||
set(value):
|
||||
reset_after_fall = value
|
||||
queue_redraw()
|
||||
@export_range(0.0, 2000.0, 16.0) var fall_margin: float = 256.0:
|
||||
set(value):
|
||||
fall_margin = value
|
||||
queue_redraw()
|
||||
@export var show_editor_bounds: bool = true:
|
||||
set(value):
|
||||
show_editor_bounds = value
|
||||
queue_redraw()
|
||||
|
||||
var _level_player: Node2D
|
||||
var _reload_pending: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
if Engine.is_editor_hint():
|
||||
update_configuration_warnings()
|
||||
return
|
||||
_level_player = get_node_or_null("Player") as Node2D
|
||||
if _level_player == null:
|
||||
push_error("LevelRoot necesita una instancia de player/player.tscn llamada Player.")
|
||||
return
|
||||
apply_camera_bounds()
|
||||
|
||||
|
||||
## Se ejecuta despues del _ready del jugador, sin limites ocultos en Camera2D.
|
||||
func apply_camera_bounds() -> void:
|
||||
var camera: Camera2D = _level_player.get_node_or_null("Camera2D") as Camera2D
|
||||
if camera == null:
|
||||
return
|
||||
var top_left: Vector2 = to_global(camera_bounds.position)
|
||||
var bottom_right: Vector2 = to_global(camera_bounds.end)
|
||||
camera.limit_left = floori(top_left.x)
|
||||
camera.limit_top = floori(top_left.y)
|
||||
camera.limit_right = ceili(bottom_right.x)
|
||||
camera.limit_bottom = ceili(bottom_right.y)
|
||||
camera.reset_smoothing()
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if Engine.is_editor_hint() or not reset_after_fall or _reload_pending:
|
||||
return
|
||||
if not is_instance_valid(_level_player):
|
||||
return
|
||||
if _level_player.global_position.y > to_global(camera_bounds.end).y + fall_margin:
|
||||
_reload_pending = true
|
||||
# La recarga se difiere para no destruir nodos durante un paso de fisica.
|
||||
get_tree().call_deferred("reload_current_scene")
|
||||
|
||||
|
||||
func _draw() -> void:
|
||||
if not Engine.is_editor_hint() or not show_editor_bounds:
|
||||
return
|
||||
draw_rect(camera_bounds, Color(0.25, 0.8, 1.0, 0.6), false, 2.0)
|
||||
if reset_after_fall:
|
||||
var y: float = camera_bounds.end.y + fall_margin
|
||||
draw_line(Vector2(camera_bounds.position.x, y), Vector2(camera_bounds.end.x, y), Color(1.0, 0.3, 0.3, 0.7), 2.0)
|
||||
|
||||
|
||||
func _get_configuration_warnings() -> PackedStringArray:
|
||||
var warnings := PackedStringArray()
|
||||
if not has_node("Player"):
|
||||
warnings.append("Falta Player. Arrastra player/player.tscn y conserva ese nombre en la raiz del nivel.")
|
||||
if not scale.is_equal_approx(Vector2.ONE) or not is_zero_approx(rotation):
|
||||
warnings.append("No escales ni rotes la raiz del nivel; edita las piezas individualmente.")
|
||||
return warnings
|
||||
@@ -0,0 +1,49 @@
|
||||
[gd_scene load_steps=8 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://levels/level_root.gd" id="level"]
|
||||
[ext_resource type="PackedScene" path="res://player/player.tscn" id="player"]
|
||||
[ext_resource type="PackedScene" path="res://ui/mobile_controls/mobile_controls.tscn" id="mobile"]
|
||||
[ext_resource type="PackedScene" path="res://world/backgrounds/city_background.tscn" id="background"]
|
||||
[ext_resource type="PackedScene" path="res://world/terrain/ground.tscn" id="ground"]
|
||||
[ext_resource type="PackedScene" path="res://world/terrain/wall.tscn" id="wall"]
|
||||
[ext_resource type="PackedScene" path="res://world/signs/sign_post.tscn" id="sign"]
|
||||
|
||||
[node name="NewLevel" type="Node2D"]
|
||||
texture_filter = 1
|
||||
script = ExtResource("level")
|
||||
camera_bounds = Rect2(0, 0, 2400, 1280)
|
||||
|
||||
[node name="CityBackground" parent="." instance=ExtResource("background")]
|
||||
|
||||
[node name="World" type="Node2D" parent="."]
|
||||
|
||||
[node name="Ground" parent="World" instance=ExtResource("ground")]
|
||||
position = Vector2(1200, 1030)
|
||||
dimensions = Vector2(2400, 260)
|
||||
|
||||
[node name="LeftBoundary" parent="World" instance=ExtResource("wall")]
|
||||
position = Vector2(0, 500)
|
||||
dimensions = Vector2(48, 1000)
|
||||
|
||||
[node name="RightBoundary" parent="World" instance=ExtResource("wall")]
|
||||
position = Vector2(2400, 500)
|
||||
dimensions = Vector2(48, 1000)
|
||||
|
||||
[node name="Scenery" type="Node2D" parent="."]
|
||||
|
||||
[node name="Signs" type="Node2D" parent="."]
|
||||
|
||||
[node name="Welcome" parent="Signs" instance=ExtResource("sign")]
|
||||
position = Vector2(330, 900)
|
||||
text = "NUEVO ESCENARIO\nEdita este texto\nen el Inspector"
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource("player")]
|
||||
position = Vector2(160, 874)
|
||||
|
||||
[node name="Enemies" type="Node2D" parent="."]
|
||||
|
||||
[node name="Items" type="Node2D" parent="."]
|
||||
|
||||
[node name="Triggers" type="Node2D" parent="."]
|
||||
|
||||
[node name="MobileControls" parent="." instance=ExtResource("mobile")]
|
||||
@@ -1,16 +1,15 @@
|
||||
[gd_scene load_steps=7 format=3]
|
||||
[gd_scene load_steps=6 format=3]
|
||||
|
||||
[ext_resource type="PackedScene" path="res://world/terrain/solid_block.tscn" id="kit_solid_block"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://jmadeu351yh6" path="res://assets/photo_5837080277660930029_w.jpg" id="1_background"]
|
||||
|
||||
[ext_resource type="PackedScene" path="res://player/player.tscn" id="2_player"]
|
||||
|
||||
[ext_resource type="PackedScene" path="res://enemies/walker/walker.tscn" id="3_walker"]
|
||||
|
||||
[ext_resource type="PackedScene" path="res://ui/mobile_controls/mobile_controls.tscn" id="4_mobile_controls"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="FloorShape"]
|
||||
size = Vector2(1171, 20)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="WallShape"]
|
||||
size = Vector2(136, 156)
|
||||
|
||||
[node name="CombatTest" type="Node2D"]
|
||||
|
||||
[node name="Background" type="Sprite2D" parent="."]
|
||||
@@ -18,17 +17,17 @@ position = Vector2(576, 324)
|
||||
scale = Vector2(0.8181818, 0.84374994)
|
||||
texture = ExtResource("1_background")
|
||||
|
||||
[node name="World" type="StaticBody2D" parent="."]
|
||||
collision_layer = 1
|
||||
collision_mask = 0
|
||||
[node name="World" type="Node2D" parent="."]
|
||||
|
||||
[node name="Floor" type="CollisionShape2D" parent="World"]
|
||||
[node name="Floor" parent="World" instance=ExtResource("kit_solid_block")]
|
||||
position = Vector2(585, 465)
|
||||
shape = SubResource("FloorShape")
|
||||
dimensions = Vector2(1171, 20)
|
||||
fill_color = Color(0.20, 0.40, 0.25, 1)
|
||||
|
||||
[node name="LeftWall" type="CollisionShape2D" parent="World"]
|
||||
[node name="LeftWall" parent="World" instance=ExtResource("kit_solid_block")]
|
||||
position = Vector2(77, 361)
|
||||
shape = SubResource("WallShape")
|
||||
dimensions = Vector2(136, 156)
|
||||
fill_color = Color(0.32, 0.57, 0.79, 1)
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource("2_player")]
|
||||
position = Vector2(95, 215)
|
||||
|
||||
Reference in new issue
Block a user