Skip to content

Commit

Permalink
Add more voice events, #83
Browse files Browse the repository at this point in the history
  • Loading branch information
Scony committed Apr 23, 2024
1 parent c29ea79 commit e905315
Show file tree
Hide file tree
Showing 19 changed files with 152 additions and 0 deletions.
Binary file added assets/voice/english/battle_control_offline.ogg
Binary file not shown.
19 changes: 19 additions & 0 deletions assets/voice/english/battle_control_offline.ogg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[remap]

importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://d1s4aitn3ee23"
path="res://.godot/imported/battle_control_offline.ogg-dfc9578bd66a366ed00dc5f9c835faa6.oggvorbisstr"

[deps]

source_file="res://assets/voice/english/battle_control_offline.ogg"
dest_files=["res://.godot/imported/battle_control_offline.ogg-dfc9578bd66a366ed00dc5f9c835faa6.oggvorbisstr"]

[params]

loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4
Binary file added assets/voice/english/battle_control_online.ogg
Binary file not shown.
19 changes: 19 additions & 0 deletions assets/voice/english/battle_control_online.ogg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[remap]

importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://c155b0rolpjco"
path="res://.godot/imported/battle_control_online.ogg-2aaf91e41e818b979090c12983665f2c.oggvorbisstr"

[deps]

source_file="res://assets/voice/english/battle_control_online.ogg"
dest_files=["res://.godot/imported/battle_control_online.ogg-2aaf91e41e818b979090c12983665f2c.oggvorbisstr"]

[params]

loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4
Binary file added assets/voice/english/not_enough_resources.ogg
Binary file not shown.
19 changes: 19 additions & 0 deletions assets/voice/english/not_enough_resources.ogg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[remap]

importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://dfl45ey8krrv8"
path="res://.godot/imported/not_enough_resources.ogg-3fe52634a179f72e03b6a5671ce83bd2.oggvorbisstr"

[deps]

source_file="res://assets/voice/english/not_enough_resources.ogg"
dest_files=["res://.godot/imported/not_enough_resources.ogg-3fe52634a179f72e03b6a5671ce83bd2.oggvorbisstr"]

[params]

loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4
Binary file added assets/voice/english/training.ogg
Binary file not shown.
19 changes: 19 additions & 0 deletions assets/voice/english/training.ogg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[remap]

importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://dys221ycstc4y"
path="res://.godot/imported/training.ogg-afecb3126489a835af1b623f2160f675.oggvorbisstr"

[deps]

source_file="res://assets/voice/english/training.ogg"
dest_files=["res://.godot/imported/training.ogg-afecb3126489a835af1b623f2160f675.oggvorbisstr"]

[params]

loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4
Binary file added assets/voice/english/unit_under_attack.ogg
Binary file not shown.
19 changes: 19 additions & 0 deletions assets/voice/english/unit_under_attack.ogg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[remap]

importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://bn0267jmm3jnp"
path="res://.godot/imported/unit_under_attack.ogg-ffdfe38e888c546dd74f0bcdddd3a4a8.oggvorbisstr"

[deps]

source_file="res://assets/voice/english/unit_under_attack.ogg"
dest_files=["res://.godot/imported/unit_under_attack.ogg-ffdfe38e888c546dd74f0bcdddd3a4a8.oggvorbisstr"]

[params]

loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4
Binary file not shown.
19 changes: 19 additions & 0 deletions assets/voice/english/your_base_is_under_attack.ogg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[remap]

importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://c573tv2alltun"
path="res://.godot/imported/your_base_is_under_attack.ogg-26681f5a6003edb415a14f5e243cf7ea.oggvorbisstr"

[deps]

source_file="res://assets/voice/english/your_base_is_under_attack.ogg"
dest_files=["res://.godot/imported/your_base_is_under_attack.ogg-26681f5a6003edb415a14f5e243cf7ea.oggvorbisstr"]

[params]

loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4
1 change: 1 addition & 0 deletions source/match/Match.gd
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func _ready():
_move_camera_to_initial_position()
if settings.visibility == settings.Visibility.FULL:
fog_of_war.reveal()
MatchSignals.match_started.emit()


func _unhandled_input(event):
Expand Down
8 changes: 8 additions & 0 deletions source/match/MatchConstants.gd
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,17 @@ class Units:

