* Ajout d'un mode infini (pour nos hard core gamers) * Ajout d'un message de découverte d'un nouvel outil * Séparation de la pelle en deux outils : la pioche et la fourche * Amélioration de la lisibilité des capsules d'énergies * Changement léger des texture du sol et de la pierre * Correction d'un bug lors du clic frénétique sur le porte de sortie du vaisseau * Ajout d'un icône de recharge * Fix de la mutation Ancien qui ne s'améliorait pas au niveau 4 + début de dev des artefacts avec un distributeur
89 lines
2.5 KiB
GDScript
89 lines
2.5 KiB
GDScript
@tool
|
|
extends CanvasLayer
|
|
class_name VendingMachine
|
|
|
|
enum State {CHOOSE,PAY,FETCH}
|
|
enum ChooseState {NONE,FIRST,SECOND}
|
|
|
|
@export_tool_button("Update", "Callable") var update_action = update
|
|
|
|
@export var state : State = State.CHOOSE : set = set_state
|
|
@export var choose_state : ChooseState = ChooseState.NONE : set = set_choose_state
|
|
@export var artefact_1 : Artefact = null : set = set_artifact_1
|
|
@export var artefact_2 : Artefact = null : set = set_artifact_2
|
|
|
|
func _ready():
|
|
update()
|
|
|
|
func update():
|
|
set_artifact_1()
|
|
set_artifact_2()
|
|
set_state()
|
|
|
|
func set_state(s := state):
|
|
state = s
|
|
if is_node_ready():
|
|
%PayButton.visible = state == State.PAY
|
|
%FetchButton.visible = state == State.FETCH
|
|
|
|
match state:
|
|
State.CHOOSE:
|
|
%IndicationLabel.text = "CHOOSE_AN_ITEM"
|
|
State.PAY:
|
|
%IndicationLabel.text = "PAY_THE_PRICE"
|
|
State.FETCH:
|
|
%IndicationLabel.text = "GET_YOUR_ITEM"
|
|
|
|
func set_choose_state(s := choose_state):
|
|
choose_state = s
|
|
if is_node_ready():
|
|
%VendingMachine3d.screen_1_hide = s != ChooseState.FIRST
|
|
%VendingMachine3d.screen_2_hide = s != ChooseState.SECOND
|
|
|
|
func set_artifact_1(a := artefact_1):
|
|
artefact_1 = a
|
|
if is_node_ready() and a:
|
|
%SelectButton1.text = a.get_artefact_name()
|
|
%VendingMachine3d.object_1_scene = a.get_3d_scene()
|
|
|
|
func set_artifact_2(a := artefact_2):
|
|
artefact_2 = a
|
|
if is_node_ready() and a:
|
|
%SelectButton2.text = a.get_artefact_name()
|
|
%VendingMachine3d.object_2_scene = a.get_3d_scene()
|
|
|
|
|
|
func _on_fetch_button_button_down():
|
|
pass # TODO : Adding the artifacts
|
|
|
|
|
|
func _on_pay_button_button_down():
|
|
# TODO : The payment
|
|
if state == State.PAY and choose_state != ChooseState.NONE:
|
|
state = State.FETCH
|
|
|
|
if choose_state == ChooseState.FIRST:
|
|
%VendingMachine3d.fall_object_1()
|
|
else :
|
|
%VendingMachine3d.fall_object_2()
|
|
|
|
func _on_select_button_1_button_down():
|
|
choose_state = ChooseState.FIRST
|
|
if state == State.CHOOSE:
|
|
state = State.PAY
|
|
|
|
func _on_select_button_2_button_down():
|
|
choose_state = ChooseState.SECOND
|
|
if state == State.CHOOSE:
|
|
state = State.PAY
|
|
|
|
func _on_select_button_bis_1_button_down():
|
|
choose_state = ChooseState.FIRST
|
|
if state == State.CHOOSE:
|
|
state = State.PAY
|
|
|
|
func _on_select_button_bis_2_button_down():
|
|
choose_state = ChooseState.SECOND
|
|
if state == State.CHOOSE:
|
|
state = State.PAY
|