Add Stage 6

This commit is contained in:
Moe Poi ~ 2023-10-15 23:04:13 +07:00
parent df9478ab48
commit b8c0b6acac
7 changed files with 1109 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://d36b03p0hs8kw"
path="res://.godot/imported/ashlands-32x32.png-5a12b8ffccd561fa811259d566bd64e6.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/tileset/ashlands/ashlands-32x32.png"
dest_files=["res://.godot/imported/ashlands-32x32.png-5a12b8ffccd561fa811259d566bd64e6.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View file

@ -11,7 +11,7 @@ config_version=5
[application]
config/name="Frontier of Hell"
run/main_scene="res://scenes/stages/stage_5.tscn"
run/main_scene="res://scenes/stages/stage_6.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"

719
scenes/stages/stage_6.tscn Normal file

File diff suppressed because one or more lines are too long

232
scripts/stages/6/config.gd Normal file
View file

@ -0,0 +1,232 @@
extends Node
var game = {
"health": 6,
"resource": 100,
"spawn_timer": 3.0,
"offset": [-20.0, 20.0],
"path_direction": [
[
{
"progress": 0,
"direction": "right",
},
{
"progress": 303,
"direction": "front"
},
{
"progress": 466,
"direction": "right"
},
{
"progress": 690,
"direction": "front"
},
{
"progress": 909,
"direction": "left"
},
{
"progress": 1289,
"direction": "front"
}
],
[
{
"progress": 0,
"direction": "front",
},
{
"progress": 315,
"direction": "left"
},
{
"progress": 607,
"direction": "front"
},
{
"progress": 826,
"direction": "right"
},
{
"progress": 1011,
"direction": "front"
}
],
[
{
"progress": 0,
"direction": "left",
},
{
"progress": 376,
"direction": "back"
},
{
"progress": 465,
"direction": "left"
},
{
"progress": 751,
"direction": "front"
},
{
"progress": 969,
"direction": "right"
},
{
"progress": 1150,
"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
}
]

View file

@ -0,0 +1,93 @@
extends Node2D
var config_path = "res://scripts/stages/6/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'])

View file

@ -0,0 +1,30 @@
extends Path2D
@onready var timer = $Timer
@export var type: int = 0
var config_path = "res://scripts/stages/6/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]))