74 lines
1.7 KiB
C#
74 lines
1.7 KiB
C#
using Newtonsoft.Json.Linq;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class TakeOrRiskPanel : MonoBehaviour
|
|
{
|
|
[SerializeField] Image CurrentPrizeFrame;
|
|
[SerializeField] Image NextPrizeFrame;
|
|
|
|
[SerializeField] private Color DisabledColor;
|
|
[SerializeField] float HSV_speed = 2;
|
|
|
|
[SerializeField] private Image TimerRing;
|
|
[SerializeField] private AnimationCurve timerFillCurve;
|
|
|
|
|
|
private Image activeFrame;
|
|
private Image inactiveFrame;
|
|
|
|
private int index = 0;
|
|
|
|
private float acceptTimer = 0;
|
|
|
|
private void OnEnable()
|
|
{
|
|
activeFrame = CurrentPrizeFrame;
|
|
inactiveFrame = NextPrizeFrame;
|
|
index = 0;
|
|
}
|
|
|
|
|
|
void Update()
|
|
{
|
|
// добавить скалирование
|
|
//подсветку на кнопку принять
|
|
|
|
ProcessInput();
|
|
DisplayGraphics();
|
|
|
|
|
|
}
|
|
|
|
private void ProcessInput()
|
|
{
|
|
if (In.GetButtonAnyPlayer(PlayerAction.left)) index = 0;
|
|
if (In.GetButtonAnyPlayer(PlayerAction.right)) index = 1;
|
|
if (index == 0)
|
|
{
|
|
activeFrame = CurrentPrizeFrame;
|
|
inactiveFrame = NextPrizeFrame;
|
|
}
|
|
else
|
|
{
|
|
activeFrame = NextPrizeFrame;
|
|
inactiveFrame = CurrentPrizeFrame;
|
|
}
|
|
|
|
|
|
acceptTimer += Time.deltaTime * (In.GetButtonAnyPlayer(PlayerAction.down) ? 1 : -1);
|
|
acceptTimer = Mathf.Clamp01(acceptTimer);
|
|
}
|
|
|
|
private void DisplayGraphics()
|
|
{
|
|
float hue = (Time.time * HSV_speed) % 1f;
|
|
activeFrame.color = Color.HSVToRGB(hue, 1, 1);
|
|
inactiveFrame.color = DisabledColor;
|
|
|
|
TimerRing.fillAmount = timerFillCurve.Evaluate(acceptTimer);
|
|
}
|
|
|
|
|
|
}
|