Merge branch 'develop' of github.com:unbolt/PollenNotIncluded into develop

This commit is contained in:
Dan 2024-05-06 13:19:43 +01:00
commit 4e2f51f50f
27 changed files with 221 additions and 76 deletions

View file

@ -55,7 +55,7 @@ _data = {
[sub_resource type="CircleShape2D" id="CircleShape2D_86nxf"] [sub_resource type="CircleShape2D" id="CircleShape2D_86nxf"]
radius = 22.0907 radius = 22.0907
[node name="Bee" type="CharacterBody2D"] [node name="Bee" type="CharacterBody2D" groups=["bee"]]
z_index = 99 z_index = 99
collision_mask = 0 collision_mask = 0
script = ExtResource("1_pnu7x") script = ExtResource("1_pnu7x")

21
entities/Dog.tscn Normal file
View file

@ -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")

View file

@ -7,7 +7,6 @@ class_name BeeGathering
var time_at_patch : float = 0.0 var time_at_patch : float = 0.0
func enter(_msg := {}): func enter(_msg := {}):
Log.pr("I am going to attempt to gather some stuff!")
bee.just_gathering = true bee.just_gathering = true
#animator.play("Idle") #animator.play("Idle")

View file

@ -6,7 +6,6 @@ class_name BeeIdle
var idle_time : float = 0.0 var idle_time : float = 0.0
func enter(_msg := {}): func enter(_msg := {}):
Log.pr("I sit by idl-bee")
#animator.play("Idle") #animator.play("Idle")
pass pass
@ -15,7 +14,6 @@ func update(delta : float):
idle_time += delta idle_time += delta
if idle_time > 2.0: if idle_time > 2.0:
Log.pr("Been idle for 2 seconds, check for something to do...")
find_something_to_do() find_something_to_do()
idle_time = 0.0 idle_time = 0.0
pass pass
@ -23,10 +21,8 @@ func update(delta : float):
func find_something_to_do(): func find_something_to_do():
if bee.nectar > 0: if bee.nectar > 0:
## Bee has pollen - head home ## Bee has pollen - head home
Log.pr(bee, "I have nectar, I should return to the hive")
state_transition.emit(self, "Travelling") state_transition.emit(self, "Travelling")
else: else:
## Bee has no pollen - they should move to a flower ## 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") state_transition.emit(self, "Travelling")
pass pass

View file

@ -5,11 +5,8 @@ class_name BeeReturning
@onready var target = get_tree().get_first_node_in_group("beehive") @onready var target = get_tree().get_first_node_in_group("beehive")
func enter(_msg := {}): func enter(_msg := {}):
Log.pr("I return to the hive!")
bee.animation_player.play("Flying") bee.animation_player.play("Flying")
func update(delta : float) -> void: func update(delta : float) -> void:
if target: if target:

View file

@ -6,12 +6,7 @@ class_name BeeSleeping
var time_at_patch : float = 0.0 var time_at_patch : float = 0.0
func enter(_msg := {}): func enter(_msg := {}):
Log.pr("BuzzzZZZzzzZZZZzzz (Sleeping)!") pass
#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...
func update(_delta):
pass pass

View file

@ -8,7 +8,6 @@ class_name BeeTravelling
var return_to_hive : bool = false var return_to_hive : bool = false
func enter(_msg := {}): func enter(_msg := {}):
Log.pr("I am on the move!")
return_to_hive = false return_to_hive = false
## Get the next target location from the bee ## Get the next target location from the bee
if bee.just_gathering: if bee.just_gathering:
@ -17,11 +16,8 @@ func enter(_msg := {}):
else: else:
target = bee.get_next_target() target = bee.get_next_target()
Log.pr(bee, target)
# If we have no target, we are returning to the hive # If we have no target, we are returning to the hive
if !target: if !target:
Log.pr("No more drones to visit, going to go back to the hive")
return_to_hive = true return_to_hive = true
bee.animation_player.play("Flying") bee.animation_player.play("Flying")

View file

@ -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 var just_gathering : bool = false # Used to check if the bee has just been gathering to return to their previous director
func _ready(): func _ready():
speed = randi_range(35,55) # Randomise the bee speed a bit 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(): func get_current_director():
return drone_manager.get_director(latest_target_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 ## If we are at the highest director, we need to go to a flower
func get_next_target(): func get_next_target():
if nectar == 0: if nectar == 0:
Log.pr("I have no nectar")
## If there is a next directory drone, lets go to it ## If there is a next directory drone, lets go to it
var next_drone = drone_manager.get_next_director(latest_target_director) var next_drone = drone_manager.get_next_director(latest_target_director)
if next_drone: if next_drone:
Log.pr("Next drone target", next_drone)
latest_target_director = next_drone.visit_order latest_target_director = next_drone.visit_order
return next_drone return next_drone
## If there is no next drone, check for a collector drone ## If there is no next drone, check for a collector drone
var collector_drone = drone_manager.get_collector() var collector_drone = drone_manager.get_collector()
if collector_drone: if collector_drone:
Log.pr("Collector drone target", collector_drone)
return collector_drone return collector_drone
else: else:
Log.pr("I have nectar")
## Let's go home, we need the previous director drones location ## Let's go home, we need the previous director drones location
var previous_drone = drone_manager.get_previous_director(latest_target_director) var previous_drone = drone_manager.get_previous_director(latest_target_director)
if previous_drone: if previous_drone:
Log.pr("Previous drone target", previous_drone)
latest_target_director = previous_drone.visit_order latest_target_director = previous_drone.visit_order
return previous_drone return previous_drone
@ -62,6 +51,10 @@ func deposit_nectar():
latest_target_director = 0 latest_target_director = 0
just_gathering = false just_gathering = false
func die():
# Move to the death state
# For now just remove the bee...
queue_free()

View file

@ -10,10 +10,8 @@ func _on_area_entered(area:Area2D):
## Check if the area entered is a flower patch ## Check if the area entered is a flower patch
if area.is_in_group("flowers"): if area.is_in_group("flowers"):
bee.in_range_of_flowers = true bee.in_range_of_flowers = true
Log.pr("I found some flowers!")
func _on_area_exited(area:Area2D): func _on_area_exited(area:Area2D):
## Check if the area exited is a flower patch ## Check if the area exited is a flower patch
if area.is_in_group("flowers"): if area.is_in_group("flowers"):
bee.in_range_of_flowers = false bee.in_range_of_flowers = false
Log.pr("I left the flowers!")

View file

@ -3,16 +3,10 @@ class_name Beehive
var dancer_in_range : bool = false var dancer_in_range : bool = false
func _ready():
Log.pr("Beehive has joined the party")
func _on_area_2d_area_entered(area:Area2D): func _on_area_2d_area_entered(area:Area2D):
Log.pr("Beehive: Area entered", area)
if area.is_in_group("dancer"): if area.is_in_group("dancer"):
dancer_in_range = true dancer_in_range = true
print("Dancer in range")
func _on_area_2d_area_exited(area:Area2D): func _on_area_2d_area_exited(area:Area2D):
if area.is_in_group("dancer"): if area.is_in_group("dancer"):
dancer_in_range = false dancer_in_range = false
print("Dancer out of range")

View file

@ -10,14 +10,11 @@ var current_state : State
# everything that uses a state machine! # everything that uses a state machine!
func _ready(): func _ready():
Log.pr("FSM Ready")
for child in get_children(): for child in get_children():
if child is State: if child is State:
states[child.name.to_lower()] = child states[child.name.to_lower()] = child
child.state_transition.connect(change_state) child.state_transition.connect(change_state)
Log.pr(states)
if initial_state: if initial_state:
initial_state.enter() initial_state.enter()
current_state = initial_state current_state = initial_state

View file

@ -28,6 +28,10 @@ window/size/viewport_height=720
enabled=PackedStringArray("res://addons/log/plugin.cfg") enabled=PackedStringArray("res://addons/log/plugin.cfg")
[gui]
theme/custom="res://resources/theme/game_theme.tres"
[layer_names] [layer_names]
2d_physics/layer_1="bees" 2d_physics/layer_1="bees"

Binary file not shown.

View file

@ -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={}

Binary file not shown.

View file

@ -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={}

View file

@ -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] [resource]
default_font = ExtResource("1_fwiur")
default_font_size = 12
Fonts/fonts/large = ExtResource("1_fwiur")
Fonts/fonts/normal = ExtResource("1_fwiur")

View file

@ -10,9 +10,6 @@ var max_bees = 100
var spawn_interval = 0.5 var spawn_interval = 0.5
var spawn_timer = 0.0 var spawn_timer = 0.0
func _ready():
Log.pr("Bee Spawner ready")
func spawn_bee(): func spawn_bee():
var bee_instance = bee.instantiate() var bee_instance = bee.instantiate()
add_child(bee_instance) add_child(bee_instance)

15
scenes/scripts/dog.gd Normal file
View file

@ -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

View file

@ -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 distractor_drone = preload("res://entities/DistractorDrone.tscn")
@onready var collector_drone = preload("res://entities/CollectorDrone.tscn") @onready var collector_drone = preload("res://entities/CollectorDrone.tscn")
func _ready() -> void:
Log.pr("Drone Manager Ready...")
## Function to detect right click event ## Function to detect right click event
func _input(event) -> void: func _input(event) -> void:
if spawning_drone: if spawning_drone:

View file

@ -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()

View file

@ -1,11 +1 @@
extends Node2D 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

View file

@ -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="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="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/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/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="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="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://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"] [sub_resource type="CircleShape2D" id="CircleShape2D_usqp5"]
radius = 142.316 radius = 142.316
[sub_resource type="CircleShape2D" id="CircleShape2D_ewfly"]
radius = 252.15
[node name="TestLevel" type="Node2D"] [node name="TestLevel" type="Node2D"]
script = ExtResource("1_lgt1m") script = ExtResource("1_lgt1m")
@ -44,15 +51,18 @@ offset_bottom = 266.0
text = "Flower patch bro" text = "Flower patch bro"
[node name="Pesticide" type="Polygon2D" parent="."] [node name="Pesticide" type="Polygon2D" parent="."]
position = Vector2(74.7948, -103.963) position = Vector2(561, 76)
scale = Vector2(0.851611, 0.815599)
color = Color(0.682353, 0.137255, 0.203922, 1) 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="."] [node name="DeathBox" type="Area2D" parent="Pesticide"]
position = Vector2(-354, 53)
color = Color(0.803922, 0.407843, 0.239216, 1) [node name="CollisionShape2D" type="CollisionShape2D" parent="Pesticide/DeathBox"]
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) shape = SubResource("CircleShape2D_ewfly")
[node name="Dog" parent="." instance=ExtResource("4_xlyy4")]
position = Vector2(705, 491)
[node name="BeeSpawner" type="Node2D" parent="."] [node name="BeeSpawner" type="Node2D" parent="."]
script = ExtResource("2_qqqq4") 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. " tooltip_text = "Spawn a dancing drone that will encourage bees to leave the hive. Best to put this near to the hive. "
text = "Dancer" 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/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/SpawnCollector" to="DroneManager" method="_on_spawn_collector_pressed"]
[connection signal="pressed" from="DroneManager/Control/MarginContainer/DroneControls/SpawnDistractor" to="DroneManager" method="_on_spawn_distractor_pressed"] [connection signal="pressed" from="DroneManager/Control/MarginContainer/DroneControls/SpawnDistractor" to="DroneManager" method="_on_spawn_distractor_pressed"]

