From 63133cf5403a9d7fbe3811d20c3d24f26a752449 Mon Sep 17 00:00:00 2001 From: chenxin <chenxin6991@163.com> Date: Thu, 22 Oct 2020 16:06:35 +0800 Subject: [PATCH] 无尽模式,添加法阵展示和结算界面滑动列表 --- Assets/Scripts/TowerDefense/UI/EndlessBossHPManager.cs | 63 +++++++++++++++++++++---------- 1 files changed, 43 insertions(+), 20 deletions(-) diff --git a/Assets/Scripts/TowerDefense/UI/EndlessBossHPManager.cs b/Assets/Scripts/TowerDefense/UI/EndlessBossHPManager.cs index bb97cca..b8fef50 100644 --- a/Assets/Scripts/TowerDefense/UI/EndlessBossHPManager.cs +++ b/Assets/Scripts/TowerDefense/UI/EndlessBossHPManager.cs @@ -1,9 +1,8 @@ using UnityEngine.UI; -using System.Collections; -using System.Collections.Generic; using UnityEngine; using Core.Utilities; using DG.Tweening; +using TMPro; /** * 无尽模式boss血量管理器 @@ -24,16 +23,12 @@ /// </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> /// 当前的进度值 @@ -57,7 +52,17 @@ 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() @@ -101,7 +106,7 @@ target = 1f; HPImage1.fillAmount = 1; HPImage2.fillAmount = 1; - index = index % colorArr.Length; + index = index % count; } /// <summary> @@ -112,7 +117,7 @@ { tween.Pause(); HPImage2.fillAmount = 0; - index = ++index % colorArr.Length; + index = ++index % count; ChangeHPImageIndex(); ResetProgress(); SetHPColor(end); @@ -134,7 +139,16 @@ /// <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> @@ -160,14 +174,23 @@ { 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; + } } } \ No newline at end of file -- Gitblit v1.9.1