| | |
| | | using UnityEngine.UI; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using Core.Utilities; |
| | | using DG.Tweening; |
| | | using TMPro; |
| | | |
| | | /** |
| | | * 无尽模式boss血量管理器 |
| | |
| | | /// </summary> |
| | | public Image HPImage2; |
| | | |
| | | private Color[] colorArr = |
| | | { |
| | | new Color(1, 0, 0), // "#FF0000" |
| | | new Color(1, 165 / 255f, 0), // "#FFA500" |
| | | new Color(1, 1, 0), // "#FFFF00" |
| | | new Color(0, 1, 0), // "#00FF00" |
| | | new Color(0, 1, 1), // "#00FFFF" |
| | | new Color(0, 0, 1), // "#0000FF" |
| | | new Color(128 / 255f, 0, 128 / 255f) // "#800080" |
| | | }; |
| | | private string path = "UI/Endless/Blood/"; |
| | | |
| | | /// <summary> |
| | | /// 血条底图 |
| | | /// </summary> |
| | | public Sprite BaseBlood; |
| | | |
| | | /// <summary> |
| | | /// 当前的进度值 |
| | |
| | | |
| | | private Tween tween; |
| | | |
| | | public Text WaveNumText; |
| | | public TextMeshProUGUI WaveNumText; |
| | | |
| | | /// <summary> |
| | | /// 血条7种颜色 |
| | | /// </summary> |
| | | private int count = 7; |
| | | |
| | | /// <summary> |
| | | /// boss信息,名字和等级 |
| | | /// </summary> |
| | | public Text BossInfo; |
| | | |
| | | // Start is called before the first frame update |
| | | private void Start() |
| | |
| | | target = 1f; |
| | | HPImage1.fillAmount = 1; |
| | | HPImage2.fillAmount = 1; |
| | | index = index % colorArr.Length; |
| | | index = index % count; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | tween.Pause(); |
| | | HPImage2.fillAmount = 0; |
| | | index = ++index % colorArr.Length; |
| | | index = ++index % count; |
| | | ChangeHPImageIndex(); |
| | | ResetProgress(); |
| | | SetHPColor(end); |
| | |
| | | /// <param name="wave"></param> |
| | | public void UpdateWave(int wave) |
| | | { |
| | | WaveNumText.text = $"×{wave}"; |
| | | WaveNumText.text = $"x{wave}"; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 设置boss信息 |
| | | /// </summary> |
| | | /// <param name="info"></param> |
| | | public void SetBossInfo(string info) |
| | | { |
| | | BossInfo.text = info; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | if (end) |
| | | { |
| | | HPImage2.color = colorArr[index]; |
| | | HPImage1.color = Color.white; |
| | | HPImage2.sprite = GetSprite(index); |
| | | HPImage1.sprite = Resources.Load($"{path}di", typeof(Sprite)) as Sprite; |
| | | } |
| | | else |
| | | { |
| | | HPImage2.color = colorArr[index]; |
| | | HPImage1.color = colorArr[(index + 1) % colorArr.Length]; |
| | | HPImage2.sprite = GetSprite(index); |
| | | HPImage1.sprite = GetSprite((index + 1) % count); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据索引获得sprite |
| | | /// </summary> |
| | | /// <param name="index"></param> |
| | | private Sprite GetSprite(int index) |
| | | { |
| | | return Resources.Load($"{path}{index}", typeof(Sprite)) as Sprite; |
| | | } |
| | | } |
| | | } |