|
@@ -18,10 +18,19 @@ class_name Game
|
|
|
@onready var game_over_scene: PackedScene = load("res://assets/scenes/game_over.tscn")
|
|
|
@onready var victory_scene: PackedScene = load("res://assets/scenes/victory.tscn")
|
|
|
|
|
|
+@onready var left_enemy_label: Label = $UI/Root/LeftEnemyLabel
|
|
|
+@onready var right_enemy_label: Label = $UI/Root/RightEnemyLabel
|
|
|
+@onready var top_enemy_label: Label = $UI/Root/TopEnemyLabel
|
|
|
+
|
|
|
@onready var spawn_points: Array[Marker2D] = [
|
|
|
- $EnemySpawns/EnemySpawn_1,
|
|
|
- $EnemySpawns/EnemySpawn_2,
|
|
|
- $EnemySpawns/EnemySpawn_3,
|
|
|
+ $EnemySpawns/EnemySpawn_Left,
|
|
|
+ $EnemySpawns/EnemySpawn_Right,
|
|
|
+ $EnemySpawns/EnemySpawn_Top,
|
|
|
+]
|
|
|
+@onready var enemy_labels: Array[Label] = [
|
|
|
+ $UI/Root/LeftEnemyLabel,
|
|
|
+ $UI/Root/RightEnemyLabel,
|
|
|
+ $UI/Root/TopEnemyLabel,
|
|
|
]
|
|
|
|
|
|
enum Phase {
|
|
@@ -57,12 +66,23 @@ var waves_completed: int = 0:
|
|
|
waves_completed = new_value
|
|
|
wave_label.text = "WAVE: %d" % (new_value + 1)
|
|
|
|
|
|
+func update_enemy_labels() -> void:
|
|
|
+ for n in 3:
|
|
|
+ var enemies = spawn_points[n].get_child_count()
|
|
|
+ enemy_labels[n].text = str(enemies)
|
|
|
+
|
|
|
+func set_enemy_label_visible(value: bool) -> void:
|
|
|
+ for label in enemy_labels:
|
|
|
+ label.visible = value
|
|
|
+
|
|
|
func _ready() -> void:
|
|
|
Game.reload_time = RELOAD_TIME # seconds
|
|
|
Game.max_ammo = 1 # shots
|
|
|
+ Game.base_accuracy = 0.33 # percent
|
|
|
waves_completed = 0
|
|
|
phase = Phase.PHASE_SETUP
|
|
|
overlay.visible = true
|
|
|
+ start_setup()
|
|
|
player_spawn.add_survivor()
|
|
|
transition.slide_out()
|
|
|
await transition.game_fully_visible
|
|
@@ -83,12 +103,13 @@ func go_to_main_menu() -> void:
|
|
|
tree.change_scene_to_packed(main_menu)
|
|
|
tree.paused = false
|
|
|
|
|
|
-func spawn_bot(spawn: Marker2D) -> void:
|
|
|
+func spawn_bot(spawn: Marker2D, index: int) -> void:
|
|
|
var bot: Bot = bot_scene.instantiate()
|
|
|
- bot.global_position = spawn.global_position
|
|
|
+ bot.name = "Bot #%d" % (index + 1)
|
|
|
bot.speed += waves_completed
|
|
|
bot.visible = false
|
|
|
- add_child(bot)
|
|
|
+ spawn.add_child(bot)
|
|
|
+ bot.position = Vector2.ZERO
|
|
|
|
|
|
func get_foes() -> Array[Area2D]:
|
|
|
var foes: Array[Area2D] = []
|
|
@@ -145,11 +166,16 @@ func _on_base_area_entered(area: Area2D) -> void:
|
|
|
if area.is_in_group("foe") || area.is_in_group("foe_weapons"):
|
|
|
base_hit()
|
|
|
|
|
|
-func start_combat() -> void:
|
|
|
- GlobalInput.dragging_disabled = true
|
|
|
+func start_setup() -> void:
|
|
|
for n in (waves_completed + 1):
|
|
|
var spawner = spawn_points.pick_random()
|
|
|
- spawn_bot(spawner)
|
|
|
+ spawn_bot(spawner, n)
|
|
|
+ update_enemy_labels()
|
|
|
+ set_enemy_label_visible(true)
|
|
|
+
|
|
|
+func start_combat() -> void:
|
|
|
+ set_enemy_label_visible(false)
|
|
|
+ GlobalInput.dragging_disabled = true
|
|
|
spawn_timer.wait_time = lerpf(3.5, 0.5, minf(float(waves_completed)/20.0, 1.0))
|
|
|
spawn_timer.start()
|
|
|
combat_start_sound.play()
|
|
@@ -170,7 +196,7 @@ func end_combat() -> void:
|
|
|
ui_root.add_child(vs)
|
|
|
var loots: Array[String] = []
|
|
|
loots.assign(LOOTS)
|
|
|
- if get_survivors().size() >= 9:
|
|
|
+ if get_survivors().size() >= 6: # this is, so the player has a reason to move survivors even later
|
|
|
loots.erase(LOOT_SURVIVOR)
|
|
|
loots.shuffle()
|
|
|
vs.set_loot_options(loots[0], loots[1], loots[2])
|
|
@@ -194,6 +220,7 @@ func end_combat() -> void:
|
|
|
LOOT_ACCURACY:
|
|
|
Game.base_accuracy += 0.1
|
|
|
self.reset_survivors()
|
|
|
+ self.start_setup()
|
|
|
)
|
|
|
GlobalInput.dragging_disabled = false
|
|
|
|