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/Dog.tscn b/entities/Dog.tscn new file mode 100644 index 0000000..648d180 --- /dev/null +++ b/entities/Dog.tscn @@ -0,0 +1,21 @@ +[gd_scene load_steps=3 format=3 uid="uid://cfhoi2rqxa3up"] + +[ext_resource type="Script" path="res://scenes/scripts/dog.gd" id="1_26pvc"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_eyufl"] +radius = 191.83 + +[node name="Dog" type="Node2D"] +position = Vector2(-5, -1) +script = ExtResource("1_26pvc") + +[node name="DogGraphic" type="Polygon2D" parent="."] +position = Vector2(4, 28) +color = Color(0.803922, 0.407843, 0.239216, 1) +offset = Vector2(0, -15) +polygon = PackedVector2Array(17, -32, 57, -45, 51, 27, 29, -5, 31, 27, 15, 57, -15, 55, -29, 31, -23, -9, -51, 25, -53, -43, -17, -32) + +[node name="DeathBox" type="Area2D" parent="."] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="DeathBox"] +shape = SubResource("CircleShape2D_eyufl") diff --git a/entities/bee/states/bee_gather.gd b/entities/bee/states/bee_gather.gd index 5723b97..18f9a5f 100644 --- a/entities/bee/states/bee_gather.gd +++ b/entities/bee/states/bee_gather.gd @@ -7,7 +7,6 @@ class_name BeeGathering var time_at_patch : float = 0.0 func enter(_msg := {}): - Log.pr("I am going to attempt to gather some stuff!") bee.just_gathering = true #animator.play("Idle") diff --git a/entities/bee/states/bee_idle.gd b/entities/bee/states/bee_idle.gd index c1f4577..6a7ea26 100644 --- a/entities/bee/states/bee_idle.gd +++ b/entities/bee/states/bee_idle.gd @@ -6,7 +6,6 @@ class_name BeeIdle var idle_time : float = 0.0 func enter(_msg := {}): - Log.pr("I sit by idl-bee") #animator.play("Idle") pass @@ -15,7 +14,6 @@ func update(delta : float): idle_time += delta if idle_time > 2.0: - Log.pr("Been idle for 2 seconds, check for something to do...") find_something_to_do() idle_time = 0.0 pass @@ -23,10 +21,8 @@ func update(delta : float): func find_something_to_do(): if bee.nectar > 0: ## Bee has pollen - head home - Log.pr(bee, "I have nectar, I should return to the hive") state_transition.emit(self, "Travelling") else: ## Bee has no pollen - they should move to a flower - Log.pr(bee, "I have no nectar, I should find a flower") state_transition.emit(self, "Travelling") pass diff --git a/entities/bee/states/bee_returning.gd b/entities/bee/states/bee_returning.gd index 0d59fa2..da5262c 100644 --- a/entities/bee/states/bee_returning.gd +++ b/entities/bee/states/bee_returning.gd @@ -5,11 +5,8 @@ class_name BeeReturning @onready var target = get_tree().get_first_node_in_group("beehive") func enter(_msg := {}): - Log.pr("I return to the hive!") - bee.animation_player.play("Flying") - func update(delta : float) -> void: if target: diff --git a/entities/bee/states/bee_sleeping.gd b/entities/bee/states/bee_sleeping.gd index 83ee7fd..044fc4d 100644 --- a/entities/bee/states/bee_sleeping.gd +++ b/entities/bee/states/bee_sleeping.gd @@ -6,12 +6,7 @@ class_name BeeSleeping var time_at_patch : float = 0.0 func enter(_msg := {}): - Log.pr("BuzzzZZZzzzZZZZzzz (Sleeping)!") - #animator.play("Idle") - -func update(_delta : float): - - # If there is a dancing bee in range of the hive then - # we have a chance to wake up the bee... + pass +func update(_delta): pass \ No newline at end of file diff --git a/entities/bee/states/bee_travelling.gd b/entities/bee/states/bee_travelling.gd index b08f7c5..fc92244 100644 --- a/entities/bee/states/bee_travelling.gd +++ b/entities/bee/states/bee_travelling.gd @@ -8,7 +8,6 @@ class_name BeeTravelling var return_to_hive : bool = false func enter(_msg := {}): - Log.pr("I am on the move!") return_to_hive = false ## Get the next target location from the bee if bee.just_gathering: @@ -17,11 +16,8 @@ func enter(_msg := {}): else: target = bee.get_next_target() - Log.pr(bee, target) - # If we have no target, we are returning to the hive if !target: - Log.pr("No more drones to visit, going to go back to the hive") return_to_hive = true bee.animation_player.play("Flying") diff --git a/entities/scripts/bee.gd b/entities/scripts/bee.gd index 7cd87fa..21142e0 100644 --- a/entities/scripts/bee.gd +++ b/entities/scripts/bee.gd @@ -15,13 +15,8 @@ var in_range_of_flowers : bool = false var just_gathering : bool = false # Used to check if the bee has just been gathering to return to their previous director func _ready(): - speed = randi_range(35,55) # Randomise the bee speed a bit - Log.pr("I have never bee-n so ready!") - - Log.pr(fsm.current_state.name) - func get_current_director(): return drone_manager.get_director(latest_target_director) @@ -32,27 +27,21 @@ func get_current_director(): ## If we are at the highest director, we need to go to a flower func get_next_target(): if nectar == 0: - Log.pr("I have no nectar") ## If there is a next directory drone, lets go to it var next_drone = drone_manager.get_next_director(latest_target_director) if next_drone: - Log.pr("Next drone target", next_drone) latest_target_director = next_drone.visit_order return next_drone ## If there is no next drone, check for a collector drone var collector_drone = drone_manager.get_collector() if collector_drone: - Log.pr("Collector drone target", collector_drone) return collector_drone else: - Log.pr("I have nectar") - ## Let's go home, we need the previous director drones location var previous_drone = drone_manager.get_previous_director(latest_target_director) if previous_drone: - Log.pr("Previous drone target", previous_drone) latest_target_director = previous_drone.visit_order return previous_drone @@ -62,6 +51,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/entities/scripts/bee_hit_box.gd b/entities/scripts/bee_hit_box.gd index 51b9cec..137c26c 100644 --- a/entities/scripts/bee_hit_box.gd +++ b/entities/scripts/bee_hit_box.gd @@ -10,10 +10,8 @@ func _on_area_entered(area:Area2D): ## Check if the area entered is a flower patch if area.is_in_group("flowers"): bee.in_range_of_flowers = true - Log.pr("I found some flowers!") func _on_area_exited(area:Area2D): ## Check if the area exited is a flower patch if area.is_in_group("flowers"): - bee.in_range_of_flowers = false - Log.pr("I left the flowers!") \ No newline at end of file + bee.in_range_of_flowers = false \ No newline at end of file diff --git a/entities/scripts/beehive.gd b/entities/scripts/beehive.gd index cd192ba..b0957a2 100644 --- a/entities/scripts/beehive.gd +++ b/entities/scripts/beehive.gd @@ -3,16 +3,10 @@ class_name Beehive var dancer_in_range : bool = false -func _ready(): - Log.pr("Beehive has joined the party") - func _on_area_2d_area_entered(area:Area2D): - Log.pr("Beehive: Area entered", area) if area.is_in_group("dancer"): dancer_in_range = true - print("Dancer in range") func _on_area_2d_area_exited(area:Area2D): if area.is_in_group("dancer"): dancer_in_range = false - print("Dancer out of range") diff --git a/entities/scripts/finite_state_machine.gd b/entities/scripts/finite_state_machine.gd index 06c0d02..514105f 100644 --- a/entities/scripts/finite_state_machine.gd +++ b/entities/scripts/finite_state_machine.gd @@ -10,14 +10,11 @@ var current_state : State # everything that uses a state machine! func _ready(): - Log.pr("FSM Ready") for child in get_children(): if child is State: states[child.name.to_lower()] = child child.state_transition.connect(change_state) - Log.pr(states) - if initial_state: initial_state.enter() current_state = initial_state 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/bee_spawner.gd b/scenes/scripts/bee_spawner.gd index 051c242..2b0be8b 100644 --- a/scenes/scripts/bee_spawner.gd +++ b/scenes/scripts/bee_spawner.gd @@ -10,9 +10,6 @@ var max_bees = 100 var spawn_interval = 0.5 var spawn_timer = 0.0 -func _ready(): - Log.pr("Bee Spawner ready") - func spawn_bee(): var bee_instance = bee.instantiate() add_child(bee_instance) diff --git a/scenes/scripts/dog.gd b/scenes/scripts/dog.gd new file mode 100644 index 0000000..62065cd --- /dev/null +++ b/scenes/scripts/dog.gd @@ -0,0 +1,15 @@ +extends Node2D +class_name Dog + +@onready var death_box = $DeathBox + +var acquired_target : Bee = null + +func _ready(): + death_box.connect("body_entered", Callable(self, "_on_body_entered")) + +func _on_body_entered(area): + if area.is_in_group("bee"): + if !acquired_target: + Log.pr("Acquired target") + acquired_target = area diff --git a/scenes/scripts/drone_manager.gd b/scenes/scripts/drone_manager.gd index 2c7c3d1..97cdcad 100644 --- a/scenes/scripts/drone_manager.gd +++ b/scenes/scripts/drone_manager.gd @@ -16,9 +16,6 @@ var director_drones : Array = [] # List of all director drones in the world @onready var distractor_drone = preload("res://entities/DistractorDrone.tscn") @onready var collector_drone = preload("res://entities/CollectorDrone.tscn") -func _ready() -> void: - Log.pr("Drone Manager Ready...") - ## Function to detect right click event func _input(event) -> void: if spawning_drone: 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/scripts/test_level.gd b/scenes/scripts/test_level.gd index a6c2d17..e251cf8 100644 --- a/scenes/scripts/test_level.gd +++ b/scenes/scripts/test_level.gd @@ -1,11 +1 @@ extends Node2D - - -# Called when the node enters the scene tree for the first time. -func _ready(): - Log.pr("Hello there...") - - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(_delta): - pass diff --git a/scenes/test_level.tscn b/scenes/test_level.tscn index 37f85c5..0810c6d 100644 --- a/scenes/test_level.tscn +++ b/scenes/test_level.tscn @@ -1,16 +1,23 @@ -[gd_scene load_steps=9 format=3 uid="uid://mk5n0hrwk4yi"] +[gd_scene load_steps=14 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="PackedScene" uid="uid://cfhoi2rqxa3up" path="res://entities/Dog.tscn" id="4_xlyy4"] [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,15 +51,18 @@ 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="Dog" type="Polygon2D" parent="."] -position = Vector2(-354, 53) -color = Color(0.803922, 0.407843, 0.239216, 1) -polygon = PackedVector2Array(819, 301, 866, 278, 888, 364, 842, 319, 832, 373, 806, 423, 775, 424, 754, 377, 762, 319, 728, 360, 739, 263, 765, 284) +[node name="DeathBox" type="Area2D" parent="Pesticide"] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Pesticide/DeathBox"] +shape = SubResource("CircleShape2D_ewfly") + +[node name="Dog" parent="." instance=ExtResource("4_xlyy4")] +position = Vector2(705, 491) [node name="BeeSpawner" type="Node2D" parent="."] script = ExtResource("2_qqqq4") @@ -123,6 +133,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/ui/scripts/ui_component.gd b/ui/scripts/ui_component.gd index 7ee9a5f..0690bfe 100644 --- a/ui/scripts/ui_component.gd +++ b/ui/scripts/ui_component.gd @@ -7,7 +7,6 @@ var last_update : float = 0 @onready var nectar_bar = get_node("%NectarBar") func _ready(): - Log.pr("UIComponent ready") update_ui() func _process(delta): @@ -17,8 +16,9 @@ func _process(delta): last_update = 0 update_ui() -func update_ui(): - Log.pr("UIComponent update_ui") + if GameState.level_complete: + update_ui() +func update_ui(): nectar_bar.value = GameState.gathered_nectar nectar_bar.max_value = GameState.required_nectar diff --git a/utility/game_state.gd b/utility/game_state.gd index 7f62ada..5290597 100644 --- a/utility/game_state.gd +++ b/utility/game_state.gd @@ -1,16 +1,21 @@ 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 - -func _ready(): - Log.pr("GameStateManager ready") +@export var required_nectar : int = 100 func add_nectar(): gathered_nectar += 1 - Log.pr("Nectar gathered", gathered_nectar) \ No newline at end of file + +func game_win(): + Log.pr("Game win") + level_complete = true + # get_tree().paused = true