Files

51 lines
1.2 KiB
C#

using System;
using Data;
using Managers;
using Prefab;
using UnityEngine;
namespace UI
{
public class AttackModeUI : MonoBehaviour
{
public UIImageAnimator icon;
public int CurrentIndex { get; private set; }
public RobotLogicDef[] robotLogic;
public RobotLogicDef CurrentLogic => robotLogic?[CurrentIndex];
private void Start()
{
robotLogic=Program.Instance.CurrentCharacter?.robotLogic;
if (robotLogic == null || robotLogic.Length == 0)
{
robotLogic= Array.Empty<RobotLogicDef>();
icon.gameObject.SetActive(false);
return;
}
UpdateUI();
}
public void UpdateUI()
{
if (CurrentLogic == null)
return;
icon.SetSprites(PackagesImageManager.Instance.GetSprites(new[]
{
CurrentLogic.icon
}));
Program.Instance.CurrentRobotLogic = CurrentLogic;
}
public void OnSwitch()
{
if (robotLogic.Length == 0)
return;
CurrentIndex += 1;
CurrentIndex %= robotLogic.Length;
UpdateUI();
}
}
}