|
|
|
using Godot;
|
|
|
|
using System;
|
|
|
|
|
|
|
|
public partial class OptionPicker : Node2D
|
|
|
|
{
|
|
|
|
// Called when the node enters the scene tree for the first time.
|
|
|
|
public override void _Ready()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
|
|
public override void _Process(double delta)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Reset()
|
|
|
|
{
|
|
|
|
foreach (Node child in GetChildren())
|
|
|
|
{
|
|
|
|
if (child is SlotSymbol slotSymbol)
|
|
|
|
{
|
|
|
|
slotSymbol.SetToRandom();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Show(bool visible = true)
|
|
|
|
{
|
|
|
|
foreach (CanvasItem child in GetChildren())
|
|
|
|
{
|
|
|
|
child.Visible = visible;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Hide()
|
|
|
|
{
|
|
|
|
Show(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public const double SLIDE_DELAY = .15;
|
|
|
|
public const double SLIDE_TIME = .25;
|
|
|
|
public SlotSymbol Select(int index)
|
|
|
|
{
|
|
|
|
SlotSymbol child = GetChildren()[index+1] as SlotSymbol;
|
|
|
|
var tween = CreateTween();
|
|
|
|
tween.TweenInterval(SLIDE_DELAY);
|
|
|
|
tween.TweenProperty(child, "position", child.Position - new Vector2(0, 180), SLIDE_TIME);
|
|
|
|
tween.TweenCallback(Callable.From(Hide));
|
|
|
|
tween.TweenProperty(child, "position", child.Position, 0);
|
|
|
|
|
|
|
|
|
|
|
|
//Show(false);
|
|
|
|
return child;
|
|
|
|
}
|
|
|
|
}
|