Added health bar and snail behavior enhancements
- Introduced a health bar for flowers, which updates based on the current GameState values. - Enhanced snail behavior with eating and sleeping states. Snails now have a chance to switch to the sleeping state while eating. - Improved mouse interaction with snails, allowing them to potentially switch to sleep mode when clicked. - Refactored cursor management into its own class for better code organization and readability. - Updated drone placement logic to use the new CursorManager class. - Added functionality for bees to replenish flower nectar levels after a certain number of deposits.
This commit is contained in:
parent
2a9e78b52e
commit
f0a7c5ca05
12 changed files with 167 additions and 33 deletions
|
|
@ -3,16 +3,36 @@ class_name SnailEating
|
|||
|
||||
@onready var snail : Snail = get_parent().get_parent() as Snail # I think this is bad but I dont care it works
|
||||
|
||||
var eat_interval : float = 3.0
|
||||
var eat_timer : float = 0.0
|
||||
|
||||
var move_to : Vector2 = Vector2.ZERO
|
||||
|
||||
func enter(_msg : Dictionary = {}) -> void:
|
||||
Log.pr("I am a snail...")
|
||||
Log.pr("I am a snail and I will eat!")
|
||||
snail.eating = true
|
||||
|
||||
func exit() -> void:
|
||||
snail.eating = false
|
||||
|
||||
func update(_delta : float) -> void:
|
||||
pass
|
||||
func update(delta : float) -> void:
|
||||
eat_timer += delta
|
||||
|
||||
if eat_timer >= eat_interval:
|
||||
snail.eat()
|
||||
eat_timer = 0.0
|
||||
|
||||
func physics_update(_delta : float) -> void:
|
||||
pass
|
||||
|
||||
if move_to == Vector2.ZERO:
|
||||
move_to = snail.get_random_target()
|
||||
|
||||
if snail.global_position.distance_to(move_to) > 3:
|
||||
snail.velocity = snail.global_position.direction_to(move_to) * snail.speed
|
||||
snail.move_and_slide()
|
||||
snail.look_at(move_to)
|
||||
else:
|
||||
move_to = Vector2.ZERO
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue