using UnityEngine.UI;
|
using System.Collections;
|
using TowerDefense.Level;
|
using System.Collections.Generic;
|
using UnityEngine;
|
|
/**
|
* 无尽模式buff预览
|
* @Author: chenxin
|
* @Date: 2020-11-12 10:01:36
|
*/
|
namespace KTGMGemClient
|
{
|
public class EndlessBuffPreview : MonoBehaviour
|
{
|
public GameObject Panel;
|
|
private bool isShow;
|
|
private string iconPath = "UI/Endless/BuffPreviewIcon/buff_";
|
|
public List<GameObject> ItemList;
|
|
public List<Image> IconList;
|
|
public List<Text> TextList;
|
|
private string[] elementNameArr = { "火", "水", "木" };
|
|
// Start is called before the first frame update
|
private void Start()
|
{
|
GetComponent<Button>().onClick.AddListener(OnClick);
|
EventCenter.Ins.Add((int)KTGMGemClient.EventType.EndlessBuffRefresh, Refresh);
|
ShowPanel();
|
}
|
|
public void OnClick()
|
{
|
ShowPanel();
|
}
|
|
private void ShowPanel()
|
{
|
if (isShow)
|
Refresh();
|
Panel.SetActive(isShow);
|
isShow = !isShow;
|
}
|
|
private void Refresh()
|
{
|
List<EndlessBuffConfig> buffList = EndlessBuffManager.instance.BuffList;
|
// 0.火 1.水 2.木
|
int[] addArr = { 0, 0, 0 };
|
|
for (int i = 0; i < buffList.Count; ++i)
|
{
|
// 只统计了加攻击力的
|
if (buffList[i].EffectType != EndlessBuffEffectType.Attack) continue;
|
|
switch (buffList[i].UseTarget)
|
{
|
case EndlessBuffUseTarget.All:
|
addArr[0] += buffList[i].Config.buff_effect[1];
|
addArr[1] += buffList[i].Config.buff_effect[1];
|
addArr[2] += buffList[i].Config.buff_effect[1];
|
break;
|
case EndlessBuffUseTarget.Element:
|
addArr[buffList[i].Config.target_type[1] - 1] += buffList[i].Config.buff_effect[1];
|
break;
|
case EndlessBuffUseTarget.Designated:
|
break;
|
}
|
}
|
|
int count = 0;
|
|
for (int i = 0; i < addArr.Length; ++i)
|
{
|
if (addArr[i] == 0) continue;
|
|
ItemList[count].SetActive(true);
|
Sprite sp = Resources.Load<Sprite>($"{iconPath}{i + 1}");
|
IconList[count].sprite = sp;
|
TextList[count].text = $"{elementNameArr[i]}精灵攻击+{addArr[i]}%";
|
++count;
|
}
|
|
for (; count < 3; ++count)
|
{
|
ItemList[count].SetActive(false);
|
}
|
}
|
}
|
}
|