diff options
Diffstat (limited to 'Scripts')
-rw-r--r-- | Scripts/GameLoop.gd | 1 | ||||
-rw-r--r-- | Scripts/NumberNode.gd | 60 |
2 files changed, 44 insertions, 17 deletions
diff --git a/Scripts/GameLoop.gd b/Scripts/GameLoop.gd index 6446fbd..9edc99a 100644 --- a/Scripts/GameLoop.gd +++ b/Scripts/GameLoop.gd @@ -39,6 +39,7 @@ func _on_between_player_and_ai_timeout(): if current_turns >= turns: win_control.visible = true anim.play("win") + anim_label.size = Vector2(1280, 720) if GlobalVariables.player.get_node("..").value > GlobalVariables.ai.get_node("..").value: anim_label.text = "YOU won!" elif GlobalVariables.player.get_node("..").value < GlobalVariables.ai.get_node("..").value: 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() |