更新
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
using System.Linq;
|
||||
using ChocDino.UIFX;
|
||||
using Cielonos.MainGame.Inventory;
|
||||
using DG.Tweening;
|
||||
using SLSFramework.UI;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Cielonos.UI
|
||||
{
|
||||
public class SupportEquipmentIcon : UIElementBase
|
||||
{
|
||||
public SupportEquipmentBase supportEquipment;
|
||||
public RuntimeFunctionUnit functionUnit;
|
||||
public Image frame;
|
||||
public Image iconImage;
|
||||
public Image timer;
|
||||
private Sequence frameOutlineSequence;
|
||||
|
||||
public void Initialize(SupportEquipmentBase supportEquipment)
|
||||
{
|
||||
if (supportEquipment == null)
|
||||
{
|
||||
iconImage.sprite = null;
|
||||
functionUnit = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.supportEquipment = supportEquipment;
|
||||
iconImage.sprite = supportEquipment.contentData.squareIcon;
|
||||
|
||||
if (supportEquipment.functionSm != null)
|
||||
{
|
||||
int functionCount = supportEquipment.functionSm.functionUnits.Count;
|
||||
|
||||
if (functionCount == 0)
|
||||
{
|
||||
|
||||
}
|
||||
else if (functionCount == 1)
|
||||
{
|
||||
functionUnit = supportEquipment.functionSm.functionUnits.Values.ToList()[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdateUI()
|
||||
{
|
||||
if (functionUnit == null) return;
|
||||
|
||||
float fillAmount;
|
||||
|
||||
if (functionUnit.maxCooldown <= 0f)
|
||||
{
|
||||
fillAmount = 0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
fillAmount = functionUnit.currentCooldown / functionUnit.maxCooldown;
|
||||
}
|
||||
|
||||
timer.fillAmount = fillAmount;
|
||||
}
|
||||
|
||||
public void UseOutlineAnimation() => SetFrameOutline(0.4f, Color.white);
|
||||
public void CanNotUseOutlineAnimation() => SetFrameOutline(0.4f, Color.red);
|
||||
|
||||
public void SetFrameOutline(float totalDuration, Color color = default, float intensity = 2f)
|
||||
{
|
||||
color = color == default ? Color.white : color;
|
||||
Color hdrColor = color * Mathf.Pow(2f, intensity);
|
||||
GlowFilter glowFilter = frame.GetComponent<GlowFilter>();
|
||||
glowFilter.Color = hdrColor;
|
||||
float fadeDuration = Mathf.Clamp(totalDuration / 2f, 0.2f, totalDuration);
|
||||
float stayDuration = totalDuration - fadeDuration;
|
||||
float strengthPeak = 0.5f;
|
||||
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.Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6049e0c150d7aee499adfa1f56e8e02f
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Cielonos.MainGame.Inventory;
|
||||
using SLSFramework.UI;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cielonos.UI
|
||||
{
|
||||
public class SupportEquipmentsUIArea : UIElementBase
|
||||
{
|
||||
public List<SupportEquipmentIcon> icons;
|
||||
|
||||
public SupportEquipmentIcon this[SupportEquipmentBase supportEquipment] =>
|
||||
icons.FirstOrDefault(icon => icon.supportEquipment == supportEquipment);
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
icons = GetComponentsInChildren<SupportEquipmentIcon>(true).ToList();
|
||||
}
|
||||
|
||||
public void Initialize(SupportEquipmentBase supportEquipment, int slotIndex)
|
||||
{
|
||||
icons[slotIndex].Initialize(supportEquipment);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
icons.ForEach(icon => icon.UpdateUI());
|
||||
}
|
||||
|
||||
public void Remove(int slotIndex)
|
||||
{
|
||||
icons[slotIndex].Initialize(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9842c3d125217e04dabddc2347566940
|
||||
Reference in New Issue
Block a user