summaryrefslogtreecommitdiff
path: root/scenes/UI
diff options
context:
space:
mode:
Diffstat (limited to 'scenes/UI')
-rw-r--r--scenes/UI/cursor.gd61
-rw-r--r--scenes/UI/cursor.gd.uid1
-rw-r--r--scenes/UI/cursor.tscn12
-rw-r--r--scenes/UI/life.gd11
-rw-r--r--scenes/UI/life.gd.uid1
-rw-r--r--scenes/UI/morale.gd11
-rw-r--r--scenes/UI/morale.gd.uid1
-rw-r--r--scenes/UI/ui.tscn39
8 files changed, 0 insertions, 137 deletions
diff --git a/scenes/UI/cursor.gd b/scenes/UI/cursor.gd
deleted file mode 100644
index c71eaa2..0000000
--- a/scenes/UI/cursor.gd
+++ /dev/null
@@ -1,61 +0,0 @@
-extends Node2D
-
-@onready var grid_manager = get_node("../GridManager")
-@onready var tilemap = get_node("../L1")
-
-var tile_size : float
-var max_x : float
-var max_y : float
-
-var dirs = {"move_right": Vector2.RIGHT,
- "move_left": Vector2.LEFT,
- "move_up": Vector2.UP,
- "move_down": Vector2.DOWN}
-var towers : Dictionary = {
- "place_warlock": {
- "scene": preload("res://scenes/defenders/warlock.tscn"),
- "cost": 10
- },
- "place_wyvern": {
- "scene": preload("res://scenes/defenders/wyvern.tscn"),
- "cost": 15
- }
-}
-
-func _ready():
- tile_size = grid_manager.tile_size
- max_x = 20 * tile_size
- max_y = 15 * tile_size
- position = position.snapped(Vector2.ONE * tile_size)
- position += Vector2(max_x / 2, max_y / 2) + Vector2(1, 0) * tile_size / 2
-
-func _unhandled_input(event):
- for dir in dirs.keys():
- if event.is_action_pressed(dir):
- handle_move(dirs[dir])
- return
- for tower in towers.keys():
- if event.is_action_pressed(tower):
- handle_tower(towers[tower])
- return
-
-func handle_tower(tower):
- var tower_cost = tower["cost"]
- if is_valid_placement_tile() && GameData.get_life() >= tower_cost:
- var tmp = tower["scene"].instantiate()
- var path = get_tree().get_root().get_node("Main/Defenders")
- path.add_child(tmp)
- tmp.global_position = position
- grid_manager.occupy_tile(position)
- GameData.subtract_life(tower_cost)
-
-func handle_move(dir):
- position += dir * tile_size
- position.x = max(position.x, tile_size / 2)
- position.y = max(position.y, tile_size + tile_size / 2)
- position.x = min(position.x, max_x - (tile_size / 2))
- position.y = min(position.y, max_y - (tile_size / 2))
-
-func is_valid_placement_tile():
- var tile_coords = tilemap.get_cell_atlas_coords(tilemap.local_to_map(global_position))
- return (tile_coords == (Vector2i(-1, -1))) && (!grid_manager.is_tile_occupied(position))
diff --git a/scenes/UI/cursor.gd.uid b/scenes/UI/cursor.gd.uid
deleted file mode 100644
index 015cefa..0000000
--- a/scenes/UI/cursor.gd.uid
+++ /dev/null
@@ -1 +0,0 @@
-uid://bwiimenoyb5og
diff --git a/scenes/UI/cursor.tscn b/scenes/UI/cursor.tscn
deleted file mode 100644
index 9da5554..0000000
--- a/scenes/UI/cursor.tscn
+++ /dev/null
@@ -1,12 +0,0 @@
-[gd_scene load_steps=3 format=3 uid="uid://cq6d7gmjbwl14"]
-
-[ext_resource type="Script" uid="uid://bwiimenoyb5og" path="res://scenes/UI/cursor.gd" id="1_4knn1"]
-[ext_resource type="Texture2D" uid="uid://di2vybjsniag4" path="res://assets/tilemap.png" id="2_gber1"]
-
-[node name="Cursor" type="Node2D"]
-script = ExtResource("1_4knn1")
-
-[node name="Sprite2D" type="Sprite2D" parent="."]
-texture = ExtResource("2_gber1")
-region_enabled = true
-region_rect = Rect2(576, 192, 16, 16)
diff --git a/scenes/UI/life.gd b/scenes/UI/life.gd
deleted file mode 100644
index b185cda..0000000
--- a/scenes/UI/life.gd
+++ /dev/null
@@ -1,11 +0,0 @@
-extends Label
-
-func _ready():
- GameData.connect("life_changed", Callable(self, "_on_life_changed"))
- update_label(GameData.get_life())
-
-func _on_life_changed(new_life: int) -> void:
- update_label(new_life)
-
-func update_label(new_life: int) -> void:
- text = "Life:" + str(new_life)
diff --git a/scenes/UI/life.gd.uid b/scenes/UI/life.gd.uid
deleted file mode 100644
index 6666d8d..0000000
--- a/scenes/UI/life.gd.uid
+++ /dev/null
@@ -1 +0,0 @@
-uid://dtj2opmwvh4y1
diff --git a/scenes/UI/morale.gd b/scenes/UI/morale.gd
deleted file mode 100644
index d5a8046..0000000
--- a/scenes/UI/morale.gd
+++ /dev/null
@@ -1,11 +0,0 @@
-extends Label
-
-func _ready():
- GameData.connect("morale_changed", Callable(self, "_on_morale_changed"))
- update_label(GameData.get_morale())
-
-func _on_life_changed(new_morale: int) -> void:
- update_label(new_morale)
-
-func update_label(new_morale: int) -> void:
- text = "Morale:" + str(new_morale)
diff --git a/scenes/UI/morale.gd.uid b/scenes/UI/morale.gd.uid
deleted file mode 100644
index 2424396..0000000
--- a/scenes/UI/morale.gd.uid
+++ /dev/null
@@ -1 +0,0 @@
-uid://b8urrbmynk327
diff --git a/scenes/UI/ui.tscn b/scenes/UI/ui.tscn
deleted file mode 100644
index 8e6a36b..0000000
--- a/scenes/UI/ui.tscn
+++ /dev/null
@@ -1,39 +0,0 @@
-[gd_scene load_steps=4 format=3 uid="uid://dycgp3yept14k"]
-
-[ext_resource type="Script" uid="uid://dtj2opmwvh4y1" path="res://scenes/UI/life.gd" id="1_suays"]
-[ext_resource type="Script" uid="uid://b8urrbmynk327" path="res://scenes/UI/morale.gd" id="1_yb1mt"]
-
-[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_nt14h"]
-bg_color = Color(0, 0.0117647, 0.552941, 1)
-
-[node name="PanelContainer" type="PanelContainer"]
-anchors_preset = 10
-anchor_right = 1.0
-offset_bottom = 17.0
-grow_horizontal = 2
-size_flags_vertical = 0
-theme_override_styles/panel = SubResource("StyleBoxFlat_nt14h")
-
-[node name="MarginContainer" type="MarginContainer" parent="."]
-layout_mode = 2
-theme_override_constants/margin_left = 6
-theme_override_constants/margin_top = 0
-
-[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer"]
-layout_mode = 2
-
-[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/HBoxContainer"]
-layout_mode = 2
-theme_override_constants/separation = -3
-
-[node name="Morale" type="Label" parent="MarginContainer/HBoxContainer/VBoxContainer"]
-layout_mode = 2
-theme_override_font_sizes/font_size = 8
-text = "Morale: 10"
-script = ExtResource("1_yb1mt")
-
-[node name="Life" type="Label" parent="MarginContainer/HBoxContainer/VBoxContainer"]
-layout_mode = 2
-theme_override_font_sizes/font_size = 8
-text = "Life: 20"
-script = ExtResource("1_suays")