mirror of
http://47.107.252.169:3000/Roguelite-Game-Developing-Team/Gen_Hack-and-Slash-Roguelite.git
synced 2025-11-20 00:57:14 +08:00
Co-authored-by: m0_75251201 <m0_75251201@noreply.gitcode.com> Reviewed-on: http://47.107.252.169:3000/Roguelite-Game-Developing-Team/Gen_Hack-and-Slash-Roguelite/pulls/60
51 lines
1.2 KiB
C#
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();
|
|
}
|
|
}
|
|
} |