summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--resources/game_stats_config.tres43
-rw-r--r--scenes/Main.tscn2
-rw-r--r--scenes/player.tscn (renamed from scenes/cursor.tscn)2
-rw-r--r--scenes/ui.tscn12
-rw-r--r--scripts/cursor.gd70
-rw-r--r--scripts/cursor.gd.uid1
-rw-r--r--scripts/game_stats_config.gd6
-rw-r--r--scripts/ui_panel.gd9
8 files changed, 40 insertions, 105 deletions
diff --git a/resources/game_stats_config.tres b/resources/game_stats_config.tres
index 1e691dc..6fd9758 100644
--- a/resources/game_stats_config.tres
+++ b/resources/game_stats_config.tres
@@ -7,7 +7,7 @@ script = ExtResource("1_t0c0a")
starting_life = 15
starting_morale = 10
max_wave = 3
-wave_time = 30.0
+wave_time = 20.0
wave_targets = [15, 40, 120]
defenders = Dictionary[String, Dictionary]({
"warlock": {
@@ -17,7 +17,7 @@ defenders = Dictionary[String, Dictionary]({
"range": 75.0,
"sprite_attacking": Vector2i(31, 2),
"sprite_idle": Vector2i(31, 1),
-"sprite_panel": Vector2i(30, 1)
+"sprite_panel": Vector2i(32, 4)
},
"wellspring": {
"cost": 1,
@@ -39,25 +39,36 @@ defenders = Dictionary[String, Dictionary]({
},
"wyvern": {
"cost": 15,
-"damage": 2.0,
+"damage": 1.0,
"damage_tick_rate": 0.25,
"fire_rate": 1.0,
"range": 35.0,
"sprite_attacking": Vector2i(25, 10),
"sprite_idle": Vector2i(24, 10),
-"sprite_panel": Vector2i(24, 10)
+"sprite_panel": Vector2i(28, 11)
+}
+})
+crawlers = Dictionary[String, Dictionary]({
+"fodder": {
+"damage": 1.0,
+"health": 10.0,
+"speed": 40.0,
+"sprite": Vector2i(25, 4),
+"worth": 2.0
+},
+"gnome": {
+"damage": 1.0,
+"health": 8.0,
+"speed": 90.0,
+"sprite": Vector2i(26, 9),
+"worth": 3.0
+},
+"soldier": {
+"damage": 1.0,
+"health": 35.0,
+"speed": 30.0,
+"sprite": Vector2i(28, 0),
+"worth": 5.0
}
})
-fodder_damage = 1.0
-fodder_speed = 40.0
-fodder_health = 10.0
-fodder_worth = 2.0
-soldier_damage = 1.0
-soldier_speed = 30.0
-soldier_health = 35.0
-soldier_worth = 5.0
-gnome_damage = 1.0
-gnome_speed = 90.0
-gnome_health = 8.0
-gnome_worth = 3.0
metadata/_custom_type_script = "uid://dndluiku7wdi8"
diff --git a/scenes/Main.tscn b/scenes/Main.tscn
index 404aafa..804177d 100644
--- a/scenes/Main.tscn
+++ b/scenes/Main.tscn
@@ -2,7 +2,7 @@
[ext_resource type="Script" uid="uid://i5bjnah05h14" path="res://scripts/wave_spawner.gd" id="2_0bbpv"]
[ext_resource type="PackedScene" uid="uid://cdgeamr56c0mx" path="res://scenes/map.tscn" id="2_vcsgt"]
-[ext_resource type="PackedScene" uid="uid://cq6d7gmjbwl14" path="res://scenes/cursor.tscn" id="4_rarhs"]
+[ext_resource type="PackedScene" uid="uid://cq6d7gmjbwl14" path="res://scenes/player.tscn" id="4_rarhs"]
[ext_resource type="PackedScene" uid="uid://dycgp3yept14k" path="res://scenes/ui.tscn" id="5_vcsgt"]
[sub_resource type="GDScript" id="GDScript_rarhs"]
diff --git a/scenes/cursor.tscn b/scenes/player.tscn
index f309af1..d709c1b 100644
--- a/scenes/cursor.tscn
+++ b/scenes/player.tscn
@@ -1,6 +1,6 @@
[gd_scene load_steps=3 format=3 uid="uid://cq6d7gmjbwl14"]
-[ext_resource type="Script" uid="uid://bwiimenoyb5og" path="res://scripts/cursor.gd" id="1_4knn1"]
+[ext_resource type="Script" uid="uid://bwiimenoyb5og" path="res://scripts/player.gd" id="1_4knn1"]
[ext_resource type="Texture2D" uid="uid://di2vybjsniag4" path="res://assets/tilemap.png" id="2_gber1"]
[node name="Cursor" type="Node2D"]
diff --git a/scenes/ui.tscn b/scenes/ui.tscn
index cb0c91f..c7d05a9 100644
--- a/scenes/ui.tscn
+++ b/scenes/ui.tscn
@@ -41,24 +41,20 @@ script = ExtResource("1_suays")
[node name="Warlock" parent="MarginContainer/HBoxContainer" instance=ExtResource("3_yev5y")]
layout_mode = 2
-texture_atlas_coords = Vector2(30, 1)
-object_name = "Warlock"
+object_name = "warlock"
cost = "10"
[node name="Wyvern" parent="MarginContainer/HBoxContainer" instance=ExtResource("3_yev5y")]
layout_mode = 2
-texture_atlas_coords = Vector2(24, 10)
-object_name = "Wyvern"
+object_name = "wyvern"
cost = "15"
[node name="Werewolf" parent="MarginContainer/HBoxContainer" instance=ExtResource("3_yev5y")]
layout_mode = 2
-texture_atlas_coords = Vector2(26, 11)
-object_name = "Werewolf"
+object_name = "werewolf"
cost = "-"
[node name="Wellspring" parent="MarginContainer/HBoxContainer" instance=ExtResource("3_yev5y")]
layout_mode = 2
-texture_atlas_coords = Vector2(38, 11)
-object_name = "Wellspring"
+object_name = "wellspring"
cost = "-"
diff --git a/scripts/cursor.gd b/scripts/cursor.gd
deleted file mode 100644
index 22c1da1..0000000
--- a/scripts/cursor.gd
+++ /dev/null
@@ -1,70 +0,0 @@
-extends Node2D
-
-@onready var tilemap = get_node("../Map/TileMapLayer")
-var game_stats_config = preload("res://resources/game_stats_config.tres")
-@onready var map_config = preload("res://resources/map_generator_resource.tres")
-
-var occupied_tiles = {}
-var max_x : int
-var max_y : int
-
-var dirs = {"move_right": Vector2.RIGHT,
- "move_left": Vector2.LEFT,
- "move_up": Vector2.UP,
- "move_down": Vector2.DOWN}
-var towers : Dictionary[String, Dictionary] = {
- "place_warlock": {
- "scene": preload("res://scenes/warlock.tscn"),
- "cost": game_stats_config.defenders["warlock"]["cost"]
- },
- "place_wyvern": {
- "scene": preload("res://scenes/wyvern.tscn"),
- "cost": game_stats_config.defenders["wyvern"]["cost"]
- }
-}
-
-func _ready():
- max_x = map_config.grid_width * map_config.tile_size
- max_y = map_config.grid_height * map_config.tile_size
- position = position.snapped(Vector2.ONE * map_config.tile_size)
- position += Vector2.ONE * map_config.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
- occupy_tile(position)
- GameData.subtract_life(tower_cost)
-
-func handle_move(dir):
- position += dir * map_config.tile_size
- position.x = max(position.x, map_config.tile_size / 2)
- position.y = max(position.y, map_config.tile_size / 2)
- position.x = min(position.x, max_x - (map_config.tile_size / 2))
- position.y = min(position.y, max_y - (map_config.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))) && (!is_tile_occupied(position))
-
-func is_tile_occupied(tile_position):
- return occupied_tiles.has(tile_position)
-
-func occupy_tile(tile_position):
- occupied_tiles[tile_position] = true
-
-func free_tile(tile_position):
- occupied_tiles.erase(tile_position)
diff --git a/scripts/cursor.gd.uid b/scripts/cursor.gd.uid
deleted file mode 100644
index 015cefa..0000000
--- a/scripts/cursor.gd.uid
+++ /dev/null
@@ -1 +0,0 @@
-uid://bwiimenoyb5og
diff --git a/scripts/game_stats_config.gd b/scripts/game_stats_config.gd
index 1710dbc..4e0a3e6 100644
--- a/scripts/game_stats_config.gd
+++ b/scripts/game_stats_config.gd
@@ -18,16 +18,16 @@ class_name GameStatsConfig
"damage" : 4.0,
"fire_rate" : 1.2,
"range": 75.0,
- "sprite_panel": Vector2i(30, 1),
+ "sprite_panel": Vector2i(32, 4),
"sprite_attacking": Vector2i(31, 2),
"sprite_idle": Vector2i(31, 1),
"cost": 10
},
"wyvern": {
- "damage" : 2.0,
+ "damage" : 1.0,
"fire_rate" : 1.0,
"range": 35.0,
- "sprite_panel": Vector2i(24, 10),
+ "sprite_panel": Vector2i(28, 11),
"sprite_attacking": Vector2i(25, 10),
"sprite_idle": Vector2i(24, 10),
"cost": 15,
diff --git a/scripts/ui_panel.gd b/scripts/ui_panel.gd
index 31275c6..7d3cd7a 100644
--- a/scripts/ui_panel.gd
+++ b/scripts/ui_panel.gd
@@ -1,16 +1,15 @@
extends Panel
var tile_set : TileSet = preload("res://resources/tiles.tres")
+var game_stats_config = preload("res://resources/game_stats_config.tres")
+@onready var util = preload("res://scripts/util.gd")
-@export var texture_atlas_coords: Vector2
@export var object_name: String
@export var cost: String
func _ready():
- var source : TileSetAtlasSource = tile_set.get_source(0)
- var texture_region : Rect2i = source.get_tile_texture_region(texture_atlas_coords)
- var tile_image : Image = source.texture.get_image().get_region(texture_region)
- $HBoxContainer/Texture.texture = ImageTexture.create_from_image(tile_image)
+ var texture = util.get_tile_texture(game_stats_config.defenders[object_name.to_lower()]["sprite_panel"])
+ $HBoxContainer/Texture.texture = texture
$HBoxContainer/Texture.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
$HBoxContainer/VBoxContainer/Label.text = object_name
$HBoxContainer/VBoxContainer/Label2.text = cost