50 lines
1.4 KiB
C#
50 lines
1.4 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class StatusIconUI : MonoBehaviour
|
|
{
|
|
public Image backgroundImage;
|
|
public Image statusImage;
|
|
public Text turnsText;
|
|
|
|
private BattleStatus status;
|
|
private Buff buff;
|
|
|
|
public void InitStatus(BattleStatus status) {
|
|
this.status = status;
|
|
Sprite sprite = Resources.Load<Sprite>(GetStatusResourcePath(status));
|
|
this.statusImage.sprite = sprite;
|
|
}
|
|
|
|
public void InitBuff(Buff buff) {
|
|
this.buff = buff;
|
|
Sprite sprite = Resources.Load<Sprite>(GetBuffResourcePath(buff.Type));
|
|
this.statusImage.sprite = sprite;
|
|
this.SetNumber(buff.Amount);
|
|
}
|
|
|
|
private static string GetStatusResourcePath(BattleStatus status) {
|
|
return "BattleIcons/StatusIcon" + status;
|
|
}
|
|
|
|
private static string GetBuffResourcePath(BuffType buffType) {
|
|
return "BattleIcons/BuffIcon" + buffType;
|
|
}
|
|
|
|
public void UpdateStatusAmount(int amount) {
|
|
if (this.status == BattleStatus.None) {
|
|
throw new System.Exception();
|
|
}
|
|
this.SetNumber(amount);
|
|
}
|
|
|
|
public void SetPosition(int index) {
|
|
this.transform.localPosition = new Vector2(-index * 22, 0);
|
|
}
|
|
|
|
private void SetNumber(int number) {
|
|
this.turnsText.text = "" + number;
|
|
}
|
|
}
|