View file

@ -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")

View file

@ -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

View file

@ -7,7 +7,6 @@ var last_update : float = 0
@onready var nectar_bar = get_node("%NectarBar") @onready var nectar_bar = get_node("%NectarBar")
func _ready(): func _ready():
Log.pr("UIComponent ready")
update_ui() update_ui()
func _process(delta): func _process(delta):
@ -17,8 +16,9 @@ func _process(delta):
last_update = 0 last_update = 0
update_ui() update_ui()
func update_ui(): if GameState.level_complete:
Log.pr("UIComponent update_ui") update_ui()
func update_ui():
nectar_bar.value = GameState.gathered_nectar nectar_bar.value = GameState.gathered_nectar
nectar_bar.max_value = GameState.required_nectar nectar_bar.max_value = GameState.required_nectar

View file

@ -1,16 +1,21 @@
class_name GameStateManager extends Node class_name GameStateManager extends Node
var level_complete : bool = false
var gathered_nectar : int = 0 : var gathered_nectar : int = 0 :
get: get:
return gathered_nectar return gathered_nectar
set(value): set(value):
gathered_nectar = 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(): func add_nectar():
gathered_nectar += 1 gathered_nectar += 1
Log.pr("Nectar gathered", gathered_nectar)
func game_win():
Log.pr("Game win")
level_complete = true
# get_tree().paused = true