1
Fork 0
mirror of https://github.com/Steffo99/hella-farm.git synced 2024-11-25 01:24:23 +00:00
hella-farm/scenes/game/main_game.gd

52 lines
1.3 KiB
GDScript3
Raw Normal View History

2024-04-14 01:38:04 +00:00
extends Node2D
class_name MainGame
2024-05-01 04:26:30 +00:00
@export var default_spawn_parent: Node2D
@onready var camera: GameCamera = $"GameCamera"
@onready var inventory: Inventory = %"Inventory"
2024-04-24 02:55:31 +00:00
@onready var cursor: Cursor = %"Cursor"
2024-04-29 04:22:15 +00:00
@onready var music: Music = %"Music"
2024-04-19 02:30:35 +00:00
2024-05-02 23:57:06 +00:00
var time_elapsed: float = 0.0
var recipe_timings := {}
2024-04-19 02:30:35 +00:00
static func get_via_group(node: Node) -> MainGame:
var result = node.get_tree().get_nodes_in_group("game")
if result.is_empty():
return null
return result[0]
2024-04-24 02:55:31 +00:00
func _ready():
2024-04-24 02:56:44 +00:00
# Set up the gold display
2024-04-24 02:55:31 +00:00
var gold_counter = inventory.get_counter(&"Gold")
2024-04-26 00:15:39 +00:00
gold_counter.changed.connect(cursor.gold_display.change)
2024-04-24 02:56:44 +00:00
cursor.gold_display.set_text(gold_counter.value)
2024-04-29 04:22:15 +00:00
2024-05-02 23:57:06 +00:00
func _physics_process(delta: float) -> void:
time_elapsed += delta
2024-05-02 03:42:45 +00:00
func _on_recipe_matched(_m: SummoningRecipe.Match, recipe: SummoningRecipe) -> void:
2024-05-02 23:57:06 +00:00
var timing = recipe_timings.get(recipe.name)
if timing == null:
recipe_timings[recipe.name] = time_elapsed
Log.p(self, "Recipe %s first completed in: %f s" % [recipe.name, time_elapsed])
2024-04-29 04:22:15 +00:00
# Quick hack for now
match recipe.name:
"FiveSheep":
music.enable_layer_1()
music.do_sync()
"FiveImps":
music.enable_layer_2()
2024-05-02 03:42:45 +00:00
"ASkull":
music.enable_layer_2()
2024-04-29 04:22:15 +00:00
"FiveChupacabra":
music.enable_layer_3()
2024-05-02 03:42:45 +00:00
"FiveTopHats":
music.enable_layer_3()
"FiveMonocles":
music.enable_layer_3()