202 lines
5.4 KiB
C#
202 lines
5.4 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Games.GlobeDefine;
|
|
using GCGame;
|
|
using Module.Log;
|
|
using GCGame.Table;
|
|
using System;
|
|
|
|
public class MessageTips : MonoBehaviour
|
|
{
|
|
public enum MsgType
|
|
{
|
|
Dual, //切磋
|
|
Team, //邀请入队
|
|
BOSS, //BOSS复活提示
|
|
}
|
|
|
|
public delegate void Invate_Fun(object[] param);
|
|
|
|
public class TipDatas
|
|
{
|
|
public MsgType m_type;
|
|
public string tips;
|
|
public float startTime;
|
|
public object[] param;
|
|
public Invate_Fun OkBack;
|
|
public Invate_Fun CancleBack;
|
|
public Invate_Fun TimeOutBack;
|
|
}
|
|
|
|
private static List<TipDatas> tipLists = new List<TipDatas>();
|
|
public static void ClearTypeData(MsgType type)
|
|
{
|
|
List<TipDatas> removes = new List<TipDatas>();
|
|
for (int i = 0; i < tipLists.Count; i++)
|
|
{
|
|
if (tipLists[i].m_type == type)
|
|
removes.Add(tipLists[i]);
|
|
}
|
|
for (int i = 0; i < removes.Count; i++)
|
|
{
|
|
tipLists.Remove(removes[i]);
|
|
}
|
|
}
|
|
public static void OpenOKCancelBox(int type,string tip,bool TimeDown,Invate_Fun OkBack, Invate_Fun CancleBack, Invate_Fun TimeOutBack, object[] param)
|
|
{
|
|
TipDatas data = new TipDatas();
|
|
data.tips = tip;
|
|
data.m_type = (MsgType)type;
|
|
if (TimeDown)
|
|
data.startTime = Time.realtimeSinceStartup;
|
|
else
|
|
data.startTime = -1;
|
|
data.OkBack = OkBack;
|
|
data.CancleBack = CancleBack;
|
|
data.TimeOutBack = TimeOutBack;
|
|
data.param = param;
|
|
|
|
//默认要把BOSS放在最底层
|
|
if (data.m_type == MsgType.BOSS && tipLists.Count>0)
|
|
{
|
|
int index = 0;
|
|
for (; index < tipLists.Count; index++)
|
|
{
|
|
//排除BOSS提示重复添加
|
|
if (tipLists[index].m_type == MsgType.BOSS && tipLists[index].param.Length>0 && param.Length>0 && object.Equals( param[0], tipLists[index].param[0]))
|
|
{
|
|
tipLists.RemoveAt(index);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (data.m_type == MsgType.BOSS && param.Length > 0)
|
|
tipLists.Insert(0, data);
|
|
if (data.m_type != MsgType.BOSS)
|
|
tipLists.Add(data);
|
|
UIManager.ShowUI(UIInfo.MessageTips,delegate(bool bSuccess, object param1)
|
|
{
|
|
if(bSuccess)
|
|
{
|
|
MessageTips tipMsg = UIManager.GetUIComponent<MessageTips>(UIInfo.MessageTips);
|
|
if (tipMsg != null)
|
|
tipMsg.UpdateInvate();
|
|
}
|
|
});
|
|
}
|
|
|
|
void OnEnable()
|
|
{
|
|
UpdateInvate();
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
if (_CurrShowTipData!=null)
|
|
{
|
|
if (_CurrShowTipData.startTime > 0 && Time.realtimeSinceStartup - _CurrShowTipData.startTime > 30)
|
|
{
|
|
GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{4911}"));
|
|
if (InvateTimeOut != null)
|
|
InvateTimeOut(_CurrShowTipData.param);
|
|
RemoveInvate();
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void OnBtnClose()
|
|
{
|
|
tipLists.Clear();
|
|
UIManager.CloseUI(UIInfo.MessageTips);
|
|
}
|
|
|
|
public GameObject MainWnd;
|
|
public Text InvateMsg;
|
|
Invate_Fun InvateOK;
|
|
Invate_Fun InvateCancle;
|
|
Invate_Fun InvateTimeOut;
|
|
|
|
public void UpdateInvate()
|
|
{
|
|
if (tipLists.Count == 0)
|
|
{
|
|
OnBtnClose();
|
|
return;
|
|
}
|
|
InvateOK = null;
|
|
InvateCancle = null;
|
|
InvateTimeOut = null;
|
|
PushOneTip(tipLists[tipLists.Count - 1]);
|
|
}
|
|
|
|
private TipDatas _CurrShowTipData = null;
|
|
public void PushOneTip(TipDatas data)
|
|
{
|
|
_CurrShowTipData = data;
|
|
InvateMsg.text = data.tips;
|
|
InvateOK = data.OkBack;
|
|
InvateCancle = data.CancleBack;
|
|
InvateTimeOut = data.TimeOutBack;
|
|
}
|
|
|
|
public void OnBtnInvateOk()
|
|
{
|
|
if(_CurrShowTipData!=null)
|
|
{
|
|
if(_CurrShowTipData.startTime > 0 && Time.realtimeSinceStartup - _CurrShowTipData.startTime > 30)
|
|
{
|
|
GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{4911}"));
|
|
RemoveInvate();
|
|
return;
|
|
}
|
|
if (InvateOK != null)
|
|
InvateOK(_CurrShowTipData.param);
|
|
}
|
|
|
|
RemoveInvate();
|
|
}
|
|
|
|
public void OnBtnInvateCancel()
|
|
{
|
|
if (InvateCancle != null && _CurrShowTipData!=null)
|
|
InvateCancle(_CurrShowTipData.param);
|
|
RemoveInvate(false);
|
|
}
|
|
|
|
private void RemoveInvate(bool RemoveTypeAll = true)
|
|
{
|
|
MsgType type = _CurrShowTipData.m_type;
|
|
if (tipLists.Count>0)
|
|
{
|
|
if(RemoveTypeAll)
|
|
{
|
|
ClearTypeData(type);
|
|
}
|
|
else
|
|
{
|
|
tipLists.Remove(_CurrShowTipData);
|
|
}
|
|
}
|
|
_CurrShowTipData = null;
|
|
if (type == MsgType.Team)
|
|
{
|
|
MainWnd.SetActive(false);
|
|
StopCoroutine(TeamCallBack());
|
|
StartCoroutine(TeamCallBack());
|
|
return;
|
|
}
|
|
UpdateInvate();
|
|
}
|
|
|
|
IEnumerator TeamCallBack()
|
|
{
|
|
yield return new WaitForSeconds(0.6f);
|
|
MainWnd.SetActive(true);
|
|
UpdateInvate();
|
|
}
|
|
}
|