-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSegmentManager.gd
40 lines (34 loc) · 974 Bytes
/
SegmentManager.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
class_name SegmentManager extends Node
@export var speaker : AudioStreamPlayer2D
@export var roundManager : RoundManager
@export var camera : CameraManager
@export var mat : StandardMaterial3D
var dur = 2
var elapsed = 0
var moving = false
func _process(delta):
LerpSegment()
func GrowBarrel():
var prevsocket = camera.activeSocket
roundManager.currentShotgunDamage = 1
roundManager.barrelSawedOff = false
camera.BeginLerp("grow barrel")
await get_tree().create_timer(.6, false).timeout
ShowSegment()
speaker.play()
await get_tree().create_timer(1.8, false).timeout
camera.BeginLerp(prevsocket)
await get_tree().create_timer(.6, false).timeout
pass
func HideSegment():
moving = false
mat.albedo_color = Color(1, 1, 1, 0)
func ShowSegment():
elapsed = 0
moving = true
func LerpSegment():
if (moving):
elapsed += get_process_delta_time()
var c = clampf(elapsed / dur, 0.0, 1.0)
var alpha = lerp(0, 1, c)
mat.albedo_color = Color(1, 1, 1, alpha)