diff --git a/game/controllers/enemy_swamp_controller.gd b/game/controllers/enemy_swamp_controller.gd index fdeefa0..caaccde 100644 --- a/game/controllers/enemy_swamp_controller.gd +++ b/game/controllers/enemy_swamp_controller.gd @@ -15,6 +15,9 @@ const MAX_POSITION = Vector2(600, 330) @export var passage : Passage +var _enemy_count := 0 + + @onready var enemy_update_timer : Timer = $EnemyUpdateTimer @@ -28,17 +31,13 @@ func create_enemy(enemy_data: EnemyData) -> void: enemy.position = enemy_data.spawn_point enemy.enemy_data = enemy_data enemy.velocity = enemy.position.direction_to(player.position) * enemy.max_speed + enemy.destroyed.connect(_on_enemy_destroyed, CONNECT_ONE_SHOT) _update_enemy.call_deferred(enemy) + _enemy_count += 1 -func _on_enemy_update_timer_timeout() -> void: - var enemies := get_tree().get_nodes_in_group("enemies") - if enemies.is_empty(): return - - var enemy : Node = enemies.pick_random() - if not enemy is AbstractEnemyShip: return - - _update_enemy(enemy) +func get_enemy_count() -> int: + return _enemy_count func _update_enemy(enemy: AbstractEnemyShip) -> void: @@ -97,3 +96,17 @@ func _get_random_player() -> PlayerShip: var player : PlayerShip = players.pick_random() return player + + +func _on_enemy_destroyed() -> void: + _enemy_count -= 1 + + +func _on_enemy_update_timer_timeout() -> void: + var enemies := get_tree().get_nodes_in_group("enemies") + if enemies.is_empty(): return + + var enemy : Node = enemies.pick_random() + if not enemy is AbstractEnemyShip: return + + _update_enemy(enemy) diff --git a/game/entities/weapons/cannon/abstract_cannon_weapon.gd b/game/entities/weapons/cannon/abstract_cannon_weapon.gd index 1e1a98b..1c42abd 100644 --- a/game/entities/weapons/cannon/abstract_cannon_weapon.gd +++ b/game/entities/weapons/cannon/abstract_cannon_weapon.gd @@ -17,8 +17,9 @@ func _ready() -> void: func shoot(ship_velocity: Vector2) -> bool: var is_shot := super.shoot(ship_velocity) if is_shot: - sprite.play(SHOT_ANIMATION) _can_shoot = false + SoundManager.play_sfx_stream(SoundManager.sfx_weapon_cannon_shot, global_position) + sprite.play(SHOT_ANIMATION) cooldown_timer.start() front_particles.restart() left_particles.restart() diff --git a/game/entities/weapons/plasma/abstract_plasma_weapon.gd b/game/entities/weapons/plasma/abstract_plasma_weapon.gd index 9f11039..5f6d1ce 100644 --- a/game/entities/weapons/plasma/abstract_plasma_weapon.gd +++ b/game/entities/weapons/plasma/abstract_plasma_weapon.gd @@ -12,8 +12,9 @@ func _ready() -> void: func shoot(ship_velocity: Vector2) -> bool: var is_shot := super.shoot(ship_velocity) if is_shot: - sprite.play(SHOT_ANIMATION) _can_shoot = false + SoundManager.play_sfx_stream(SoundManager.sfx_weapon_plasma_shot, global_position) + sprite.play(SHOT_ANIMATION) cooldown_timer.start() return is_shot diff --git a/game/entities/weapons/plasma/player_plasma_weapon.tscn b/game/entities/weapons/plasma/player_plasma_weapon.tscn index e1cb33c..4ab2538 100644 --- a/game/entities/weapons/plasma/player_plasma_weapon.tscn +++ b/game/entities/weapons/plasma/player_plasma_weapon.tscn @@ -57,8 +57,9 @@ script = ExtResource("2_hxkfe") projectile_scene = ExtResource("3_hxkfe") [node name="AnimatedSprite2D" parent="." index="0"] +position = Vector2(7, 0) sprite_frames = SubResource("SpriteFrames_hxkfe") -animation = &"shot" +animation = &"reloading" [node name="Muzzle" parent="." index="2"] -position = Vector2(1, 2) +position = Vector2(8, 2) diff --git a/game/entities/weapons/railgun/abstract_railgun_weapon.gd b/game/entities/weapons/railgun/abstract_railgun_weapon.gd index 972a88a..69d3c44 100644 --- a/game/entities/weapons/railgun/abstract_railgun_weapon.gd +++ b/game/entities/weapons/railgun/abstract_railgun_weapon.gd @@ -12,8 +12,9 @@ func _ready() -> void: func shoot(ship_velocity: Vector2) -> bool: var is_shot := super.shoot(ship_velocity) if is_shot: - sprite.play(SHOT_ANIMATION) _can_shoot = false + SoundManager.play_sfx_stream(SoundManager.sfx_weapon_railgun_shot, global_position) + sprite.play(SHOT_ANIMATION) return is_shot diff --git a/game/entities/weapons/shrapnel/abstract_shrapnel_weapon.gd b/game/entities/weapons/shrapnel/abstract_shrapnel_weapon.gd index 11f44de..cc9e155 100644 --- a/game/entities/weapons/shrapnel/abstract_shrapnel_weapon.gd +++ b/game/entities/weapons/shrapnel/abstract_shrapnel_weapon.gd @@ -15,8 +15,9 @@ func _ready() -> void: func shoot(ship_velocity: Vector2) -> bool: var is_shot := super.shoot(ship_velocity) if is_shot: - sprite.play(SHOT_ANIMATION) _can_shoot = false + SoundManager.play_sfx_stream(SoundManager.sfx_weapon_sharapnel_shot, global_position) + sprite.play(SHOT_ANIMATION) cooldown_timer.start() shot_particles.restart() shell_particles.emit_particle(Transform2D(), Vector2(), Color(), Color(), 0) diff --git a/game/entities/world/passage.gd b/game/entities/world/passage.gd index 5798f23..1069bf7 100644 --- a/game/entities/world/passage.gd +++ b/game/entities/world/passage.gd @@ -30,7 +30,8 @@ func _physics_process(delta: float) -> void: _current_progress += delta _update_progress_indicator() if _current_progress >= passage_data.length: - completed.emit() + if enemy_swamp_controller.get_enemy_count() == 0: + completed.emit() func _set_passage_data(new_data: PassageData) -> void: diff --git a/game/managers/sound_manager.gd b/game/managers/sound_manager.gd index 6a1093b..03a06f2 100644 --- a/game/managers/sound_manager.gd +++ b/game/managers/sound_manager.gd @@ -27,6 +27,10 @@ const MUSIC_BUS = "Music" @export_group("SFX Sounds", "sfx") @export_subgroup("Weapon", "sfx_weapon") @export var sfx_weapon_gatling_shot : AudioStream +@export var sfx_weapon_cannon_shot : AudioStream +@export var sfx_weapon_plasma_shot : AudioStream +@export var sfx_weapon_railgun_shot : AudioStream +@export var sfx_weapon_sharapnel_shot : AudioStream var _ui_players : Array[AudioStreamPlayer] = [] diff --git a/game/managers/sound_manager.tscn b/game/managers/sound_manager.tscn index e443950..cc5b0d1 100644 --- a/game/managers/sound_manager.tscn +++ b/game/managers/sound_manager.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=7 format=3 uid="uid://bc0np3ldfspq4"] +[gd_scene load_steps=11 format=3 uid="uid://bc0np3ldfspq4"] [ext_resource type="Script" uid="uid://cx5qcukr66whc" path="res://game/managers/sound_manager.gd" id="1_cg0sy"] [ext_resource type="AudioStream" uid="uid://bqcqigmj23ub5" path="res://sound/ui/ui_accept.wav" id="2_agyxs"] @@ -6,6 +6,10 @@ [ext_resource type="AudioStream" uid="uid://bmlticluh8uqd" path="res://sound/ui/ui_next.wav" id="4_fpnh3"] [ext_resource type="AudioStream" uid="uid://bm1qd04yh32i8" path="res://sound/ui/ui_previous.wav" id="5_22ptj"] [ext_resource type="AudioStream" uid="uid://vbk40x6ifoyv" path="res://sound/sfx/weapon/gatling_shot.wav" id="6_0i6kl"] +[ext_resource type="AudioStream" uid="uid://sritblmebes1" path="res://sound/sfx/weapon/cannon_shot.wav" id="7_fpnh3"] +[ext_resource type="AudioStream" uid="uid://b4l3ksw7gh8u0" path="res://sound/sfx/weapon/plasma_shot.wav" id="8_6ll5c"] +[ext_resource type="AudioStream" uid="uid://bqo2n7jytda3r" path="res://sound/sfx/weapon/shrapnel_shot.wav" id="8_22ptj"] +[ext_resource type="AudioStream" uid="uid://cflrm2y3yp371" path="res://sound/sfx/weapon/railgun_shot.wav" id="8_ab171"] [node name="SoundManager" type="Node"] script = ExtResource("1_cg0sy") @@ -20,3 +24,7 @@ ui_stream_decline = ExtResource("3_0i6kl") ui_stream_next = ExtResource("4_fpnh3") ui_stream_previous = ExtResource("5_22ptj") sfx_weapon_gatling_shot = ExtResource("6_0i6kl") +sfx_weapon_cannon_shot = ExtResource("7_fpnh3") +sfx_weapon_plasma_shot = ExtResource("8_6ll5c") +sfx_weapon_railgun_shot = ExtResource("8_ab171") +sfx_weapon_sharapnel_shot = ExtResource("8_22ptj") diff --git a/sound/sfx/weapon/cannon_shot.wav b/sound/sfx/weapon/cannon_shot.wav new file mode 100644 index 0000000..7313d25 --- /dev/null +++ b/sound/sfx/weapon/cannon_shot.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:77389ecca71553241a66892f8bc8d2bb5868e7e30aa5c3943c46b38d242fe57d +size 89272 diff --git a/sound/sfx/weapon/cannon_shot.wav.import b/sound/sfx/weapon/cannon_shot.wav.import new file mode 100644 index 0000000..0d068c5 --- /dev/null +++ b/sound/sfx/weapon/cannon_shot.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://sritblmebes1" +path="res://.godot/imported/cannon_shot.wav-c7bcdeb19abdda67666e9038cc65f8e0.sample" + +[deps] + +source_file="res://sound/sfx/weapon/cannon_shot.wav" +dest_files=["res://.godot/imported/cannon_shot.wav-c7bcdeb19abdda67666e9038cc65f8e0.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/sound/sfx/weapon/gatling_shot.wav b/sound/sfx/weapon/gatling_shot.wav index 9d2c8f4..c1bd258 100644 --- a/sound/sfx/weapon/gatling_shot.wav +++ b/sound/sfx/weapon/gatling_shot.wav @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b6c49e7a60249d9cd2b01103ff99ab3dabee5ea5688dfaba40c499765a9c993b -size 29148 +oid sha256:b1880c97d66e9e32e4771f3226bc88722da13379b71d6f2afa649cdde1157ea4 +size 8248 diff --git a/sound/sfx/weapon/plasma_shot.wav b/sound/sfx/weapon/plasma_shot.wav new file mode 100644 index 0000000..d1617db --- /dev/null +++ b/sound/sfx/weapon/plasma_shot.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:23463f72e026755734f1c07ab809f570f7ee5af6f27e0fc5ad6a2055d86b5d8c +size 69192 diff --git a/sound/sfx/weapon/plasma_shot.wav.import b/sound/sfx/weapon/plasma_shot.wav.import new file mode 100644 index 0000000..8e11470 --- /dev/null +++ b/sound/sfx/weapon/plasma_shot.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://b4l3ksw7gh8u0" +path="res://.godot/imported/plasma_shot.wav-fe7a6ee9f275f4b069e448b5e0578c62.sample" + +[deps] + +source_file="res://sound/sfx/weapon/plasma_shot.wav" +dest_files=["res://.godot/imported/plasma_shot.wav-fe7a6ee9f275f4b069e448b5e0578c62.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/sound/sfx/weapon/railgun_shot.wav b/sound/sfx/weapon/railgun_shot.wav new file mode 100644 index 0000000..303aa6a --- /dev/null +++ b/sound/sfx/weapon/railgun_shot.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:900f9f7b7dfca41ebb56b794c2c6d26b37aa4688975c22ecf1062c01fa7d489b +size 213548 diff --git a/sound/sfx/weapon/railgun_shot.wav.import b/sound/sfx/weapon/railgun_shot.wav.import new file mode 100644 index 0000000..275284e --- /dev/null +++ b/sound/sfx/weapon/railgun_shot.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://cflrm2y3yp371" +path="res://.godot/imported/railgun_shot.wav-37f3af63c2f54f3e3d9c14d736e4f542.sample" + +[deps] + +source_file="res://sound/sfx/weapon/railgun_shot.wav" +dest_files=["res://.godot/imported/railgun_shot.wav-37f3af63c2f54f3e3d9c14d736e4f542.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/sound/sfx/weapon/shrapnel_shot.wav b/sound/sfx/weapon/shrapnel_shot.wav new file mode 100644 index 0000000..b96121b --- /dev/null +++ b/sound/sfx/weapon/shrapnel_shot.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ee1b1bc60f4582ef8c2f8870ce3abdb05312aa8f233c6bda579048e921095403 +size 52364 diff --git a/sound/sfx/weapon/shrapnel_shot.wav.import b/sound/sfx/weapon/shrapnel_shot.wav.import new file mode 100644 index 0000000..b584b8d --- /dev/null +++ b/sound/sfx/weapon/shrapnel_shot.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://bqo2n7jytda3r" +path="res://.godot/imported/shrapnel_shot.wav-947cd08a876f013d81106ab310e8ad03.sample" + +[deps] + +source_file="res://sound/sfx/weapon/shrapnel_shot.wav" +dest_files=["res://.godot/imported/shrapnel_shot.wav-947cd08a876f013d81106ab310e8ad03.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2