diff --git a/project.godot b/project.godot index bac35a1..d12489c 100644 --- a/project.godot +++ b/project.godot @@ -11,7 +11,7 @@ config_version=5 [application] config/name="Frontier of Hell" -run/main_scene="res://scenes/stages/stage_4.tscn" +run/main_scene="res://scenes/stages/stage_5.tscn" config/features=PackedStringArray("4.1", "Mobile") boot_splash/bg_color=Color(0.141176, 0.141176, 0.141176, 1) boot_splash/image="res://assets/icons/logo.png" diff --git a/scenes/stages/stage_5.tscn b/scenes/stages/stage_5.tscn new file mode 100644 index 0000000..c3df829 --- /dev/null +++ b/scenes/stages/stage_5.tscn @@ -0,0 +1,314 @@ +[gd_scene load_steps=13 format=3 uid="uid://i18iy1wmek4s"] + +[ext_resource type="Script" path="res://scripts/stages/5/game_manager.gd" id="1_kectu"] +[ext_resource type="Texture2D" uid="uid://bq6hnxbt4w37u" path="res://assets/tileset/snowland/Snowland@64x64.png" id="1_s0uo6"] +[ext_resource type="PackedScene" uid="uid://bhnv1dsggssil" path="res://scenes/ui/pause_menu.tscn" id="2_tph65"] +[ext_resource type="PackedScene" uid="uid://cd5r1v6f8hahx" path="res://scenes/ui/tower_menu.tscn" id="3_dwrfi"] +[ext_resource type="Script" path="res://scripts/stages/5/summon.gd" id="3_h0a0o"] +[ext_resource type="PackedScene" uid="uid://cy88k4uxt1v37" path="res://scenes/ui/game_stats.tscn" id="4_qm2yl"] +[ext_resource type="PackedScene" uid="uid://bvoenhbaqiqj2" path="res://scenes/towers/placement/placement.tscn" id="5_vmpbi"] +[ext_resource type="PackedScene" uid="uid://cikgeqqhctm7k" path="res://scenes/base/base.tscn" id="6_yj08v"] + +[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_pf042"] +texture = ExtResource("1_s0uo6") +texture_region_size = Vector2i(64, 64) +0:0/0 = 0 +1:0/0 = 0 +2:0/0 = 0 +3:0/0 = 0 +4:0/0 = 0 +5:0/0 = 0 +6:0/0 = 0 +7:0/0 = 0 +8:0/0 = 0 +9:0/0 = 0 +10:0/0 = 0 +11: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0 = 0 +8:15/0 = 0 +9:15/0 = 0 +10:15/0 = 0 +11:15/0 = 0 +12:15/0 = 0 +13:15/0 = 0 +14:15/0 = 0 +15:15/0 = 0 +0:11/size_in_atlas = Vector2i(5, 5) +0:11/0 = 0 +5:11/size_in_atlas = Vector2i(3, 5) +5:11/0 = 0 +8:11/size_in_atlas = Vector2i(1, 3) +8:11/0 = 0 +9:13/size_in_atlas = Vector2i(3, 1) +9:13/0 = 0 +9:3/size_in_atlas = Vector2i(1, 2) +9:3/0 = 0 +12:5/size_in_atlas = Vector2i(1, 2) +12:5/0 = 0 + +[sub_resource type="TileSet" id="TileSet_vkpt8"] +tile_size = Vector2i(64, 64) +sources/0 = SubResource("TileSetAtlasSource_pf042") + +[sub_resource type="Curve2D" id="Curve2D_sq2la"] +_data = { +"points": PackedVector2Array(0, 0, 0, 0, 667, -47, 0, 0, 0, 0, 673, 152, 0, 0, 0, 0, 913, 163, 0, 0, 0, 0, 920, 688) +} +point_count = 4 + +[sub_resource type="Curve2D" id="Curve2D_hxvx8"] +_data = { +"points": PackedVector2Array(0, 0, 0, 0, -57, 159, 0, 0, 0, 0, 212, 164, 0, 0, 0, 0, 221, 409, 0, 0, 0, 0, 916, 420, 0, 0, 0, 0, 920, 687) +} +point_count = 5 + +[node name="GameManager" type="Node2D"] +script = ExtResource("1_kectu") + +[node name="TileMap" type="TileMap" parent="."] +tile_set = SubResource("TileSet_vkpt8") +format = 2 +layer_0/tile_data = PackedInt32Array(10, 65536, 1, 65546, 65536, 1, 131082, 65536, 1, 131086, 65536, 1, 131085, 65536, 1, 131084, 65536, 1, 131083, 65536, 1, 196622, 65536, 1, 262158, 65536, 1, 655374, 65536, 1, 589838, 65536, 1, 524302, 65536, 1, 458766, 65536, 1, 393230, 65536, 1, 327694, 65536, 1, -65526, 65536, 1, 196607, 65536, 1, 131072, 65536, 1, 131073, 65536, 1, 131074, 65536, 1, 131075, 65536, 1, 196611, 65536, 1, 262147, 65536, 1, 393229, 65536, 1, 393228, 65536, 1, 393227, 65536, 1, 393226, 65536, 1, 393225, 65536, 1, 393224, 65536, 1, 393223, 65536, 1, 393222, 65536, 1, 393221, 65536, 1, 393220, 65536, 1, 393219, 65536, 1, 327683, 65536, 1, 196623, 655360, 9, 262159, 655360, 9, 327695, 655360, 9, 458767, 655360, 8, 393231, 655360, 9, 524303, 655360, 9, 589839, 655360, 9, 655375, 655360, 9, 196612, 655360, 9, 262148, 655360, 9, 11, 655360, 9, -65525, 655360, 9, 131076, 655360, 9, 9, 851968, 9, 524301, 851968, 8, 589837, 851968, 8, 655373, 851968, 8, 262157, 851968, 8, 262146, 851968, 8, 327682, 851968, 8, 393218, 851968, 8, 65545, 851968, 8, 131081, 851968, 8, -65527, 851968, 8, 458765, 851968, 7, 458757, 786432, 7, 458761, 786432, 7, 458758, 720896, 7, 458759, 720896, 7, 458760, 720896, 7, 458762, 720896, 7, 458763, 720896, 7, 458764, 720896, 7, 458756, 720896, 7, 458755, 720896, 7, 458754, 917504, 8, 327684, 655360, 10, 327685, 786432, 10, 327686, 786432, 10, 327687, 786432, 10, 327688, 786432, 10, 327689, 786432, 10, 327690, 786432, 10, 327691, 786432, 10, 327692, 786432, 10, 327693, 851968, 10, 196621, 851968, 7, 196619, 786432, 7, 196618, 720896, 7, 196620, 720896, 7, 196617, 917504, 8, 196610, 851968, 7, 262143, 720896, 7, 196608, 720896, 7, 196609, 720896, 7, 131071, 786432, 10, 65536, 786432, 10, 65537, 786432, 10, 65539, 720896, 10, 65538, 786432, 10, 65540, 983040, 7, 65547, 655360, 10, 65548, 786432, 10, 65549, 786432, 10, 65550, 786432, 10, 65551, 983040, 7, 131087, 655360, 8, 655372, 786432, 8, 655371, 786432, 8, 655370, 786432, 8, 655369, 786432, 8, 655368, 786432, 8, 655367, 786432, 8, 655366, 786432, 8, 655365, 786432, 8, 655364, 786432, 8, 655363, 786432, 8, 655362, 786432, 8, 655361, 786432, 8, 655360, 786432, 8, 589824, 786432, 8, 524288, 786432, 8, 458752, 786432, 8, 393216, 786432, 8, 327680, 786432, 8, 262144, 786432, 8, 262145, 786432, 8, 327681, 786432, 8, 393217, 786432, 8, 458753, 786432, 8, 524289, 786432, 8, 589825, 786432, 8, 589826, 786432, 8, 524290, 786432, 8, 524291, 786432, 8, 524292, 786432, 8, 524293, 786432, 8, 524294, 786432, 8, 524295, 786432, 8, 524296, 786432, 8, 524297, 786432, 8, 524298, 786432, 8, 524299, 786432, 8, 524300, 786432, 8, 589836, 786432, 8, 589835, 786432, 8, 589834, 786432, 8, 589833, 786432, 8, 589832, 786432, 8, 589831, 786432, 8, 589830, 786432, 8, 589829, 786432, 8, 589828, 786432, 8, 589827, 786432, 8, 8, 786432, 8, 7, 786432, 8, 6, 786432, 8, 5, 786432, 8, 4, 786432, 8, 3, 786432, 8, 2, 786432, 8, 1, 786432, 8, 0, 786432, 8, 65541, 786432, 8, 131077, 786432, 8, 196613, 786432, 8, 262149, 786432, 8, 262150, 786432, 8, 262151, 786432, 8, 262152, 786432, 8, 262153, 786432, 8, 262154, 786432, 8, 262155, 786432, 8, 262156, 786432, 8, 65542, 786432, 8, 131078, 786432, 8, 196614, 786432, 8, 196615, 786432, 8, 196616, 786432, 8, 131080, 786432, 8, 65544, 786432, 8, 65543, 786432, 8, 131079, 786432, 8, 12, 786432, 8, 13, 786432, 8, 14, 786432, 8, 15, 786432, 8, 655376, 786432, 8, 655377, 786432, 8, 589841, 786432, 8, 524305, 786432, 8, 16, 786432, 8, 17, 786432, 8, 65553, 786432, 8, 131089, 786432, 8, 196625, 786432, 8, 262161, 786432, 8, 327697, 786432, 8, 393233, 786432, 8, 458769, 786432, 8, 524304, 786432, 8, 589840, 786432, 8, 458768, 786432, 8, 393232, 786432, 8, 327696, 786432, 8, 262160, 786432, 8, 196624, 786432, 8, 131088, 786432, 8, 65552, 786432, 8) +layer_1/name = "" +layer_1/enabled = true +layer_1/modulate = Color(1, 1, 1, 1) +layer_1/y_sort_enabled = false +layer_1/y_sort_origin = 0 +layer_1/z_index = 0 +layer_1/tile_data = PackedInt32Array(589828, 786432, 9, 589831, 786432, 9, 196614, 786432, 9, 589834, 720896, 9, 65552, 720896, 9, 65541, 720896, 9, 458768, 786432, 9, 524289, 589824, 3, 589826, 655360, 4, 589824, 655360, 4, 327681, 720896, 12, 262154, 589824, 13) + +[node name="Path2D" type="Path2D" parent="."] +curve = SubResource("Curve2D_sq2la") +script = ExtResource("3_h0a0o") + +[node name="Timer" type="Timer" parent="Path2D"] +one_shot = true + +[node name="Path2D2" type="Path2D" parent="."] +curve = SubResource("Curve2D_hxvx8") +script = ExtResource("3_h0a0o") +type = 1 + +[node name="Timer" type="Timer" parent="Path2D2"] +one_shot = true + +[node name="CanvasLayer" type="CanvasLayer" parent="."] + +[node name="PauseMenu" parent="CanvasLayer" instance=ExtResource("2_tph65")] +visible = false + +[node name="TowerMenu" parent="CanvasLayer" instance=ExtResource("3_dwrfi")] +visible = false + +[node name="GameStats" parent="CanvasLayer" instance=ExtResource("4_qm2yl")] +metadata/_edit_use_anchors_ = true + +[node name="Placements" type="Node2D" parent="."] + +[node name="placement" parent="Placements" instance=ExtResource("5_vmpbi")] +position = Vector2(1043, 280) + +[node name="placement2" parent="Placements" instance=ExtResource("5_vmpbi")] +position = Vector2(336, 237) + +[node name="placement3" parent="Placements" instance=ExtResource("5_vmpbi")] +position = Vector2(375, 542) + +[node name="placement4" parent="Placements" instance=ExtResource("5_vmpbi")] +position = Vector2(679, 541) + +[node name="Bases" type="Node2D" parent="."] + +[node name="base" parent="Bases" instance=ExtResource("6_yj08v")] +position = Vector2(902, 682) + +[node name="base2" parent="Bases" instance=ExtResource("6_yj08v")] +position = Vector2(947, 681) + +[connection signal="timeout" from="Path2D/Timer" to="Path2D" method="_on_timer_timeout"] +[connection signal="timeout" from="Path2D2/Timer" to="Path2D2" method="_on_timer_timeout"] diff --git a/scripts/stages/5/config.gd b/scripts/stages/5/config.gd new file mode 100644 index 0000000..edb220f --- /dev/null +++ b/scripts/stages/5/config.gd @@ -0,0 +1,190 @@ +extends Node + + +var game = { + "health": 6, + "resource": 100, + "spawn_timer": 3.0, + "offset": [-20.0, 25.0], + "path_direction": [ + [ + { + "progress": 0, + "direction": "front", + }, + { + "progress": 199, + "direction": "right" + }, + { + "progress": 440, + "direction": "front" + } + ], + [ + { + "progress": 0, + "direction": "right", + }, + { + "progress": 269, + "direction": "front" + }, + { + "progress": 514, + "direction": "right" + }, + { + "progress": 1210, + "direction": "front" + } + ] + ] +} + +var menu = [ + { + "name": "Cannon", + "image": load("res://assets/icons/towers/cannon-1.png"), + "image_disabled": load("res://assets/icons/towers/cannon-1-disabled.png"), + "price": 10 + }, + { + "name": "Railgun", + "image": load("res://assets/icons/towers/railgun-1.png"), + "image_disabled": load("res://assets/icons/towers/railgun-1-disabled.png"), + "price": 20 + }, + { + "name": "Cannon (V2)", + "image": load("res://assets/icons/towers/cannon-2.png"), + "image_disabled": load("res://assets/icons/towers/cannon-2-disabled.png"), + "price": 50 + }, + { + "name": "Railgun (V2)", + "image": load("res://assets/icons/towers/railgun-2.png"), + "image_disabled": load("res://assets/icons/towers/railgun-2-disabled.png"), + "price": 60 + }, + { + "name": "Cannon (V3)", + "image": load("res://assets/icons/towers/cannon-3.png"), + "image_disabled": load("res://assets/icons/towers/cannon-3-disabled.png"), + "price": 90 + }, + { + "name": "Railgun (V3)", + "image": load("res://assets/icons/towers/railgun-3.png"), + "image_disabled": load("res://assets/icons/towers/railgun-3-disabled.png"), + "price": 100 + } +] + +var tower = [ + { + "name": "Cannon", + "asset": preload("res://scenes/towers/cannon_1.tscn"), + "bullet": preload("res://scenes/bullets/bullet_1.tscn"), + "timer": 1, + "speed": 200, + "damage": 30, + "health": 100, + "durability_reduction": 10 + }, + { + "name": "Railgun", + "asset": preload("res://scenes/towers/railgun_1.tscn"), + "bullet": preload("res://scenes/bullets/bullet_1.tscn"), + "timer": 1, + "speed": 200, + "damage": 40, + "health": 100, + "durability_reduction": 10 + }, + { + "name": "Cannon (V2)", + "asset": preload("res://scenes/towers/cannon_2.tscn"), + "bullet": preload("res://scenes/bullets/bullet_1.tscn"), + "timer": 1, + "speed": 200, + "damage": 40, + "health": 100, + "durability_reduction": 10 + }, + { + "name": "Railgun (V2)", + "asset": preload("res://scenes/towers/railgun_2.tscn"), + "bullet": preload("res://scenes/bullets/bullet_1.tscn"), + "timer": 1, + "speed": 200, + "damage": 40, + "health": 100, + "durability_reduction": 10 + }, + { + "name": "Cannon (V3)", + "asset": preload("res://scenes/towers/cannon_3.tscn"), + "bullet": preload("res://scenes/bullets/bullet_1.tscn"), + "timer": 1, + "speed": 200, + "damage": 40, + "health": 100, + "durability_reduction": 10 + }, + { + "name": "Railgun (V3)", + "asset": preload("res://scenes/towers/railgun_3.tscn"), + "bullet": preload("res://scenes/bullets/bullet_1.tscn"), + "timer": 1, + "speed": 200, + "damage": 40, + "health": 100, + "durability_reduction": 10 + } +] + +var enemy = [ + { + "name": "Demon", + "health": 100, + "speed": 30, + "damage": 1, + "reward": 10 + }, + { + "name": "Orc", + "health": 100, + "speed": 30, + "damage": 1, + "reward": 20 + }, + { + "name": "Cyclops", + "health": 100, + "speed": 30, + "damage": 1, + "reward": 30 + }, + { + "name": "Demon Boar", + "health": 100, + "speed": 30, + "damage": 1, + "reward": 40 + }, + { + "name": "Demon Fungus", + "health": 100, + "speed": 30, + "damage": 1, + "reward": 50 + }, + { + "name": "Demon Shark", + "health": 100, + "speed": 30, + "damage": 1, + "reward": 60 + } +] diff --git a/scripts/stages/5/game_manager.gd b/scripts/stages/5/game_manager.gd new file mode 100644 index 0000000..d9f0cbb --- /dev/null +++ b/scripts/stages/5/game_manager.gd @@ -0,0 +1,93 @@ +extends Node2D + +var config_path = "res://scripts/stages/5/config.gd" +var config = load(config_path).new() + +var data = { + "paused": false, + "tower": {}, + "health": config.game['health'], + "resource": config.game['resource'] +} + +func _ready(): + $CanvasLayer/GameStats.connect("on_paused", on_game_paused) + $CanvasLayer/PauseMenu.connect("on_resume", on_game_resume) + $CanvasLayer/GameStats.set_resource(data['resource']) + var bases = $Bases.get_children() + for base in bases: + base.connect("enemy_entered_base", on_enemy_entered_base) + var placements = $Placements.get_children() + for placement in placements: + placement.connect("on_placement", on_tower_placement) + $CanvasLayer/TowerMenu.connect("build_tower", on_build_tower) + +func on_game_paused(): + data['paused'] = !data['paused'] + get_tree().paused = data['paused'] + $CanvasLayer/PauseMenu.show_menu() + +func on_game_resume(): + data['paused'] = !data['paused'] + get_tree().paused = data['paused'] + $CanvasLayer/PauseMenu.hide_menu() + +func on_tower_placement(pos, tower_placement_id): + var tower_id = null + var disabled = false + var disabled_2 = false + if data['tower'].has(str(tower_placement_id)): + match data['tower'][str(tower_placement_id)]['id']: + 0: + tower_id = 2 + 1: + tower_id = 3 + 2: + tower_id = 4 + 3: + tower_id = 5 + _: + tower_id = null + + if data['resource'] < config.menu[tower_id]['price']: + disabled = true + else: + if data['resource'] < config.menu[0]['price']: + disabled = true + if data['resource'] < config.menu[1]['price']: + disabled_2 = true + $CanvasLayer/TowerMenu.show_menu(tower_id, pos, tower_placement_id, disabled, disabled_2) + +func on_build_tower(pos, tower_id, tower_placement_id): + if data['tower'].has(str(tower_placement_id)): + var current_tower = get_tree().current_scene.get_node(str(data['tower'][str(tower_placement_id)]['name'])) + current_tower.queue_free() + else: + data['tower'][str(tower_placement_id)] = {} + + var tower = config.tower[tower_id]['asset'].instantiate() + get_tree().current_scene.add_child(tower) + tower.set_config(config_path) + tower.set_tower(tower_id, tower_placement_id) + tower.set_timer() + tower.global_position = pos + tower.connect("on_destroy", on_tower_destroy) + + data['tower'][str(tower_placement_id)]['id'] = tower_id + data['tower'][str(tower_placement_id)]['name'] = tower.name + data['resource'] -= config.menu[tower_id]['price'] + $CanvasLayer/GameStats.set_resource(data['resource']) + +func on_tower_destroy(tower_placement_id): + data['tower'].erase(str(tower_placement_id)) + +func on_enemy_entered_base(enemy): + data['health'] -= enemy.damage + $CanvasLayer/GameStats.set_damage(enemy.damage) + + if data['health'] < 1: + print("Game Over") + +func on_enemy_reward(value: int): + data['resource'] += value + $CanvasLayer/GameStats.set_resource(data['resource']) diff --git a/scripts/stages/5/summon.gd b/scripts/stages/5/summon.gd new file mode 100644 index 0000000..425f16f --- /dev/null +++ b/scripts/stages/5/summon.gd @@ -0,0 +1,30 @@ +extends Path2D + +@onready var timer = $Timer +@export var type: int = 0 + +var config_path = "res://scripts/stages/5/config.gd" +var config = load(config_path).new() + +var spawn_first: bool = true + +var enemy: PackedScene = preload("res://scenes/enemies/demon.tscn") + +func _ready(): + summon() + timer.wait_time = config.game['spawn_timer'] + timer.start() + +func _on_timer_timeout(): + summon() + timer.start() + +func summon(): + var rng = RandomNumberGenerator.new() + + var enemy_instance = enemy.instantiate() + add_child(enemy_instance) + enemy_instance.set_config(config_path) + enemy_instance.set_enemy(0) + enemy_instance.set_direction(type) + enemy_instance.set_v_offset(rng.randf_range(config.game['offset'][0], config.game['offset'][1]))