UI调整
This commit is contained in:
@@ -3,6 +3,7 @@ using ChocDino.UIFX;
|
||||
using Cielonos.MainGame.Inventory;
|
||||
using DG.Tweening;
|
||||
using SLSUtilities.UI;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
@@ -11,18 +12,21 @@ namespace Cielonos.MainGame.UI
|
||||
public class SupportEquipmentIcon : UIElementBase
|
||||
{
|
||||
public SupportEquipmentBase supportEquipment;
|
||||
public RuntimeFunctionUnit functionUnit;
|
||||
public Image frame;
|
||||
public Image iconImage;
|
||||
public Image timer;
|
||||
private Sequence frameOutlineSequence;
|
||||
public Image timerImage;
|
||||
public TMP_Text timerText;
|
||||
public TMP_Text costText;
|
||||
|
||||
private RuntimeFunctionUnit _functionUnit;
|
||||
private Sequence _frameOutlineSequence;
|
||||
|
||||
public void Initialize(SupportEquipmentBase supportEquipment)
|
||||
{
|
||||
if (supportEquipment == null)
|
||||
{
|
||||
iconImage.sprite = null;
|
||||
functionUnit = null;
|
||||
_functionUnit = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -35,40 +39,91 @@ namespace Cielonos.MainGame.UI
|
||||
|
||||
if (functionCount == 0)
|
||||
{
|
||||
|
||||
DisableAllParts();
|
||||
}
|
||||
else if (functionCount == 1)
|
||||
{
|
||||
functionUnit = supportEquipment.functionSm.functionUnits.Values.ToList()[0];
|
||||
_functionUnit = supportEquipment.functionSm.mainFunction;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
//如果有多个功能单元,优先显示主功能单元
|
||||
_functionUnit = supportEquipment.functionSm.mainFunction;
|
||||
}
|
||||
|
||||
timerImage.gameObject.SetActive(true);
|
||||
timerText.gameObject.SetActive(true);
|
||||
costText.gameObject.SetActive(true);
|
||||
iconImage.color = Color.white;
|
||||
|
||||
if (_functionUnit.maxCooldown <= 0)
|
||||
{
|
||||
timerImage.gameObject.SetActive(false);
|
||||
timerText.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
if(_functionUnit.data.energyCost <= 0)
|
||||
{
|
||||
costText.gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
costText.text = Mathf.CeilToInt(_functionUnit.data.energyCost).ToString("D");
|
||||
}
|
||||
|
||||
if (_functionUnit.data.tags.Contains("Disruption"))
|
||||
{
|
||||
Color newColor = Color.yellow;
|
||||
iconImage.color = newColor;
|
||||
newColor.a = 0.5f;
|
||||
frame.color = newColor;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
DisableAllParts();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void DisableAllParts()
|
||||
{
|
||||
iconImage.sprite = null;
|
||||
iconImage.color = Color.clear;
|
||||
timerImage.gameObject.SetActive(false);
|
||||
timerText.gameObject.SetActive(false);
|
||||
costText.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public override void UpdateUI()
|
||||
{
|
||||
if (functionUnit == null) return;
|
||||
if (_functionUnit == null) return;
|
||||
|
||||
float fillAmount;
|
||||
|
||||
if (functionUnit.maxCooldown <= 0f)
|
||||
if (_functionUnit.maxCooldown <= 0f)
|
||||
{
|
||||
fillAmount = 0f;
|
||||
//无冷却
|
||||
}
|
||||
else
|
||||
{
|
||||
fillAmount = functionUnit.currentCooldown / functionUnit.maxCooldown;
|
||||
float fillAmount = 1f - _functionUnit.currentCooldown / _functionUnit.maxCooldown;
|
||||
timerImage.fillAmount = fillAmount;
|
||||
|
||||
if (_functionUnit.currentCooldown > 0f)
|
||||
{
|
||||
timerText.text = _functionUnit.currentCooldown.ToString("F1");
|
||||
}
|
||||
else
|
||||
{
|
||||
timerText.text = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (_functionUnit.data.energyCost > 0)
|
||||
{
|
||||
float playerCurrentEnergy = MainGameManager.Player.attributeSm[CharacterAttribute.Energy];
|
||||
costText.color = playerCurrentEnergy >= _functionUnit.data.energyCost ? Color.cyan : Color.orangeRed;
|
||||
costText.text = Mathf.CeilToInt(_functionUnit.data.energyCost).ToString("D");
|
||||
}
|
||||
|
||||
timer.fillAmount = fillAmount;
|
||||
}
|
||||
|
||||
public void UseOutlineAnimation() => SetFrameOutline(0.4f, Color.white);
|
||||
@@ -85,13 +140,13 @@ namespace Cielonos.MainGame.UI
|
||||
float fadeDuration = Mathf.Clamp(totalDuration / 2f, 0.2f, totalDuration);
|
||||
float stayDuration = totalDuration - fadeDuration;
|
||||
float strengthPeak = 0.25f;
|
||||
frameOutlineSequence?.Kill(true);
|
||||
frameOutlineSequence = DOTween.Sequence();
|
||||
frameOutlineSequence.Append(DOTween.To(() => glowFilter.Strength, x => glowFilter.Strength = x, strengthPeak, fadeDuration).SetEase(Ease.OutQuad));
|
||||
frameOutlineSequence.AppendInterval(stayDuration);
|
||||
frameOutlineSequence.Append(DOTween.To(() => glowFilter.Strength, x => glowFilter.Strength = x, 0f, fadeDuration).SetEase(Ease.InQuad));
|
||||
frameOutlineSequence.OnComplete(() => GetComponent<Canvas>().sortingOrder = 0);
|
||||
frameOutlineSequence.Play();
|
||||
_frameOutlineSequence?.Kill(true);
|
||||
_frameOutlineSequence = DOTween.Sequence();
|
||||
_frameOutlineSequence.Append(DOTween.To(() => glowFilter.Strength, x => glowFilter.Strength = x, strengthPeak, fadeDuration).SetEase(Ease.OutQuad));
|
||||
_frameOutlineSequence.AppendInterval(stayDuration);
|
||||
_frameOutlineSequence.Append(DOTween.To(() => glowFilter.Strength, x => glowFilter.Strength = x, 0f, fadeDuration).SetEase(Ease.InQuad));
|
||||
_frameOutlineSequence.OnComplete(() => GetComponent<Canvas>().sortingOrder = 0);
|
||||
_frameOutlineSequence.Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ namespace Cielonos.MainGame.UI
|
||||
private void Awake()
|
||||
{
|
||||
icons = GetComponentsInChildren<SupportEquipmentIcon>(true).ToList();
|
||||
icons.ForEach(icon => icon.DisableAllParts());
|
||||
}
|
||||
|
||||
public void Initialize(SupportEquipmentBase supportEquipment, int slotIndex)
|
||||
|
||||
Reference in New Issue
Block a user