From 074227281d6b90a70bd39eb05222d45cc5474cf3 Mon Sep 17 00:00:00 2001 From: altaf-creator Date: Mon, 15 Apr 2024 07:26:37 +0700 Subject: FINISHED! --- Scripts/NumberNode.gd | 60 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 17 deletions(-) (limited to 'Scripts/NumberNode.gd') 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() -- cgit v1.2.3