summaryrefslogtreecommitdiff
path: root/Scripts/NumberNode.gd
diff options
context:
space:
mode:
authoraltaf-creator <dev@altafcreator.com>2024-04-15 07:26:37 +0700
committeraltaf-creator <dev@altafcreator.com>2024-04-15 07:26:37 +0700
commit074227281d6b90a70bd39eb05222d45cc5474cf3 (patch)
treeac2a4c4a726109a94432dac2ede862a3effab523 /Scripts/NumberNode.gd
parenta0c5063fbc0f7f4f1205a58f764995243d800184 (diff)
FINISHED!
Diffstat (limited to 'Scripts/NumberNode.gd')
-rw-r--r--Scripts/NumberNode.gd60
1 files changed, 43 insertions, 17 deletions
diff --git a/Scripts/NumberNode.gd b/Scripts/NumberNode.gd
index 5fc4742..b15f535 100644
--- a/Scripts/NumberNode.gd
+++ b/Scripts/NumberNode.gd
@@ -29,6 +29,9 @@ enum Operations {
var size : float = 1
+var stored_node
+var stored_prev_value
+
func _ready():
size = sprite.scale.x
target_pos = position
@@ -48,32 +51,25 @@ func join_from(node : NumberNode):
node.value += self.value
- var modifier_label = node.get_node_or_null("ModifierLabel")
-
- if self.modifier_operation == Operations.ADDITION:
- node.value += roundi(self.modifier)
- if modifier_label: modifier_label.pop("+ " + str(self.modifier))
- if self.modifier_operation == Operations.SUBTRACTION:
- node.value -= roundi(self.modifier)
- if modifier_label: modifier_label.pop("- " + str(self.modifier))
- if self.modifier_operation == Operations.MULTIPLICATION:
- node.value = roundi(float(node.value) * self.modifier)
- if modifier_label: modifier_label.pop("* " + str(self.modifier))
- if self.modifier_operation == Operations.DIVISION:
- node.value = roundi(float(node.value) / float(self.modifier))
- if modifier_label: modifier_label.pop("/ " + str(self.modifier))
+ if self.modifier_operation != Operations.NONE:
+ $"ModifierTimer".start()
+ GlobalVariables.gameloop.get_node("BetweenPlayerAndAI").wait_time = 2
+ stored_node = node
+ stored_prev_value = prev_value
+ else:
+ GlobalVariables.gameloop.get_node("BetweenPlayerAndAI").wait_time = 1
node.target_pos = self.position
node.update_visuals()
if node.value >= prev_value:
- print("YYY")
node.get_node("Score").playing = true
else:
- print("NNOOOOOO")
node.get_node("Ouch").playing = true
+
+ visible = false
- queue_free()
+ if self.modifier_operation == Operations.NONE: queue_free()
func update_visuals():
label.text = str(self.value)
@@ -111,3 +107,33 @@ func softlock_check():
get_node(GlobalVariables.NODE).add_child(new)
new.softlock_check()
+
+
+func _on_modifier_timer_timeout():
+ var node = stored_node
+ var prev_value = stored_prev_value
+
+ var modifier_label = node.get_node_or_null("Control/ModifierLabel")
+
+ if self.modifier_operation == Operations.ADDITION:
+ node.value += roundi(self.modifier)
+ if modifier_label: modifier_label.pop("+ " + str(self.modifier))
+ if self.modifier_operation == Operations.SUBTRACTION:
+ node.value -= roundi(self.modifier)
+ if modifier_label: modifier_label.pop("- " + str(self.modifier))
+ if self.modifier_operation == Operations.MULTIPLICATION:
+ node.value = roundi(float(node.value) * self.modifier)
+ if modifier_label: modifier_label.pop("* " + str(self.modifier))
+ if self.modifier_operation == Operations.DIVISION:
+ node.value = roundi(float(node.value) / float(self.modifier))
+ if modifier_label: modifier_label.pop("/ " + str(self.modifier))
+
+ node.get_node("Control/AnimationPlayer").play("mod")
+ node.update_visuals()
+
+ if node.value >= prev_value:
+ node.get_node("Score").playing = true
+ else:
+ node.get_node("Ouch").playing = true
+
+ queue_free()