41 lines
1.6 KiB
C#
41 lines
1.6 KiB
C#
using ChocDino.UIFX;
|
|
using Cielonos.MainGame.Inventory;
|
|
using DG.Tweening;
|
|
using SLSUtilities.UI;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace Cielonos.MainGame.UI
|
|
{
|
|
public class MainWeaponDisplayer : UIElementBase
|
|
{
|
|
public Image rectIcon;
|
|
public TMP_Text weaponNameText;
|
|
public Image frame;
|
|
private Sequence frameOutlineSequence;
|
|
|
|
public void Initialize(RuntimeFunctionUnit functionUnit, string weaponName)
|
|
{
|
|
rectIcon.sprite = functionUnit.data.icon;
|
|
weaponNameText.text = weaponName;
|
|
}
|
|
|
|
public void SetFrameOutline(float totalDuration, Color color = default, float intensity = 2f)
|
|
{
|
|
color = color == default ? Color.cyan : 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();
|
|
}
|
|
}
|
|
} |