équilibrages, fix et évolutions
* résolution du bug de disparition des items #94 * améliorations définitives dans le camion via compost #88 * ajout de plus d'aléatoire dans le zone de départ * suppression des récompenses de quota (pour l'instant) * équilibrage du gain en graine * ajout de la clarté dans les actions
This commit is contained in:
132
entities/interactables/truck/compost/scripts/compost.gd
Normal file
132
entities/interactables/truck/compost/scripts/compost.gd
Normal file
@@ -0,0 +1,132 @@
|
||||
extends Interactable
|
||||
class_name Compost
|
||||
|
||||
const FILLED_ICON = preload("res://common/icons/bucket.svg")
|
||||
|
||||
signal rewarded(c : Compost)
|
||||
|
||||
var reward : Reward = null :
|
||||
set(r):
|
||||
reward = r
|
||||
update_info()
|
||||
var containing_seed : int = 0 :
|
||||
set(c):
|
||||
containing_seed = c
|
||||
update_info()
|
||||
|
||||
func _ready():
|
||||
update_info()
|
||||
|
||||
func pointer_text() -> String:
|
||||
return "Compost"
|
||||
|
||||
func inspector_info() -> Inspector.Info:
|
||||
var info = Inspector.Info.new(
|
||||
pointer_text(),
|
||||
"Fill this machine with seeds to get an reward",
|
||||
%Sprite.texture,
|
||||
)
|
||||
|
||||
if reward != null:
|
||||
info.framed_infos.append(
|
||||
Inspector.FramedInfo.new(
|
||||
"On filled",
|
||||
reward.desc(),
|
||||
FILLED_ICON,
|
||||
)
|
||||
)
|
||||
|
||||
return info
|
||||
|
||||
func update_info():
|
||||
%Count.text = "" if reward == null else "%d/%d" % [containing_seed, reward.get_seed_needed()]
|
||||
%Icon.texture = null if reward == null else reward.icon()
|
||||
|
||||
func interact_text():
|
||||
if reward:
|
||||
return "Put a seed (%d left)" % (reward.get_seed_needed() - containing_seed)
|
||||
else:
|
||||
return ""
|
||||
|
||||
func can_interact(p : Player) -> bool:
|
||||
return reward and p.inventory.get_item() and p.inventory.get_item() is Seed
|
||||
|
||||
func interact(p : Player) -> bool:
|
||||
if not can_interact(p):
|
||||
return false
|
||||
|
||||
p.play_sfx("harvest")
|
||||
p.inventory.remove_current_item()
|
||||
containing_seed += 1
|
||||
if containing_seed >= reward.get_seed_needed():
|
||||
containing_seed = 0
|
||||
reward.reward(p)
|
||||
rewarded.emit(self)
|
||||
%AnimationPlayer.play("bump")
|
||||
|
||||
return true
|
||||
|
||||
func product(_player : Player):
|
||||
pass
|
||||
|
||||
class Reward:
|
||||
|
||||
var seed_needed : int = 1
|
||||
|
||||
func _init(_seed_needed : int):
|
||||
seed_needed = _seed_needed
|
||||
|
||||
func reward(_p: Player):
|
||||
pass
|
||||
|
||||
func get_seed_needed() -> int:
|
||||
return seed_needed
|
||||
|
||||
func desc() -> String:
|
||||
return ""
|
||||
|
||||
func icon() -> Texture:
|
||||
return null
|
||||
|
||||
class UpgradeMaxEnergyReward extends Reward:
|
||||
func reward(p: Player):
|
||||
p.upgrade_max_energy(1)
|
||||
|
||||
func desc() -> String:
|
||||
return "Upgrade max energy"
|
||||
|
||||
func icon() -> Texture:
|
||||
return preload("res://common/icons/bolt.svg")
|
||||
|
||||
class UpgradeMaxInventoryReward extends Reward:
|
||||
func reward(p: Player):
|
||||
p.upgrade_inventory_size()
|
||||
|
||||
func desc() -> String:
|
||||
return "Upgrade max inventory size"
|
||||
|
||||
func icon() -> Texture:
|
||||
return preload("res://common/icons/backpack.svg")
|
||||
|
||||
class GiveItemReward extends Reward:
|
||||
|
||||
var item : Item
|
||||
|
||||
func _init(_seed_needed : int, _item : Item):
|
||||
item = _item
|
||||
seed_needed = _seed_needed
|
||||
|
||||
func reward(p: Player):
|
||||
print(item)
|
||||
if p.inventory.is_full():
|
||||
print("drop")
|
||||
p.terrain.drop_item(item, p.global_position, 10)
|
||||
else:
|
||||
print("give")
|
||||
p.pick_item(item)
|
||||
|
||||
func desc() -> String:
|
||||
return "Give the item %s" % item.get_item_name()
|
||||
|
||||
func icon() -> Texture:
|
||||
return item.icon
|
||||
@@ -0,0 +1 @@
|
||||
uid://dw6jgsasb2fe1
|
||||
Reference in New Issue
Block a user