35 lines
942 B
C#
35 lines
942 B
C#
using PrizeSystem;
|
|
using UnityEngine.UI;
|
|
|
|
public class CountablePrizeConfigurator : BasePrizeConfigurator, IControlable
|
|
{
|
|
public Image icon;
|
|
public MNumberStepper numberInput;
|
|
|
|
public override void Configure(PrizeType prizeType)
|
|
{
|
|
icon.sprite = PrizeSystemManager.GetPrizeIcon(prizeType);
|
|
|
|
int maxValue = prizeType switch
|
|
{
|
|
PrizeType.Hopper => 10,
|
|
PrizeType.Ticket => 100,
|
|
PrizeType.Marbles => 10,
|
|
_ => 1
|
|
};
|
|
|
|
numberInput.Initialize(value: 1, min: 1, maxValue);
|
|
}
|
|
|
|
public override void UpdateControls()
|
|
{
|
|
numberInput.SetDirection(In.GetAxis(JoystickSide.Both, InteractMode.Continious).x);
|
|
|
|
if (In.GetAction(JoystickSide.Both, InteractMode.Continious))
|
|
{
|
|
Prize prize = PrizeUtils.CreatePrize(CountablePrizeType.Hopper, numberInput.Value);
|
|
Complete(prize);
|
|
}
|
|
}
|
|
}
|