Add shop supplies and rebalance early economy
This commit is contained in:
parent
6386c5e3e3
commit
6a5923fdb8
41 changed files with 1159 additions and 52 deletions
|
|
@ -9,11 +9,18 @@ const FishInventoryType = preload("res://inventory/fish_inventory.gd")
|
|||
const FishSaleResultType = preload("res://economy/fish_sale_result.gd")
|
||||
const FishSaleServiceType = preload("res://economy/fish_sale_service.gd")
|
||||
const PlayerWalletType = preload("res://economy/player_wallet.gd")
|
||||
const FishingShopStockType = preload("res://economy/fishing_shop_stock.gd")
|
||||
const ItemCatalogType = preload("res://items/item_catalog.gd")
|
||||
const ItemDataType = preload("res://items/item_data.gd")
|
||||
const PlayerBagType = preload("res://inventory/player_bag.gd")
|
||||
const FishingSpotType = preload("res://fishing/fishing_spot.gd")
|
||||
const PlayerFishingUpgradesType = preload(
|
||||
"res://progression/player_fishing_upgrades.gd"
|
||||
)
|
||||
const PlayerType = preload("res://player/player.gd")
|
||||
const PlayerCoolerCapacityType = preload(
|
||||
"res://progression/player_cooler_capacity.gd"
|
||||
)
|
||||
const ShopInteractionType = preload(
|
||||
"res://world/fishing_shop_interaction.gd"
|
||||
)
|
||||
|
|
@ -30,6 +37,7 @@ enum CloseReason {
|
|||
|
||||
@onready var _wallet_label: Label = %WalletLabel
|
||||
@onready var _fish_list: ItemList = %FishList
|
||||
@onready var _sales_title: Label = %SalesTitle
|
||||
@onready var _fish_empty: Label = %FishEmpty
|
||||
@onready var _fish_texture: TextureRect = %FishTexture
|
||||
@onready var _fish_name: Label = %FishName
|
||||
|
|
@ -44,6 +52,11 @@ enum CloseReason {
|
|||
@onready var _barrier_effect: Label = %BarrierEffect
|
||||
@onready var _barrier_cost: Label = %BarrierCost
|
||||
@onready var _barrier_purchase: Button = %BarrierPurchase
|
||||
@onready var _supplies_list: VBoxContainer = %SuppliesList
|
||||
@onready var _cooler_level: Label = %CoolerLevel
|
||||
@onready var _cooler_effect: Label = %CoolerEffect
|
||||
@onready var _cooler_cost: Label = %CoolerCost
|
||||
@onready var _cooler_purchase: Button = %CoolerPurchase
|
||||
@onready var _confirmation: PanelContainer = %SaleConfirmation
|
||||
@onready var _confirmation_text: Label = %ConfirmationText
|
||||
@onready var _confirm_sale: Button = %ConfirmSale
|
||||
|
|
@ -57,6 +70,9 @@ var _buyer: FishBuyerProfileType
|
|||
var _upgrades: PlayerFishingUpgradesType
|
||||
var _fishing_spot: FishingSpotType
|
||||
var _interaction: ShopInteractionType
|
||||
var _bag: PlayerBagType
|
||||
var _item_catalog: ItemCatalogType
|
||||
var _cooler_capacity: PlayerCoolerCapacityType
|
||||
var _selected_catch_id: StringName
|
||||
var _confirmation_catch_id: StringName
|
||||
var _prior_movement_enabled: bool = true
|
||||
|
|
@ -77,6 +93,7 @@ func _ready() -> void:
|
|||
_cancel_sale.pressed.connect(_close_sale_confirmation)
|
||||
_reel_purchase.pressed.connect(_purchase_reel_speed)
|
||||
_barrier_purchase.pressed.connect(_purchase_barrier_power)
|
||||
_cooler_purchase.pressed.connect(_purchase_cooler_capacity)
|
||||
|
||||
|
||||
func setup(
|
||||
|
|
@ -88,6 +105,9 @@ func setup(
|
|||
upgrades: PlayerFishingUpgradesType,
|
||||
fishing_spot: FishingSpotType,
|
||||
interaction: ShopInteractionType,
|
||||
bag: PlayerBagType,
|
||||
item_catalog: ItemCatalogType,
|
||||
cooler_capacity: PlayerCoolerCapacityType,
|
||||
) -> void:
|
||||
_player = player
|
||||
_inventory = inventory
|
||||
|
|
@ -97,12 +117,21 @@ func setup(
|
|||
_upgrades = upgrades
|
||||
_fishing_spot = fishing_spot
|
||||
_interaction = interaction
|
||||
_bag = bag
|
||||
_item_catalog = item_catalog
|
||||
_cooler_capacity = cooler_capacity
|
||||
if not _inventory.catches_changed.is_connected(_on_inventory_changed):
|
||||
_inventory.catches_changed.connect(_on_inventory_changed)
|
||||
if not _wallet.balance_changed.is_connected(_on_wallet_changed):
|
||||
_wallet.balance_changed.connect(_on_wallet_changed)
|
||||
if not _upgrades.upgrades_changed.is_connected(_on_upgrades_changed):
|
||||
_upgrades.upgrades_changed.connect(_on_upgrades_changed)
|
||||
if not _bag.contents_changed.is_connected(_on_bag_changed):
|
||||
_bag.contents_changed.connect(_on_bag_changed)
|
||||
if not _cooler_capacity.capacity_changed.is_connected(
|
||||
_on_cooler_capacity_changed
|
||||
):
|
||||
_cooler_capacity.capacity_changed.connect(_on_cooler_capacity_changed)
|
||||
_refresh_all()
|
||||
|
||||
|
||||
|
|
@ -207,6 +236,8 @@ func _refresh_all() -> void:
|
|||
_refresh_fish_list()
|
||||
_refresh_selected_fish()
|
||||
_refresh_upgrades()
|
||||
_refresh_supplies()
|
||||
_refresh_cooler_capacity()
|
||||
|
||||
|
||||
func _refresh_wallet() -> void:
|
||||
|
|
@ -222,6 +253,10 @@ func _refresh_fish_list() -> void:
|
|||
var catches: Array[FishCatchType] = (
|
||||
_inventory.get_all_catches() if _inventory != null else []
|
||||
)
|
||||
_sales_title.text = "Cooler %d / %d • Full base value" % [
|
||||
catches.size(),
|
||||
_cooler_capacity.get_capacity() if _cooler_capacity != null else 0,
|
||||
]
|
||||
catches.sort_custom(
|
||||
func(a: FishCatchType, b: FishCatchType) -> bool:
|
||||
return a.catch_sequence > b.catch_sequence
|
||||
|
|
@ -335,6 +370,65 @@ func _refresh_upgrades() -> void:
|
|||
_barrier_purchase.text = "MAX" if barrier_cost < 0 else "Purchase"
|
||||
|
||||
|
||||
func _refresh_supplies() -> void:
|
||||
if _supplies_list == null:
|
||||
return
|
||||
for child: Node in _supplies_list.get_children():
|
||||
_supplies_list.remove_child(child)
|
||||
child.queue_free()
|
||||
for item_id: StringName in FishingShopStockType.get_stock_item_ids():
|
||||
var item: ItemDataType = _item_catalog.get_item_by_id(item_id)
|
||||
if item == null:
|
||||
continue
|
||||
var button := Button.new()
|
||||
button.custom_minimum_size = Vector2(195, 54)
|
||||
button.icon = item.icon
|
||||
button.expand_icon = true
|
||||
button.alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
button.text = "%s\n$%d • Owned %d" % [
|
||||
item.display_name,
|
||||
FishingShopStockType.get_price(item_id),
|
||||
_bag.get_quantity(item_id),
|
||||
]
|
||||
button.tooltip_text = item.description
|
||||
button.disabled = (
|
||||
_transaction_in_progress
|
||||
or _closing
|
||||
or not _bag.can_add_item(item_id, 1)
|
||||
or not _wallet.can_afford(
|
||||
FishingShopStockType.get_price(item_id)
|
||||
)
|
||||
)
|
||||
button.pressed.connect(_purchase_supply.bind(item_id))
|
||||
_supplies_list.add_child(button)
|
||||
|
||||
|
||||
func _refresh_cooler_capacity() -> void:
|
||||
if _cooler_capacity == null:
|
||||
return
|
||||
var level: int = _cooler_capacity.get_level()
|
||||
var cost: int = _cooler_capacity.get_next_cost()
|
||||
var next_capacity: int = _cooler_capacity.get_next_capacity()
|
||||
_cooler_level.text = "Level %d" % level
|
||||
_cooler_purchase.disabled = (
|
||||
cost < 0
|
||||
or _transaction_in_progress
|
||||
or _closing
|
||||
or not _cooler_capacity.can_purchase(_wallet)
|
||||
)
|
||||
if cost < 0:
|
||||
_cooler_effect.text = "%d fish" % _cooler_capacity.get_capacity()
|
||||
_cooler_cost.text = "MAX"
|
||||
_cooler_purchase.text = "MAX"
|
||||
else:
|
||||
_cooler_effect.text = "%d → %d fish" % [
|
||||
_cooler_capacity.get_capacity(),
|
||||
next_capacity,
|
||||
]
|
||||
_cooler_cost.text = "$%d" % cost
|
||||
_cooler_purchase.text = "Purchase"
|
||||
|
||||
|
||||
func _on_fish_selected(index: int) -> void:
|
||||
if index < 0 or index >= _fish_list.item_count:
|
||||
return
|
||||
|
|
@ -405,6 +499,59 @@ func _purchase_barrier_power() -> void:
|
|||
_purchase_upgrade(false)
|
||||
|
||||
|
||||
func _purchase_supply(item_id: StringName) -> void:
|
||||
if _transaction_in_progress or not _is_transaction_context_valid():
|
||||
_feedback.text = "Unable to complete purchase."
|
||||
return
|
||||
var price: int = FishingShopStockType.get_price(item_id)
|
||||
if not _bag.can_add_item(item_id, 1):
|
||||
_feedback.text = "Bag cannot accept this item."
|
||||
return
|
||||
if not _wallet.can_afford(price):
|
||||
_feedback.text = "Not enough money."
|
||||
return
|
||||
var transaction_generation: int = _generation
|
||||
_transaction_in_progress = true
|
||||
var purchased: bool = FishingShopStockType.purchase_one(
|
||||
item_id,
|
||||
_wallet,
|
||||
_bag,
|
||||
_item_catalog
|
||||
)
|
||||
_transaction_in_progress = false
|
||||
if transaction_generation != _generation or not visible:
|
||||
return
|
||||
_feedback.text = (
|
||||
"Item purchased." if purchased else "Unable to complete purchase."
|
||||
)
|
||||
_refresh_all()
|
||||
|
||||
|
||||
func _purchase_cooler_capacity() -> void:
|
||||
if _transaction_in_progress or not _is_transaction_context_valid():
|
||||
_feedback.text = "Unable to complete purchase."
|
||||
return
|
||||
var cost: int = _cooler_capacity.get_next_cost()
|
||||
if cost < 0:
|
||||
_feedback.text = "Maximum level reached."
|
||||
return
|
||||
if not _wallet.can_afford(cost):
|
||||
_feedback.text = "Not enough money."
|
||||
return
|
||||
var transaction_generation: int = _generation
|
||||
_transaction_in_progress = true
|
||||
var purchased: bool = _cooler_capacity.purchase(_wallet)
|
||||
_transaction_in_progress = false
|
||||
if transaction_generation != _generation or not visible:
|
||||
return
|
||||
_feedback.text = (
|
||||
"Upgrade purchased."
|
||||
if purchased
|
||||
else "Unable to complete purchase."
|
||||
)
|
||||
_refresh_all()
|
||||
|
||||
|
||||
func _purchase_upgrade(is_reel_speed: bool) -> void:
|
||||
if _transaction_in_progress or not _is_transaction_context_valid():
|
||||
_feedback.text = "Unable to complete purchase."
|
||||
|
|
@ -472,6 +619,8 @@ func _on_inventory_changed() -> void:
|
|||
func _on_wallet_changed(_balance: int, _delta: int) -> void:
|
||||
_refresh_wallet()
|
||||
_refresh_upgrades()
|
||||
_refresh_supplies()
|
||||
_refresh_cooler_capacity()
|
||||
|
||||
|
||||
func _on_upgrades_changed(
|
||||
|
|
@ -481,6 +630,15 @@ func _on_upgrades_changed(
|
|||
_refresh_upgrades()
|
||||
|
||||
|
||||
func _on_bag_changed() -> void:
|
||||
_refresh_supplies()
|
||||
|
||||
|
||||
func _on_cooler_capacity_changed(_level: int, _capacity: int) -> void:
|
||||
_refresh_cooler_capacity()
|
||||
_refresh_fish_list()
|
||||
|
||||
|
||||
func _apply_mouse_close_policy(reason: CloseReason) -> void:
|
||||
if not _mouse_snapshot_stored:
|
||||
return
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
[gd_scene load_steps=6 format=3]
|
||||
[gd_scene load_steps=7 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://ui/fishing_shop.gd" id="1_script"]
|
||||
[ext_resource type="Theme" path="res://ui/game_theme.tres" id="2_theme"]
|
||||
[ext_resource type="Texture2D" path="res://items/icons/placeholder/reel_speed_upgrade.svg" id="3_reel"]
|
||||
[ext_resource type="Texture2D" path="res://items/icons/placeholder/barrier_power_upgrade.svg" id="4_barrier"]
|
||||
[ext_resource type="Texture2D" path="res://items/icons/placeholder/fish_coin.svg" id="5_coin"]
|
||||
[ext_resource type="Texture2D" path="res://items/icons/placeholder/cooler_expansion.svg" id="6_cooler"]
|
||||
|
||||
[node name="FishingShop" type="Control"]
|
||||
unique_name_in_owner = true
|
||||
|
|
@ -37,10 +38,10 @@ anchor_left = 0.5
|
|||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -450.0
|
||||
offset_top = -260.0
|
||||
offset_right = 450.0
|
||||
offset_bottom = 260.0
|
||||
offset_left = -480.0
|
||||
offset_top = -310.0
|
||||
offset_right = 480.0
|
||||
offset_bottom = 310.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
|
|
@ -98,12 +99,13 @@ size_flags_vertical = 3
|
|||
theme_override_constants/separation = 12
|
||||
|
||||
[node name="FishSales" type="VBoxContainer" parent="ShopPanel/Margin/Layout/Body"]
|
||||
custom_minimum_size = Vector2(500, 0)
|
||||
custom_minimum_size = Vector2(420, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 6
|
||||
|
||||
[node name="SalesTitle" type="Label" parent="ShopPanel/Margin/Layout/Body/FishSales"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Sell individual Cooler fish • Full base value"
|
||||
theme_override_font_sizes/font_size = 17
|
||||
|
|
@ -111,11 +113,11 @@ theme_override_font_sizes/font_size = 17
|
|||
[node name="SalesBody" type="HSplitContainer" parent="ShopPanel/Margin/Layout/Body/FishSales"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
split_offset = 265
|
||||
split_offset = 220
|
||||
theme_override_constants/separation = 8
|
||||
|
||||
[node name="ListPanel" type="PanelContainer" parent="ShopPanel/Margin/Layout/Body/FishSales/SalesBody"]
|
||||
custom_minimum_size = Vector2(250, 0)
|
||||
custom_minimum_size = Vector2(205, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ListMargin" type="MarginContainer" parent="ShopPanel/Margin/Layout/Body/FishSales/SalesBody/ListPanel"]
|
||||
|
|
@ -143,7 +145,7 @@ icon_mode = 1
|
|||
same_column_width = true
|
||||
|
||||
[node name="FishDetail" type="PanelContainer" parent="ShopPanel/Margin/Layout/Body/FishSales/SalesBody"]
|
||||
custom_minimum_size = Vector2(220, 0)
|
||||
custom_minimum_size = Vector2(185, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="DetailMargin" type="MarginContainer" parent="ShopPanel/Margin/Layout/Body/FishSales/SalesBody/FishDetail"]
|
||||
|
|
@ -159,7 +161,7 @@ theme_override_constants/separation = 6
|
|||
|
||||
[node name="FishTexture" type="TextureRect" parent="ShopPanel/Margin/Layout/Body/FishSales/SalesBody/FishDetail/DetailMargin/DetailStack"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(190, 100)
|
||||
custom_minimum_size = Vector2(160, 90)
|
||||
layout_mode = 2
|
||||
expand_mode = 1
|
||||
stretch_mode = 5
|
||||
|
|
@ -186,7 +188,7 @@ disabled = true
|
|||
text = "Sell Selected"
|
||||
|
||||
[node name="Upgrades" type="VBoxContainer" parent="ShopPanel/Margin/Layout/Body"]
|
||||
custom_minimum_size = Vector2(310, 0)
|
||||
custom_minimum_size = Vector2(270, 0)
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 8
|
||||
|
||||
|
|
@ -195,6 +197,27 @@ layout_mode = 2
|
|||
text = "Fishing Upgrades"
|
||||
theme_override_font_sizes/font_size = 17
|
||||
|
||||
[node name="Supplies" type="VBoxContainer" parent="ShopPanel/Margin/Layout/Body"]
|
||||
custom_minimum_size = Vector2(210, 0)
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 6
|
||||
|
||||
[node name="Title" type="Label" parent="ShopPanel/Margin/Layout/Body/Supplies"]
|
||||
layout_mode = 2
|
||||
text = "Supplies"
|
||||
theme_override_font_sizes/font_size = 17
|
||||
|
||||
[node name="Scroll" type="ScrollContainer" parent="ShopPanel/Margin/Layout/Body/Supplies"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
horizontal_scroll_mode = 0
|
||||
|
||||
[node name="SuppliesList" type="VBoxContainer" parent="ShopPanel/Margin/Layout/Body/Supplies/Scroll"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 5
|
||||
|
||||
[node name="ReelCard" type="PanelContainer" parent="ShopPanel/Margin/Layout/Body/Upgrades"]
|
||||
layout_mode = 2
|
||||
|
||||
|
|
@ -210,7 +233,7 @@ layout_mode = 2
|
|||
theme_override_constants/separation = 9
|
||||
|
||||
[node name="Icon" type="TextureRect" parent="ShopPanel/Margin/Layout/Body/Upgrades/ReelCard/Margin/Row"]
|
||||
custom_minimum_size = Vector2(60, 60)
|
||||
custom_minimum_size = Vector2(48, 48)
|
||||
layout_mode = 2
|
||||
texture = ExtResource("3_reel")
|
||||
expand_mode = 1
|
||||
|
|
@ -261,7 +284,7 @@ layout_mode = 2
|
|||
theme_override_constants/separation = 9
|
||||
|
||||
[node name="Icon" type="TextureRect" parent="ShopPanel/Margin/Layout/Body/Upgrades/BarrierCard/Margin/Row"]
|
||||
custom_minimum_size = Vector2(60, 60)
|
||||
custom_minimum_size = Vector2(48, 48)
|
||||
layout_mode = 2
|
||||
texture = ExtResource("4_barrier")
|
||||
expand_mode = 1
|
||||
|
|
@ -297,6 +320,57 @@ unique_name_in_owner = true
|
|||
layout_mode = 2
|
||||
text = "Purchase"
|
||||
|
||||
[node name="CoolerCard" type="PanelContainer" parent="ShopPanel/Margin/Layout/Body/Upgrades"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Margin" type="MarginContainer" parent="ShopPanel/Margin/Layout/Body/Upgrades/CoolerCard"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 9
|
||||
theme_override_constants/margin_top = 9
|
||||
theme_override_constants/margin_right = 9
|
||||
theme_override_constants/margin_bottom = 9
|
||||
|
||||
[node name="Row" type="HBoxContainer" parent="ShopPanel/Margin/Layout/Body/Upgrades/CoolerCard/Margin"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 9
|
||||
|
||||
[node name="Icon" type="TextureRect" parent="ShopPanel/Margin/Layout/Body/Upgrades/CoolerCard/Margin/Row"]
|
||||
custom_minimum_size = Vector2(48, 48)
|
||||
layout_mode = 2
|
||||
texture = ExtResource("6_cooler")
|
||||
expand_mode = 1
|
||||
stretch_mode = 5
|
||||
texture_filter = 1
|
||||
|
||||
[node name="Data" type="VBoxContainer" parent="ShopPanel/Margin/Layout/Body/Upgrades/CoolerCard/Margin/Row"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Name" type="Label" parent="ShopPanel/Margin/Layout/Body/Upgrades/CoolerCard/Margin/Row/Data"]
|
||||
layout_mode = 2
|
||||
text = "Cooler Capacity"
|
||||
theme_override_font_sizes/font_size = 17
|
||||
|
||||
[node name="CoolerLevel" type="Label" parent="ShopPanel/Margin/Layout/Body/Upgrades/CoolerCard/Margin/Row/Data"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Level 0"
|
||||
|
||||
[node name="CoolerEffect" type="Label" parent="ShopPanel/Margin/Layout/Body/Upgrades/CoolerCard/Margin/Row/Data"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "12 → 18 fish"
|
||||
|
||||
[node name="CoolerCost" type="Label" parent="ShopPanel/Margin/Layout/Body/Upgrades/CoolerCard/Margin/Row/Data"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "$75"
|
||||
|
||||
[node name="CoolerPurchase" type="Button" parent="ShopPanel/Margin/Layout/Body/Upgrades/CoolerCard/Margin/Row"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Purchase"
|
||||
|
||||
[node name="SaleConfirmation" type="PanelContainer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
|
|
|
|||
|
|
@ -23,6 +23,12 @@ const PlayerFishingUpgradesType = preload(
|
|||
const ShopInteractionType = preload(
|
||||
"res://world/fishing_shop_interaction.gd"
|
||||
)
|
||||
const PlayerItemEffectsType = preload(
|
||||
"res://progression/player_item_effects.gd"
|
||||
)
|
||||
const PlayerCoolerCapacityType = preload(
|
||||
"res://progression/player_cooler_capacity.gd"
|
||||
)
|
||||
|
||||
@onready var _status_label: Label = %StatusLabel
|
||||
@onready var _catch_track: Control = %CatchTrack
|
||||
|
|
@ -40,6 +46,7 @@ const ShopInteractionType = preload(
|
|||
@onready var _hotbar_ui: HotbarUIType = %Hotbar
|
||||
@onready var _fishing_shop: FishingShopType = %FishingShop
|
||||
@onready var _shop_prompt: PanelContainer = %ShopPrompt
|
||||
@onready var _effect_status: Label = %EffectStatus
|
||||
|
||||
var _showcase_active: bool = false
|
||||
var _player_menu_open: bool = false
|
||||
|
|
@ -47,6 +54,7 @@ var _gameplay_ui_enabled: bool = false
|
|||
var _fishing_spot: FishingSpotType
|
||||
var _system_menu_open: bool = false
|
||||
var _shop_open: bool = false
|
||||
var _item_effects: PlayerItemEffectsType
|
||||
|
||||
|
||||
func setup(
|
||||
|
|
@ -64,8 +72,11 @@ func setup(
|
|||
main_shop_buyer: FishBuyerProfileType,
|
||||
fishing_upgrades: PlayerFishingUpgradesType,
|
||||
shop_interaction: ShopInteractionType,
|
||||
item_effects: PlayerItemEffectsType,
|
||||
cooler_capacity: PlayerCoolerCapacityType,
|
||||
) -> void:
|
||||
_fishing_spot = fishing_spot
|
||||
_item_effects = item_effects
|
||||
fishing_spot.status_changed.connect(_on_fishing_status_changed)
|
||||
fishing_spot.catch_display_changed.connect(_on_catch_display_changed)
|
||||
fishing_spot.showcase_changed.connect(_on_showcase_changed)
|
||||
|
|
@ -83,7 +94,8 @@ func setup(
|
|||
fishing_spot,
|
||||
bag,
|
||||
hotbar,
|
||||
item_catalog
|
||||
item_catalog,
|
||||
cooler_capacity
|
||||
)
|
||||
_hotbar_ui.setup(hotbar, bag, item_catalog, fishing_spot)
|
||||
_fishing_shop.setup(
|
||||
|
|
@ -94,11 +106,42 @@ func setup(
|
|||
main_shop_buyer,
|
||||
fishing_upgrades,
|
||||
fishing_spot,
|
||||
shop_interaction
|
||||
shop_interaction,
|
||||
bag,
|
||||
item_catalog,
|
||||
cooler_capacity
|
||||
)
|
||||
_fishing_shop.menu_visibility_changed.connect(_on_shop_visibility_changed)
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if _item_effects == null or not _gameplay_ui_enabled:
|
||||
_effect_status.hide()
|
||||
return
|
||||
var parts: Array[String] = []
|
||||
for item_id: StringName in [
|
||||
PlayerItemEffectsType.COFFEE_ID,
|
||||
PlayerItemEffectsType.ENERGY_DRINK_ID,
|
||||
PlayerItemEffectsType.SNACK_ID,
|
||||
PlayerItemEffectsType.FISH_FINDER_ID,
|
||||
]:
|
||||
var remaining: float = _item_effects.get_remaining(item_id)
|
||||
if remaining <= 0.0:
|
||||
continue
|
||||
var label: String = {
|
||||
PlayerItemEffectsType.COFFEE_ID: "Coffee",
|
||||
PlayerItemEffectsType.ENERGY_DRINK_ID: "Energy",
|
||||
PlayerItemEffectsType.SNACK_ID: "Snack",
|
||||
PlayerItemEffectsType.FISH_FINDER_ID: "Finder",
|
||||
}.get(item_id, "")
|
||||
parts.append(
|
||||
"%s %d:%02d"
|
||||
% [label, int(remaining) / 60, int(remaining) % 60]
|
||||
)
|
||||
_effect_status.text = " ".join(parts)
|
||||
_effect_status.visible = not parts.is_empty()
|
||||
|
||||
|
||||
func close_player_menu() -> void:
|
||||
_player_menu.close_menu()
|
||||
|
||||
|
|
|
|||
|
|
@ -167,6 +167,20 @@ horizontal_alignment = 1
|
|||
[node name="FishingShop" parent="." instance=ExtResource("8_shop")]
|
||||
unique_name_in_owner = true
|
||||
|
||||
[node name="EffectStatus" type="Label" parent="."]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
z_index = 54
|
||||
offset_left = 18.0
|
||||
offset_top = 18.0
|
||||
offset_right = 500.0
|
||||
offset_bottom = 44.0
|
||||
mouse_filter = 2
|
||||
theme = ExtResource("3_theme")
|
||||
theme_override_colors/font_shadow_color = Color(0, 0, 0, 0.9)
|
||||
theme_override_constants/shadow_offset_x = 2
|
||||
theme_override_constants/shadow_offset_y = 2
|
||||
|
||||
[node name="ScreenFade" type="ColorRect" parent="."]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@ const OwnedItemType = preload("res://items/owned_item.gd")
|
|||
const PlayerBagType = preload("res://inventory/player_bag.gd")
|
||||
const PlayerHotbarType = preload("res://inventory/player_hotbar.gd")
|
||||
const ItemDragSourceType = preload("res://ui/item_drag_source.gd")
|
||||
const PlayerCoolerCapacityType = preload(
|
||||
"res://progression/player_cooler_capacity.gd"
|
||||
)
|
||||
|
||||
signal menu_visibility_changed(is_open: bool)
|
||||
|
||||
|
|
@ -59,6 +62,7 @@ enum CloseReason {
|
|||
@onready var _sort_option: OptionButton = %SortOption
|
||||
@onready var _sort_direction: Button = %SortDirection
|
||||
@onready var _held_value: Label = %HeldValue
|
||||
@onready var _cooler_count: Label = %CoolerCount
|
||||
@onready var _inventory_empty: Label = %InventoryEmpty
|
||||
@onready var _inventory_grid: GridContainer = %InventoryGrid
|
||||
@onready var _detail_texture: TextureRect = %DetailTexture
|
||||
|
|
@ -86,6 +90,7 @@ var _fishing_spot: FishingSpotType
|
|||
var _bag: PlayerBagType
|
||||
var _hotbar: PlayerHotbarType
|
||||
var _item_catalog: ItemCatalogType
|
||||
var _cooler_capacity: PlayerCoolerCapacityType
|
||||
var _current_section: Section = Section.COOLER
|
||||
var _sort_mode: SortMode = SortMode.CATCH_ORDER
|
||||
var _sort_descending: bool = true
|
||||
|
|
@ -138,6 +143,7 @@ func setup(
|
|||
bag: PlayerBagType,
|
||||
hotbar: PlayerHotbarType,
|
||||
item_catalog: ItemCatalogType,
|
||||
cooler_capacity: PlayerCoolerCapacityType,
|
||||
) -> void:
|
||||
_player = player
|
||||
_inventory = inventory
|
||||
|
|
@ -150,6 +156,7 @@ func setup(
|
|||
_bag = bag
|
||||
_hotbar = hotbar
|
||||
_item_catalog = item_catalog
|
||||
_cooler_capacity = cooler_capacity
|
||||
if not _inventory.catches_changed.is_connected(_on_inventory_changed):
|
||||
_inventory.catches_changed.connect(_on_inventory_changed)
|
||||
if not _collection_log.fish_discovered.is_connected(_on_fish_discovered):
|
||||
|
|
@ -160,6 +167,10 @@ func setup(
|
|||
_fishing_spot.bite_activated.connect(_on_bite_activated)
|
||||
if not _bag.contents_changed.is_connected(_on_bag_changed):
|
||||
_bag.contents_changed.connect(_on_bag_changed)
|
||||
if not _cooler_capacity.capacity_changed.is_connected(
|
||||
_on_cooler_capacity_changed
|
||||
):
|
||||
_cooler_capacity.capacity_changed.connect(_on_cooler_capacity_changed)
|
||||
_refresh_all()
|
||||
|
||||
|
||||
|
|
@ -461,6 +472,14 @@ func _refresh_economy_summary() -> void:
|
|||
)
|
||||
_wallet_balance.text = "Wallet: $%d" % balance
|
||||
_held_value.text = "Held fish base value: $%d" % held_total
|
||||
_cooler_count.text = "%d / %d" % [
|
||||
_inventory.get_all_catches().size() if _inventory != null else 0,
|
||||
_cooler_capacity.get_capacity() if _cooler_capacity != null else 0,
|
||||
]
|
||||
|
||||
|
||||
func _on_cooler_capacity_changed(_level: int, _capacity: int) -> void:
|
||||
_refresh_economy_summary()
|
||||
|
||||
|
||||
func _refresh_inventory() -> void:
|
||||
|
|
|
|||
|
|
@ -140,6 +140,12 @@ text = "Newest first"
|
|||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="CoolerCount" type="Label" parent="MenuPanel/Margin/Layout/Content/InventorySection/SortBar"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "0 / 12"
|
||||
theme_override_colors/font_color = Color(0.208, 0.725, 0.78, 1)
|
||||
|
||||
[node name="HeldValue" type="Label" parent="MenuPanel/Margin/Layout/Content/InventorySection/SortBar"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue