-
Notifications
You must be signed in to change notification settings - Fork 1
/
ayam4.gd
138 lines (121 loc) · 2.99 KB
/
ayam4.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
extends Button
var animation_ayam
var HP = 70.0
var status = "Normal"
var kipas
var lampu
var mood
var sudahMati = false
func _ready():
HP = 70.0
animation_ayam = get_child(0)
kipas = "Off"
lampu = "Off"
GlobalVar.cuaca = "Panas"
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if GlobalVar.cuaca == "Panas" && kipas == "Off" || GlobalVar.cuaca == "Panas" && lampu == "On":
mood = "Buruk"
elif GlobalVar.cuaca == "Hujan" && lampu == "Off" || GlobalVar.cuaca == "Hujan" && kipas == "On":
mood = "Buruk"
else:
mood = "Bagus"
get_node("HPBar").value = HP
if HP > 100:
HP = 100
if status == "Sakit" && HP == 0:
status = "Mati"
change_status(status)
elif status == "Sakit":
change_status(status)
else :
if HP > 70:
status = "Senang"
change_status(status)
elif HP > 40:
status = "Normal"
change_status(status)
elif HP > 0:
status = "Marah"
change_status(status)
else:
status = "Mati"
change_status(status)
if status == "Mati" and not sudahMati:
GlobalVar.mati += 1
if GlobalVar.mati == 2:
lampu("Off")
kipas("Off")
#queue_free()
sudahMati = true
pass
func change_status(status):
animation_ayam.play(status)
func _on_ayam1_pressed():
if status != "Mati":
if GlobalVar.makanan == true && status != "Sakit":
GlobalVar.makan -= 1
if GlobalVar.makan == 0:
get_node("/root/Level 4/MakananTimer").start(5)
get_node("/root/Level 4/Tools/makanan/makan").play("cooldown")
HP += 20
if GlobalVar.minuman == true && status != "Sakit":
GlobalVar.minum -= 1
if GlobalVar.minum == 0:
get_node("/root/Level 4/MinumanTimer").start(5)
get_node("/root/Level 4/Tools/Air/air").play("cooldown")
HP += 10
if GlobalVar.vaksin == true && status == "Sakit":
GlobalVar.vaks -= 1
if GlobalVar.vaks == 0:
get_node("/root/Level 4/VaksinTimer").start(5)
get_node("/root/Level 4/Tools/vaksin/Vaksin").play("cooldown")
status = "Normal"
if HP > 50:
HP = 50
pass # Replace with function body.
func _on_HPTimer_timeout():
if HP > 0:
if status == "Sakit" && mood == "Buruk":
HP -=5
elif status == "Sakit" || mood == "Buruk":
HP -=2
else:
HP -=1
if HP < 0:
HP = 0
pass # Replace with function body.
func _on_SakitTimer_timeout():
randomize()
var t = rand_range(0,100)
get_node("SakitTimer").start(t)
if status != "Mati":
status = "Sakit"
pass # Replace with function body.
func kipas(status):
if status == "On":
get_node("../Bk1/k1").play()
kipas = status
else:
get_node("../Bk1/k1").stop()
kipas = status
func lampu(status):
if status == "On":
get_node("../BL1/L1").frame = 1
lampu = status
else:
get_node("../BL1/L1").frame = 0
lampu = status
func _on_Bk1_toggled(button_pressed):
if button_pressed:
kipas("On")
else :
kipas("Off")
pass # Replace with function body.
func _on_BL1_toggled(button_pressed):
if button_pressed:
lampu("On")
else:
lampu("Off")
pass # Replace with function body.