Add functionality to Victory UI

This commit is contained in:
Moe Poi ~ 2023-10-19 20:20:13 +07:00
parent e84c9f4996
commit 2318b579fe
20 changed files with 97 additions and 20 deletions

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=11 format=3 uid="uid://btdewn34d67m"]
[gd_scene load_steps=12 format=3 uid="uid://btdewn34d67m"]
[ext_resource type="Script" path="res://scripts/stages/1/game_manager.gd" id="1_aosti"]
[ext_resource type="TileSet" uid="uid://2u7m4ggcr08j" path="res://scenes/stages/stage_1.tres" id="2_3jjum"]
@ -9,6 +9,7 @@
[ext_resource type="PackedScene" uid="uid://bvoenhbaqiqj2" path="res://scenes/towers/placement/placement.tscn" id="6_mao4r"]
[ext_resource type="PackedScene" uid="uid://bigsx1yvw0pvg" path="res://scenes/ui/game_duration.tscn" id="7_8kqnd"]
[ext_resource type="PackedScene" uid="uid://cikgeqqhctm7k" path="res://scenes/base/base.tscn" id="8_rsf1n"]
[ext_resource type="PackedScene" uid="uid://r8kq68v8iflb" path="res://scenes/ui/victory.tscn" id="8_wl8vl"]
[sub_resource type="Curve2D" id="Curve2D_csucy"]
_data = {
@ -53,6 +54,9 @@ metadata/_edit_use_anchors_ = true
[node name="GameDuration" parent="CanvasLayer" instance=ExtResource("7_8kqnd")]
[node name="Victory" parent="CanvasLayer" instance=ExtResource("8_wl8vl")]
visible = false
[node name="Placements" type="Node2D" parent="."]
[node name="placement" parent="Placements" instance=ExtResource("6_mao4r")]

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=14 format=3 uid="uid://bj5auw303w08w"]
[gd_scene load_steps=15 format=3 uid="uid://bj5auw303w08w"]
[ext_resource type="Script" path="res://scripts/stages/2/game_manager.gd" id="1_4r6ye"]
[ext_resource type="Texture2D" uid="uid://bq6hnxbt4w37u" path="res://assets/tileset/snowland/Snowland@64x64.png" id="1_d077v"]
@ -9,6 +9,7 @@
[ext_resource type="PackedScene" uid="uid://cy88k4uxt1v37" path="res://scenes/ui/game_stats.tscn" id="4_puhii"]
[ext_resource type="PackedScene" uid="uid://cikgeqqhctm7k" path="res://scenes/base/base.tscn" id="6_e20hd"]
[ext_resource type="PackedScene" uid="uid://bigsx1yvw0pvg" path="res://scenes/ui/game_duration.tscn" id="7_y7bof"]
[ext_resource type="PackedScene" uid="uid://r8kq68v8iflb" path="res://scenes/ui/victory.tscn" id="8_o3n86"]
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_amj2r"]
texture = ExtResource("1_d077v")
@ -290,6 +291,9 @@ metadata/_edit_use_anchors_ = true
[node name="GameDuration" parent="CanvasLayer" instance=ExtResource("7_y7bof")]
[node name="Victory" parent="CanvasLayer" instance=ExtResource("8_o3n86")]
visible = false
[node name="Placements" type="Node2D" parent="."]
[node name="placement" parent="Placements" instance=ExtResource("2_4fmnc")]

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=13 format=3 uid="uid://bxk5llqn5csgu"]
[gd_scene load_steps=14 format=3 uid="uid://bxk5llqn5csgu"]
[ext_resource type="Texture2D" uid="uid://bq6hnxbt4w37u" path="res://assets/tileset/snowland/Snowland@64x64.png" id="1_l1d1t"]
[ext_resource type="Script" path="res://scripts/stages/3/game_manager.gd" id="1_u4jwa"]
@ -7,6 +7,7 @@
[ext_resource type="Script" path="res://scripts/stages/3/summon.gd" id="3_wyim2"]
[ext_resource type="PackedScene" uid="uid://cy88k4uxt1v37" path="res://scenes/ui/game_stats.tscn" id="4_2c35u"]
[ext_resource type="PackedScene" uid="uid://bigsx1yvw0pvg" path="res://scenes/ui/game_duration.tscn" id="7_w8rhw"]
[ext_resource type="PackedScene" uid="uid://r8kq68v8iflb" path="res://scenes/ui/victory.tscn" id="8_2707t"]
[ext_resource type="PackedScene" uid="uid://bvoenhbaqiqj2" path="res://scenes/towers/placement/placement.tscn" id="8_mm6r8"]
[ext_resource type="PackedScene" uid="uid://cikgeqqhctm7k" path="res://scenes/base/base.tscn" id="9_057um"]
@ -277,6 +278,9 @@ metadata/_edit_use_anchors_ = true
[node name="GameDuration" parent="CanvasLayer" instance=ExtResource("7_w8rhw")]
[node name="Victory" parent="CanvasLayer" instance=ExtResource("8_2707t")]
visible = false
[node name="Placements" type="Node2D" parent="."]
[node name="placement" parent="Placements" instance=ExtResource("8_mm6r8")]

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=14 format=3 uid="uid://cxo5fh50r6uxs"]
[gd_scene load_steps=15 format=3 uid="uid://cxo5fh50r6uxs"]
[ext_resource type="Texture2D" uid="uid://bq6hnxbt4w37u" path="res://assets/tileset/snowland/Snowland@64x64.png" id="1_436vn"]
[ext_resource type="Script" path="res://scripts/stages/4/game_manager.gd" id="1_lhtrq"]
@ -9,6 +9,7 @@
[ext_resource type="PackedScene" uid="uid://bigsx1yvw0pvg" path="res://scenes/ui/game_duration.tscn" id="7_5comn"]
[ext_resource type="PackedScene" uid="uid://bvoenhbaqiqj2" path="res://scenes/towers/placement/placement.tscn" id="7_v8e5o"]
[ext_resource type="PackedScene" uid="uid://cikgeqqhctm7k" path="res://scenes/base/base.tscn" id="8_trc1r"]
[ext_resource type="PackedScene" uid="uid://r8kq68v8iflb" path="res://scenes/ui/victory.tscn" id="8_x1qs2"]
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_8oq7c"]
texture = ExtResource("1_436vn")
@ -284,6 +285,9 @@ metadata/_edit_use_anchors_ = true
[node name="GameDuration" parent="CanvasLayer" instance=ExtResource("7_5comn")]
[node name="Victory" parent="CanvasLayer" instance=ExtResource("8_x1qs2")]
visible = false
[node name="Placements" type="Node2D" parent="."]
[node name="placement" parent="Placements" instance=ExtResource("7_v8e5o")]

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=14 format=3 uid="uid://i18iy1wmek4s"]
[gd_scene load_steps=15 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"]
@ -9,6 +9,7 @@
[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"]
[ext_resource type="PackedScene" uid="uid://bigsx1yvw0pvg" path="res://scenes/ui/game_duration.tscn" id="7_khyn2"]
[ext_resource type="PackedScene" uid="uid://r8kq68v8iflb" path="res://scenes/ui/victory.tscn" id="8_j6swr"]
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_pf042"]
texture = ExtResource("1_s0uo6")
@ -291,6 +292,9 @@ metadata/_edit_use_anchors_ = true
[node name="GameDuration" parent="CanvasLayer" instance=ExtResource("7_khyn2")]
[node name="Victory" parent="CanvasLayer" instance=ExtResource("8_j6swr")]
visible = false
[node name="Placements" type="Node2D" parent="."]
[node name="placement" parent="Placements" instance=ExtResource("5_vmpbi")]

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=16 format=3 uid="uid://dcecwku0if8tg"]
[gd_scene load_steps=17 format=3 uid="uid://dcecwku0if8tg"]
[ext_resource type="Script" path="res://scripts/stages/6/game_manager.gd" id="1_04mdc"]
[ext_resource type="Texture2D" uid="uid://d36b03p0hs8kw" path="res://assets/tileset/ashlands/ashlands-32x32.png" id="1_a4nl1"]
@ -10,6 +10,7 @@
[ext_resource type="PackedScene" uid="uid://bvoenhbaqiqj2" path="res://scenes/towers/placement/placement.tscn" id="5_ypi0p"]
[ext_resource type="PackedScene" uid="uid://cikgeqqhctm7k" path="res://scenes/base/base.tscn" id="6_h3kdb"]
[ext_resource type="PackedScene" uid="uid://bigsx1yvw0pvg" path="res://scenes/ui/game_duration.tscn" id="8_tv86d"]
[ext_resource type="PackedScene" uid="uid://r8kq68v8iflb" path="res://scenes/ui/victory.tscn" id="9_pc113"]
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_ebym7"]
texture = ExtResource("1_a4nl1")
@ -686,6 +687,9 @@ metadata/_edit_use_anchors_ = true
[node name="GameDuration" parent="CanvasLayer" instance=ExtResource("8_tv86d")]
[node name="Victory" parent="CanvasLayer" instance=ExtResource("9_pc113")]
visible = false
[node name="Placements" type="Node2D" parent="."]
[node name="placement" parent="Placements" instance=ExtResource("5_ypi0p")]

View file

@ -1,14 +1,17 @@
[gd_scene load_steps=2 format=3 uid="uid://r8kq68v8iflb"]
[gd_scene load_steps=3 format=3 uid="uid://r8kq68v8iflb"]
[ext_resource type="Texture2D" uid="uid://bbll7rkbty50k" path="res://assets/icons/victory.png" id="1_3fse5"]
[ext_resource type="Script" path="res://scripts/ui/victory.gd" id="1_qdex0"]
[node name="Victory" type="Control"]
process_mode = 2
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_qdex0")
[node name="Panel" type="Panel" parent="."]
layout_mode = 1
@ -40,8 +43,10 @@ layout_mode = 2
size_flags_horizontal = 4
texture = ExtResource("1_3fse5")
[node name="Button" type="Button" parent="Panel/MarginContainer/VBoxContainer"]
[node name="NextStage" type="Button" parent="Panel/MarginContainer/VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 6
text = "Next Stage"
[connection signal="pressed" from="Panel/MarginContainer/VBoxContainer/NextStage" to="." method="_on_next_stage_pressed"]

View file

@ -22,7 +22,8 @@ var game = {
"direction": "right"
}
]
]
],
"next_stage": 2
}
var menu = [

View file

@ -30,6 +30,9 @@ func _ready():
placement.connect("on_placement", on_tower_placement)
$CanvasLayer/TowerMenu.connect("build_tower", on_build_tower)
# Set Next Stage
$CanvasLayer/Victory.set_next_stage(config.game['next_stage'])
func _process(_delta):
$CanvasLayer/GameDuration.update_duration($Duration.time_left)
@ -108,4 +111,5 @@ func on_enemy_reward(value: int):
$CanvasLayer/GameStats.set_resource(data['resource'])
func _on_duration_timeout():
get_tree().change_scene_to_file("res://scenes/ui/victory.tscn")
get_tree().paused = true
$CanvasLayer/Victory.show()

View file

@ -52,7 +52,8 @@ var game = {
"direction": "front"
}
]
]
],
"next_stage": 3
}
var menu = [

View file

@ -29,6 +29,9 @@ func _ready():
placement.connect("on_placement", on_tower_placement)
$CanvasLayer/TowerMenu.connect("build_tower", on_build_tower)
# Set Next Stage
$CanvasLayer/Victory.set_next_stage(config.game['next_stage'])
func _process(_delta):
$CanvasLayer/GameDuration.update_duration($Duration.time_left)
@ -107,4 +110,5 @@ func on_enemy_reward(value: int):
$CanvasLayer/GameStats.set_resource(data['resource'])
func _on_duration_timeout():
get_tree().change_scene_to_file("res://scenes/ui/victory.tscn")
get_tree().paused = true
$CanvasLayer/Victory.show()

View file

@ -34,7 +34,8 @@ var game = {
"direction": "left"
}
]
]
],
"next_stage": 4
}
var menu = [

View file

@ -29,6 +29,9 @@ func _ready():
placement.connect("on_placement", on_tower_placement)
$CanvasLayer/TowerMenu.connect("build_tower", on_build_tower)
# Set Next Stage
$CanvasLayer/Victory.set_next_stage(config.game['next_stage'])
func _process(_delta):
$CanvasLayer/GameDuration.update_duration($Duration.time_left)
@ -107,4 +110,5 @@ func on_enemy_reward(value: int):
$CanvasLayer/GameStats.set_resource(data['resource'])
func _on_duration_timeout():
get_tree().change_scene_to_file("res://scenes/ui/victory.tscn")
get_tree().paused = true
$CanvasLayer/Victory.show()

View file

@ -40,7 +40,8 @@ var game = {
"direction": "right"
}
]
]
],
"next_stage": 5
}
var menu = [

View file

@ -29,6 +29,9 @@ func _ready():
placement.connect("on_placement", on_tower_placement)
$CanvasLayer/TowerMenu.connect("build_tower", on_build_tower)
# Set Next Stage
$CanvasLayer/Victory.set_next_stage(config.game['next_stage'])
func _process(_delta):
$CanvasLayer/GameDuration.update_duration($Duration.time_left)
@ -107,4 +110,5 @@ func on_enemy_reward(value: int):
$CanvasLayer/GameStats.set_resource(data['resource'])
func _on_duration_timeout():
get_tree().change_scene_to_file("res://scenes/ui/victory.tscn")
get_tree().paused = true
$CanvasLayer/Victory.show()

View file

@ -40,7 +40,8 @@ var game = {
"direction": "front"
}
]
]
],
"next_stage": 6
}
var menu = [

View file

@ -29,6 +29,9 @@ func _ready():
placement.connect("on_placement", on_tower_placement)
$CanvasLayer/TowerMenu.connect("build_tower", on_build_tower)
# Set Next Stage
$CanvasLayer/Victory.set_next_stage(config.game['next_stage'])
func _process(_delta):
$CanvasLayer/GameDuration.update_duration($Duration.time_left)
@ -107,4 +110,5 @@ func on_enemy_reward(value: int):
$CanvasLayer/GameStats.set_resource(data['resource'])
func _on_duration_timeout():
get_tree().change_scene_to_file("res://scenes/ui/victory.tscn")
get_tree().paused = true
$CanvasLayer/Victory.show()

View file

@ -82,7 +82,8 @@ var game = {
"direction": "front"
}
]
]
],
"next_stage": 0
}
var menu = [

View file

@ -29,6 +29,9 @@ func _ready():
placement.connect("on_placement", on_tower_placement)
$CanvasLayer/TowerMenu.connect("build_tower", on_build_tower)
# Set Next Stage
$CanvasLayer/Victory.set_next_stage(config.game['next_stage'])
func _process(_delta):
$CanvasLayer/GameDuration.update_duration($Duration.time_left)
@ -107,4 +110,5 @@ func on_enemy_reward(value: int):
$CanvasLayer/GameStats.set_resource(data['resource'])
func _on_duration_timeout():
get_tree().change_scene_to_file("res://scenes/ui/victory.tscn")
get_tree().paused = true
$CanvasLayer/Victory.show()

18
scripts/ui/victory.gd Normal file
View file

@ -0,0 +1,18 @@
extends Control
var next_stage: int = 0
func set_next_stage(value: int):
if value != 0:
next_stage = value
else:
$Panel/MarginContainer/VBoxContainer/NextStage.text = "Main Menu"
func _on_next_stage_pressed():
get_tree().paused = false
if next_stage != 0:
get_tree().change_scene_to_file("res://scenes/stages/stage_{stage_id}.tscn".format({"stage_id": str(next_stage)}))
else:
get_tree().change_scene_to_file("res://scenes/ui/main_menu.tscn")