amélioration de l'UI de l'inventaire et ajout de la récompense d'amélioration de taille d'inventaire #52
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
extends ObjectiveReward
|
||||
class_name UpgradePlayerMaxEnergyReward
|
||||
|
||||
@export var upgrade_amount = 1
|
||||
|
||||
func _init(_upgrade_amount : int = 1):
|
||||
upgrade_amount = _upgrade_amount
|
||||
|
||||
func reward(objective : Objective):
|
||||
objective.planet.player.upgrade_max_energy(upgrade_amount)
|
||||
|
||||
func get_icon() -> Texture:
|
||||
return preload("res://common/icons/bolt.svg")
|
||||
|
||||
func get_text() -> String:
|
||||
return "+"+str(upgrade_amount)+" max"
|
||||
|
||||
func get_description() -> String:
|
||||
return "Increase player max energy by " + str(upgrade_amount) + "."
|
||||
@@ -0,0 +1 @@
|
||||
uid://qywwuv3et7oq
|
||||
@@ -1,5 +1,5 @@
|
||||
extends ObjectiveReward
|
||||
class_name UpgradePlayerMaxEnergyReward
|
||||
class_name UpgradePlayerInventorySizeReward
|
||||
|
||||
@export var upgrade_amount = 1
|
||||
|
||||
@@ -7,13 +7,13 @@ func _init(_upgrade_amount : int = 1):
|
||||
upgrade_amount = _upgrade_amount
|
||||
|
||||
func reward(objective : Objective):
|
||||
objective.planet.player.upgrade_max_energy(upgrade_amount)
|
||||
objective.planet.player.upgrade_inventory_size(upgrade_amount)
|
||||
|
||||
func get_icon() -> Texture:
|
||||
return preload("res://common/icons/bolt.svg")
|
||||
return preload("res://common/icons/backpack.svg")
|
||||
|
||||
func get_text() -> String:
|
||||
return "+"+str(upgrade_amount)+" max"
|
||||
|
||||
func get_description() -> String:
|
||||
return "Increase player max energy by " + str(upgrade_amount) + "."
|
||||
return "Increase player inventory size by " + str(upgrade_amount) + "."
|
||||
|
||||
@@ -3,6 +3,7 @@ class_name Player
|
||||
|
||||
const MAX_REACH = 100
|
||||
const HOLDING_ITEM_SPRITE_SIZE = 20.
|
||||
const DEFAULT_INVENTORY_SIZE = 2
|
||||
|
||||
signal player_updated(player: Player)
|
||||
signal upgraded
|
||||
@@ -25,7 +26,7 @@ var energy : int = max_energy :
|
||||
energy = v
|
||||
player_updated.emit(self)
|
||||
|
||||
@onready var inventory : Inventory = Inventory.new()
|
||||
@onready var inventory : Inventory = Inventory.new(DEFAULT_INVENTORY_SIZE)
|
||||
@onready var preview_zone : Area2D = null
|
||||
@onready var action_zone : Area2D = null
|
||||
|
||||
@@ -123,13 +124,9 @@ func try_move(move_to : Vector2):
|
||||
instruction = MoveInstruction.new(move_to)
|
||||
|
||||
func pick_item(item : Item) -> Item:
|
||||
var itemAdded = inventory.add_item(item)
|
||||
inventory.add_item(item)
|
||||
var currentItem : Item = inventory.get_item()
|
||||
var itemSwapped : bool = false
|
||||
if itemAdded:
|
||||
inventory.set_current_item(inventory.length() - 1)
|
||||
else:
|
||||
itemSwapped = inventory.set_item(item, inventory.current_item_ind)
|
||||
play_sfx("pick")
|
||||
if !itemSwapped:
|
||||
currentItem = null
|
||||
@@ -174,6 +171,11 @@ func upgrade_max_energy(amount = 1):
|
||||
upgraded.emit()
|
||||
player_updated.emit(self)
|
||||
|
||||
func upgrade_inventory_size(amount = 1):
|
||||
inventory.size += amount
|
||||
upgraded.emit()
|
||||
player_updated.emit(self)
|
||||
|
||||
func recharge(amount : int = max_energy):
|
||||
energy = energy + amount
|
||||
upgraded.emit()
|
||||
|
||||
@@ -6,10 +6,8 @@ const MODULATE_INSPECTED_COLOR = Color.GRAY
|
||||
@onready var default_modulate : Color = modulate
|
||||
@onready var inspectable_signals_setuped : bool = setup_inspectable_signals()
|
||||
|
||||
var inspected : bool = false :
|
||||
set(v):
|
||||
inspected = v
|
||||
modulate = MODULATE_INSPECTED_COLOR if inspected else default_modulate
|
||||
func inspect(is_inspected : bool = true):
|
||||
modulate = MODULATE_INSPECTED_COLOR if is_inspected else default_modulate
|
||||
|
||||
func setup_inspectable_signals() -> bool:
|
||||
mouse_entered.connect(_on_mouse_entered)
|
||||
@@ -17,10 +15,10 @@ func setup_inspectable_signals() -> bool:
|
||||
return true
|
||||
|
||||
func _on_mouse_entered():
|
||||
Pointer.inspect_entity(self)
|
||||
Pointer.inspect(self, inspector_info())
|
||||
|
||||
func _on_mouse_excited():
|
||||
Pointer.stop_inspect_entity(self)
|
||||
Pointer.stop_inspect(self)
|
||||
|
||||
func pointer_text():
|
||||
return ""
|
||||
@@ -29,3 +27,7 @@ func inspector_info() -> Inspector.Info:
|
||||
return Inspector.Info.new(
|
||||
pointer_text()
|
||||
)
|
||||
|
||||
func _notification(what):
|
||||
if (what == NOTIFICATION_PREDELETE):
|
||||
Pointer.stop_inspect(self)
|
||||
|
||||
Reference in New Issue
Block a user