41 lines
1013 B
GDScript3
41 lines
1013 B
GDScript3
|
extends Node3D
|
||
|
|
||
|
static var FUSE_SOUND:AudioStream = preload("res://assets/sounds/fuse.ogg")
|
||
|
static var EXPLOSION_SOUND:AudioStream = preload("res://assets/sounds/explode.wav")
|
||
|
|
||
|
var grow_explosion:bool = false
|
||
|
|
||
|
func reset_rule_enforcement_device() -> void:
|
||
|
'''
|
||
|
Start the fuse sound
|
||
|
'''
|
||
|
%SOUNDS.stream = FUSE_SOUND
|
||
|
%SOUNDS.volume_db = -10
|
||
|
%SOUNDS.play()
|
||
|
visible = true
|
||
|
%EXPLOSION.visible = false
|
||
|
grow_explosion = false
|
||
|
%EXPLOSION.scale = Vector3(0.355,0.355,0.355)
|
||
|
|
||
|
func explode() -> void:
|
||
|
'''
|
||
|
Make the rule enforcement device go boom
|
||
|
'''
|
||
|
|
||
|
%SOUNDS.stream = EXPLOSION_SOUND
|
||
|
%SOUNDS.volume_db = 0
|
||
|
%SOUNDS.play()
|
||
|
grow_explosion = true
|
||
|
%EXPLOSION.visible = true
|
||
|
|
||
|
func _ready() -> void:
|
||
|
reset_rule_enforcement_device()
|
||
|
|
||
|
func _process(_delta: float) -> void:
|
||
|
%TIME_LEFT.text = ("%.02f" % GLOBALVARS.seconds_left).replace(".",":")
|
||
|
if grow_explosion and %EXPLOSION.scale < Vector3(3,3,3):
|
||
|
%EXPLOSION.scale += Vector3(0.2,0.2,0.2)
|
||
|
elif grow_explosion:
|
||
|
%EXPLOSION.visible = false
|
||
|
visible = false
|