Add RulesComponent, GameRulesResource, and BeeDeath state. Update Bee entity with death animation. Include new textures for particles. Add Highlight animation to Beehive.

This commit is contained in:
Dan 2024-05-09 15:08:57 +01:00
parent 1da411cacd
commit d879ca30bd
222 changed files with 3980 additions and 149 deletions

View file

@ -1,8 +1,9 @@
[gd_scene load_steps=18 format=3 uid="uid://deek6uv574xas"]
[gd_scene load_steps=21 format=3 uid="uid://deek6uv574xas"]
[ext_resource type="Script" path="res://entities/scripts/bee.gd" id="1_pnu7x"]
[ext_resource type="Script" path="res://entities/scripts/finite_state_machine.gd" id="1_t3s5d"]
[ext_resource type="Script" path="res://entities/bee/states/bee_idle.gd" id="3_vasc5"]
[ext_resource type="Script" path="res://entities/bee/states/bee_death.gd" id="5_1q5nb"]
[ext_resource type="Script" path="res://entities/bee/states/bee_gather.gd" id="5_4vs4l"]
[ext_resource type="Script" path="res://entities/scripts/bee_hit_box.gd" id="5_agq38"]
[ext_resource type="Script" path="res://entities/bee/states/bee_travelling.gd" id="5_qtx0r"]
@ -10,6 +11,7 @@
[ext_resource type="Script" path="res://entities/bee/states/bee_returning.gd" id="8_dptvu"]
[ext_resource type="Texture2D" uid="uid://ch3qalaaky8ng" path="res://resources/textures/bee_body.png" id="10_yi42o"]
[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"
@ -35,8 +37,88 @@ 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
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("BeeBody:rotation")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.5, 2),
"transitions": PackedFloat32Array(1, 1, 1),
"update": 0,
"values": [0.0, 1.5708, 1.5708]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("BeeBody:position")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 0.6, 2),
"transitions": PackedFloat32Array(1, 1, 1),
"update": 0,
"values": [Vector2(0, 0), Vector2(0, 50), Vector2(0, 50)]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("ImpactCloud:self_modulate:a")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0, 0.4, 1.3),
"transitions": PackedFloat32Array(1, 1, 1),
"update": 0,
"values": [0.0, 0.0, 0.5]
}
tracks/3/type = "method"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath(".")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"times": PackedFloat32Array(2),
"transitions": PackedFloat32Array(1),
"values": [{
"args": [],
"method": &"queue_free"
}]
}
tracks/4/type = "value"
tracks/4/imported = false
tracks/4/enabled = true
tracks/4/path = NodePath(".:modulate:a")
tracks/4/interp = 1
tracks/4/loop_wrap = true
tracks/4/keys = {
"times": PackedFloat32Array(0, 1.6, 2),
"transitions": PackedFloat32Array(1, 1, 1),
"update": 0,
"values": [1.0, 1.0, 0.0]
}
tracks/5/type = "value"
tracks/5/imported = false
tracks/5/enabled = true
tracks/5/path = NodePath("ImpactCloud:visible")
tracks/5/interp = 1
tracks/5/loop_wrap = true
tracks/5/keys = {
"times": PackedFloat32Array(0, 2),
"transitions": PackedFloat32Array(1, 1),
"update": 1,
"values": [true, false]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_m27po"]
_data = {
"Death": SubResource("Animation_1dh34"),
"Flying": SubResource("Animation_iys4n"),
"Idle": SubResource("Animation_t75ra"),
"RESET": SubResource("Animation_0encb")
@ -66,9 +148,10 @@ _data = {
}
[sub_resource type="CircleShape2D" id="CircleShape2D_86nxf"]
radius = 22.0907
radius = 13.0384
[node name="Bee" type="CharacterBody2D" groups=["bee"]]
self_modulate = Color(1, 1, 1, 0.169489)
z_index = 99
collision_mask = 0
script = ExtResource("1_pnu7x")
@ -103,6 +186,9 @@ initial_state = NodePath("Idle")
[node name="Idle" type="Node" parent="StateMachine"]
script = ExtResource("3_vasc5")
[node name="Death" type="Node" parent="StateMachine"]
script = ExtResource("5_1q5nb")
[node name="Travelling" type="Node" parent="StateMachine"]
script = ExtResource("5_qtx0r")
@ -116,11 +202,13 @@ script = ExtResource("7_6qlbu")
script = ExtResource("8_dptvu")
[node name="BeeBody" type="Sprite2D" parent="."]
position = Vector2(0, 10.0475)
rotation = 0.378783
scale = Vector2(0.1, 0.1)
texture = ExtResource("10_yi42o")
[node name="BeeWings" type="Sprite2D" parent="BeeBody"]
scale = Vector2(1, 0.1)
scale = Vector2(1, 0.999992)
texture = ExtResource("11_utbwk")
[node name="CPUParticles2D" type="CPUParticles2D" parent="BeeBody"]
@ -131,5 +219,19 @@ gravity = Vector2(0, 0)
linear_accel_min = 5.0
linear_accel_max = 10.0
[node name="Shadow" type="Sprite2D" parent="."]
modulate = Color(0, 0, 0, 0.0784314)
position = Vector2(0, 50)
scale = Vector2(0.07, 0.04)
texture = ExtResource("10_yi42o")
[node name="ImpactCloud" type="CPUParticles2D" parent="."]
self_modulate = Color(1, 1, 1, 0)
position = Vector2(0, 50)
texture = ExtResource("12_52rft")
gravity = Vector2(0, 0)
scale_amount_min = 0.01
scale_amount_max = 0.1
[connection signal="area_entered" from="HitBox" to="HitBox" method="_on_area_entered"]
[connection signal="area_exited" from="HitBox" to="HitBox" method="_on_area_exited"]

View file

@ -1,12 +1,35 @@
[gd_scene load_steps=5 format=3 uid="uid://dyu4mucawjlu6"]
[gd_scene load_steps=8 format=3 uid="uid://dyu4mucawjlu6"]
[ext_resource type="Script" path="res://entities/scripts/beehive.gd" id="1_ej1r1"]
[ext_resource type="Texture2D" uid="uid://dijxeckxe7trv" path="res://resources/textures/beehive.png" id="2_2xhre"]
[ext_resource type="PackedScene" uid="uid://6w1nq8lhq3tq" path="res://components/DropShadowComponent.tscn" id="3_uglsl"]
[ext_resource type="Texture2D" uid="uid://dhf4dessaw5p5" path="res://resources/particles/twirl_01.png" id="4_4biie"]
[sub_resource type="CircleShape2D" id="CircleShape2D_h6wmc"]
radius = 250.0
[sub_resource type="Animation" id="Animation_41718"]
resource_name = "Highlight"
length = 5.0
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("AreaHighlight:rotation")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 5),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [6.28319, 0.0]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_qs4pr"]
_data = {
"Highlight": SubResource("Animation_41718")
}
[node name="Beehive" type="Node2D"]
script = ExtResource("1_ej1r1")
@ -24,5 +47,17 @@ drop_shadow_distance = 20
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource("CircleShape2D_h6wmc")
[node name="AreaHighlight" type="Sprite2D" parent="."]
visible = false
self_modulate = Color(1, 1, 0.117647, 0.352941)
rotation = 6.28319
texture = ExtResource("4_4biie")
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
"": SubResource("AnimationLibrary_qs4pr")
}
autoplay = "Highlight"
[connection signal="area_entered" from="Area2D" to="." method="_on_area_2d_area_entered"]
[connection signal="area_exited" from="Area2D" to="." method="_on_area_2d_area_exited"]

