You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
125 lines
3.3 KiB
125 lines
3.3 KiB
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using TMPro;
|
|
|
|
public partial class MateSkillCoolTimeView : View
|
|
{
|
|
[SerializeField] SlotUI[] slots;
|
|
[SerializeField] Image activeMateIndicatorImg;
|
|
|
|
private void Start()
|
|
{
|
|
for(int i = 0; i < slots.Length; ++i)
|
|
{
|
|
slots[i].SetMate(null);
|
|
}
|
|
|
|
activeMateIndicatorImg.gameObject.SetActive(false);
|
|
Show();
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
int activeMateSlotIndex = -1;
|
|
for (int i = 0; i < slots.Length; ++i)
|
|
{
|
|
var slot = slots[i];
|
|
|
|
slot.Update();
|
|
if (slot.mate != null && slot.mate == MateMgr.Instance.ActiveMate)
|
|
{
|
|
activeMateSlotIndex = i;
|
|
}
|
|
}
|
|
|
|
if(activeMateSlotIndex >= 0)
|
|
{
|
|
activeMateIndicatorImg.gameObject.SetActive(true);
|
|
activeMateIndicatorImg.rectTransform.position = slots[activeMateSlotIndex].mateImage.rectTransform.position;
|
|
}
|
|
else
|
|
{
|
|
activeMateIndicatorImg.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
public override void Show()
|
|
{
|
|
viewState = ViewState.Shown;
|
|
gameObject.SetActive(true);
|
|
}
|
|
|
|
public override void Hide()
|
|
{
|
|
gameObject.SetActive(false);
|
|
viewState = ViewState.Hidden;
|
|
}
|
|
|
|
public void SetMateAt(SlotGroup<IVMate>.Slot slot)
|
|
{
|
|
if(slots.Length <= slot.slotIndex) return;
|
|
slots[slot.slotIndex].SetMate(slot.item);
|
|
}
|
|
|
|
public void RemoveMateAt(int slotIndex)
|
|
{
|
|
if(slots.Length <= slotIndex) return;
|
|
slots[slotIndex].SetMate(null);
|
|
}
|
|
}
|
|
|
|
public partial class MateSkillCoolTimeView : View
|
|
{
|
|
[Serializable]
|
|
struct SlotUI
|
|
{
|
|
public ExtendImage mateImage;
|
|
public ExtendImage gradeImage;
|
|
public Image coolTimeFillImage;
|
|
public TextMeshProUGUI coolTimeText;
|
|
public GameObject emptySlot;
|
|
public IVMate mate => _mate;
|
|
|
|
IVMate _mate;
|
|
|
|
public void SetMate(IVMate mate)
|
|
{
|
|
_mate = mate;
|
|
|
|
if (mate != null)
|
|
{
|
|
emptySlot?.SetActive(false);
|
|
mateImage?.SetImageInAtlasAsync(mate.Data.SDImgAtlasPath, mate.Data.SDImgNameInAtlas);
|
|
gradeImage?.gameObject.SetActive(true);
|
|
gradeImage?.SetImageInAtlasAsync(mate.Data.GradeImgAtlasPath, mate.Data.GradeImgNameInAtlas);
|
|
}
|
|
else
|
|
{
|
|
mateImage?.ReleaseAsyncAtlasImage();
|
|
gradeImage?.gameObject.SetActive(false);
|
|
emptySlot?.SetActive(true);
|
|
}
|
|
}
|
|
|
|
public void Update()
|
|
{
|
|
if (mate is null) return;
|
|
|
|
if (coolTimeText != null)
|
|
{
|
|
var remainTime = mate.Skill.CoolTimeRemainTime;
|
|
if(remainTime > 1)
|
|
coolTimeText.text = mate.Skill.CoolTimeRemainTime.ToString("F0");
|
|
else if(remainTime > 0)
|
|
coolTimeText.text = remainTime.ToString("F2");
|
|
else
|
|
coolTimeText.text = "";
|
|
}
|
|
|
|
if (coolTimeFillImage != null)
|
|
coolTimeFillImage.fillAmount = 1f - mate.Skill.ElapsedCoolTimeRate;
|
|
}
|
|
}
|
|
}
|
|
|