/
Mixing Station.gd
81 lines (68 loc) · 2.15 KB
/
Mixing Station.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
extends StaticBody2D
var player_near_mixing_station
var mixing
var item
var item_ready = false
var poison_type
var runtime
onready var player = $"../../Player"
onready var t = get_node("MixingTimer")
onready var popup = $"../../PoisonMenu"
export var simple_poison_percent = .25
export var simple_runtime = 10
export var better_poison_percent = .50
export var better_runtime = 15
export var killer_poison_percent = 1
export var killer_runtime = 25
onready var screen_print = $"../../Bottom Box/TextPrint"
func _ready():
player_near_mixing_station = false
mixing = false
$MixSprite.play("Idle")
func _process(delta):
if(player_near_mixing_station and not mixing and player.holding.size() > 0):
if(player.holding.size() > 0):
if(Input.is_action_just_pressed("ui_select") and typeof(player.holding[0]) != TYPE_STRING):
popup.show()
elif(player.holding.size() == 0 and player_near_mixing_station):
if(Input.is_action_just_pressed("ui_select") and item_ready):
player.add_object(item)
item_ready = false
$MixingDone.hide()
if(not player_near_mixing_station):
popup.hide()
func which_poison(percent):
poison_type = percent
if(percent == simple_poison_percent):
runtime = simple_runtime
elif(percent == better_poison_percent):
runtime = better_runtime
elif(percent == killer_poison_percent):
runtime = killer_runtime
func poison():
item = player.holding.pop_front()
screen_print.append_bbcode("%s is now being poisoned\n" % screen_print.get_object_name(item))
item.poison(poison_type)
# the mixing station is now mixing
mixing = true
# play the mixing animation
$MixSprite.play("Mix")
# wait 10 seconds
t.set_wait_time(runtime)
# start the stove timer
t.start()
# wait until the timer completes it's wait time
yield(t, "timeout")
# mixing is over, go back to idle
$MixSprite.play("Idle")
mixing = false
$MixingDone.show()
$"MixingDone".play("ready")
item_ready = true
func _on_Area2D_body_entered(body):
# check to see if that body is the player
if(body.get_name() == "Player"):
player_near_mixing_station = true
func _on_Area2D_body_exited(body):
if(body.get_name() == "Player"):
player_near_mixing_station = false