125
entities/Flowers.tscn Normal file
View file

@ -0,0 +1,125 @@
[gd_scene load_steps=8 format=3 uid="uid://bme541qdw7nai"]
[ext_resource type="Script" path="res://entities/scripts/flowers.gd" id="1_72iub"]
[ext_resource type="PackedScene" uid="uid://rnykx61eqxyk" path="res://scenes/decor/flower_1.tscn" id="1_biusc"]
[ext_resource type="PackedScene" uid="uid://b7quc1hxenh5p" path="res://scenes/decor/flower_2.tscn" id="2_k5hnf"]
[ext_resource type="Texture2D" uid="uid://dhf4dessaw5p5" path="res://resources/particles/twirl_01.png" id="3_xruiv"]
[sub_resource type="CircleShape2D" id="CircleShape2D_1tovu"]
radius = 142.316
[sub_resource type="Animation" id="Animation_41718"]
resource_name = "Highlight"
length = 5.0
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("AreaHighlight:rotation")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 5),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [6.28319, 0.0]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_qs4pr"]
_data = {
"Highlight": SubResource("Animation_41718")
}
[node name="Flowers" type="Node2D"]
script = ExtResource("1_72iub")
[node name="FlowerSprites" type="Node2D" parent="."]
[node name="Flower1" parent="FlowerSprites" instance=ExtResource("1_biusc")]
position = Vector2(-10, 41)
scale = Vector2(0.5, 0.5)
[node name="Flower4" parent="FlowerSprites" instance=ExtResource("1_biusc")]
position = Vector2(-50, -75)
scale = Vector2(0.5, 0.5)
[node name="Flower5" parent="FlowerSprites" instance=ExtResource("1_biusc")]
position = Vector2(-53, -4)
scale = Vector2(0.5, 0.5)
[node name="Flower6" parent="FlowerSprites" instance=ExtResource("1_biusc")]
position = Vector2(45, -69)
scale = Vector2(0.5, 0.5)
[node name="Flower14" parent="FlowerSprites" instance=ExtResource("1_biusc")]
position = Vector2(-99, -46)
scale = Vector2(0.5, 0.5)
[node name="Flower15" parent="FlowerSprites" instance=ExtResource("1_biusc")]
position = Vector2(100, -42)
scale = Vector2(0.5, 0.5)
[node name="Flower16" parent="FlowerSprites" instance=ExtResource("1_biusc")]
position = Vector2(117, 13)
scale = Vector2(0.5, 0.5)
[node name="Flower17" parent="FlowerSprites" instance=ExtResource("1_biusc")]
position = Vector2(71, 88)
scale = Vector2(0.5, 0.5)
[node name="Flower7" parent="FlowerSprites" instance=ExtResource("1_biusc")]
position = Vector2(64, 17)
scale = Vector2(0.5, 0.5)
[node name="Flower8" parent="FlowerSprites" instance=ExtResource("1_biusc")]
position = Vector2(-84, 60)
scale = Vector2(0.5, 0.5)
[node name="Flower9" parent="FlowerSprites" instance=ExtResource("1_biusc")]
position = Vector2(30, 68)
scale = Vector2(0.5, 0.5)
[node name="Flower10" parent="FlowerSprites" instance=ExtResource("1_biusc")]
position = Vector2(0, -61)
scale = Vector2(0.5, 0.5)
[node name="Flower11" parent="FlowerSprites" instance=ExtResource("1_biusc")]
position = Vector2(1, -123)
scale = Vector2(0.5, 0.5)
[node name="Flower12" parent="FlowerSprites" instance=ExtResource("1_biusc")]
position = Vector2(-68, 117)
scale = Vector2(0.5, 0.5)
[node name="Flower13" parent="FlowerSprites" instance=ExtResource("1_biusc")]
position = Vector2(13, 108)
scale = Vector2(0.5, 0.5)
[node name="Flower2" parent="FlowerSprites" instance=ExtResource("2_k5hnf")]
position = Vector2(-31, 83)
scale = Vector2(0.5, 0.5)
[node name="Flower3" parent="FlowerSprites" instance=ExtResource("2_k5hnf")]
position = Vector2(4, -16)
scale = Vector2(0.5, 0.5)
[node name="FlowerCollectionArea" type="Area2D" parent="." groups=["flowers"]]
position = Vector2(1, 2)
collision_layer = 7
collision_mask = 7
[node name="CollisionShape2D" type="CollisionShape2D" parent="FlowerCollectionArea"]
shape = SubResource("CircleShape2D_1tovu")
[node name="AreaHighlight" type="Sprite2D" parent="."]
visible = false
modulate = Color(1, 1, 0.160784, 0.345098)
rotation = 6.28319
scale = Vector2(0.6, 0.6)
texture = ExtResource("3_xruiv")
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
"": SubResource("AnimationLibrary_qs4pr")
}
autoplay = "Highlight"

