114 lines
3.6 KiB
C#
114 lines
3.6 KiB
C#
using DonkeysAndDroids;
|
|
using Godot;
|
|
using RobotAndDonkey.Game.Cards;
|
|
using RobotAndDonkey.Game.Execution.Commands;
|
|
using RobotAndDonkey.Game.Execution.Results;
|
|
|
|
public partial class DrawGlitch : Control, IScreen
|
|
{
|
|
// Called when the node enters the scene tree for the first time.
|
|
public override void _Ready()
|
|
{
|
|
m_CardControl = GetNode<CardControl>("%Card");
|
|
m_Background = GetNode<Control>("%Background");
|
|
m_Deck = GetNode<CardRow>("%Deck");
|
|
m_AcceptButton = GetNode<Button>("VBoxContainer/MarginContainer/HBoxContainer/AcceptButton");
|
|
m_DeferButton = GetNode<Button>("VBoxContainer/MarginContainer/HBoxContainer/DeferButton");
|
|
m_AcceptButton.Pressed += OnAcceptPressed;
|
|
m_DeferButton.Pressed += OnDeferPressed;
|
|
}
|
|
|
|
private void OnDeferPressed()
|
|
{
|
|
Main.Instance.Execute(new DeferCardCommand(Main.Instance.CurrentRequest.RequestId));
|
|
}
|
|
|
|
private void OnAcceptPressed()
|
|
{
|
|
Main.Instance.Execute(new AcceptCardCommand(Main.Instance.CurrentRequest.RequestId));
|
|
}
|
|
|
|
public void Deactivate()
|
|
{
|
|
}
|
|
|
|
public void EnableInputs()
|
|
{
|
|
m_Background.Modulate = new(1, 1, 1);
|
|
m_CardControl.Modulate = new(1, 1, 1);
|
|
m_CardControl.Disabled = false;
|
|
m_AcceptButton.Disabled = false;
|
|
m_DeferButton.Disabled = false;
|
|
m_Deck.Disabled = false;
|
|
}
|
|
|
|
public void DisableInputs()
|
|
{
|
|
m_CardControl.Disabled = true;
|
|
m_AcceptButton.Disabled = true;
|
|
m_DeferButton.Disabled = true;
|
|
m_Deck.Disabled = true;
|
|
}
|
|
|
|
public void Activate()
|
|
{
|
|
}
|
|
|
|
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
public override void _Process(double delta)
|
|
{
|
|
}
|
|
|
|
public void Configure(Card card, Tween tween)
|
|
{
|
|
m_CardControl.Configure(card, null);
|
|
var energy = new DeferCardCommand(Main.Instance.CurrentRequest.RequestId).EstimateEnergyCost(Main.Instance.CoreLoop);
|
|
m_DeferButton.Text = $"Defer ({energy} energy)";
|
|
Deck.Configure([], null, false, false);
|
|
Deck.Configure(CardRow.GetSortedCards(Main.Instance.CoreLoop.PatchDeck), tween, false, false);
|
|
Tooltip.Instance.Describe(card);
|
|
}
|
|
|
|
public bool HandleResult(Result result, Tween tween)
|
|
{
|
|
switch (result)
|
|
{
|
|
case RunCardResult:
|
|
{
|
|
tween.TweenCallback(Callable.From(() =>
|
|
{
|
|
m_CardControl.Disabled = true;
|
|
m_AcceptButton.Disabled = true;
|
|
m_DeferButton.Disabled = true;
|
|
m_Deck.Disabled = true;
|
|
}));
|
|
tween.TweenProperty(m_Background, "modulate", new Color(1, 1, 1, 0), 0.5f);
|
|
tween.TweenCallback(Callable.From(() => Main.Instance.Music.Play(MusicManager.ESound.Card)));
|
|
m_CardControl.AnimateCard(tween);
|
|
tween.TweenProperty(m_CardControl, "modulate", new Color(1, 1, 1, 0), 0.5f);
|
|
return true;
|
|
}
|
|
case DeckResult deckResult:
|
|
{
|
|
Deck.Configure(CardRow.GetSortedCards(deckResult.Deck), tween, false, false);
|
|
return true;
|
|
}
|
|
case ModifyCardResult modifyCardResult:
|
|
{
|
|
Deck.ModifyCard(modifyCardResult.Card, modifyCardResult.Modifier, tween);
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public CardRow Deck => m_Deck;
|
|
|
|
private CardRow m_Deck;
|
|
|
|
private CardControl m_CardControl;
|
|
private Button m_AcceptButton;
|
|
private Button m_DeferButton;
|
|
private Control m_Background;
|
|
} |