Refactor: Added explicit typing and void return types
- Introduced explicit typing to variables and functions across multiple scripts for better code clarity. - Specified 'void' as the return type for functions that do not return a value. - Removed redundant code in some scripts.
This commit is contained in:
parent
a62cd6018e
commit
2a9e78b52e
37 changed files with 216 additions and 248 deletions
|
|
@ -3,14 +3,14 @@ extends Node2D
|
|||
@export var parent_sprite : Sprite2D = null
|
||||
@export var drop_shadow_distance : int = 10
|
||||
|
||||
var drop_shadow_sprite = null
|
||||
var drop_shadow_sprite : Sprite2D = null
|
||||
|
||||
func _ready():
|
||||
func _ready() -> void:
|
||||
if parent_sprite is Sprite2D:
|
||||
drop_shadow()
|
||||
pass
|
||||
|
||||
func drop_shadow():
|
||||
func drop_shadow() -> void:
|
||||
drop_shadow_sprite = parent_sprite.duplicate()
|
||||
|
||||
drop_shadow_sprite.scale = Vector2(1.1, 1.1)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
extends State
|
||||
class_name BeeDeath
|
||||
|
||||
@onready var bee = get_parent().get_parent() as Bee
|
||||
@onready var bee : Bee = get_parent().get_parent() as Bee
|
||||
|
||||
|
||||
func enter(_msg := {}):
|
||||
func enter(_msg : Dictionary = {}) -> void:
|
||||
GameState.bee_died()
|
||||
bee.bee_position_animation.play("Death")
|
||||
bee.bee_wing_animation.stop()
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@ extends State
|
|||
class_name BeeGathering
|
||||
|
||||
@export var animator : AnimationPlayer
|
||||
@onready var bee = get_parent().get_parent() as Bee # I think this is bad but I dont care it works
|
||||
@onready var bee : Bee= get_parent().get_parent() as Bee # I think this is bad but I dont care it works
|
||||
|
||||
var time_at_patch : float = 0.0
|
||||
|
||||
var target : Vector2 = Vector2.ZERO
|
||||
|
||||
func enter(_msg := {}):
|
||||
func enter(_msg : Dictionary = {}) -> void:
|
||||
bee.just_gathering = true
|
||||
|
||||
Log.pr("Gathering now...")
|
||||
|
|
@ -16,7 +16,7 @@ func enter(_msg := {}):
|
|||
randomize()
|
||||
target = bee.get_global_position() + Vector2(randi_range(-100, 100), randi_range(-100, 100))
|
||||
|
||||
func update(_delta : float):
|
||||
func update(_delta : float) -> void:
|
||||
|
||||
if bee.in_range_of_flowers:
|
||||
#animator.play("Gathering")
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
extends State
|
||||
class_name BeeIdle
|
||||
|
||||
@onready var bee = get_parent().get_parent() as Bee # I think this is bad but I dont care it works
|
||||
@onready var bee : Bee = get_parent().get_parent() as Bee # I think this is bad but I dont care it works
|
||||
|
||||
var idle_time : float = 0.0
|
||||
|
||||
|
|
@ -10,14 +10,14 @@ var target : Vector2 = Vector2.ZERO
|
|||
var acquire_new_target : bool = false
|
||||
|
||||
|
||||
func enter(_msg := {}):
|
||||
func enter(_msg : Dictionary = {}) -> void:
|
||||
if acquire_new_target:
|
||||
target = bee.get_global_position() + Vector2(randi_range(-60, 60), randi_range(-60, 60))
|
||||
|
||||
func exit():
|
||||
func exit() -> void:
|
||||
acquire_new_target = true
|
||||
|
||||
func update(delta : float):
|
||||
func update(delta : float) -> void:
|
||||
|
||||
if target == Vector2.ZERO:
|
||||
randomize()
|
||||
|
|
@ -39,7 +39,7 @@ func physics_update(delta : float) -> void:
|
|||
bee.move_and_collide(bee.velocity)
|
||||
bee.bee_body.look_at(target)
|
||||
|
||||
func find_something_to_do():
|
||||
func find_something_to_do() -> void:
|
||||
if bee.nectar > 0:
|
||||
Log.pr("I have pollen, time to move..")
|
||||
## Bee has pollen - head home
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
extends State
|
||||
class_name BeeReturning
|
||||
|
||||
@onready var bee = get_parent().get_parent() as Bee # I think this is bad but I dont care it works
|
||||
@onready var target = get_tree().get_first_node_in_group("beehive")
|
||||
@onready var bee : Bee = get_parent().get_parent() as Bee # I think this is bad but I dont care it works
|
||||
@onready var target : Beehive = get_tree().get_first_node_in_group("beehive")
|
||||
|
||||
func enter(_msg := {}) -> void:
|
||||
func enter(_msg : Dictionary = {}) -> void:
|
||||
Log.pr("Returning to the hive")
|
||||
bee.bee_position_animation.play("Flying")
|
||||
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ class_name BeeSleeping
|
|||
|
||||
var time_at_patch : float = 0.0
|
||||
|
||||
func enter(_msg := {}) -> void:
|
||||
func enter(_msg : Dictionary = {}) -> void:
|
||||
pass
|
||||
|
||||
func update(_delta) -> void:
|
||||
func update(_delta : float) -> void:
|
||||
pass
|
||||
|
||||
func physics_update(_delta : float) -> void:
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@ class_name BeeTravelling
|
|||
|
||||
@export var target : Drone = null
|
||||
|
||||
@onready var bee = get_parent().get_parent() as Bee # I think this is bad but I dont care it works
|
||||
@onready var bee : Bee = get_parent().get_parent() as Bee # I think this is bad but I dont care it works
|
||||
|
||||
var return_to_hive : bool = false
|
||||
var moving_to : Vector2 = Vector2(0,0)
|
||||
|
||||
func enter(_msg := {}):
|
||||
func enter(_msg : Dictionary = {}) -> void:
|
||||
return_to_hive = false
|
||||
## Get the next target location from the bee
|
||||
if bee.just_gathering:
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
extends Node2D
|
||||
class_name Bee
|
||||
|
||||
@onready var fsm = $StateMachine as FiniteStateMachine
|
||||
@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 fsm : FiniteStateMachine = $StateMachine as FiniteStateMachine
|
||||
@onready var drone_manager : DroneManager = get_tree().get_first_node_in_group("dronemanager") as DroneManager
|
||||
@onready var bee_position_animation : AnimationPlayer = $BeePositionAnimation as AnimationPlayer
|
||||
@onready var bee_wing_animation : AnimationPlayer = $WingAnimation as AnimationPlayer
|
||||
@onready var bee_body : Sprite2D = $BeeBody as Sprite2D
|
||||
@onready var impact_cloud : CPUParticles2D = $ImpactCloud
|
||||
|
||||
@export var nectar : int = 0
|
||||
|
|
@ -17,13 +17,13 @@ var latest_target_director : int = 0
|
|||
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():
|
||||
func _ready() -> void:
|
||||
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")
|
||||
|
||||
func get_current_director():
|
||||
func get_current_director() -> DirectorDrone:
|
||||
return drone_manager.get_director(latest_target_director)
|
||||
|
||||
## Get the next target to move to
|
||||
|
|
@ -31,23 +31,23 @@ func get_current_director():
|
|||
## If we have nectar, we need to go down the director list
|
||||
## If we are at the lower director, we need to go the hive
|
||||
## If we are at the highest director, we need to go to a flower
|
||||
func get_next_target():
|
||||
func get_next_target() -> Drone:
|
||||
if nectar == 0:
|
||||
Log.pr("No nectar!")
|
||||
|
||||
## 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 : DirectorDrone = drone_manager.get_next_director(latest_target_director)
|
||||
if next_drone:
|
||||
latest_target_director = next_drone.visit_order
|
||||
return next_drone
|
||||
|
||||
## If there is no next drone, check for a collector drone
|
||||
var collector_drone = drone_manager.get_collector()
|
||||
var collector_drone : CollectorDrone = drone_manager.get_collector()
|
||||
if collector_drone:
|
||||
return collector_drone
|
||||
else:
|
||||
## 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 : DirectorDrone = drone_manager.get_previous_director(latest_target_director)
|
||||
if previous_drone:
|
||||
Log.pr("Previous drone", previous_drone)
|
||||
latest_target_director = previous_drone.visit_order
|
||||
|
|
@ -56,6 +56,8 @@ func get_next_target():
|
|||
Log.pr("No previous drone")
|
||||
return null
|
||||
|
||||
return null
|
||||
|
||||
func deposit_nectar() -> void:
|
||||
if nectar > 0:
|
||||
GameState.add_nectar(nectar)
|
||||
|
|
|
|||
|
|
@ -1,17 +1,13 @@
|
|||
extends Area2D
|
||||
|
||||
@onready var bee = get_parent() as Bee
|
||||
@onready var bee : Bee = get_parent() as Bee
|
||||
|
||||
func _ready():
|
||||
pass
|
||||
|
||||
|
||||
func _on_area_entered(area:Area2D):
|
||||
func _on_area_entered(area : Area2D) -> void:
|
||||
## Check if the area entered is a flower patch
|
||||
if area.is_in_group("flowers"):
|
||||
bee.in_range_of_flowers = true
|
||||
|
||||
func _on_area_exited(area:Area2D):
|
||||
func _on_area_exited(area : Area2D) -> void:
|
||||
## Check if the area exited is a flower patch
|
||||
if area.is_in_group("flowers"):
|
||||
bee.in_range_of_flowers = false
|
||||
|
|
@ -3,18 +3,18 @@ class_name Beehive
|
|||
|
||||
var dancer_in_range : bool = false
|
||||
|
||||
@onready var outline = $AreaHighlight
|
||||
@onready var outline : Sprite2D = $AreaHighlight
|
||||
|
||||
func show_outline():
|
||||
func show_outline() -> void:
|
||||
outline.visible = true
|
||||
|
||||
func hide_outline():
|
||||
func hide_outline() -> void:
|
||||
outline.visible = false
|
||||
|
||||
func _on_area_2d_area_entered(area:Area2D):
|
||||
func _on_area_2d_area_entered(area : Area2D) -> void:
|
||||
if area.is_in_group("dancer"):
|
||||
dancer_in_range = true
|
||||
|
||||
func _on_area_2d_area_exited(area:Area2D):
|
||||
func _on_area_2d_area_exited(area : Area2D) -> void:
|
||||
if area.is_in_group("dancer"):
|
||||
dancer_in_range = false
|
||||
|
|
|
|||
|
|
@ -1,11 +1 @@
|
|||
class_name CollectorDrone extends Drone
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(_delta):
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -1,11 +1 @@
|
|||
class_name DancerDrone extends Drone
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(_delta):
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
class_name DirectorDrone extends Drone
|
||||
|
||||
@onready var edit_cursor = preload("res://resources/cursors/message_dots_round.png")
|
||||
@onready var label = get_node("Label")
|
||||
@onready var edit_cursor : Resource = preload("res://resources/cursors/message_dots_round.png")
|
||||
@onready var label : Label = get_node("Label")
|
||||
|
||||
@export var visit_order : int = 0 :
|
||||
get:
|
||||
|
|
@ -10,22 +10,16 @@ class_name DirectorDrone extends Drone
|
|||
visit_order = value
|
||||
update_label_value()
|
||||
|
||||
func _ready():
|
||||
pass
|
||||
|
||||
func _process(_delta):
|
||||
pass
|
||||
|
||||
func update_label_value():
|
||||
func update_label_value() -> void:
|
||||
$Label.text = str(visit_order)
|
||||
|
||||
func _on_click_detection_mouse_entered():
|
||||
func _on_click_detection_mouse_entered() -> void:
|
||||
if GameState.placing_drone == false:
|
||||
Log.pr("Mouse entered the director drone!")
|
||||
label.visible = true
|
||||
Input.set_custom_mouse_cursor(edit_cursor, Input.CURSOR_ARROW, Vector2(32, 32))
|
||||
|
||||
func _on_click_detection_mouse_exited():
|
||||
func _on_click_detection_mouse_exited() -> void:
|
||||
if GameState.placing_drone == false:
|
||||
Log.pr("Mouse exited the director drone!")
|
||||
label.visible = false
|
||||
|
|
@ -33,7 +27,7 @@ func _on_click_detection_mouse_exited():
|
|||
GameState.reset_cursor()
|
||||
|
||||
|
||||
func _on_click_detection_input_event(_viewport:Node, event:InputEvent, _shape_idx:int):
|
||||
func _on_click_detection_input_event(_viewport:Node, event:InputEvent, _shape_idx:int) -> void:
|
||||
if GameState.placing_drone == false:
|
||||
if (event is InputEventMouseButton && event.button_index == MOUSE_BUTTON_RIGHT && event.pressed):
|
||||
#Input.set_custom_mouse_cursor(null)
|
||||
|
|
|
|||
|
|
@ -1,12 +1 @@
|
|||
class_name DistractorDrone extends Drone
|
||||
|
||||
#var dog : Dog = null
|
||||
|
||||
func _ready():
|
||||
# Get the dog in the scene (there will only ever be one...)
|
||||
#dog = get_tree().get_first_node_in_group("dog") as Dog
|
||||
#Log.pr(dog)
|
||||
pass
|
||||
|
||||
func _process(_delta):
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ var current_state : State
|
|||
#NOTE This is a generic finite_state_machine, it handles all states, changes to this code will affect
|
||||
# everything that uses a state machine!
|
||||
|
||||
func _ready():
|
||||
for child in get_children():
|
||||
func _ready() -> void:
|
||||
for child : Node in get_children():
|
||||
if child is State:
|
||||
states[child.name.to_lower()] = child
|
||||
child.state_transition.connect(change_state)
|
||||
|
|
@ -20,18 +20,18 @@ func _ready():
|
|||
current_state = initial_state
|
||||
|
||||
# Call the current states update function
|
||||
func _process(delta):
|
||||
func _process(delta : float) -> void:
|
||||
if current_state:
|
||||
current_state.update(delta)
|
||||
|
||||
func _physics_process(delta):
|
||||
func _physics_process(delta : float) -> void:
|
||||
if current_state:
|
||||
current_state.physics_update(delta)
|
||||
|
||||
# Use force_change_state cautiously, it immediately switches to a state regardless of any transitions.
|
||||
# This is used to force us into a 'death state' when killed
|
||||
func force_change_state(new_state : String):
|
||||
var newState = states.get(new_state.to_lower())
|
||||
func force_change_state(new_state : String) -> void:
|
||||
var newState : State = states.get(new_state.to_lower())
|
||||
|
||||
if !newState:
|
||||
print(new_state + " does not exist in the dictionary of states")
|
||||
|
|
@ -44,20 +44,20 @@ func force_change_state(new_state : String):
|
|||
# NOTE Calling exit like so: (current_state.Exit()) may cause warnings when flushing queries, like when the enemy is being removed after death.
|
||||
# call_deferred is safe and prevents this from occuring. We get the Exit function from the state as a callable and then call it in a thread-safe manner
|
||||
if current_state:
|
||||
var exit_callable = Callable(current_state, "exit")
|
||||
var exit_callable : Callable = Callable(current_state, "exit")
|
||||
exit_callable.call_deferred()
|
||||
|
||||
newState.enter()
|
||||
|
||||
current_state = newState
|
||||
|
||||
func change_state(source_state : State, new_state_name : String):
|
||||
func change_state(source_state : State, new_state_name : String) -> void:
|
||||
if source_state != current_state:
|
||||
#print("Invalid change_state trying from: " + source_state.name + " but currently in: " + current_state.name)
|
||||
#This typically only happens when trying to switch from death state following a force_change
|
||||
return
|
||||
|
||||
var new_state = states.get(new_state_name.to_lower())
|
||||
var new_state : State = states.get(new_state_name.to_lower())
|
||||
if !new_state:
|
||||
print("New state is empty")
|
||||
return
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
extends Node2D
|
||||
class_name Flowers
|
||||
|
||||
@onready var outline = $AreaHighlight
|
||||
@onready var outline : Sprite2D = $AreaHighlight
|
||||
|
||||
@export var health : int = 100
|
||||
|
||||
var spawn_snails : bool = false
|
||||
|
||||
@onready var spawn_area = $FlowerCollectionArea/CollisionShape2D
|
||||
@onready var snail = $Snail
|
||||
@onready var spawn_area : CollisionShape2D = $FlowerCollectionArea/CollisionShape2D
|
||||
@onready var snail : Snail = $Snail
|
||||
|
||||
func _ready():
|
||||
func _ready() -> void:
|
||||
hide_outline()
|
||||
|
||||
## Check if this level is spawning snails or not
|
||||
|
|
@ -22,21 +22,21 @@ func _ready():
|
|||
snail.global_position = get_random_snail_spawn()
|
||||
|
||||
|
||||
func show_outline():
|
||||
func show_outline() -> void:
|
||||
outline.visible = true
|
||||
|
||||
func hide_outline():
|
||||
func hide_outline() -> void:
|
||||
outline.visible = false
|
||||
|
||||
|
||||
func get_random_snail_spawn():
|
||||
var circle_radius = spawn_area.shape.radius
|
||||
var random_angle = randf_range(0, TAU)
|
||||
func get_random_snail_spawn() -> Vector2:
|
||||
var circle_radius : float = spawn_area.shape.radius
|
||||
var random_angle : float = randf_range(0, TAU)
|
||||
|
||||
var x = circle_radius * cos(random_angle)
|
||||
var y = circle_radius * sin(random_angle)
|
||||
var x : float = circle_radius * cos(random_angle)
|
||||
var y : float = circle_radius * sin(random_angle)
|
||||
|
||||
var circle_center = spawn_area.global_position
|
||||
var random_point = circle_center + Vector2(x, y)
|
||||
var circle_center : Vector2 = spawn_area.global_position
|
||||
var random_point : Vector2 = circle_center + Vector2(x, y)
|
||||
|
||||
return random_point
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
extends Sprite2D
|
||||
class_name Snail
|
||||
|
||||
var enabled : bool = false
|
||||
var eating : bool = false
|
||||
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@ class_name State
|
|||
|
||||
signal state_transition
|
||||
|
||||
func enter(_msg := {}):
|
||||
func enter(_msg : Dictionary = {}) -> void:
|
||||
pass
|
||||
|
||||
func exit():
|
||||
func exit() -> void :
|
||||
pass
|
||||
|
||||
func update(_delta:float):
|
||||
func update(_delta : float) -> void:
|
||||
pass
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
extends Node2D
|
||||
class_name VegetablePatch
|
||||
|
||||
@onready var death_box = $DeathBox
|
||||
@onready var death_box : Area2D = $DeathBox
|
||||
|
||||
func _ready():
|
||||
func _ready() -> void:
|
||||
death_box.connect("body_entered", Callable(self, "_on_body_entered"))
|
||||
|
||||
func _on_body_entered(area):
|
||||
func _on_body_entered(area : Bee) -> void:
|
||||
if area.is_in_group("bee"):
|
||||
area.die()
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
extends State
|
||||
class_name SnailEating
|
||||
|
||||
@onready var snail = get_parent().get_parent() as Snail # I think this is bad but I dont care it works
|
||||
@onready var snail : Snail = get_parent().get_parent() as Snail # I think this is bad but I dont care it works
|
||||
|
||||
func enter(_msg := {}):
|
||||
func enter(_msg : Dictionary = {}) -> void:
|
||||
Log.pr("I am a snail...")
|
||||
snail.eating = true
|
||||
|
||||
func exit():
|
||||
func exit() -> void:
|
||||
snail.eating = false
|
||||
|
||||
func update(_delta : float):
|
||||
func update(_delta : float) -> void:
|
||||
pass
|
||||
|
||||
func physics_update(_delta : float) -> void:
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
extends State
|
||||
class_name SnailSleeping
|
||||
|
||||
@onready var snail = get_parent().get_parent() as Snail # I think this is bad but I dont care it works
|
||||
@onready var snail : Snail = get_parent().get_parent() as Snail # I think this is bad but I dont care it works
|
||||
|
||||
func enter(_msg := {}):
|
||||
func enter(_msg : Dictionary = {}) -> void:
|
||||
Log.pr("I am a snail asleep...")
|
||||
|
||||
func exit():
|
||||
func exit() -> void:
|
||||
pass
|
||||
|
||||
func update(_delta : float):
|
||||
func update(_delta : float) -> void:
|
||||
pass
|
||||
|
||||
func physics_update(_delta : float) -> void:
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
class_name Level extends Node
|
||||
|
||||
@onready var rules = get_node("RulesComponent") as RulesComponent
|
||||
@onready var bee_spawner = get_node("BeeSpawner") as BeeSpawner
|
||||
@onready var ui_controls = get_node("UiComponent") as UIComponent
|
||||
@onready var rules : RulesComponent = get_node("RulesComponent") as RulesComponent
|
||||
@onready var bee_spawner : BeeSpawner = get_node("BeeSpawner") as BeeSpawner
|
||||
@onready var ui_controls : UIComponent = get_node("UiComponent") as UIComponent
|
||||
|
||||
func _ready():
|
||||
func _ready() -> void:
|
||||
update_game_state()
|
||||
|
||||
func update_game_state():
|
||||
func update_game_state() -> void:
|
||||
GameState.required_nectar = rules.game_rules.nectar_required
|
||||
GameState.level_par = rules.game_rules.level_par
|
||||
GameState.level_number = rules.game_rules.level_number
|
||||
|
|
|
|||
|
|
@ -24,6 +24,11 @@ Str="*res://utility/utility_strings.gd"
|
|||
SceneMgr="*res://utility/global_scene_manager.gd"
|
||||
HighScoreMgr="*res://utility/high_scores.gd"
|
||||
|
||||
[debug]
|
||||
|
||||
gdscript/warnings/untyped_declaration=1
|
||||
gdscript/warnings/inferred_declaration=1
|
||||
|
||||
[display]
|
||||
|
||||
window/size/viewport_width=1280
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
extends Node2D
|
||||
class_name BeeSpawner
|
||||
|
||||
var bee = preload("res://entities/Bee.tscn")
|
||||
var bee : Resource = preload("res://entities/Bee.tscn")
|
||||
|
||||
@onready var beehive = get_node("../Beehive")
|
||||
@onready var bee_sound = get_node("BigBeeSound")
|
||||
@onready var small_bee_sound = get_node("BeeSound")
|
||||
@onready var beehive : Beehive = get_node("../Beehive")
|
||||
@onready var bee_sound : AudioStreamPlayer = get_node("BigBeeSound")
|
||||
@onready var small_bee_sound : AudioStreamPlayer = get_node("BeeSound")
|
||||
|
||||
var bee_count : int = 0
|
||||
var max_bees : int = 100
|
||||
|
|
@ -13,12 +13,12 @@ var spawn_interval : float = 0.5
|
|||
var spawn_timer : float = 0.0
|
||||
var bee_sound_timer : float = 0.0
|
||||
|
||||
func spawn_bee():
|
||||
var bee_instance = bee.instantiate()
|
||||
func spawn_bee() -> void:
|
||||
var bee_instance : Bee = bee.instantiate()
|
||||
add_child(bee_instance)
|
||||
bee_instance.position = beehive.global_position
|
||||
|
||||
func _process(delta):
|
||||
func _process(delta : float) -> void:
|
||||
spawn_timer += delta
|
||||
|
||||
if spawn_timer > spawn_interval and bee_count < max_bees and beehive.dancer_in_range:
|
||||
|
|
@ -30,7 +30,7 @@ func _process(delta):
|
|||
if bee_count > 0 and small_bee_sound.playing == false:
|
||||
small_bee_sound.play()
|
||||
|
||||
func _physics_process(delta):
|
||||
func _physics_process(delta : float) -> void:
|
||||
bee_sound_timer += delta
|
||||
if bee_sound_timer > 1.0 and bee_count > 0:
|
||||
bee_sound_timer = 0.0
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
extends Node2D
|
||||
class_name Dog
|
||||
|
||||
@onready var death_box = $DeathBox
|
||||
@onready var outline = $AreaHighlight
|
||||
@onready var death_box : Area2D = $DeathBox
|
||||
@onready var outline : Sprite2D = $AreaHighlight
|
||||
|
||||
var acquired_target : Bee = null
|
||||
var acquired_target : Node2D = null
|
||||
var target_timer : float = 0.0
|
||||
@export var distracted : bool = false
|
||||
var distracted_by : Node2D = null
|
||||
|
||||
func _ready():
|
||||
func _ready() -> void:
|
||||
death_box.connect("body_entered", Callable(self, "_on_body_entered"))
|
||||
death_box.connect("body_exited", Callable(self, "_on_body_exited"))
|
||||
|
||||
func _process(delta):
|
||||
func _process(delta : float) -> void:
|
||||
if acquired_target:
|
||||
target_timer += delta
|
||||
|
||||
|
|
@ -32,14 +32,14 @@ func _process(delta):
|
|||
# Look around
|
||||
rotation = lerp_angle(rotation, rotation + get_angle_to(distracted_by.global_position), 0.5)
|
||||
|
||||
func show_outline():
|
||||
func show_outline() -> void:
|
||||
outline.visible = true
|
||||
|
||||
func hide_outline():
|
||||
func hide_outline() -> void:
|
||||
outline.visible = false
|
||||
|
||||
|
||||
func _on_body_entered(area):
|
||||
func _on_body_entered(area : Node2D) -> void:
|
||||
if area.is_in_group("bee") and distracted == false:
|
||||
if !acquired_target:
|
||||
Log.pr("Acquired target")
|
||||
|
|
@ -52,7 +52,7 @@ func _on_body_entered(area):
|
|||
distracted = true
|
||||
distracted_by = area
|
||||
|
||||
func _on_body_exited(area):
|
||||
func _on_body_exited(area : Node2D) -> void:
|
||||
if area == acquired_target:
|
||||
Log.pr("Lost target")
|
||||
acquired_target = null
|
||||
|
|
|
|||
|
|
@ -1,23 +1,23 @@
|
|||
extends HBoxContainer
|
||||
|
||||
@onready var buttons = get_children()
|
||||
@onready var buttons : Array[Node] = get_children()
|
||||
|
||||
func disable_buttons():
|
||||
func disable_buttons() -> void:
|
||||
## Disable all buttons
|
||||
for button in buttons:
|
||||
for button : Button in buttons:
|
||||
button.disabled = true
|
||||
|
||||
visible = false
|
||||
|
||||
func enable_buttons():
|
||||
func enable_buttons() -> void:
|
||||
## Enable all buttons
|
||||
for button in buttons:
|
||||
for button : Button in buttons:
|
||||
button.disabled = false
|
||||
|
||||
visible = true
|
||||
|
||||
func reset_button_focus():
|
||||
func reset_button_focus() -> void:
|
||||
## Reset focus on all buttons
|
||||
for button in buttons:
|
||||
for button : Button in buttons:
|
||||
button.release_focus()
|
||||
|
||||
|
|
@ -6,23 +6,23 @@ var spawning_type : String = ""
|
|||
|
||||
var director_drones : Array = [] # List of all director drones in the world
|
||||
|
||||
@onready var rules = get_parent().get_node("RulesComponent")
|
||||
@onready var beehive = get_parent().get_node("Beehive")
|
||||
@onready var flowers = get_parent().get_node("Flowers")
|
||||
@onready var dog = null
|
||||
@onready var drone_controls = %DroneControls
|
||||
@onready var ui_controls = get_parent().get_node("UiComponent")
|
||||
@onready var spawned_drones_container = get_node("SpawnedDrones")
|
||||
@onready var place_cursor = preload("res://resources/cursors/target_round_b.png")
|
||||
@onready var rules : RulesComponent = get_parent().get_node("RulesComponent") as RulesComponent
|
||||
@onready var beehive : Beehive = get_parent().get_node("Beehive")
|
||||
@onready var flowers : Flowers = get_parent().get_node("Flowers")
|
||||
@onready var dog : Dog = null
|
||||
@onready var drone_controls : HBoxContainer = %DroneControls
|
||||
@onready var ui_controls : UIComponent = get_parent().get_node("UiComponent")
|
||||
@onready var spawned_drones_container : Node = get_node("SpawnedDrones")
|
||||
@onready var place_cursor : Resource = preload("res://resources/cursors/target_round_b.png")
|
||||
|
||||
# Drones!
|
||||
@onready var director_drone = preload("res://entities/DirectorDrone.tscn")
|
||||
@onready var dancer_drone = preload("res://entities/DancerDrone.tscn")
|
||||
@onready var distractor_drone = preload("res://entities/DistractorDrone.tscn")
|
||||
@onready var collector_drone = preload("res://entities/CollectorDrone.tscn")
|
||||
@onready var director_drone : Resource = preload("res://entities/DirectorDrone.tscn")
|
||||
@onready var dancer_drone : Resource = preload("res://entities/DancerDrone.tscn")
|
||||
@onready var distractor_drone : Resource = preload("res://entities/DistractorDrone.tscn")
|
||||
@onready var collector_drone : Resource = preload("res://entities/CollectorDrone.tscn")
|
||||
|
||||
|
||||
func _ready():
|
||||
func _ready() -> void:
|
||||
if !rules.game_rules.collector_enabled:
|
||||
%SpawnCollector.visible = false
|
||||
if !rules.game_rules.dancer_enabled:
|
||||
|
|
@ -37,7 +37,7 @@ func _ready():
|
|||
dog = get_parent().get_node("Dog")
|
||||
|
||||
## Function to detect right click event
|
||||
func _input(event) -> void:
|
||||
func _input(event : InputEvent) -> void:
|
||||
if spawning_drone:
|
||||
if (event is InputEventMouseButton && event.button_index == MOUSE_BUTTON_RIGHT && event.pressed):
|
||||
Log.pr("Cancelling placement of drone")
|
||||
|
|
@ -49,7 +49,7 @@ func _input(event) -> void:
|
|||
func spawn_drone(drone_type : String) -> void:
|
||||
Log.pr("This function will put a " + drone_type + " drone in the world")
|
||||
|
||||
var new_drone = null
|
||||
var new_drone : Node = null
|
||||
# Create a new instance of the drone
|
||||
if drone_type == "director":
|
||||
new_drone = director_drone.instantiate()
|
||||
|
|
@ -119,22 +119,22 @@ func _on_spawn_dancer_pressed() -> void:
|
|||
ui_controls.show_help_text("Help_Drone_Placement_Dancer")
|
||||
place_drone("dancer")
|
||||
|
||||
func _on_spawn_director_mouse_entered():
|
||||
func _on_spawn_director_mouse_entered() -> void:
|
||||
reset_node_highlights()
|
||||
ui_controls.show_help_text("Help_Drone_Placement_Director")
|
||||
|
||||
func _on_spawn_collector_mouse_entered():
|
||||
func _on_spawn_collector_mouse_entered() -> void:
|
||||
reset_node_highlights()
|
||||
flowers.show_outline()
|
||||
ui_controls.show_help_text("Help_Drone_Placement_Collector")
|
||||
|
||||
func _on_spawn_distractor_mouse_entered():
|
||||
func _on_spawn_distractor_mouse_entered() -> void:
|
||||
reset_node_highlights()
|
||||
if dog:
|
||||
dog.show_outline()
|
||||
ui_controls.show_help_text("Help_Drone_Placement_Distractor")
|
||||
|
||||
func _on_spawn_dancer_mouse_entered():
|
||||
func _on_spawn_dancer_mouse_entered() -> void:
|
||||
reset_node_highlights()
|
||||
beehive.show_outline()
|
||||
ui_controls.show_help_text("Help_Drone_Placement_Dancer")
|
||||
|
|
@ -147,10 +147,10 @@ func _on_button_mouse_exited() -> void:
|
|||
# reset_node_highlights.call_deferred()
|
||||
pass
|
||||
|
||||
func update_director_drone_list():
|
||||
func update_director_drone_list() -> void:
|
||||
director_drones.clear()
|
||||
var x = 1
|
||||
for drone in spawned_drones_container.get_children():
|
||||
var x : int = 1
|
||||
for drone : Node in spawned_drones_container.get_children():
|
||||
if drone is DirectorDrone:
|
||||
drone.visit_order = x
|
||||
director_drones.append(drone)
|
||||
|
|
@ -159,32 +159,32 @@ func update_director_drone_list():
|
|||
Log.pr(director_drones.size())
|
||||
|
||||
func get_director(drone_number : int) -> DirectorDrone:
|
||||
for drone in director_drones:
|
||||
for drone : Node in director_drones:
|
||||
if drone.visit_order == drone_number:
|
||||
return drone
|
||||
return null
|
||||
|
||||
func get_next_director(current_director_number : int) -> DirectorDrone:
|
||||
for drone in director_drones:
|
||||
for drone : Node in director_drones:
|
||||
if drone.visit_order == current_director_number + 1:
|
||||
return drone
|
||||
return null
|
||||
|
||||
func get_previous_director(current_director_number : int) -> DirectorDrone:
|
||||
for drone in director_drones:
|
||||
for drone : Node in director_drones:
|
||||
if drone.visit_order == current_director_number - 1:
|
||||
return drone
|
||||
return null
|
||||
|
||||
## For now this just returns the first collector drone it finds
|
||||
## This will need to be updated to return the closest collector drone potentially?
|
||||
func get_collector():
|
||||
for drone in spawned_drones_container.get_children():
|
||||
func get_collector() -> CollectorDrone:
|
||||
for drone : Node in spawned_drones_container.get_children():
|
||||
if drone is CollectorDrone:
|
||||
return drone
|
||||
return null
|
||||
|
||||
func reset_node_highlights():
|
||||
func reset_node_highlights() -> void:
|
||||
ui_controls.hide_help_text()
|
||||
beehive.hide_outline()
|
||||
flowers.hide_outline()
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
extends Level
|
||||
class_name HighScoresScreen
|
||||
|
||||
func _ready():
|
||||
func _ready() -> void:
|
||||
update_game_state()
|
||||
%BeeDeathLabel.text = Str.format_number(HighScoreMgr.loaded_data.total_bees_killed)
|
||||
%HoneyCountLabel.text = Str.format_number(HighScoreMgr.loaded_data.total_honey_collected)
|
||||
|
|
@ -15,5 +15,5 @@ func _ready():
|
|||
|
||||
%MainMenuButton.connect("pressed", Callable(self, "on_main_menu_button_pressed"))
|
||||
|
||||
func on_main_menu_button_pressed():
|
||||
func on_main_menu_button_pressed() -> void:
|
||||
SceneMgr.load_scene("MAINMENU")
|
||||
|
|
@ -1,18 +1,18 @@
|
|||
extends Level
|
||||
class_name MainMenu
|
||||
|
||||
@onready var level_select = get_node("%MenuButton")
|
||||
@onready var high_scores = get_node("%HighScores")
|
||||
@onready var exit_button = get_node("%ExitGame")
|
||||
@onready var level_select : MenuButton = get_node("%MenuButton")
|
||||
@onready var high_scores : Button = get_node("%HighScores")
|
||||
@onready var exit_button : Button = get_node("%ExitGame")
|
||||
|
||||
func _ready():
|
||||
func _ready() -> void:
|
||||
level_select.get_popup().id_pressed.connect(_on_item_menu_pressed)
|
||||
high_scores.connect("pressed", Callable(self, "on_high_scores_pressed"))
|
||||
exit_button.connect("pressed", Callable(self, "on_exit_pressed"))
|
||||
update_game_state()
|
||||
|
||||
|
||||
func _on_item_menu_pressed(id):
|
||||
func _on_item_menu_pressed(id : int) -> void:
|
||||
## Load the appropriate level based on the selection that has been made
|
||||
Log.pr(id)
|
||||
|
||||
|
|
@ -36,12 +36,12 @@ func _on_item_menu_pressed(id):
|
|||
# Load level 6
|
||||
SceneMgr.load_scene("LEVEL6")
|
||||
|
||||
func on_high_scores_pressed():
|
||||
func on_high_scores_pressed() -> void:
|
||||
## Load the high scores screen
|
||||
Log.pr("High scores button pressed")
|
||||
SceneMgr.load_scene("HIGHSCORES")
|
||||
pass
|
||||
|
||||
func on_exit_pressed():
|
||||
func on_exit_pressed() -> void:
|
||||
# Quit the game
|
||||
get_tree().quit()
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ const SCENES : Dictionary = {
|
|||
|
||||
var loading_scene_res : Resource = null
|
||||
|
||||
func _ready():
|
||||
func _ready() -> void:
|
||||
## LOAD GAME DATA
|
||||
HighScoreMgr.load()
|
||||
HighScoreMgr.debug_output()
|
||||
|
|
@ -25,7 +25,7 @@ func _ready():
|
|||
SceneMgr.connect("change_scene", Callable(self, "_on_change_scene"))
|
||||
$TransitionScene.connect("transitioned", Callable(self, "_on_transition_scene_transitioned"))
|
||||
|
||||
func _on_change_scene(scene_name):
|
||||
func _on_change_scene(scene_name : String) -> void:
|
||||
Log.pr("Going to load a scene.", scene_name)
|
||||
if SCENES.has(scene_name):
|
||||
GameState.reset()
|
||||
|
|
@ -35,6 +35,6 @@ func _on_change_scene(scene_name):
|
|||
else:
|
||||
loading_scene_res = null
|
||||
|
||||
func _on_transition_scene_transitioned():
|
||||
func _on_transition_scene_transitioned() -> void:
|
||||
$CurrentScene.get_child(0).queue_free()
|
||||
$CurrentScene.add_child(loading_scene_res.instantiate())
|
||||
|
|
|
|||
|
|
@ -2,14 +2,14 @@ extends CanvasLayer
|
|||
|
||||
signal transitioned
|
||||
|
||||
func _ready():
|
||||
func _ready() -> void:
|
||||
$AnimationPlayer.play("fade_to_normal")
|
||||
|
||||
func transition():
|
||||
func transition() -> void:
|
||||
$AnimationPlayer.play("fade_to_black")
|
||||
Log.pr("Fading to black")
|
||||
|
||||
func _on_animation_player_animation_finished(anim_name:StringName):
|
||||
func _on_animation_player_animation_finished(anim_name : StringName) -> void:
|
||||
if anim_name == "fade_to_black":
|
||||
Log.pr("Sending transitioned signal...")
|
||||
emit_signal("transitioned")
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
extends Control
|
||||
|
||||
@onready var main_menu_button = get_node("%MainMenu")
|
||||
@onready var main_menu_button : Button = get_node("%MainMenu")
|
||||
|
||||
func _ready():
|
||||
func _ready() -> void:
|
||||
visible = false
|
||||
main_menu_button.connect("pressed", Callable(self, "on_main_menu_pressed"))
|
||||
|
||||
func _process(_delta):
|
||||
func _process(_delta : float) -> void:
|
||||
if GameState.game_over == true:
|
||||
visible = true
|
||||
|
||||
func on_main_menu_pressed():
|
||||
func on_main_menu_pressed() -> void:
|
||||
GameState.reset()
|
||||
SceneMgr.load_scene("MAINMENU")
|
||||
|
|
@ -1,26 +1,26 @@
|
|||
extends Control
|
||||
|
||||
@onready var time_label = get_node("%TimeSpent")
|
||||
@onready var drones_label = get_node("%DronesUsed")
|
||||
@onready var points_label = get_node("%TotalPoints")
|
||||
@onready var time_label : Label = get_node("%TimeSpent")
|
||||
@onready var drones_label : Label = get_node("%DronesUsed")
|
||||
@onready var points_label : Label = get_node("%TotalPoints")
|
||||
|
||||
@onready var main_menu_button = get_node("%MainMenu")
|
||||
@onready var main_menu_button : Button = get_node("%MainMenu")
|
||||
|
||||
func _ready():
|
||||
func _ready() -> void:
|
||||
visible = false
|
||||
|
||||
main_menu_button.connect("pressed", Callable(self, "on_main_menu_pressed"))
|
||||
|
||||
func _process(_delta):
|
||||
func _process(_delta : float) -> void:
|
||||
if GameState.level_complete == true:
|
||||
update_points()
|
||||
visible = true
|
||||
|
||||
func update_points():
|
||||
func update_points() -> void:
|
||||
time_label.text = "Time Spent: " + Str.seconds_to_hms(GameState.level_timer)
|
||||
drones_label.text = "Drones Used: " + str(GameState.drones_used)
|
||||
points_label.text = "Total Points: " + Str.format_number(GameState.level_points)
|
||||
|
||||
func on_main_menu_pressed():
|
||||
func on_main_menu_pressed() -> void:
|
||||
GameState.reset()
|
||||
SceneMgr.load_scene("MAINMENU")
|
||||
|
|
@ -4,18 +4,18 @@ class_name UIComponent
|
|||
var update_interval : float = 1
|
||||
var last_update : float = 0
|
||||
|
||||
@onready var nectar_bar = get_node("%NectarBar")
|
||||
@onready var help_text_container = get_node("%HelpTextContainer")
|
||||
@onready var help_text_items = help_text_container.get_children()
|
||||
@onready var level_text_label = get_node("%LevelText")
|
||||
@onready var level_timer_label = get_node("%LevelTimer")
|
||||
@onready var par_text_label = get_node("%ParText")
|
||||
@onready var bee_counter = get_node("%BeeCounter")
|
||||
@onready var nectar_bar : ProgressBar = get_node("%NectarBar")
|
||||
@onready var help_text_container : VBoxContainer = get_node("%HelpTextContainer")
|
||||
@onready var help_text_items : Array[Node] = help_text_container.get_children()
|
||||
@onready var level_text_label : Label = get_node("%LevelText")
|
||||
@onready var level_timer_label : Label = get_node("%LevelTimer")
|
||||
@onready var par_text_label : Label = get_node("%ParText")
|
||||
@onready var bee_counter : Label = get_node("%BeeCounter")
|
||||
|
||||
|
||||
var disable_pause : bool = false
|
||||
|
||||
func _ready():
|
||||
func _ready() -> void:
|
||||
hide_help_text()
|
||||
update_ui()
|
||||
%PauseMenu.hide()
|
||||
|
|
@ -26,7 +26,7 @@ func _ready():
|
|||
|
||||
bee_counter.hide()
|
||||
|
||||
func _process(delta):
|
||||
func _process(delta : float) -> void:
|
||||
last_update += delta
|
||||
|
||||
disable_pause = false # This is a mega hacky way to stop the game instantly repausing after unpausing
|
||||
|
|
@ -47,39 +47,39 @@ func _unhandled_input(event : InputEvent) -> void:
|
|||
Log.pr("Game is not paused, so pausing it...")
|
||||
pause_game()
|
||||
|
||||
func update_ui():
|
||||
func update_ui() -> void:
|
||||
nectar_bar.value = GameState.gathered_nectar
|
||||
nectar_bar.max_value = GameState.required_nectar
|
||||
|
||||
bee_counter.text = "Bees: " + str(GameState.bees_available - GameState.dead_bees) + "/" + str(GameState.bees_available)
|
||||
bee_counter.show()
|
||||
|
||||
func hide_help_text():
|
||||
for item in help_text_items:
|
||||
func hide_help_text() -> void:
|
||||
for item : Node in help_text_items:
|
||||
item.hide()
|
||||
|
||||
func show_help_text(label: String):
|
||||
func show_help_text(label: String) -> void:
|
||||
hide_help_text()
|
||||
for item in help_text_items:
|
||||
for item : Node in help_text_items:
|
||||
if item.name == label:
|
||||
item.show()
|
||||
|
||||
func update_level_text(text: String):
|
||||
func update_level_text(text: String) -> void:
|
||||
level_text_label.text = text
|
||||
|
||||
func update_par_text(text: String):
|
||||
func update_par_text(text: String) -> void:
|
||||
par_text_label.text = text
|
||||
|
||||
func quit_game():
|
||||
func quit_game() -> void:
|
||||
get_tree().paused = false
|
||||
GameState.reset()
|
||||
SceneMgr.load_scene("MAINMENU")
|
||||
|
||||
func pause_game():
|
||||
func pause_game() -> void:
|
||||
get_tree().paused = true
|
||||
%PauseMenu.show()
|
||||
|
||||
func unpause_game():
|
||||
func unpause_game() -> void:
|
||||
Log.pr("Pause Menu: Close button pressed")
|
||||
disable_pause = true
|
||||
%PauseMenu.hide()
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
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 := preload("res://resources/cursors/pointer_a.png")
|
||||
@onready var default_cursor : Resource = preload("res://resources/cursors/pointer_a.png")
|
||||
|
||||
var placing_drone : bool = false
|
||||
|
||||
|
|
@ -59,13 +59,13 @@ var judge_level_par : int = 0 :
|
|||
get:
|
||||
## Return an amount of points based on the difference between the number of drones_used and the level_par
|
||||
## Using more drones than the par is bad and should result in less points
|
||||
var diff = drones_used - level_par
|
||||
var diff : int = drones_used - level_par
|
||||
if diff > 0:
|
||||
return -diff * 100
|
||||
else:
|
||||
return 0
|
||||
|
||||
func _process(delta) -> void:
|
||||
func _process(delta : float) -> void:
|
||||
if level_started and !level_complete and !game_over:
|
||||
level_timer += delta
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
class_name HighScores extends Node
|
||||
|
||||
@onready var loaded_data = SaveStateResource.new()
|
||||
@onready var loaded_data : SaveStateResource = SaveStateResource.new()
|
||||
|
||||
func save():
|
||||
func save() -> void:
|
||||
var save_data : SaveStateResource = SaveStateResource.new()
|
||||
|
||||
save_data.level_1_score = loaded_data.level_1_score
|
||||
|
|
@ -17,7 +17,7 @@ func save():
|
|||
|
||||
ResourceSaver.save(save_data, "user://savedata.tres")
|
||||
|
||||
func load():
|
||||
func load() -> void:
|
||||
var save_data : SaveStateResource = load("user://savedata.tres")
|
||||
|
||||
if save_data:
|
||||
|
|
@ -31,14 +31,14 @@ func load():
|
|||
loaded_data.total_bees_killed = save_data.total_bees_killed
|
||||
loaded_data.total_honey_collected = save_data.total_honey_collected
|
||||
|
||||
func add_honey(honey : int):
|
||||
func add_honey(honey : int) -> void:
|
||||
loaded_data.total_honey_collected += honey
|
||||
|
||||
func add_dead_bees(dead : int):
|
||||
func add_dead_bees(dead : int) -> void:
|
||||
loaded_data.total_bees_killed += dead
|
||||
|
||||
func update_highscore(level : int, points : int) -> void:
|
||||
var current_highscore = get_level_highscore(level)
|
||||
var current_highscore : int = get_level_highscore(level)
|
||||
|
||||
if points > current_highscore:
|
||||
match level:
|
||||
|
|
@ -56,11 +56,11 @@ func update_highscore(level : int, points : int) -> void:
|
|||
loaded_data.level_6_score = points
|
||||
pass
|
||||
|
||||
func debug_save_high_score():
|
||||
func debug_save_high_score() -> void:
|
||||
loaded_data.level_1_score = 3000
|
||||
save()
|
||||
|
||||
func debug_output():
|
||||
func debug_output() -> void:
|
||||
Log.pr("High Scores", loaded_data.level_1_score)
|
||||
|
||||
func get_level_highscore(level : int) -> int:
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
class_name StringUtilities extends Node
|
||||
|
||||
func seconds_to_hms(seconds: float) -> String:
|
||||
var ms = fmod(seconds, 1) * 100
|
||||
var s = fmod(seconds, 60)
|
||||
var m = fmod(seconds, 3600) / 60
|
||||
var ms : float = fmod(seconds, 1) * 100
|
||||
var s : float = fmod(seconds, 60)
|
||||
var m : float = fmod(seconds, 3600) / 60
|
||||
|
||||
var formatted : String = "%02d:%02d:%02d" % [m, s, ms]
|
||||
|
||||
|
|
@ -15,14 +15,14 @@ func seconds_to_hms(seconds: float) -> String:
|
|||
func format_number(number: int) -> String:
|
||||
# Handle negative numbers by adding the "minus" sign in advance, as we discard it
|
||||
# when looping over the number.
|
||||
var formatted_number := "-" if sign(number) == -1 else ""
|
||||
var index := 0
|
||||
var number_string := str(abs(number))
|
||||
var formatted_number : String = "-" if sign(number) == -1 else ""
|
||||
var index : int = 0
|
||||
var number_string : String = str(abs(number))
|
||||
|
||||
for digit in number_string:
|
||||
for digit : String in number_string:
|
||||
formatted_number += digit
|
||||
|
||||
var counter := number_string.length() - index
|
||||
var counter : int = number_string.length() - index
|
||||
|
||||
# Don't add a comma at the end of the number, but add a comma every 3 digits
|
||||
# (taking into account the number's length).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue