using Protobuf;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
using Core.Utilities;
|
using TowerDefense.Level;
|
|
/**
|
* 无尽模式查看已经获得道具
|
* @Author: chenxin
|
* @Date: 2020-10-19 16:53:29
|
*/
|
namespace KTGMGemClient
|
{
|
public class EndlessViewObtainedProps : Singleton<EndlessViewObtainedProps>
|
{
|
/// <summary>
|
/// 奖励信息界面
|
/// </summary>
|
public GameObject RewardInfoUI;
|
|
/// <summary>
|
/// 初级宝箱文本
|
/// </summary>
|
public Text PrimaryTreasure;
|
|
/// <summary>
|
/// 中级宝箱文本
|
/// </summary>
|
public Text MiddleTreasure;
|
|
/// <summary>
|
/// 高级宝箱文本
|
/// </summary>
|
public Text AdvancedTreasure;
|
|
/// <summary>
|
/// 钻石文本
|
/// </summary>
|
public Text Gold;
|
|
/// <summary>
|
/// 奖励信息界面是否正在展示
|
/// </summary>
|
private bool isShow;
|
|
private int[] countArr = { 0, 0, 0, 0 };
|
|
// Start is called before the first frame update
|
private void Start()
|
{
|
EndlessDropManager.instance.ObtainDropEvent += OnObtainDrop;
|
}
|
|
private void OnEnable()
|
{
|
RewardInfoUI.SetActive(false);
|
isShow = false;
|
}
|
|
public void OnClick()
|
{
|
AudioSourceManager.Ins.Play(AudioEnum.UI);
|
|
isShow = !isShow;
|
|
if (isShow) Refresh();
|
|
RewardInfoUI.SetActive(isShow);
|
}
|
|
/// <summary>
|
/// 刷新掉落奖励界面
|
/// </summary>
|
private void Refresh()
|
{
|
CalculateCount();
|
PrimaryTreasure.text = $"初级宝箱×{countArr[0]}";
|
MiddleTreasure.text = $"中级宝箱×{countArr[1]}";
|
AdvancedTreasure.text = $"高级宝箱×{countArr[2]}";
|
Gold.text = $"钻石×{countArr[3]}";
|
}
|
|
/// <summary>
|
/// 重新统计数量
|
/// </summary>
|
private void CalculateCount()
|
{
|
// 统计数量
|
int[] arr = { 0, 0, 0, 0 };
|
List<EndlessDrop> list = EndlessDropManager.instance.GetAllObtainedDrop();
|
|
for (int i = 0; i < list.Count; ++i)
|
{
|
switch (list[i].Reward.type)
|
{
|
case CURRENCY.Gold:
|
arr[3] += list[i].Reward.count;
|
break;
|
case CURRENCY.Box:
|
arr[list[i].Reward.id - 1] += list[i].Reward.count;
|
break;
|
}
|
}
|
|
countArr = arr;
|
}
|
|
/// <summary>
|
/// 获得掉落
|
/// </summary>
|
public void OnObtainDrop(EndlessDrop data)
|
{
|
if (RewardInfoUI.activeInHierarchy) Refresh();
|
}
|
}
|
}
|