View file

@ -0,0 +1,96 @@
[gd_scene load_steps=7 format=3 uid="uid://clomllso36j02"]
[ext_resource type="Script" path="res://entities/scripts/vegetable_patch.gd" id="1_0gto5"]
[ext_resource type="Texture2D" uid="uid://s673b25l7g3k" path="res://resources/textures/veg.png" id="1_xnay0"]
[ext_resource type="Texture2D" uid="uid://dn35q8nkyy8q2" path="res://resources/particles/light_03.png" id="2_og86v"]
[sub_resource type="Curve" id="Curve_j5a63"]
_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(1, 1), 1.4, 0.0, 0, 0]
point_count = 2
[sub_resource type="Gradient" id="Gradient_am1ne"]
offsets = PackedFloat32Array(0.789238, 1)
colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 0)
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_qfjud"]
radius = 85.57
height = 669.91
[node name="VegetablePatch" type="Node2D"]
script = ExtResource("1_0gto5")
[node name="Veg" type="Sprite2D" parent="."]
texture = ExtResource("1_xnay0")
offset = Vector2(1, 18)
[node name="Outline" type="Sprite2D" parent="Veg"]
visible = false
modulate = Color(0.882353, 0, 0, 1)
show_behind_parent = true
scale = Vector2(1.05, 1.025)
texture = ExtResource("1_xnay0")
offset = Vector2(1, 18)
[node name="PesticideClouds" type="Node2D" parent="."]
[node name="PesticideCloud_1" type="CPUParticles2D" parent="PesticideClouds"]
position = Vector2(2, -63)
amount = 6
lifetime = 3.0
texture = ExtResource("2_og86v")
emission_shape = 1
emission_sphere_radius = 20.0
gravity = Vector2(0, 0)
scale_amount_min = 0.1
scale_amount_max = 0.4
scale_amount_curve = SubResource("Curve_j5a63")
color = Color(0.94902, 0.184314, 0.27451, 0.27451)
color_ramp = SubResource("Gradient_am1ne")
[node name="PesticideCloud_2" type="CPUParticles2D" parent="PesticideClouds"]
position = Vector2(-1, -236)
amount = 6
lifetime = 3.0
texture = ExtResource("2_og86v")
emission_shape = 1
emission_sphere_radius = 20.0
gravity = Vector2(0, 0)
scale_amount_min = 0.1
scale_amount_max = 0.4
scale_amount_curve = SubResource("Curve_j5a63")
color = Color(0.94902, 0.184314, 0.27451, 0.27451)
color_ramp = SubResource("Gradient_am1ne")
[node name="PesticideCloud_3" type="CPUParticles2D" parent="PesticideClouds"]
position = Vector2(2, 110)
amount = 6
lifetime = 3.0
texture = ExtResource("2_og86v")
emission_shape = 1
emission_sphere_radius = 20.0
gravity = Vector2(0, 0)
scale_amount_min = 0.1
scale_amount_max = 0.4
scale_amount_curve = SubResource("Curve_j5a63")
color = Color(0.94902, 0.184314, 0.27451, 0.27451)
color_ramp = SubResource("Gradient_am1ne")
[node name="PesticideCloud_4" type="CPUParticles2D" parent="PesticideClouds"]
position = Vector2(6, 269)
amount = 6
lifetime = 3.0
texture = ExtResource("2_og86v")
emission_shape = 1
emission_sphere_radius = 20.0
gravity = Vector2(0, 0)
scale_amount_min = 0.1
scale_amount_max = 0.4
scale_amount_curve = SubResource("Curve_j5a63")
color = Color(0.94902, 0.184314, 0.27451, 0.27451)
color_ramp = SubResource("Gradient_am1ne")
[node name="DeathBox" type="Area2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="DeathBox"]
position = Vector2(2, 14)
shape = SubResource("CapsuleShape2D_qfjud")

View file

@ -0,0 +1,15 @@
extends State
class_name BeeDeath
@onready var bee = get_parent().get_parent() as Bee
func enter(_msg := {}):
bee.bee_position_animation.play("Death")
bee.bee_wing_animation.stop()
func update(_delta : float) -> void:
pass
func physics_update(_delta : float) -> void:
pass

View file

@ -42,4 +42,4 @@ func physics_update(delta : float) -> void:
if bee.position.distance_to(target) > 2:
bee.velocity = (target - bee.position).normalized() * bee.speed / 2 * delta
bee.move_and_collide(bee.velocity)
bee.look_at(target)
bee.bee_body.look_at(target)

View file

@ -37,7 +37,7 @@ func physics_update(delta : float) -> void:
bee.velocity = (target - bee.position).normalized() * bee.speed / 2 * delta
bee.move_and_collide(bee.velocity)
bee.look_at(target)
bee.bee_body.look_at(target)
func find_something_to_do():
if bee.nectar > 0:

View file

@ -18,7 +18,7 @@ func physics_update(delta : float) -> void:
bee.velocity = (target.get_global_position() - bee.position).normalized() * bee.speed * delta
bee.move_and_collide(bee.velocity)
bee.look_at(target.position)
bee.bee_body.look_at(target.position)
else:
# Deposit the nectar and return it idle state

View file

@ -41,7 +41,7 @@ func physics_update(delta : float) -> void:
bee.velocity = (moving_to - bee.position).normalized() * bee.speed * delta
bee.move_and_collide(bee.velocity)
bee.look_at(target.position)
bee.bee_body.look_at(target.position)
else:
# Bee has arrived at location, if its the hive or a collector drone do the things

View file

@ -5,6 +5,8 @@ class_name Bee
@onready var drone_manager = get_tree().get_first_node_in_group("dronemanager") as DroneManager
@onready var bee_position_animation = $BeePositionAnimation as AnimationPlayer
@onready var bee_wing_animation = $WingAnimation as AnimationPlayer
@onready var bee_body = $BeeBody as Sprite2D
@onready var impact_cloud : CPUParticles2D = $ImpactCloud
@export var nectar : int = 0
@export var speed : int = 30
@ -16,6 +18,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():
modulate = Color(1,1,1,1)
impact_cloud.visible = false
speed = randi_range(35,55) # Randomise the bee speed a bit
bee_wing_animation.play("Fly")
@ -61,8 +65,7 @@ func deposit_nectar():
func die():
# Move to the death state
# For now just remove the bee...
queue_free()
fsm.force_change_state("Death")

View file

@ -3,6 +3,14 @@ class_name Beehive
var dancer_in_range : bool = false
@onready var outline = $AreaHighlight
func show_outline():
outline.visible = true
func hide_outline():
outline.visible = false
func _on_area_2d_area_entered(area:Area2D):
if area.is_in_group("dancer"):
dancer_in_range = true

View file

@ -0,0 +1,10 @@
extends Node2D
class_name Flowers
@onready var outline = $AreaHighlight
func show_outline():
outline.visible = true
func hide_outline():
outline.visible = false

View file

@ -0,0 +1,12 @@
extends Node2D
class_name VegetablePatch
@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()