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
15
utility/cursor_manager.gd
Normal file
15
utility/cursor_manager.gd
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
extends Node
|
||||
class_name CursorManager
|
||||
|
||||
@onready var default_cursor : Resource = preload("res://resources/cursors/pointer_a.png")
|
||||
@onready var place_cursor : Resource = preload("res://resources/cursors/target_round_b.png")
|
||||
@onready var edit_cursor : Resource = preload("res://resources/cursors/message_dots_round.png")
|
||||
|
||||
func reset_cursor() -> void:
|
||||
Input.set_custom_mouse_cursor(default_cursor, Input.CURSOR_ARROW, Vector2(8, 8))
|
||||
|
||||
func place() -> void:
|
||||
Input.set_custom_mouse_cursor(place_cursor, Input.CURSOR_ARROW, Vector2(32, 32))
|
||||
|
||||
func edit() -> void:
|
||||
Input.set_custom_mouse_cursor(edit_cursor, Input.CURSOR_ARROW, Vector2(32, 32))
|
||||
|
|
@ -1,8 +1,5 @@
|
|||
class_name GameStateManager extends Node
|
||||
|
||||
## THIS SHOULD NOT EXIST HERE BUT I AM NOT GOING TO MAKE A NEW CLASS FOR IT RIGHT NOW
|
||||
@onready var default_cursor : Resource = preload("res://resources/cursors/pointer_a.png")
|
||||
|
||||
var placing_drone : bool = false
|
||||
|
||||
var level_timer : float = 0.0
|
||||
|
|
@ -15,15 +12,20 @@ var game_over : bool = false
|
|||
|
||||
## Game Rules ##############################################################
|
||||
|
||||
# Nectar levels - Depleted by snails, increased by bee visits?? Or time, TBD
|
||||
# TODO: Decide how to renew the nectar levels
|
||||
# Nectar levels - Depleted by snails, increased by bee nectar deposits
|
||||
# This is capped out at 10... Seems like a good amount
|
||||
# This has to be at least 1 at all times or the bees dont know wtf is going on
|
||||
var flower_nectar_level_charge : int = 0
|
||||
var flower_nectar_level_charge_required : int = 10
|
||||
var max_flower_nectar_level : int = 10
|
||||
var flower_nectar_level : int = 10 :
|
||||
get:
|
||||
return flower_nectar_level
|
||||
set(value):
|
||||
if value > 10:
|
||||
if value > max_flower_nectar_level:
|
||||
flower_nectar_level = 10
|
||||
elif value < 1:
|
||||
flower_nectar_level = 1
|
||||
else:
|
||||
flower_nectar_level = value
|
||||
|
||||
|
|
@ -69,11 +71,20 @@ func _process(delta : float) -> void:
|
|||
if level_started and !level_complete and !game_over:
|
||||
level_timer += delta
|
||||
|
||||
## For every 10 times the bees deposit nectar it will charge
|
||||
# the nectar level of the flowers by 1
|
||||
func pollenate() -> void:
|
||||
flower_nectar_level_charge += 1
|
||||
if flower_nectar_level_charge >= flower_nectar_level_charge_required:
|
||||
flower_nectar_level += 1
|
||||
flower_nectar_level_charge = 0
|
||||
|
||||
func bee_died() -> void:
|
||||
dead_bees += 1
|
||||
|
||||
# Add the nectar to the total gathered nectar
|
||||
func add_nectar(nectar : int) -> void:
|
||||
pollenate()
|
||||
gathered_nectar += nectar
|
||||
|
||||
func add_drone() -> void:
|
||||
|
|
@ -107,6 +118,3 @@ func reset() -> void:
|
|||
drones_used = 0
|
||||
dead_bees = 0
|
||||
spawn_snails = false
|
||||
|
||||
func reset_cursor() -> void:
|
||||
Input.set_custom_mouse_cursor(default_cursor, Input.CURSOR_ARROW, Vector2(8, 8))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue