阶段性完成

This commit is contained in:
SoulliesOfficial
2025-12-08 05:27:53 -05:00
parent ef7b479712
commit f7af60351b
8770 changed files with 15637030 additions and 208354 deletions

View File

@@ -0,0 +1,92 @@
using System;
using DG.Tweening;
using SLSFramework.General;
using UnityEngine;
using UnityEngine.UI;
namespace SLSFramework.UI
{
public class AttributeBarBase : UIElementBase
{
public Image fillImage;
public LerpFloat fillLerp = new LerpFloat(1f, 0.2f);
public bool useLerpColor;
public LerpColor fillColor;
protected virtual void Awake()
{
fillLerp = new LerpFloat(1f, 0.2f);
}
public void UpdateFillImage(float currentValue, float maxValue, bool isInstant = false)
{
if (maxValue < 0)
{
Debug.LogWarning("Max value is less than zero. Cannot update fill image.");
return;
}
if (currentValue <= 0)
{
fillImage.fillAmount = 0;
return;
}
if (!isInstant)
{
float targetFill = currentValue / maxValue;
fillLerp.targetValue = targetFill;
}
else
{
fillLerp.targetValue = currentValue / maxValue;
fillLerp.currentValue = currentValue / maxValue;
}
}
public void UpdateFillColor(Color color, bool isInstant = false)
{
if (useLerpColor)
{
if (!isInstant)
{
fillColor.targetValue = color;
}
else
{
fillColor.targetValue = color;
fillColor.currentValue = color;
}
}
else
{
fillImage.color = color;
}
}
public void Update()
{
fillLerp.Update(1);
fillImage.fillAmount = fillLerp.currentValue;
if (useLerpColor)
{
fillColor.Update(1);
fillImage.color = fillColor.currentValue;
}
}
private Tweener blinkTweener;
public virtual void Blink(Color blinkColor, float duration = 0.2f)
{
blinkTweener?.Kill();
Color originalColor = useLerpColor ? fillColor.targetValue : fillImage.color;
blinkTweener = fillImage.DOColor(blinkColor, duration / 2).SetLoops(2, LoopType.Yoyo).OnComplete(() =>
{
fillImage.color = originalColor;
});
blinkTweener.Play();
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5b0e70941af825444a13a71584f8293f

View File

@@ -0,0 +1,11 @@
using Cielonos.MainGame;
using SLSFramework.UI;
using UnityEngine;
namespace Cielonos.UI
{
public class PlayerEnergyBar : AttributeBarBase
{
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: cf21b5081a05af848a744cb0f84e85dd

View File

@@ -0,0 +1,38 @@
using Cielonos.MainGame;
using SLSFramework.General;
using SLSFramework.UI;
using UnityEngine;
using UnityEngine.UI.Extensions.ColorPicker;
namespace Cielonos.UI
{
public class PlayerHealthBar : AttributeBarBase
{
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);
}*/
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 21cc57bd78333344a976ee2432ed2fc9

View File

@@ -0,0 +1,53 @@
using System;
using Cielonos.MainGame;
using SLSFramework.UI;
using TMPro;
using UnityEngine;
namespace Cielonos.UI
{
public class PlayerInfoUIArea : UIElementBase
{
public TMP_Text nameText;
public TMP_Text healthText;
public PlayerHealthBar healthBar;
public PlayerEnergyBar energyBar;
private void Start()
{
UpdateHealth(true);
UpdateEnergy(true);
}
public void UpdateHealth(bool isInstant = false)
{
float currentHealth = MainGameManager.Player.attributeSm["Health"];
float maximumHealth = MainGameManager.Player.attributeSm["MaximumHealth"];
float ratio = currentHealth / maximumHealth;
Color fillColor = healthBar.GetTargetColor(ratio);
string colorHex = ColorUtility.ToHtmlStringRGB(fillColor);
healthBar.UpdateFillImage(currentHealth, maximumHealth);
healthBar.UpdateFillColor(fillColor, isInstant);
if(!isInstant) healthBar.Blink(Color.white);
int currentHealthInt = Mathf.CeilToInt(currentHealth);
int maximumHealthInt = Mathf.CeilToInt(maximumHealth);
if (ratio <= 0.2f)
{
healthText.text = $"<color=#{colorHex}>{currentHealthInt}</color> <size=18>/ {maximumHealthInt}</size>";
}
else
{
healthText.text = $"{currentHealthInt} <size=18>/ {maximumHealthInt}</size>";
}
}
public void UpdateEnergy(bool isInstant = false)
{
float currentEnergy = MainGameManager.Player.attributeSm["Energy"];
float maximumEnergy = MainGameManager.Player.attributeSm["MaximumEnergy"];
energyBar.UpdateFillImage(currentEnergy, maximumEnergy);
if(!isInstant) energyBar.Blink(Color.white);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: ef18d95d744f79046978ef973afc9e65