summaryrefslogtreecommitdiff
path: root/Scripts/NumberNode.gd
diff options
context:
space:
mode:
Diffstat (limited to 'Scripts/NumberNode.gd')
-rw-r--r--Scripts/NumberNode.gd39
1 files changed, 27 insertions, 12 deletions
diff --git a/Scripts/NumberNode.gd b/Scripts/NumberNode.gd
index 41c5d4a..b566781 100644
--- a/Scripts/NumberNode.gd
+++ b/Scripts/NumberNode.gd
@@ -18,7 +18,6 @@ enum Operations {
@export_group("Visuals")
@export_subgroup("Visual Nodes")
@export var label : Label
-@export var label_modifier : Label
@export var sprite : Sprite2D
@export var sprite_modifier : Sprite2D
@export_subgroup("Visual Values")
@@ -34,16 +33,22 @@ func _process(_delta):
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))
+
node.position = self.position
node.update_visuals()
@@ -54,21 +59,31 @@ func update_visuals():
sprite.modulate = color
if self.modifier_operation == Operations.ADDITION:
- label_modifier.text = "+ " + str(self.modifier)
sprite_modifier.visible = true
- label_modifier.visible = true
if self.modifier_operation == Operations.SUBTRACTION:
- label_modifier.text = "- " + str(self.modifier)
sprite_modifier.visible = true
- label_modifier.visible = true
if self.modifier_operation == Operations.MULTIPLICATION:
- label_modifier.text = "× " + str(self.modifier)
sprite_modifier.visible = true
- label_modifier.visible = true
if self.modifier_operation == Operations.DIVISION:
- label_modifier.text = "÷ " + str(self.modifier)
sprite_modifier.visible = true
- label_modifier.visible = true
if self.modifier_operation == Operations.NONE:
sprite_modifier.visible = false
- label_modifier.visible = false
+
+## @deprecated
+func softlock_check():
+ var shape_cast : ShapeCast2D = $"ShapeCast2D3" # sorry, too lazy to change names!
+
+ shape_cast.force_shapecast_update()
+
+ if shape_cast.get_collision_count() < 2:
+ print("softlock may happen, " + str(shape_cast.collision_result))
+ var pos = Vector2(randf_range(global_position.x - 80, global_position.x + 80), randf_range(global_position.y - 80, global_position.y + 80))
+
+ var scene : PackedScene = load("res://Reusable Scenes/number_node.tscn")
+
+ var new = scene.instantiate()
+ new.global_position = pos
+ new.value = value
+
+ get_node(GlobalVariables.NODE).add_child(new)
+ new.softlock_check()