Enhanced snail animations and interactions
Added new animation states for the snail entity, including 'Move' and 'Sleep'. The snail now hides certain elements when eating and plays appropriate animations when transitioning between states. Also introduced a new texture for sleep indication.
This commit is contained in:
parent
5777a7f2f1
commit
b8f42a552e
6 changed files with 268 additions and 9 deletions
|
|
@ -4,6 +4,7 @@ class_name Snail
|
|||
@onready var fsm : FiniteStateMachine = $StateMachine as FiniteStateMachine
|
||||
@onready var flowers : Flowers = get_parent()
|
||||
@onready var sprite : Sprite2D = $Sprite
|
||||
@onready var animation : AnimationPlayer = $AnimationPlayer
|
||||
|
||||
var enabled : bool = false
|
||||
var eating : bool = false
|
||||
|
|
@ -13,6 +14,7 @@ var mouse_over : bool = false
|
|||
func _ready() -> void:
|
||||
connect("mouse_entered", Callable(self, "on_mouse_entered"))
|
||||
connect("mouse_exited", Callable(self, "on_mouse_exited"))
|
||||
animation.connect("animation_finished", Callable(self, "on_animation_finished"))
|
||||
|
||||
# Detect mouse left click and trigger function
|
||||
func _input(event : InputEvent) -> void:
|
||||
|
|
@ -27,6 +29,12 @@ func eat() -> void:
|
|||
# Reduce the GameState flower_nectar_level
|
||||
GameState.flower_nectar_level -= 1
|
||||
|
||||
func hide_zeds() -> void:
|
||||
$Z.hide()
|
||||
$Z2.hide()
|
||||
$Z3.hide()
|
||||
$Sprite/ShadowShell.hide()
|
||||
|
||||
func maybe_sleep() -> void:
|
||||
# If the snail is still eating, then we want a 30% chance of switching it it to the sleeping state
|
||||
if eating:
|
||||
|
|
@ -46,4 +54,8 @@ func on_mouse_entered() -> void:
|
|||
func on_mouse_exited() -> void:
|
||||
# Reset the cursor to the default
|
||||
mouse_over = false
|
||||
CursorMgr.reset_cursor()
|
||||
CursorMgr.reset_cursor()
|
||||
|
||||
func on_animation_finished(anim_name : StringName) -> void:
|
||||
if anim_name == "GoingToSleep":
|
||||
animation.play("Sleep")
|
||||
Loading…
Add table
Add a link
Reference in a new issue