Add final progression to tiny sword, fixes and tweeks required
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
class_name AlchemyTower
|
||||
extends Node2D
|
||||
|
||||
const UNLOCK_GOAL_ID: StringName = &"gold_2M_food_200k_wood_200k"
|
||||
|
||||
## Emitted when production progress changes (0.0 to 1.0)
|
||||
signal production_progress_updated(progress: float)
|
||||
## Emitted when magic gold balance changes
|
||||
@@ -16,6 +18,8 @@ signal production_completed(amount: BigNumber)
|
||||
## Reference to game state
|
||||
@onready var game_state: LevelGameState = find_parent("LevelGameState")
|
||||
@onready var _alchemy_currencies_panel: AlchemyCurrenciesPanel = $AlchemyCurrenciesPanel
|
||||
@onready var _sprite: Sprite2D = $Sprite2D
|
||||
@onready var _area: Area2D = $Area2D
|
||||
|
||||
## Current production state
|
||||
var production_time_elapsed: float = 0.0
|
||||
@@ -36,17 +40,23 @@ func _ready() -> void:
|
||||
# Initialize production time
|
||||
current_production_time = data.base_production_time_seconds
|
||||
|
||||
# Register this tower as an available generator
|
||||
game_state.set_generator_available(get_generator_id(), true)
|
||||
# Hide tower until unlock goal is completed
|
||||
_sprite.visible = false
|
||||
_area.monitoring = false
|
||||
|
||||
# Connect to magic gold balance changes
|
||||
game_state.currency_changed.connect(_on_currency_changed)
|
||||
game_state.goal_completed.connect(_on_goal_completed)
|
||||
|
||||
# Connect panel signals if available
|
||||
if alchemy_panel:
|
||||
alchemy_panel.craft_requested.connect(_on_craft_requested)
|
||||
alchemy_panel.alchemy_workers_changed.connect(_on_alchemy_workers_changed)
|
||||
|
||||
# If goal was already completed in a previous session, unlock immediately
|
||||
if game_state.is_goal_completed(UNLOCK_GOAL_ID):
|
||||
_unlock_tower()
|
||||
|
||||
# Initial progress update
|
||||
production_progress_updated.emit(0.0)
|
||||
|
||||
@@ -200,3 +210,15 @@ func _on_area_2d_mouse_entered() -> void:
|
||||
|
||||
func _on_area_2d_mouse_exited() -> void:
|
||||
_alchemy_currencies_panel.visible = false
|
||||
|
||||
|
||||
func _on_goal_completed(goal_id: StringName) -> void:
|
||||
if goal_id == UNLOCK_GOAL_ID:
|
||||
_unlock_tower()
|
||||
|
||||
|
||||
func _unlock_tower() -> void:
|
||||
_sprite.visible = true
|
||||
_area.monitoring = true
|
||||
game_state.set_generator_available(get_generator_id(), true)
|
||||
game_state.register_generator(get_generator_id(), true, true, 1)
|
||||
|
||||
@@ -26,10 +26,10 @@ shape = SubResource("RectangleShape2D_8pntr")
|
||||
|
||||
[node name="AlchemyCurrenciesPanel" parent="." unique_id=731368154 instance=ExtResource("2_8pntr")]
|
||||
visible = false
|
||||
offset_left = 65.0
|
||||
offset_top = -75.0
|
||||
offset_right = 65.0
|
||||
offset_bottom = -75.0
|
||||
offset_left = 44.0
|
||||
offset_top = -81.0
|
||||
offset_right = 444.0
|
||||
offset_bottom = 219.0
|
||||
currency = ExtResource("7_b8p5n")
|
||||
craft_recipes = ExtResource("5_recipes")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user