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")
|
||||
|
||||
|
||||
BIN
docs/gyms/tiny_sword/buildings/barracks/Barracks.png
Normal file
BIN
docs/gyms/tiny_sword/buildings/barracks/Barracks.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.7 KiB |
40
docs/gyms/tiny_sword/buildings/barracks/Barracks.png.import
Normal file
40
docs/gyms/tiny_sword/buildings/barracks/Barracks.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cx11iodvbcfb1"
|
||||
path="res://.godot/imported/Barracks.png-6c10bd8efd919b8eb03e40d568e18cf1.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://docs/gyms/tiny_sword/buildings/barracks/Barracks.png"
|
||||
dest_files=["res://.godot/imported/Barracks.png-6c10bd8efd919b8eb03e40d568e18cf1.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
25
docs/gyms/tiny_sword/buildings/barracks/barracks.gd
Normal file
25
docs/gyms/tiny_sword/buildings/barracks/barracks.gd
Normal file
@@ -0,0 +1,25 @@
|
||||
extends Node2D
|
||||
|
||||
const UNLOCK_GOAL_ID: StringName = &"gold_50M_food_5M_wood_5M"
|
||||
|
||||
@onready var _sprite: Sprite2D = $Sprite2D
|
||||
@onready var _area: Area2D = $Area2D
|
||||
@onready var _game_state: LevelGameState = find_parent("LevelGameState")
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_sprite.visible = false
|
||||
_area.monitoring = false
|
||||
_game_state.goal_completed.connect(_on_goal_completed)
|
||||
if _game_state.is_goal_completed(UNLOCK_GOAL_ID):
|
||||
_unlock()
|
||||
|
||||
|
||||
func _on_goal_completed(goal_id: StringName) -> void:
|
||||
if goal_id == UNLOCK_GOAL_ID:
|
||||
_unlock()
|
||||
|
||||
|
||||
func _unlock() -> void:
|
||||
_sprite.visible = true
|
||||
_area.monitoring = true
|
||||
1
docs/gyms/tiny_sword/buildings/barracks/barracks.gd.uid
Normal file
1
docs/gyms/tiny_sword/buildings/barracks/barracks.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://xk7d3maod6uc
|
||||
40
docs/gyms/tiny_sword/buildings/barracks/barracks.tscn
Normal file
40
docs/gyms/tiny_sword/buildings/barracks/barracks.tscn
Normal file
@@ -0,0 +1,40 @@
|
||||
[gd_scene format=3 uid="uid://cyvijgwj6l8vg"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://jeoiinukrrsp" path="res://core/generator/currency_generator.tscn" id="1_gen"]
|
||||
[ext_resource type="Script" uid="uid://xk7d3maod6uc" path="res://docs/gyms/tiny_sword/buildings/barracks/barracks.gd" id="1_script"]
|
||||
[ext_resource type="Resource" path="res://docs/gyms/tiny_sword/currencies/unit.tres" id="2_unit"]
|
||||
[ext_resource type="Resource" path="res://docs/gyms/tiny_sword/buildings/barracks/barracks_generator.tres" id="3_data"]
|
||||
[ext_resource type="Texture2D" uid="uid://cx11iodvbcfb1" path="res://docs/gyms/tiny_sword/buildings/barracks/Barracks.png" id="4_ud3ae"]
|
||||
[ext_resource type="PackedScene" uid="uid://ckos7f22pnmyh" path="res://core/generator/generator_container.tscn" id="5_panel"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_barracks"]
|
||||
size = Vector2(160, 175)
|
||||
|
||||
[node name="Barracks" type="Node2D" unique_id=1061432510]
|
||||
script = ExtResource("1_script")
|
||||
|
||||
[node name="CurrencyGenerator" parent="." unique_id=427948318 node_paths=PackedStringArray("info_generator_container") instance=ExtResource("1_gen")]
|
||||
currency = ExtResource("2_unit")
|
||||
data = ExtResource("3_data")
|
||||
press_buys_generator = false
|
||||
info_generator_container = NodePath("../GeneratorContainer")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=1503773416]
|
||||
texture = ExtResource("4_ud3ae")
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="." unique_id=1808028142]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D" unique_id=614030143]
|
||||
position = Vector2(1, 19.5)
|
||||
shape = SubResource("RectangleShape2D_barracks")
|
||||
|
||||
[node name="GeneratorContainer" parent="." unique_id=1905754561 node_paths=PackedStringArray("_generator") instance=ExtResource("5_panel")]
|
||||
visible = false
|
||||
offset_left = 138.0
|
||||
offset_top = -100.0
|
||||
offset_right = 402.0
|
||||
offset_bottom = 110.0
|
||||
_generator = NodePath("../CurrencyGenerator")
|
||||
|
||||
[connection signal="mouse_entered" from="Area2D" to="CurrencyGenerator" method="_on_area_2d_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Area2D" to="CurrencyGenerator" method="_on_area_2d_mouse_exited"]
|
||||
@@ -0,0 +1,18 @@
|
||||
[gd_resource type="Resource" script_class="CurrencyGeneratorData" format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://core/generator/currency_generator_data.gd" id="1_data"]
|
||||
[ext_resource type="Resource" path="res://docs/gyms/tiny_sword/currencies/worker.tres" id="2_worker"]
|
||||
[ext_resource type="Resource" path="res://docs/gyms/tiny_sword/goals/gold_50M_food_5M_wood_5M_goal.tres" id="3_goal"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_data")
|
||||
id = &"barracks"
|
||||
name = "Barracks"
|
||||
starts_unlocked = false
|
||||
starts_available = false
|
||||
initial_owned = 1
|
||||
purchase_currency = ExtResource("2_worker")
|
||||
unlock_goal = ExtResource("3_goal")
|
||||
initial_cost = 1.0
|
||||
coefficient = 1.0
|
||||
initial_productivity = 1.0
|
||||
@@ -1,20 +1,26 @@
|
||||
extends Node2D
|
||||
|
||||
const PRESTIGE_GOAL_ID: StringName = &"gold_350k_wood_20k"
|
||||
|
||||
@onready var _prestige_panel: PrestigePanel = $PrestigePanel
|
||||
@onready var game_state: LevelGameState = find_parent("LevelGameState")
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
if game_state:
|
||||
game_state.goal_completed.connect(_on_goal_completed)
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
func _on_area_2d_mouse_entered() -> void:
|
||||
## TODO: remove this comment to enable prestige panel
|
||||
#_prestige_panel.visible = true
|
||||
pass
|
||||
if game_state and game_state.is_goal_completed(PRESTIGE_GOAL_ID):
|
||||
_prestige_panel.visible = true
|
||||
|
||||
|
||||
func _on_area_2d_mouse_exited() -> void:
|
||||
_prestige_panel.visible = false
|
||||
|
||||
|
||||
func _on_goal_completed(goal_id: StringName) -> void:
|
||||
if goal_id == PRESTIGE_GOAL_ID:
|
||||
# Prestige is now unlocked — panel will show on next hover.
|
||||
pass
|
||||
|
||||
BIN
docs/gyms/tiny_sword/buildings/devil_idol/Castle.png
Normal file
BIN
docs/gyms/tiny_sword/buildings/devil_idol/Castle.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
40
docs/gyms/tiny_sword/buildings/devil_idol/Castle.png.import
Normal file
40
docs/gyms/tiny_sword/buildings/devil_idol/Castle.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://rpedoq4102to"
|
||||
path="res://.godot/imported/Castle.png-abe84e074a7668619903091d591ffce7.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://docs/gyms/tiny_sword/buildings/devil_idol/Castle.png"
|
||||
dest_files=["res://.godot/imported/Castle.png-abe84e074a7668619903091d591ffce7.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
135
docs/gyms/tiny_sword/buildings/devil_idol/devil_idol.gd
Normal file
135
docs/gyms/tiny_sword/buildings/devil_idol/devil_idol.gd
Normal file
@@ -0,0 +1,135 @@
|
||||
class_name DevilIdol
|
||||
extends Node2D
|
||||
|
||||
const UNLOCK_GOAL_ID: StringName = &"gold_50M_food_5M_wood_5M"
|
||||
const SAVE_KEY: String = "devil_idol_state"
|
||||
const HP_KEY: String = "current_hp"
|
||||
|
||||
## Emitted when the idol takes damage.
|
||||
signal idol_damaged(current_hp: BigNumber, max_hp: BigNumber)
|
||||
## Emitted when the idol is destroyed (one-time win condition).
|
||||
signal idol_destroyed()
|
||||
|
||||
## Maximum HP mantissa.
|
||||
@export var max_hp_mantissa: float = 1.0
|
||||
## Maximum HP exponent (default 1e12 = 1 trillion).
|
||||
@export var max_hp_exponent: int = 12
|
||||
|
||||
@onready var game_state: LevelGameState = find_parent("LevelGameState")
|
||||
@onready var _sprite: Sprite2D = $Sprite2D
|
||||
@onready var _area: Area2D = $Area2D
|
||||
@onready var _panel: PanelContainer = $IdolPanel
|
||||
@onready var _hp_value: Label = $IdolPanel/MarginContainer/VBoxContainer/HPValue
|
||||
@onready var _damage_button: Button = $IdolPanel/MarginContainer/VBoxContainer/DamageButton
|
||||
@onready var _victory_label: Label = $IdolPanel/MarginContainer/VBoxContainer/VictoryLabel
|
||||
|
||||
var _max_hp: BigNumber
|
||||
var _current_hp: BigNumber
|
||||
var _is_targetable: bool = false
|
||||
var _is_destroyed: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
assert(game_state != null, "DevilIdol: LevelGameState parent not found")
|
||||
|
||||
_max_hp = BigNumber.new(max_hp_mantissa, max_hp_exponent)
|
||||
_current_hp = BigNumber.new(max_hp_mantissa, max_hp_exponent)
|
||||
|
||||
# Load persisted HP from save data
|
||||
_load_state()
|
||||
|
||||
# Panel hidden by default; shown on hover if unlocked
|
||||
_panel.visible = false
|
||||
_victory_label.visible = false
|
||||
_damage_button.pressed.connect(_on_damage_button_pressed)
|
||||
|
||||
# Connect to goal completion for unlocking
|
||||
game_state.goal_completed.connect(_on_goal_completed)
|
||||
|
||||
# If goal was already completed in a previous session, unlock immediately
|
||||
if game_state.is_goal_completed(UNLOCK_GOAL_ID):
|
||||
_unlock_idol()
|
||||
|
||||
_update_ui()
|
||||
|
||||
|
||||
func _on_area_2d_mouse_entered() -> void:
|
||||
if _is_targetable and not _is_destroyed:
|
||||
_panel.visible = true
|
||||
|
||||
|
||||
func _on_area_2d_mouse_exited() -> void:
|
||||
_panel.visible = false
|
||||
|
||||
|
||||
func _on_goal_completed(goal_id: StringName) -> void:
|
||||
if goal_id == UNLOCK_GOAL_ID:
|
||||
_unlock_idol()
|
||||
|
||||
|
||||
func _unlock_idol() -> void:
|
||||
_is_targetable = true
|
||||
|
||||
|
||||
func _on_damage_button_pressed() -> void:
|
||||
if _is_destroyed:
|
||||
return
|
||||
|
||||
var unit_balance: BigNumber = game_state.get_currency_amount_by_id(&"unit")
|
||||
if unit_balance.mantissa <= 0.0:
|
||||
return
|
||||
|
||||
# Spend all available units as damage
|
||||
var damage: BigNumber = BigNumber.new(unit_balance.mantissa, unit_balance.exponent)
|
||||
if game_state.spend_currency_by_id(&"unit", damage):
|
||||
_current_hp = _current_hp.subtract(damage)
|
||||
if _current_hp.mantissa <= 0.0:
|
||||
_current_hp = BigNumber.new(0.0, 0)
|
||||
_is_destroyed = true
|
||||
idol_destroyed.emit()
|
||||
_victory_label.visible = true
|
||||
_panel.visible = true
|
||||
|
||||
idol_damaged.emit(_current_hp, _max_hp)
|
||||
_save_state()
|
||||
_update_ui()
|
||||
|
||||
|
||||
func _update_ui() -> void:
|
||||
if _is_destroyed:
|
||||
_hp_value.text = "0 / %s — DESTROYED" % _max_hp.to_string_suffix(2)
|
||||
_damage_button.disabled = true
|
||||
_damage_button.text = "VICTORY!"
|
||||
return
|
||||
|
||||
var progress_pct: float = 0.0
|
||||
if _max_hp.mantissa > 0.0:
|
||||
progress_pct = (1.0 - (_current_hp.mantissa / _max_hp.mantissa)) * pow(10.0, float(_current_hp.exponent - _max_hp.exponent))
|
||||
progress_pct = clampf(progress_pct * 100.0, 0.0, 100.0)
|
||||
|
||||
_hp_value.text = "%s / %s (%.1f%%)" % [_current_hp.to_string_suffix(2), _max_hp.to_string_suffix(2), progress_pct]
|
||||
|
||||
var unit_balance: BigNumber = game_state.get_currency_amount_by_id(&"unit")
|
||||
_damage_button.text = "Send Army (%s units)" % unit_balance.to_string_suffix(2)
|
||||
_damage_button.disabled = unit_balance.mantissa <= 0.0
|
||||
|
||||
|
||||
func _save_state() -> void:
|
||||
if game_state == null:
|
||||
return
|
||||
var payload: Dictionary = {HP_KEY: _current_hp.serialize()}
|
||||
game_state.set_external_save_data(SAVE_KEY, payload)
|
||||
|
||||
|
||||
func _load_state() -> void:
|
||||
if game_state == null:
|
||||
return
|
||||
var saved: Dictionary = game_state.get_external_save_data(SAVE_KEY)
|
||||
if saved.has(HP_KEY):
|
||||
var raw_hp: Variant = saved.get(HP_KEY)
|
||||
if raw_hp is Dictionary:
|
||||
_current_hp = BigNumber.deserialize(raw_hp)
|
||||
if _current_hp.mantissa <= 0.0:
|
||||
_current_hp = BigNumber.new(0.0, 0)
|
||||
_is_destroyed = true
|
||||
_victory_label.visible = true
|
||||
@@ -0,0 +1 @@
|
||||
uid://blfof77kjp7x0
|
||||
57
docs/gyms/tiny_sword/buildings/devil_idol/devil_idol.tscn
Normal file
57
docs/gyms/tiny_sword/buildings/devil_idol/devil_idol.tscn
Normal file
@@ -0,0 +1,57 @@
|
||||
[gd_scene format=3 uid="uid://d1cvlnd5vwjol"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://blfof77kjp7x0" path="res://docs/gyms/tiny_sword/buildings/devil_idol/devil_idol.gd" id="1_script"]
|
||||
[ext_resource type="Texture2D" uid="uid://rpedoq4102to" path="res://docs/gyms/tiny_sword/buildings/devil_idol/Castle.png" id="2_g7pcm"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_idol"]
|
||||
size = Vector2(312, 198)
|
||||
|
||||
[node name="DevilIdol" type="Node2D" unique_id=797117647]
|
||||
script = ExtResource("1_script")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=661703335]
|
||||
texture = ExtResource("2_g7pcm")
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="." unique_id=1812195052]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D" unique_id=1492517397]
|
||||
position = Vector2(1, 22)
|
||||
shape = SubResource("RectangleShape2D_idol")
|
||||
|
||||
[node name="IdolPanel" type="PanelContainer" parent="." unique_id=906038530]
|
||||
offset_left = -200.0
|
||||
offset_top = -120.0
|
||||
offset_right = 200.0
|
||||
offset_bottom = -10.0
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="IdolPanel" unique_id=1952977282]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 10
|
||||
theme_override_constants/margin_top = 10
|
||||
theme_override_constants/margin_right = 10
|
||||
theme_override_constants/margin_bottom = 10
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="IdolPanel/MarginContainer" unique_id=1214756176]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 8
|
||||
|
||||
[node name="TitleLabel" type="Label" parent="IdolPanel/MarginContainer/VBoxContainer" unique_id=1268978638]
|
||||
layout_mode = 2
|
||||
text = "Devil Idol"
|
||||
|
||||
[node name="HPValue" type="Label" parent="IdolPanel/MarginContainer/VBoxContainer" unique_id=529436307]
|
||||
layout_mode = 2
|
||||
text = "??? / ???"
|
||||
|
||||
[node name="DamageButton" type="Button" parent="IdolPanel/MarginContainer/VBoxContainer" unique_id=1565608485]
|
||||
layout_mode = 2
|
||||
disabled = true
|
||||
text = "Send Army"
|
||||
|
||||
[node name="VictoryLabel" type="Label" parent="IdolPanel/MarginContainer/VBoxContainer" unique_id=169309796]
|
||||
layout_mode = 2
|
||||
text = "THE DEVIL IDOL HAS BEEN DESTROYED!"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[connection signal="mouse_entered" from="Area2D" to="." method="_on_area_2d_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Area2D" to="." method="_on_area_2d_mouse_exited"]
|
||||
25
docs/gyms/tiny_sword/buildings/farm/farm.gd
Normal file
25
docs/gyms/tiny_sword/buildings/farm/farm.gd
Normal file
@@ -0,0 +1,25 @@
|
||||
extends Node2D
|
||||
|
||||
const UNLOCK_GOAL_ID: StringName = &"gold_total_1300"
|
||||
|
||||
@onready var _sprite: Sprite2D = $Sprite2D
|
||||
@onready var _area: Area2D = $Area2D
|
||||
@onready var _game_state: LevelGameState = find_parent("LevelGameState")
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_sprite.visible = false
|
||||
_area.monitoring = false
|
||||
_game_state.goal_completed.connect(_on_goal_completed)
|
||||
if _game_state.is_goal_completed(UNLOCK_GOAL_ID):
|
||||
_unlock()
|
||||
|
||||
|
||||
func _on_goal_completed(goal_id: StringName) -> void:
|
||||
if goal_id == UNLOCK_GOAL_ID:
|
||||
_unlock()
|
||||
|
||||
|
||||
func _unlock() -> void:
|
||||
_sprite.visible = true
|
||||
_area.monitoring = true
|
||||
1
docs/gyms/tiny_sword/buildings/farm/farm.gd.uid
Normal file
1
docs/gyms/tiny_sword/buildings/farm/farm.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dnsblnjy82goo
|
||||
@@ -1,6 +1,7 @@
|
||||
[gd_scene format=3 uid="uid://djedqovgngrx5"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://jeoiinukrrsp" path="res://core/generator/currency_generator.tscn" id="1_rvsna"]
|
||||
[ext_resource type="Script" path="res://docs/gyms/tiny_sword/buildings/farm/farm.gd" id="1_script"]
|
||||
[ext_resource type="Resource" uid="uid://bxg2au0ijp242" path="res://docs/gyms/tiny_sword/currencies/food.tres" id="2_djlc5"]
|
||||
[ext_resource type="Resource" uid="uid://d08h51y0pnsnf" path="res://docs/gyms/tiny_sword/buildings/farm/farm_generator.tres" id="3_82rmq"]
|
||||
[ext_resource type="Texture2D" uid="uid://dfdh8r03sj7qv" path="res://docs/gyms/tiny_sword/buildings/farm/House1.png" id="4_djlc5"]
|
||||
@@ -10,6 +11,7 @@
|
||||
size = Vector2(106, 157)
|
||||
|
||||
[node name="Farm" type="Node2D" unique_id=283335851]
|
||||
script = ExtResource("1_script")
|
||||
|
||||
[node name="CurrencyGenerator" parent="." unique_id=967969064 node_paths=PackedStringArray("info_generator_container") instance=ExtResource("1_rvsna")]
|
||||
currency = ExtResource("2_djlc5")
|
||||
|
||||
@@ -1,13 +1,35 @@
|
||||
extends Node2D
|
||||
|
||||
@onready var _generator_container: GeneratorPanel = $GeneratorContainer
|
||||
const UNLOCK_GOAL_ID: StringName = &"gold_total_13k"
|
||||
|
||||
@onready var _generator_container: GeneratorPanel = $GeneratorContainer
|
||||
@onready var _sprite: Sprite2D = $Sprite2D
|
||||
@onready var _area: Area2D = $Area2D
|
||||
@onready var _game_state: LevelGameState = find_parent("LevelGameState")
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
_generator_container.visible = false
|
||||
_sprite.visible = false
|
||||
_area.monitoring = false
|
||||
_game_state.goal_completed.connect(_on_goal_completed)
|
||||
if _game_state.is_goal_completed(UNLOCK_GOAL_ID):
|
||||
_unlock()
|
||||
|
||||
|
||||
func _on_area_2d_mouse_entered() -> void:
|
||||
_generator_container.visible = true
|
||||
|
||||
|
||||
func _on_area_2d_mouse_exited() -> void:
|
||||
_generator_container.visible = false
|
||||
|
||||
|
||||
func _on_goal_completed(goal_id: StringName) -> void:
|
||||
if goal_id == UNLOCK_GOAL_ID:
|
||||
_unlock()
|
||||
|
||||
|
||||
func _unlock() -> void:
|
||||
_sprite.visible = true
|
||||
_area.monitoring = true
|
||||
|
||||
@@ -1,14 +1,37 @@
|
||||
extends Node2D
|
||||
|
||||
@onready var _research_panel: ResearchPanel = $ResearchPanel
|
||||
const RESEARCH_GOAL_ID: StringName = &"gold_350k_wood_20k"
|
||||
|
||||
@onready var _research_panel: ResearchPanel = $ResearchPanel
|
||||
@onready var _sprite: Sprite2D = $Sprite2D
|
||||
@onready var _area: Area2D = $Area2D
|
||||
@onready var game_state: LevelGameState = find_parent("LevelGameState")
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
_research_panel.visible = false
|
||||
_sprite.visible = false
|
||||
_area.monitoring = false
|
||||
if game_state:
|
||||
game_state.goal_completed.connect(_on_goal_completed)
|
||||
if game_state.is_goal_completed(RESEARCH_GOAL_ID):
|
||||
_unlock()
|
||||
|
||||
|
||||
func _on_area_2d_mouse_entered() -> void:
|
||||
_research_panel.visible = true
|
||||
if game_state and game_state.is_goal_completed(RESEARCH_GOAL_ID):
|
||||
_research_panel.visible = true
|
||||
|
||||
|
||||
func _on_area_2d_mouse_exited() -> void:
|
||||
_research_panel.visible = false
|
||||
|
||||
|
||||
func _on_goal_completed(goal_id: StringName) -> void:
|
||||
if goal_id == RESEARCH_GOAL_ID:
|
||||
_unlock()
|
||||
|
||||
|
||||
func _unlock() -> void:
|
||||
_sprite.visible = true
|
||||
_area.monitoring = true
|
||||
|
||||
Reference in New Issue
Block a user