class VoiceNarrator:
enum Events {
MATCH_STARTED,
MATCH_ABORTED,
UNIT_LOST,
UNIT_PRODUCTION_STARTED,
NOT_ENOUGH_RESOURCES,
}

const EVENT_TO_ASSET_MAPPING = {
Events.MATCH_STARTED: preload("res://assets/voice/english/battle_control_online.ogg"),
Events.MATCH_ABORTED: preload("res://assets/voice/english/battle_control_offline.ogg"),
Events.UNIT_LOST: preload("res://assets/voice/english/unit_lost.ogg"),
Events.UNIT_PRODUCTION_STARTED: preload("res://assets/voice/english/training.ogg"),
Events.NOT_ENOUGH_RESOURCES: preload("res://assets/voice/english/not_enough_resources.ogg"),
}
4 changes: 4 additions & 0 deletions source/match/MatchSignals.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ signal place_structure(structure_prototype)
signal schedule_navigation_rebake(domain)

# notifications
signal match_started
signal match_aborted
signal terrain_targeted(position)
signal unit_spawned(unit)
signal unit_targeted(unit)
signal unit_selected(unit)
signal unit_deselected(unit)
signal unit_died(unit)
signal unit_production_started(unit_prototype, producer_unit)
signal not_enough_resources_for_production(player)
2 changes: 2 additions & 0 deletions source/match/Menu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@ func _on_resume_button_pressed():


func _on_exit_button_pressed():
MatchSignals.match_aborted.emit()
await get_tree().create_timer(1.74).timeout # Give voice narrator some time to finish.
get_tree().paused = false
get_tree().change_scene_to_file("res://source/main-menu/Main.tscn")
1 change: 1 addition & 0 deletions source/match/players/human/Human.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ script = ExtResource("1_m624e")
script = ExtResource("4_ljr74")

[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="VoiceNarratorController"]
process_mode = 3
20 changes: 20 additions & 0 deletions source/match/players/human/VoiceNarratorController.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,17 @@ extends Node


func _ready():
MatchSignals.match_started.connect(
_handle_event.bind(Constants.Match.VoiceNarrator.Events.MATCH_STARTED)
)
MatchSignals.match_aborted.connect(
_handle_event.bind(Constants.Match.VoiceNarrator.Events.MATCH_ABORTED)
)
MatchSignals.unit_died.connect(_on_unit_died)
MatchSignals.unit_production_started.connect(_on_production_started)
MatchSignals.not_enough_resources_for_production.connect(
_on_not_enough_resources_for_production
)


func _handle_event(event):
Expand All @@ -15,3 +25,13 @@ func _handle_event(event):
func _on_unit_died(unit):
if unit.is_in_group("controlled_units"):
_handle_event(Constants.Match.VoiceNarrator.Events.UNIT_LOST)


func _on_production_started(_unit_prototype, producer_unit):
if producer_unit.is_in_group("controlled_units"):
_handle_event(Constants.Match.VoiceNarrator.Events.UNIT_PRODUCTION_STARTED)


func _on_not_enough_resources_for_production(player):
if player == get_parent():
_handle_event(Constants.Match.VoiceNarrator.Events.NOT_ENOUGH_RESOURCES)
2 changes: 2 additions & 0 deletions source/match/units/traits/ProductionQueue.gd
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,15 @@ func produce(unit_prototype, ignore_limit = false):
return
var production_cost = Constants.Match.Units.PRODUCTION_COSTS[unit_prototype.resource_path]
if not _unit.player.has_resources(production_cost):
MatchSignals.not_enough_resources_for_production.emit(_unit.player)
return
_unit.player.subtract_resources(production_cost)
var queue_element = ProductionQueueElement.new()
queue_element.unit_prototype = unit_prototype
queue_element.time_total = Constants.Match.Units.PRODUCTION_TIMES[unit_prototype.resource_path]
queue_element.time_left = Constants.Match.Units.PRODUCTION_TIMES[unit_prototype.resource_path]
_enqueue_element(queue_element)
MatchSignals.unit_production_started.emit(unit_prototype, _unit)


func cancel_all():
Expand Down

0 comments on commit e905315

Please sign in to comment.