Audio system
This commit is contained in:
parent
b0ba8adcd7
commit
de2736c701
38 changed files with 2538 additions and 78 deletions
|
|
@ -2,6 +2,10 @@ extends Interactible
|
|||
|
||||
var plant: StringName
|
||||
@onready var defuse_timer: Timer = $DefuseTimer
|
||||
@export var bomb_audio: MultiplayerAudio3D
|
||||
@export var tick_curve : Curve
|
||||
var tick_time: float
|
||||
var tick_stop: bool
|
||||
|
||||
func _ready() -> void:
|
||||
super()
|
||||
|
|
@ -9,20 +13,33 @@ func _ready() -> void:
|
|||
Session.bomb_timer.timeout.connect(on_timeout)
|
||||
Session.begin_bomb_stage()
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if tick_stop:
|
||||
return
|
||||
if multiplayer.is_server():
|
||||
tick_time += delta
|
||||
if tick_time >= tick_curve.sample(1-Session.bomb_timer.time_left/Session.bomb_timer.wait_time):
|
||||
bomb_audio.multiplayer_play()
|
||||
|
||||
tick_time = 0
|
||||
|
||||
func on_timeout():
|
||||
if multiplayer.is_server() == false:
|
||||
return
|
||||
|
||||
tick_stop = true
|
||||
$BoomAudio.play()
|
||||
Session.kill_site(plant)
|
||||
|
||||
func on_defuse_timeout():
|
||||
Session.defuse_win()
|
||||
tick_stop = true
|
||||
|
||||
func interaction_start(player_id: int):
|
||||
if Session.player_nodes[player_id].team != Session.TEAMS.DEFENCE:
|
||||
if tick_stop or Session.player_nodes[player_id].team != Session.TEAMS.DEFENCE:
|
||||
return
|
||||
super(player_id)
|
||||
defuse_timer.start()
|
||||
$DefuseAudio.multiplayer_play()
|
||||
Session.player_nodes[player_id].passive.rpc_id(player_id)
|
||||
|
||||
func interaction_end():
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ func enter():
|
|||
machine.animation_player.play(machine.animation_prefix+"plant")
|
||||
machine.animation_player.animation_finished.connect(on_animation_finished)
|
||||
machine.speed_modifier = 0.0
|
||||
machine.player.get_node("PlantAudio").multiplayer_play()
|
||||
|
||||
func exit():
|
||||
machine.animation_player.animation_finished.disconnect(on_animation_finished)
|
||||
|
|
@ -26,3 +27,4 @@ func state_input(event: InputEvent) -> void:
|
|||
return
|
||||
if event.is_action_released("plr_bomb"):
|
||||
transition.emit("Idle")
|
||||
machine.player.get_node("PlantAudio").multiplayer_stop()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue