// Author: whc // Desc: using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class TipsUI : UIBase { public Transform m_NodeHintTf; public Transform m_NodeDialogTf; public Transform m_NodeChoiceTf; private UnitPool m_HintPool; public UnitPool vHintPool { get { if (m_HintPool == null) m_HintPool = new UnitPool(m_NodeHintTf); return m_HintPool; } } private UnitPool m_DialogPool; public UnitPool vDailogPool { get { if (m_DialogPool == null) m_DialogPool = new UnitPool(m_NodeDialogTf); return m_DialogPool; } } private UnitPool m_ChoicePool; public UnitPool vChoicePool { get { if (m_ChoicePool == null) m_ChoicePool = new UnitPool(m_NodeChoiceTf); return m_ChoicePool; } } private UnitPool m_WaitPool; public UnitPool vWaitPool { get { if (m_WaitPool == null) m_WaitPool = new UnitPool(m_NodeHintTf); return m_WaitPool; } } public override void Awake() { base.Awake(); m_NodeHintTf = transform.Find("NodeHint"); m_NodeDialogTf = transform.Find("NodeDialog"); m_NodeChoiceTf = transform.Find("NodeChoice"); } private void OnEnable() { Inform.Listen(eInformId.TipDialog, ShowDialog); Inform.Listen(eInformId.TipHint, ShowHint); Inform.Listen(eInformId.TipChoice, ShowChoice); Inform.Listen(eInformId.TipWait, ShowWait); } private void OnDisable() { Inform.Cancel(eInformId.TipDialog, ShowDialog); Inform.Cancel(eInformId.TipHint, ShowHint); Inform.Cancel(eInformId.TipChoice, ShowChoice); Inform.Cancel(eInformId.TipWait, ShowWait); } //bool isShowOutGame = false; //bool isCheckWhenBack = false; //void OnApplicationFocus(bool _focus) //{ // //Debug.Log("OnApplicationFocus _focus:"+ _focus.ToString()); // if(_focus) // { // if (!isCheckWhenBack) // return; // isCheckWhenBack = false; // isShowOutGame = true; // if (!Game.Instance.GetNet().IsLoop()) // return; // if (!Game.Instance.GetNet().IsConnected()) // { // Game.Instance.GetNet().ShowReconnectTips(); // //Tips.Instance.SafeShowChoice("失去网络链接, 是否重连?", ReConnect, ExitWork); // } // } // else // { // isCheckWhenBack = true; // if (!isShowOutGame) // return; // Debug.Log("请不要离开太久, 否则会中断服务器链接."); // //Tips.Instance.ShowHint("请不要离开太久, 否则会中断服务器链接."); // } //} public void GameExit() { Application.Quit(); } int m_lastFrame = 0; private void Update() { if (m_lastFrame < 8) { m_lastFrame++; return; } m_lastFrame = 0; if (Tips.Instance.SafeTipQue.Count <= 0) return; SwitchTipDataShow(Tips.Instance.SafeTipQue.Dequeue()); } public void SwitchTipDataShow(TipData _Data) { switch (_Data.m_type) { case eTipType.Hint: ShowHint(_Data); break; case eTipType.Dialog: ShowDialog(_Data); break; case eTipType.Choice: ShowChoice(_Data); break; case eTipType.Wait: ShowWait(_Data); break; default: Debug.LogError("not switch (_Data.m_type). type:" + _Data.m_type.ToString()); break; } } public void ShowDialog(TipData _Data) { TipDialogUnit vUnit = vDailogPool.GetAnyHide(); vUnit.Refresh(_Data); } public void ShowHint(TipData _Data) { TipHintUnit vUnit = vHintPool.GetAnyHide(); vUnit.Refresh(_Data); } public void ShowChoice(TipData _Data) { TipChoiceUnit vUnit = vChoicePool.GetAnyHide(); vUnit.Refresh(_Data); } public void ShowWait(TipData _Data) { TipWaitUnit vUnit = vWaitPool.GetAnyHide(); vUnit.Refresh(_Data); } }