阶段性完成
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
using SLSFramework.UI;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cielonos.UI
|
||||
{
|
||||
public class BossArmorBar : AttributeBarBase
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0c1b96a081e25b347bcc1ea933e8d81a
|
||||
@@ -0,0 +1,10 @@
|
||||
using SLSFramework.UI;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cielonos.UI
|
||||
{
|
||||
public class BossEnergyBar : AttributeBarBase
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0bbae2c48c344864294bf391cfe233ea
|
||||
@@ -0,0 +1,23 @@
|
||||
using SLSFramework.General;
|
||||
using SLSFramework.UI;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI.Extensions.ColorPicker;
|
||||
|
||||
namespace Cielonos.UI
|
||||
{
|
||||
public class BossHealthBar : 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 03e5988a86ef307438dec5eaa2be5c92
|
||||
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Cielonos.MainGame.Characters;
|
||||
using SLSFramework.UI;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cielonos.UI
|
||||
{
|
||||
public partial class BossInfoUIArea : UIElementBase
|
||||
{
|
||||
public GameObject infoUnitPrefab;
|
||||
public List<BossInfoUnit> bossInfoUnits;
|
||||
|
||||
public void CreateInfoUnit(CharacterBase boss)
|
||||
{
|
||||
BossInfoUnit unit = Instantiate(infoUnitPrefab, transform).GetComponent<BossInfoUnit>();
|
||||
unit.Initialize(boss);
|
||||
bossInfoUnits.Add(unit);
|
||||
}
|
||||
|
||||
public void RemoveInfoUnit(CharacterBase boss)
|
||||
{
|
||||
BossInfoUnit unitToRemove = null;
|
||||
foreach (var unit in bossInfoUnits.Where(unit => unit.bossCharacter == boss))
|
||||
{
|
||||
unitToRemove = unit;
|
||||
break;
|
||||
}
|
||||
|
||||
if (unitToRemove != null)
|
||||
{
|
||||
bossInfoUnits.Remove(unitToRemove);
|
||||
Destroy(unitToRemove.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public partial class BossInfoUIArea
|
||||
{
|
||||
|
||||
public BossInfoUnit this[CharacterBase boss] => bossInfoUnits.FirstOrDefault(unit => unit.bossCharacter == boss);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 007806af29ee211448f10779ca372faa
|
||||
@@ -0,0 +1,70 @@
|
||||
using Cielonos.MainGame.Characters;
|
||||
using Cielonos.MainGame.Characters.Buffs;
|
||||
using SLSFramework.UI;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cielonos.UI
|
||||
{
|
||||
public class BossInfoUnit : UIElementBase
|
||||
{
|
||||
public CharacterBase bossCharacter;
|
||||
public TMP_Text nameText;
|
||||
public RectTransform barContainer;
|
||||
public BossHealthBar healthBar;
|
||||
public BossArmorBar armorBar;
|
||||
public BossEnergyBar energyBar;
|
||||
|
||||
public void Initialize(CharacterBase character)
|
||||
{
|
||||
bossCharacter = character;
|
||||
nameText.text = "Nexus Crab"; //TODO: 后续改为读取角色名称
|
||||
UpdateHealth(true);
|
||||
UpdateArmor(true);
|
||||
UpdateEnergy(true);
|
||||
}
|
||||
|
||||
public void UpdateHealth(bool isInstant = false)
|
||||
{
|
||||
float currentHealth = bossCharacter.attributeSm["Health"];
|
||||
float maximumHealth = bossCharacter.attributeSm["MaximumHealth"];
|
||||
float ratio = currentHealth / maximumHealth;
|
||||
Color fillColor = healthBar.GetTargetColor(ratio);
|
||||
healthBar.UpdateFillImage(currentHealth, maximumHealth);
|
||||
healthBar.UpdateFillColor(fillColor, isInstant);
|
||||
if(!isInstant) healthBar.Blink(Color.white);
|
||||
}
|
||||
|
||||
public void UpdateArmor(bool isInstant = false)
|
||||
{
|
||||
if (bossCharacter.buffSm.TryGetBuff(out GeneralIncapacitation incapacitation))
|
||||
{
|
||||
float remainingTime = incapacitation.independentStackSubmodule.LongestUnit.remainingTime;
|
||||
float maximumTime = incapacitation.independentStackSubmodule.LongestUnit.duration;
|
||||
armorBar.UpdateFillColor(new Color(1, 0.3f, 0.3f), true);
|
||||
armorBar.UpdateFillImage(remainingTime, maximumTime);
|
||||
armorBar.gameObject.SetActive(true);
|
||||
return;
|
||||
}
|
||||
|
||||
float currentArmor = 100;
|
||||
if (bossCharacter.buffSm.TryGetBuff(out ElectronicDisturbance buff))
|
||||
{
|
||||
currentArmor = 100 - buff.unitedStackSubmodule.stackAmount;
|
||||
}
|
||||
float maximumArmor = 100;
|
||||
armorBar.UpdateFillColor(new Color(1, 0.78f, 0.58f), true);
|
||||
armorBar.UpdateFillImage(currentArmor, maximumArmor);
|
||||
//armorBar.gameObject.SetActive(currentArmor < maximumArmor);
|
||||
if(!isInstant) armorBar.Blink(Color.white);
|
||||
}
|
||||
|
||||
public void UpdateEnergy(bool isInstant = false)
|
||||
{
|
||||
float currentEnergy = bossCharacter.attributeSm["Energy"];
|
||||
float maximumEnergy = bossCharacter.attributeSm["MaximumEnergy"];
|
||||
energyBar.UpdateFillImage(currentEnergy, maximumEnergy);
|
||||
if(!isInstant) energyBar.Blink(Color.white);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4642970701976654bb4f955663cc70b3
|
||||
Reference in New Issue
Block a user