Update bee animations, game over component UI, and game state handling. Set up game over conditions based on the number of dead bees.
This commit is contained in:
parent
2a4a578f19
commit
f4e2169009
11 changed files with 203 additions and 37 deletions
|
|
@ -13,30 +13,6 @@
|
|||
[ext_resource type="Texture2D" uid="uid://bsskcrayofs8n" path="res://resources/textures/bee_wings.png" id="11_utbwk"]
|
||||
[ext_resource type="Texture2D" uid="uid://b2jr0mt5xymog" path="res://resources/particles/smoke_01.png" id="12_52rft"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_iys4n"]
|
||||
resource_name = "Flying"
|
||||
length = 5.0
|
||||
loop_mode = 1
|
||||
step = 0.25
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("BeeBody:position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 1, 2, 3, 4, 5),
|
||||
"transitions": PackedFloat32Array(-2, -2, -2, -2, -2, -2),
|
||||
"update": 0,
|
||||
"values": [Vector2(0, 0), Vector2(0, 10), Vector2(0, 5), Vector2(0, -5), Vector2(0, 10), Vector2(0, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_t75ra"]
|
||||
resource_name = "Idle"
|
||||
|
||||
[sub_resource type="Animation" id="Animation_0encb"]
|
||||
length = 0.001
|
||||
|
||||
[sub_resource type="Animation" id="Animation_1dh34"]
|
||||
resource_name = "Death"
|
||||
length = 2.0
|
||||
|
|
@ -116,6 +92,30 @@ tracks/5/keys = {
|
|||
"values": [true, false]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_iys4n"]
|
||||
resource_name = "Flying"
|
||||
length = 5.0
|
||||
loop_mode = 1
|
||||
step = 0.25
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("BeeBody:position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 1, 2, 3, 4, 5),
|
||||
"transitions": PackedFloat32Array(-2, -2, -2, -2, -2, -2),
|
||||
"update": 0,
|
||||
"values": [Vector2(0, 0), Vector2(0, 10), Vector2(0, 5), Vector2(0, -5), Vector2(0, 10), Vector2(0, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_t75ra"]
|
||||
resource_name = "Idle"
|
||||
|
||||
[sub_resource type="Animation" id="Animation_0encb"]
|
||||
length = 0.001
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_m27po"]
|
||||
_data = {
|
||||
"Death": SubResource("Animation_1dh34"),
|
||||
|
|
@ -202,8 +202,8 @@ script = ExtResource("7_6qlbu")
|
|||
script = ExtResource("8_dptvu")
|
||||
|
||||
[node name="BeeBody" type="Sprite2D" parent="."]
|
||||
position = Vector2(0, 10.0475)
|
||||
rotation = 0.378783
|
||||
position = Vector2(0, 50)
|
||||
rotation = 1.5708
|
||||
scale = Vector2(0.1, 0.1)
|
||||
texture = ExtResource("10_yi42o")
|
||||
|
||||
|
|
@ -226,7 +226,7 @@ scale = Vector2(0.07, 0.04)
|
|||
texture = ExtResource("10_yi42o")
|
||||
|
||||
[node name="ImpactCloud" type="CPUParticles2D" parent="."]
|
||||
self_modulate = Color(1, 1, 1, 0)
|
||||
self_modulate = Color(1, 1, 1, 0.333333)
|
||||
position = Vector2(0, 50)
|
||||
texture = ExtResource("12_52rft")
|
||||
gravity = Vector2(0, 0)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ class_name BeeDeath
|
|||
|
||||
|
||||
func enter(_msg := {}):
|
||||
GameState.bee_died()
|
||||
bee.bee_position_animation.play("Death")
|
||||
bee.bee_wing_animation.stop()
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=15 format=3 uid="uid://dalh10tit6qg"]
|
||||
[gd_scene load_steps=16 format=3 uid="uid://dalh10tit6qg"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://dn6aa6f2f4g4i" path="res://components/RulesComponent.tscn" id="1_g1iu7"]
|
||||
[ext_resource type="Script" path="res://levels/scripts/level_1.gd" id="1_jrhhc"]
|
||||
|
|
@ -14,6 +14,7 @@
|
|||
[ext_resource type="PackedScene" uid="uid://b7eeptlk47ymd" path="res://ui/UiComponent.tscn" id="11_ndtvv"]
|
||||
[ext_resource type="PackedScene" uid="uid://ct3c16xm33r2a" path="res://scenes/elements/drone_manager.tscn" id="12_37aah"]
|
||||
[ext_resource type="PackedScene" uid="uid://cwutwy11pityw" path="res://ui/LevelCompleteComponent.tscn" id="13_we755"]
|
||||
[ext_resource type="PackedScene" uid="uid://b5whit1dshr3" path="res://ui/GameOverComponent.tscn" id="15_jn0bj"]
|
||||
|
||||
[node name="Level1" type="Node2D"]
|
||||
script = ExtResource("1_jrhhc")
|
||||
|
|
@ -149,3 +150,8 @@ z_index = 1000
|
|||
offset_right = 1280.0
|
||||
offset_bottom = 720.0
|
||||
mouse_filter = 1
|
||||
|
||||
[node name="GameOverComponent" parent="." instance=ExtResource("15_jn0bj")]
|
||||
z_index = 900
|
||||
offset_right = 1280.0
|
||||
offset_bottom = 720.0
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=16 format=3 uid="uid://dcgmtmjsrtafq"]
|
||||
[gd_scene load_steps=17 format=3 uid="uid://dcgmtmjsrtafq"]
|
||||
|
||||
[ext_resource type="Script" path="res://levels/scripts/level_2.gd" id="1_dtbi3"]
|
||||
[ext_resource type="PackedScene" uid="uid://dn6aa6f2f4g4i" path="res://components/RulesComponent.tscn" id="2_gln7y"]
|
||||
|
|
@ -15,6 +15,7 @@
|
|||
[ext_resource type="PackedScene" uid="uid://b7eeptlk47ymd" path="res://ui/UiComponent.tscn" id="12_mmtyl"]
|
||||
[ext_resource type="PackedScene" uid="uid://ct3c16xm33r2a" path="res://scenes/elements/drone_manager.tscn" id="13_pibpn"]
|
||||
[ext_resource type="PackedScene" uid="uid://cwutwy11pityw" path="res://ui/LevelCompleteComponent.tscn" id="14_uyhgj"]
|
||||
[ext_resource type="PackedScene" uid="uid://b5whit1dshr3" path="res://ui/GameOverComponent.tscn" id="16_450js"]
|
||||
|
||||
[node name="Level2" type="Node2D"]
|
||||
script = ExtResource("1_dtbi3")
|
||||
|
|
@ -152,3 +153,8 @@ visible = false
|
|||
z_index = 999
|
||||
offset_right = 1280.0
|
||||
offset_bottom = 720.0
|
||||
|
||||
[node name="GameOverComponent" parent="." instance=ExtResource("16_450js")]
|
||||
z_index = 900
|
||||
offset_right = 1280.0
|
||||
offset_bottom = 720.0
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=16 format=3 uid="uid://bw12t0pk5eecr"]
|
||||
[gd_scene load_steps=17 format=3 uid="uid://bw12t0pk5eecr"]
|
||||
|
||||
[ext_resource type="Script" path="res://levels/scripts/level_3.gd" id="1_6fiq4"]
|
||||
[ext_resource type="PackedScene" uid="uid://dn6aa6f2f4g4i" path="res://components/RulesComponent.tscn" id="2_qf6aq"]
|
||||
|
|
@ -15,6 +15,7 @@
|
|||
[ext_resource type="PackedScene" uid="uid://b7eeptlk47ymd" path="res://ui/UiComponent.tscn" id="13_cw1ps"]
|
||||
[ext_resource type="PackedScene" uid="uid://ct3c16xm33r2a" path="res://scenes/elements/drone_manager.tscn" id="14_mtjsg"]
|
||||
[ext_resource type="PackedScene" uid="uid://cwutwy11pityw" path="res://ui/LevelCompleteComponent.tscn" id="15_1jo0f"]
|
||||
[ext_resource type="PackedScene" uid="uid://b5whit1dshr3" path="res://ui/GameOverComponent.tscn" id="16_61bnh"]
|
||||
|
||||
[node name="Level3" type="Node2D"]
|
||||
script = ExtResource("1_6fiq4")
|
||||
|
|
@ -184,3 +185,8 @@ visible = false
|
|||
z_index = 999
|
||||
offset_right = 1280.0
|
||||
offset_bottom = 720.0
|
||||
|
||||
[node name="GameOverComponent" parent="." instance=ExtResource("16_61bnh")]
|
||||
z_index = 900
|
||||
offset_right = 1280.0
|
||||
offset_bottom = 720.0
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ func _ready():
|
|||
func update_game_state():
|
||||
GameState.required_nectar = rules.game_rules.nectar_required
|
||||
GameState.level_par = rules.game_rules.level_par
|
||||
GameState.level_number = rules.game_rules.level_number
|
||||
GameState.bees_available = rules.game_rules.bees_available
|
||||
ui_controls.update_level_text("Level : " + str(rules.game_rules.level_number))
|
||||
ui_controls.update_par_text("Par : " + str(rules.game_rules.level_par))
|
||||
bee_spawner.max_bees = rules.game_rules.bees_available
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ border_width_top = 4
|
|||
border_width_right = 4
|
||||
border_width_bottom = 4
|
||||
border_color = Color(0.819608, 0.454902, 0.254902, 1)
|
||||
corner_radius_bottom_left = 5
|
||||
shadow_color = Color(0, 0, 0, 0.258824)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_vj6bi"]
|
||||
|
|
|
|||
71
ui/GameOverComponent.tscn
Normal file
71
ui/GameOverComponent.tscn
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://b5whit1dshr3"]
|
||||
|
||||
[ext_resource type="Script" path="res://ui/scripts/game_over_component.gd" id="1_p4mrd"]
|
||||
|
||||
[node name="GameOverComponent" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_p4mrd")
|
||||
|
||||
[node name="BackgroundOverlay" type="Panel" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_constants/margin_left = 10
|
||||
theme_override_constants/margin_top = 10
|
||||
theme_override_constants/margin_right = 10
|
||||
theme_override_constants/margin_bottom = 10
|
||||
|
||||
[node name="CenterContainer" type="CenterContainer" parent="MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/CenterContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="NotCool" type="Label" parent="MarginContainer/CenterContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
tooltip_text = "Valheim is a great game."
|
||||
mouse_filter = 0
|
||||
theme_override_colors/font_color = Color(0.819608, 0.454902, 0.254902, 1)
|
||||
theme_override_font_sizes/font_size = 30
|
||||
text = "Sucking at something is the
|
||||
first step towards being
|
||||
kinda good at something.
|
||||
|
||||
Try again."
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/CenterContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 20
|
||||
theme_override_constants/margin_top = 20
|
||||
theme_override_constants/margin_right = 20
|
||||
theme_override_constants/margin_bottom = 20
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/CenterContainer/VBoxContainer/MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="TryAgain" type="Button" parent="MarginContainer/CenterContainer/VBoxContainer/MarginContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
text = "Try Again"
|
||||
|
||||
[node name="MainMenu" type="Button" parent="MarginContainer/CenterContainer/VBoxContainer/MarginContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Main Menu"
|
||||
15
ui/scripts/game_over_component.gd
Normal file
15
ui/scripts/game_over_component.gd
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
extends Control
|
||||
|
||||
@onready var main_menu_button = get_node("%MainMenu")
|
||||
|
||||
func _ready():
|
||||
visible = false
|
||||
main_menu_button.connect("pressed", Callable(self, "on_main_menu_pressed"))
|
||||
|
||||
func _process(_delta):
|
||||
if GameState.game_over == true:
|
||||
visible = true
|
||||
|
||||
func on_main_menu_pressed():
|
||||
GameState.reset()
|
||||
SceneMgr.load_scene("MAINMENU")
|
||||
|
|
@ -4,8 +4,11 @@ var placing_drone : bool = false
|
|||
|
||||
var level_timer : float = 0.0
|
||||
|
||||
var level_number : int = 0
|
||||
|
||||
var level_started : bool = false
|
||||
var level_complete : bool = false
|
||||
var game_over : bool = false
|
||||
|
||||
var gathered_nectar : int = 0 :
|
||||
get:
|
||||
|
|
@ -15,9 +18,17 @@ var gathered_nectar : int = 0 :
|
|||
if gathered_nectar > required_nectar and !level_complete:
|
||||
game_win()
|
||||
|
||||
@export var required_nectar : int = 100
|
||||
@export var level_par : int = 2
|
||||
@export var drones_used : int = 0
|
||||
var required_nectar : int = 100
|
||||
var level_par : int = 2
|
||||
var drones_used : int = 0
|
||||
var bees_available : int = 0
|
||||
var dead_bees : int = 0 :
|
||||
get:
|
||||
return dead_bees
|
||||
set(value):
|
||||
dead_bees = value
|
||||
if dead_bees >= bees_available and !game_over:
|
||||
game_lose()
|
||||
|
||||
var level_points : int = 0 :
|
||||
get:
|
||||
|
|
@ -34,9 +45,12 @@ var judge_level_par : int = 0 :
|
|||
return 0
|
||||
|
||||
func _process(delta):
|
||||
if level_started and !level_complete:
|
||||
if level_started and !level_complete and !game_over:
|
||||
level_timer += delta
|
||||
|
||||
func bee_died():
|
||||
dead_bees += 1
|
||||
|
||||
func add_nectar():
|
||||
gathered_nectar += 1
|
||||
|
||||
|
|
@ -53,10 +67,15 @@ func game_win():
|
|||
Log.pr("Game win")
|
||||
level_complete = true
|
||||
HighScoreMgr.add_honey(gathered_nectar)
|
||||
# get_tree().paused = true
|
||||
HighScoreMgr.update_highscore(level_number, level_points)
|
||||
HighScoreMgr.add_dead_bees(dead_bees)
|
||||
HighScoreMgr.save()
|
||||
|
||||
func game_lose():
|
||||
pass
|
||||
Log.pr("Game lose")
|
||||
game_over = true
|
||||
HighScoreMgr.add_dead_bees(dead_bees)
|
||||
HighScoreMgr.save()
|
||||
|
||||
func reset():
|
||||
level_timer = 0.0
|
||||
|
|
@ -64,3 +83,4 @@ func reset():
|
|||
level_complete = false
|
||||
gathered_nectar = 0
|
||||
drones_used = 0
|
||||
dead_bees = 0
|
||||
|
|
|
|||
|
|
@ -33,7 +33,28 @@ func load():
|
|||
|
||||
func add_honey(honey : int):
|
||||
loaded_data.total_honey_collected += honey
|
||||
save()
|
||||
|
||||
func add_dead_bees(dead : int):
|
||||
loaded_data.total_bees_killed += dead
|
||||
|
||||
func update_highscore(level : int, points : int) -> void:
|
||||
var current_highscore = get_level_highscore(level)
|
||||
|
||||
if points > current_highscore:
|
||||
match level:
|
||||
1:
|
||||
loaded_data.level_1_score = points
|
||||
2:
|
||||
loaded_data.level_2_score = points
|
||||
3:
|
||||
loaded_data.level_3_score = points
|
||||
4:
|
||||
loaded_data.level_4_score = points
|
||||
5:
|
||||
loaded_data.level_5_score = points
|
||||
6:
|
||||
loaded_data.level_6_score = points
|
||||
pass
|
||||
|
||||
func debug_save_high_score():
|
||||
loaded_data.level_1_score = 3000
|
||||
|
|
@ -41,3 +62,20 @@ func debug_save_high_score():
|
|||
|
||||
func debug_output():
|
||||
Log.pr("High Scores", loaded_data.level_1_score)
|
||||
|
||||
func get_level_highscore(level : int) -> int:
|
||||
match level:
|
||||
1:
|
||||
return loaded_data.level_1_score
|
||||
2:
|
||||
return loaded_data.level_2_score
|
||||
3:
|
||||
return loaded_data.level_3_score
|
||||
4:
|
||||
return loaded_data.level_4_score
|
||||
5:
|
||||
return loaded_data.level_5_score
|
||||
6:
|
||||
return loaded_data.level_6_score
|
||||
|
||||
return 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue