Files
Cielonos/Assets/Scripts/MainGame/UI/PlayerUI/PlayerInfo/PlayerHealthBar.cs

53 lines
1.5 KiB
C#
Raw Normal View History

2026-02-13 09:22:11 -05:00
using ChocDino.UIFX;
2025-12-08 05:27:53 -05:00
using Cielonos.MainGame;
2026-02-13 09:22:11 -05:00
using DG.Tweening;
using Sirenix.OdinInspector;
using SLSUtilities.General;
using SLSUtilities.UI;
2025-12-08 05:27:53 -05:00
using UnityEngine;
using UnityEngine.UI.Extensions.ColorPicker;
2026-02-13 09:22:11 -05:00
namespace Cielonos.MainGame.UI
2025-12-08 05:27:53 -05:00
{
public class PlayerHealthBar : AttributeBarBase
{
2026-02-13 09:22:11 -05:00
public GlowFilter glowFilter;
private Tweener colorTweener;
2025-12-08 05:27:53 -05:00
protected override void Awake()
{
base.Awake();
useLerpColor = true;
fillColor = new LerpColor(GetTargetColor(1), 0.2f);
}
public Color GetTargetColor(float ratio)
{
float hue = Mathf.Lerp(120f, 0f, 1 - ratio);
return HSVUtil.ConvertHsvToRgb(hue, 0.41f, 1f, 1f);
/*if (ratio >= 0.9f)
{
return HSVUtil.ConvertHsvToRgb(120f, 0.41f, 1f, 1f);
}
else if(ratio >= 0.2f)
{
float hue = Mathf.Lerp(120f, 0f, (0.9f - ratio) / (0.9f - 0.2f));
return HSVUtil.ConvertHsvToRgb(hue, 0.41f, 1f, 1f);
}
else
{
return HSVUtil.ConvertHsvToRgb(0f, 0.41f, 1f, 1f);
}*/
}
2026-02-13 09:22:11 -05:00
public void GetHurtGlowBlink()
{
colorTweener?.Kill();
colorTweener = DOTween.To(() => glowFilter.Color, x => glowFilter.Color = x, Color.red, 0.1f)
.From(Color.white)
.SetLoops(2, LoopType.Yoyo);
colorTweener.Play();
}
2025-12-08 05:27:53 -05:00
}
}