|
@@ -1,4 +1,5 @@
|
|
|
extends Node2D
|
|
|
+class_name Game
|
|
|
|
|
|
@onready var health_bar: HealthBar = $HealthBar
|
|
|
@onready var overlay: CanvasLayer = $Overlay
|
|
@@ -35,6 +36,10 @@ enum Loot {
|
|
|
LOOT_LOWER_COOLDOWN,
|
|
|
}
|
|
|
|
|
|
+const RELOAD_TIME: float = 4.0
|
|
|
+static var reload_time: float = RELOAD_TIME # seconds
|
|
|
+static var max_ammo: int = 1 # shots
|
|
|
+
|
|
|
var phase: Phase = Phase.PHASE_SETUP:
|
|
|
set(new_value):
|
|
|
phase = new_value
|
|
@@ -52,9 +57,12 @@ var waves_completed: int = 0:
|
|
|
wave_label.text = "WAVE: %d" % (new_value + 1)
|
|
|
|
|
|
func _ready() -> void:
|
|
|
+ Game.reload_time = RELOAD_TIME # seconds
|
|
|
+ Game.max_ammo = 1 # shots
|
|
|
waves_completed = 0
|
|
|
phase = Phase.PHASE_SETUP
|
|
|
overlay.visible = true
|
|
|
+ player_spawn.add_survivor()
|
|
|
transition.slide_out()
|
|
|
await transition.game_fully_visible
|
|
|
|
|
@@ -77,6 +85,7 @@ func go_to_main_menu() -> void:
|
|
|
func spawn_bot(spawn: Marker2D) -> void:
|
|
|
var bot: Bot = bot_scene.instantiate()
|
|
|
bot.global_position = spawn.global_position
|
|
|
+ bot.speed += waves_completed
|
|
|
bot.visible = false
|
|
|
add_child(bot)
|
|
|
|
|
@@ -103,12 +112,13 @@ func activate_foe() -> void:
|
|
|
|
|
|
func reset_survivors() -> void:
|
|
|
var survivors = get_survivors()
|
|
|
+ #for survivor in survivors:
|
|
|
+ # survivor.reparent(self)
|
|
|
for survivor in survivors:
|
|
|
- survivor.reparent(self)
|
|
|
- for survivor in survivors:
|
|
|
- player_spawn.drop(survivor)
|
|
|
- survivor.position = Vector2.ZERO
|
|
|
- survivor.rotation = 0.0
|
|
|
+ #player_spawn.drop(survivor)
|
|
|
+ #survivor.position = Vector2.ZERO
|
|
|
+ #survivor.rotation = 0.0
|
|
|
+ survivor.ammo = Game.max_ammo
|
|
|
|
|
|
func _on_timer_timeout() -> void:
|
|
|
activate_foe()
|
|
@@ -116,7 +126,7 @@ func _on_timer_timeout() -> void:
|
|
|
func base_hit() -> void:
|
|
|
health_bar.health -= 1
|
|
|
if health_bar.health == 0:
|
|
|
- game_over()
|
|
|
+ await game_over()
|
|
|
|
|
|
func game_over() -> void:
|
|
|
spawn_timer.stop()
|
|
@@ -144,14 +154,24 @@ func start_combat() -> void:
|
|
|
combat_start_sound.play()
|
|
|
activate_foe()
|
|
|
|
|
|
+const LOOT_SURVIVOR: String = "+1 SURVIVOR"
|
|
|
+const LOOT_HEALTH: String = "+3 HEALTH"
|
|
|
+const LOOT_AMMO: String = "BIGGER MAGAZINES"
|
|
|
+const LOOT_RELOAD_TIME: String = "FASTER RELOADING"
|
|
|
+const LOOTS: Array[String] = [LOOT_SURVIVOR, LOOT_HEALTH, LOOT_AMMO, LOOT_RELOAD_TIME]
|
|
|
+
|
|
|
func end_combat() -> void:
|
|
|
phase = Phase.PHASE_LOOT
|
|
|
spawn_timer.stop()
|
|
|
+ await get_tree().create_timer(1.5).timeout
|
|
|
var vs: Victory = victory_scene.instantiate()
|
|
|
ui_root.add_child(vs)
|
|
|
- vs.set_loot_options("+1 SURVIVOR", "+3 HEALTH", "FASTER SHOTS")
|
|
|
+ var loots: Array[String] = []
|
|
|
+ loots.assign(LOOTS)
|
|
|
+ loots.shuffle()
|
|
|
+ vs.set_loot_options(loots[0], loots[1], loots[2])
|
|
|
await vs.loot_selected
|
|
|
- var loot = vs.selection
|
|
|
+ var loot: String = loots[vs.selection]
|
|
|
print("selected loot: " + str(loot))
|
|
|
var next_wave = waves_completed + 2
|
|
|
await transition.transition("WAVE %d" % next_wave, func ():
|
|
@@ -160,12 +180,14 @@ func end_combat() -> void:
|
|
|
self.next_phase_button.disabled = false
|
|
|
self.reset_survivors()
|
|
|
match loot:
|
|
|
- 0:
|
|
|
+ LOOT_SURVIVOR:
|
|
|
self.player_spawn.add_survivor()
|
|
|
- 1:
|
|
|
+ LOOT_HEALTH:
|
|
|
self.health_bar.health += 3
|
|
|
- 2:
|
|
|
- pass # TODO: increase fire rate
|
|
|
+ LOOT_RELOAD_TIME:
|
|
|
+ Game.reload_time *= 0.9
|
|
|
+ LOOT_AMMO:
|
|
|
+ Game.max_ammo += 1
|
|
|
)
|
|
|
GlobalInput.dragging_disabled = false
|
|
|
|