-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPickupIndicator.gd
133 lines (110 loc) · 3.51 KB
/
PickupIndicator.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
class_name PickupIndicator extends Node
@export var description : DescriptionManager
@export var interaction : InteractionManager
@export var obj : Node3D
@export var collider : Node3D
@export var dur : float
@export var axisOffset : float
@export var originalAxis : float
@export var activeAxis : String
@export var uiArray : Array[Label]
@export var itemName : String
@export_multiline var itemDescription : String
@export var whichSide : String
@export var dealerGridIndex : int
@export var sound_placeDown : AudioStream
@export var sound_indicatorPickup : AudioStream
@export var sound_indicatorPutdown : AudioStream
@export var sound_pickup : AudioStream
var speaker_indicatorCheck : AudioStreamPlayer2D
var locationInDynamicArray
var itemManager
var isDealerItem = false
var dealerGridName
var lerpEnabled = true
var interactionAllowed = false
var interactionInvalid = false
var current = 0
var next = 0
var elapsed = 0
var moving = false
var fs = false
var fs2 = false
func _ready():
speaker_indicatorCheck = get_node("/root/main/speaker parent/speaker_indicator check")
interaction = get_node("/root/main/standalone managers/interaction manager")
description = get_node("/root/main/standalone managers/description manager")
itemManager = get_node("/root/main/standalone managers/item manager")
func _process(delta):
if (lerpEnabled): LerpMovement()
CheckIfActive()
pass
func CheckIfActive():
if (interactionAllowed && !interactionInvalid):
if (interaction.activeParent != null and interaction.activeParent == collider):
if (!fs):
BeginPickup()
fs2 = false
fs = true
if (interaction.activeParent != collider):
if (!fs2):
Revert()
fs = false
fs2 = true
pass
func BeginPickup():
speaker_indicatorCheck.pitch_scale = randf_range(.9, 1.0)
speaker_indicatorCheck.play()
current = originalAxis
next = axisOffset
description.uiArray[0].text = itemName
description.uiArray[1].text = itemName
description.uiArray[2].text = itemDescription
description.uiArray[3].text = itemDescription
elapsed = 0
moving = true
description.BeginLerp()
itemManager.hasBegun = true
pass
func Revert():
#if (itemManager.hasBegun): description.EndLerp()
itemManager.hasBegun = false
match(activeAxis):
"x":
current = obj.transform.origin.x
"y":
current = obj.transform.origin.y
"z":
current = obj.transform.origin.z
next = originalAxis
elapsed = 0
moving = true
pass
func LerpMovement():
if (moving):
elapsed += get_process_delta_time()
var c = clampf(elapsed / dur, 0.0, 1.0)
var pos = lerp(current, next, c)
match(activeAxis):
"x":
obj.transform.origin = Vector3(pos, obj.transform.origin.y, obj.transform.origin.z)
"y":
obj.transform.origin = Vector3(obj.transform.origin.x, pos, obj.transform.origin.z)
"z":
obj.transform.origin = Vector3(obj.transform.origin.x, obj.transform.origin.y, pos)
func SnapToMax():
match(activeAxis):
"x":
obj.transform.origin = Vector3(axisOffset, obj.transform.origin.y, obj.transform.origin.z)
"y":
obj.transform.origin = Vector3(obj.transform.origin.x, axisOffset, obj.transform.origin.z)
"z":
obj.transform.origin = Vector3(obj.transform.origin.x, obj.transform.origin.y, axisOffset)
func SnapToMin():
match(activeAxis):
"x":
obj.transform.origin = Vector3(originalAxis, obj.transform.origin.y, obj.transform.origin.z)
"y":
obj.transform.origin = Vector3(obj.transform.origin.x, originalAxis, obj.transform.origin.z)
"z":
obj.transform.origin = Vector3(obj.transform.origin.x, obj.transform.origin.y, originalAxis)