diff --git a/entities/Bee.tscn b/entities/Bee.tscn index e1737cb..c574285 100644 --- a/entities/Bee.tscn +++ b/entities/Bee.tscn @@ -55,7 +55,7 @@ _data = { [sub_resource type="CircleShape2D" id="CircleShape2D_86nxf"] radius = 22.0907 -[node name="Bee" type="CharacterBody2D"] +[node name="Bee" type="CharacterBody2D" groups=["bee"]] z_index = 99 collision_mask = 0 script = ExtResource("1_pnu7x") diff --git a/entities/scripts/bee.gd b/entities/scripts/bee.gd index 7cd87fa..cfab9ed 100644 --- a/entities/scripts/bee.gd +++ b/entities/scripts/bee.gd @@ -62,6 +62,10 @@ func deposit_nectar(): latest_target_director = 0 just_gathering = false +func die(): + # Move to the death state + # For now just remove the bee... + queue_free() diff --git a/project.godot b/project.godot index 784258a..dcb3bf6 100644 --- a/project.godot +++ b/project.godot @@ -28,6 +28,10 @@ window/size/viewport_height=720 enabled=PackedStringArray("res://addons/log/plugin.cfg") +[gui] + +theme/custom="res://resources/theme/game_theme.tres" + [layer_names] 2d_physics/layer_1="bees" diff --git a/resources/fonts/Kaph-Italic.ttf b/resources/fonts/Kaph-Italic.ttf new file mode 100644 index 0000000..d10a69c Binary files /dev/null and b/resources/fonts/Kaph-Italic.ttf differ diff --git a/resources/fonts/Kaph-Italic.ttf.import b/resources/fonts/Kaph-Italic.ttf.import new file mode 100644 index 0000000..fdb8c71 --- /dev/null +++ b/resources/fonts/Kaph-Italic.ttf.import @@ -0,0 +1,33 @@ +[remap] + +importer="font_data_dynamic" +type="FontFile" +uid="uid://dwdgp7kjweao7" +path="res://.godot/imported/Kaph-Italic.ttf-1ab006790939f5d710ad0b74d2c82e38.fontdata" + +[deps] + +source_file="res://resources/fonts/Kaph-Italic.ttf" +dest_files=["res://.godot/imported/Kaph-Italic.ttf-1ab006790939f5d710ad0b74d2c82e38.fontdata"] + +[params] + +Rendering=null +antialiasing=1 +generate_mipmaps=false +multichannel_signed_distance_field=false +msdf_pixel_range=8 +msdf_size=48 +allow_system_fallback=true +force_autohinter=false +hinting=1 +subpixel_positioning=1 +oversampling=0.0 +Fallbacks=null +fallbacks=[] +Compress=null +compress=true +preload=[] +language_support={} +script_support={} +opentype_features={} diff --git a/resources/fonts/Kaph-Regular.ttf b/resources/fonts/Kaph-Regular.ttf new file mode 100644 index 0000000..b84049c Binary files /dev/null and b/resources/fonts/Kaph-Regular.ttf differ diff --git a/resources/fonts/Kaph-Regular.ttf.import b/resources/fonts/Kaph-Regular.ttf.import new file mode 100644 index 0000000..cdb268a --- /dev/null +++ b/resources/fonts/Kaph-Regular.ttf.import @@ -0,0 +1,33 @@ +[remap] + +importer="font_data_dynamic" +type="FontFile" +uid="uid://beyoaacc7uhy1" +path="res://.godot/imported/Kaph-Regular.ttf-2e09e72cc59e741e8ff9885a176f06d5.fontdata" + +[deps] + +source_file="res://resources/fonts/Kaph-Regular.ttf" +dest_files=["res://.godot/imported/Kaph-Regular.ttf-2e09e72cc59e741e8ff9885a176f06d5.fontdata"] + +[params] + +Rendering=null +antialiasing=1 +generate_mipmaps=false +multichannel_signed_distance_field=false +msdf_pixel_range=8 +msdf_size=48 +allow_system_fallback=true +force_autohinter=false +hinting=1 +subpixel_positioning=1 +oversampling=0.0 +Fallbacks=null +fallbacks=[] +Compress=null +compress=true +preload=[] +language_support={} +script_support={} +opentype_features={} diff --git a/resources/theme/game_theme.tres b/resources/theme/game_theme.tres index 25dd81e..fde2abe 100644 --- a/resources/theme/game_theme.tres +++ b/resources/theme/game_theme.tres @@ -1,3 +1,9 @@ -[gd_resource type="Theme" format=3 uid="uid://cpkvret5gi66h"] +[gd_resource type="Theme" load_steps=2 format=3 uid="uid://cpkvret5gi66h"] + +[ext_resource type="FontFile" uid="uid://beyoaacc7uhy1" path="res://resources/fonts/Kaph-Regular.ttf" id="1_fwiur"] [resource] +default_font = ExtResource("1_fwiur") +default_font_size = 12 +Fonts/fonts/large = ExtResource("1_fwiur") +Fonts/fonts/normal = ExtResource("1_fwiur") diff --git a/scenes/scripts/pesticide.gd b/scenes/scripts/pesticide.gd new file mode 100644 index 0000000..91cf9ce --- /dev/null +++ b/scenes/scripts/pesticide.gd @@ -0,0 +1,11 @@ +extends Polygon2D +class_name Pesticide + +@onready var death_box = $DeathBox + +func _ready(): + death_box.connect("body_entered", Callable(self, "_on_body_entered")) + +func _on_body_entered(area): + if area.is_in_group("bee"): + area.die() \ No newline at end of file diff --git a/scenes/test_level.tscn b/scenes/test_level.tscn index 37f85c5..58e984c 100644 --- a/scenes/test_level.tscn +++ b/scenes/test_level.tscn @@ -1,16 +1,22 @@ -[gd_scene load_steps=9 format=3 uid="uid://mk5n0hrwk4yi"] +[gd_scene load_steps=13 format=3 uid="uid://mk5n0hrwk4yi"] [ext_resource type="Script" path="res://scenes/scripts/test_level.gd" id="1_lgt1m"] [ext_resource type="PackedScene" uid="uid://dyu4mucawjlu6" path="res://entities/Beehive.tscn" id="2_5ueyo"] [ext_resource type="Script" path="res://scenes/scripts/drone_manager.gd" id="2_474nc"] [ext_resource type="Script" path="res://scenes/scripts/bee_spawner.gd" id="2_qqqq4"] +[ext_resource type="Script" path="res://scenes/scripts/pesticide.gd" id="3_gg2a6"] [ext_resource type="Script" path="res://scenes/scripts/drone_controls.gd" id="3_rqkyv"] [ext_resource type="Theme" uid="uid://cpkvret5gi66h" path="res://resources/theme/game_theme.tres" id="6_1kbwe"] [ext_resource type="PackedScene" uid="uid://b7eeptlk47ymd" path="res://ui/UiComponent.tscn" id="6_xuemm"] +[ext_resource type="PackedScene" uid="uid://cwutwy11pityw" path="res://ui/LevelCompleteComponent.tscn" id="8_4k5cm"] +[ext_resource type="Script" path="res://ui/scripts/level_complete_component.gd" id="9_qrlto"] [sub_resource type="CircleShape2D" id="CircleShape2D_usqp5"] radius = 142.316 +[sub_resource type="CircleShape2D" id="CircleShape2D_ewfly"] +radius = 252.15 + [node name="TestLevel" type="Node2D"] script = ExtResource("1_lgt1m") @@ -44,10 +50,15 @@ offset_bottom = 266.0 text = "Flower patch bro" [node name="Pesticide" type="Polygon2D" parent="."] -position = Vector2(74.7948, -103.963) -scale = Vector2(0.851611, 0.815599) +position = Vector2(561, 76) color = Color(0.682353, 0.137255, 0.203922, 1) -polygon = PackedVector2Array(441, 122, 520, 54, 548, 154, 625, 114, 593, 234, 686, 281, 581, 325, 605, 472, 512, 363, 399, 468, 429, 311, 239, 362, 322, 226, 152, 92, 345, 130, 346, 15) +polygon = PackedVector2Array(-201, -145, 111, -237, 250, -30, 185, 172, -80, 253, -259, 82) +script = ExtResource("3_gg2a6") + +[node name="DeathBox" type="Area2D" parent="Pesticide"] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Pesticide/DeathBox"] +shape = SubResource("CircleShape2D_ewfly") [node name="Dog" type="Polygon2D" parent="."] position = Vector2(-354, 53) @@ -123,6 +134,13 @@ layout_mode = 2 tooltip_text = "Spawn a dancing drone that will encourage bees to leave the hive. Best to put this near to the hive. " text = "Dancer" +[node name="LevelCompleteComponent" parent="." instance=ExtResource("8_4k5cm")] +unique_name_in_owner = true +visible = false +offset_right = 1280.0 +offset_bottom = 720.0 +script = ExtResource("9_qrlto") + [connection signal="pressed" from="DroneManager/Control/MarginContainer/DroneControls/SpawnDirector" to="DroneManager" method="_on_spawn_director_pressed"] [connection signal="pressed" from="DroneManager/Control/MarginContainer/DroneControls/SpawnCollector" to="DroneManager" method="_on_spawn_collector_pressed"] [connection signal="pressed" from="DroneManager/Control/MarginContainer/DroneControls/SpawnDistractor" to="DroneManager" method="_on_spawn_distractor_pressed"] diff --git a/ui/LevelCompleteComponent.tscn b/ui/LevelCompleteComponent.tscn new file mode 100644 index 0000000..9825ba4 --- /dev/null +++ b/ui/LevelCompleteComponent.tscn @@ -0,0 +1,40 @@ +[gd_scene load_steps=2 format=3 uid="uid://cwutwy11pityw"] + +[sub_resource type="LabelSettings" id="LabelSettings_phhcy"] +font_size = 32 + +[node name="LevelCompleteComponent" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[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="Label" type="Label" parent="MarginContainer/CenterContainer"] +layout_mode = 2 +text = "The Bees Are Happy!" +label_settings = SubResource("LabelSettings_phhcy") diff --git a/ui/scripts/level_complete_component.gd b/ui/scripts/level_complete_component.gd new file mode 100644 index 0000000..f103a15 --- /dev/null +++ b/ui/scripts/level_complete_component.gd @@ -0,0 +1,11 @@ +extends Control + +# Called when the node enters the scene tree for the first time. +func _ready(): + visible = false + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(_delta): + if GameState.level_complete == true: + visible = true diff --git a/utility/game_state.gd b/utility/game_state.gd index 7f62ada..a0c6a88 100644 --- a/utility/game_state.gd +++ b/utility/game_state.gd @@ -1,16 +1,25 @@ class_name GameStateManager extends Node +var level_complete : bool = false + var gathered_nectar : int = 0 : get: return gathered_nectar set(value): gathered_nectar = value + if gathered_nectar > required_nectar: + game_win() -@export var required_nectar : int = 200 +@export var required_nectar : int = 100 func _ready(): Log.pr("GameStateManager ready") func add_nectar(): gathered_nectar += 1 - Log.pr("Nectar gathered", gathered_nectar) \ No newline at end of file + Log.pr("Nectar gathered", gathered_nectar) + +func game_win(): + Log.pr("Game win") + level_complete = true + # get_tree().paused = true