122 lines
3.6 KiB
C#
122 lines
3.6 KiB
C#
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using GCGame.Table;
|
|||
|
using Games.ImpactModle;
|
|||
|
using System.Collections;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine.EventSystems;
|
|||
|
using Games.Events;
|
|||
|
using Games.LogicObj;
|
|||
|
|
|||
|
public class ImpactInfoItem : UIItemBase
|
|||
|
{
|
|||
|
public Text Name;
|
|||
|
public Text LeaveTime;
|
|||
|
public Image Icon;
|
|||
|
public Text Miaoshu;
|
|||
|
public Text Num;
|
|||
|
|
|||
|
ClientImpactInfo m_ImpactInfo = null;
|
|||
|
|
|||
|
IEnumerator UpdateOnePre()
|
|||
|
{
|
|||
|
while(true)
|
|||
|
{
|
|||
|
yield return new WaitForSeconds(1);
|
|||
|
if (m_ImpactInfo == null)
|
|||
|
yield break;
|
|||
|
if(m_ImpactInfo.RemainTime - Time.realtimeSinceStartup<0)
|
|||
|
{
|
|||
|
Hide();
|
|||
|
break;
|
|||
|
}
|
|||
|
LeaveTime.text = GetTimeStr(m_ImpactInfo.RemainTime - Time.realtimeSinceStartup);
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
public override void Show(Hashtable hash)
|
|||
|
{
|
|||
|
base.Show();
|
|||
|
m_ImpactInfo = (ClientImpactInfo)hash["InitObj"];
|
|||
|
ShowItem(m_ImpactInfo);
|
|||
|
}
|
|||
|
|
|||
|
public void ShowItem(ClientImpactInfo impactInfo )
|
|||
|
{
|
|||
|
Tab_Impact _tabImpact = TableManager.GetImpactByID(impactInfo.ImpactId, 0);
|
|||
|
if(_tabImpact==null)
|
|||
|
{
|
|||
|
Hide();
|
|||
|
return;
|
|||
|
}
|
|||
|
StopCoroutine(UpdateOnePre());
|
|||
|
Name.text = _tabImpact.Name;
|
|||
|
if (impactInfo.m_BuffDescribe != "")
|
|||
|
{
|
|||
|
Miaoshu.text = impactInfo.m_BuffDescribe;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
Miaoshu.text = _tabImpact.Instruction;
|
|||
|
}
|
|||
|
if (_tabImpact.IsForever == 1 || impactInfo.IsForever == true)
|
|||
|
{
|
|||
|
LeaveTime.text = StrDictionary.GetClientDictionaryString("#{2890}");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
// 解决在紫禁之巅中 隐身 Buff 倒计时的问题,其它场景先不管
|
|||
|
if (GameManager.gameManager.m_RunningScene == 658 && impactInfo.ImpactId == 4308)
|
|||
|
{
|
|||
|
LeaveTime.text = GetTimeStr(impactInfo.RemainTime - Time.realtimeSinceStartup);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
LeaveTime.text = GetTimeStr(impactInfo.RemainTime - Time.realtimeSinceStartup - 1);
|
|||
|
}
|
|||
|
StartCoroutine(UpdateOnePre());
|
|||
|
}
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(Icon, _tabImpact.BuffIcon);
|
|||
|
if (_tabImpact.MaxOverlayCount != -1)
|
|||
|
{
|
|||
|
Num.gameObject.SetActive(true);
|
|||
|
Num.text = impactInfo.AddNum.ToString();
|
|||
|
}
|
|||
|
else
|
|||
|
Num.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
public string GetTimeStr(float timeSeconds)
|
|||
|
{
|
|||
|
int day = 0;
|
|||
|
int hour = 0;
|
|||
|
int minute = 0;
|
|||
|
int second = 0;
|
|||
|
if (timeSeconds <= 0)
|
|||
|
{
|
|||
|
return StrDictionary.GetClientDictionaryString("#{1648}", 0, 0);
|
|||
|
}
|
|||
|
day = Mathf.FloorToInt(timeSeconds / (3600 * 24));
|
|||
|
hour = Mathf.FloorToInt((timeSeconds - day * 3600 * 24) / 3600);
|
|||
|
minute = Mathf.FloorToInt((timeSeconds - day * 3600 * 24 - hour * 3600) / 60);
|
|||
|
second = Mathf.FloorToInt(timeSeconds - day * 3600 * 24 - hour * 3600 - minute * 60);
|
|||
|
string result = "";
|
|||
|
if (day > 0)
|
|||
|
result = string.Format("{0}{1}" + StrDictionary.GetClientDictionaryString("#{9906}"), result, day);
|
|||
|
if (hour > 0)
|
|||
|
result = string.Format("{0}{1}" + StrDictionary.GetClientDictionaryString("#{9903}"), result, hour);
|
|||
|
result = string.Format("{0}{1}" + StrDictionary.GetClientDictionaryString("#{9904}"), result, minute);
|
|||
|
result = string.Format("{0}{1}" + StrDictionary.GetClientDictionaryString("#{9905}"), result, second);
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
}
|