123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- /// <summary>
- /// 这里主要处理和登录相关的UI
- ///
- /// </summary>
- public class PopUIManager : MonoBehaviour {
- [SerializeField]
- private PopBase[] popAry;//所有的POP弹框
- private Dictionary<PopType, PopBase> popDict = new Dictionary<PopType, PopBase>();
- void Start () {
- InitPops();
- MessageCenterController.Instance.Register(GameEnum.MESSAGE_ENTER_COURSE, EnterCourse);//创建房间后 进入房间
- MessageCenterController.Instance.Register(GameEnum.MESSAGE_EXIT_COURSE, ExitCourse);//退出房间
- MessageCenterController.Instance.Register(GameEnum.MESSAGE_SHOW_RECONNECT_POP, ShowReConnect);//重连
- MessageCenterController.Instance.Register(GameEnum.MESSAGE_SHOW_LOGOUT, ShowLogOut);//登出
- MessageCenterController.Instance.Register(GameEnum.MESSAGE_RESET_ACCOUNT, ShowResetLogin);//账号重置
- MessageCenterController.Instance.Register(GameEnum.MESSAGE_SHOW_MSG_POP, ShowMsgPop);//消息提示框弹出
- MessageCenterController.Instance.Register(GameEnum.MESSAGE_SHOW_CHANGE_CONFIRM_POP, ShowChangeConfirm);
- MessageCenterController.Instance.Register(GameEnum.MESSAGE_SHOW_IMAGE_POP, ShowImagePop);
- MessageCenterController.Instance.Register(GameEnum.MESSAGE_HIDE_IMAGE_POP, HIdeImagePop);
- MessageCenterController.Instance.Register(GameEnum.MESSAGE_HIDE_POP_BY_TYPE, HidePop);//影藏弹框
- MessageCenterController.Instance.Register(GameEnum.MESSAGE_SHOW_POP_BY_TYPE, ShowPop);//显示弹框
- }
- private void OnDestroy()
- {
- MessageCenterController.Instance.UnRegister(GameEnum.MESSAGE_ENTER_COURSE, EnterCourse);//创建房间后 进入房间
- MessageCenterController.Instance.UnRegister(GameEnum.MESSAGE_SHOW_RECONNECT_POP, ShowReConnect);//重连
- MessageCenterController.Instance.UnRegister(GameEnum.MESSAGE_SHOW_LOGOUT, ShowLogOut);//登出
- MessageCenterController.Instance.UnRegister(GameEnum.MESSAGE_RESET_ACCOUNT, ShowResetLogin);//账号重置
- MessageCenterController.Instance.UnRegister(GameEnum.MESSAGE_SHOW_MSG_POP, ShowMsgPop);//消息提示框弹出
-
- MessageCenterController.Instance.UnRegister(GameEnum.MESSAGE_SHOW_CHANGE_CONFIRM_POP, ShowChangeConfirm);
- MessageCenterController.Instance.UnRegister(GameEnum.MESSAGE_SHOW_IMAGE_POP, ShowImagePop);
- MessageCenterController.Instance.UnRegister(GameEnum.MESSAGE_HIDE_IMAGE_POP, HIdeImagePop);
- MessageCenterController.Instance.UnRegister(GameEnum.MESSAGE_HIDE_POP_BY_TYPE, HidePop);//影藏弹框
- MessageCenterController.Instance.UnRegister(GameEnum.MESSAGE_SHOW_POP_BY_TYPE, ShowPop);//显示弹框
- }
- private void InitPops()
- {
- //初始化POP的列表
- for (int i = 0; i < popAry.Length; i++)
- {
- if (popDict.ContainsKey(popAry[i].MType))
- {
- CDebug.Log(popAry[i].name + " 类型异常");
- }
- else
- {
- if (popAry[i].MType == PopType.Login)
- {
- popAry[i].Show();
- }
- else
- {
- popAry[i].gameObject.SetActive(false);
- }
- popDict.Add(popAry[i].MType, popAry[i]);
- }
- }
- }
- private void SetPop(PopType t, bool v, System.Object datas = null)
- {
- if (v)
- {
- if (datas != null)
- {
- GetPopByType(t).Show(datas);
- }
- else
- {
- GetPopByType(t).Show();
- }
- }
- else
- {
- GetPopByType(t).Hide();
- }
- }
- private PopBase GetPopByType(PopType t)
- {
- //CDebug.Log(t.ToString());
- if(!popDict.ContainsKey(t))
- {
- CDebug.Log(t.ToString() + "不存在");
- }
- return popDict[t];
- }
- private void EnterCourse(System.Object datas = null)
- {
- SetPop(PopType.Login, false);
- SetPop(PopType.RoomList, false);
- SetPop(PopType.CourseList, false);
- }
- private void ExitCourse(System.Object datas = null)
- {
- SetPop(PopType.RoomList, true);
- HIdeImagePop(null);
- }
- //检查重连
- public void ShowReConnect(System.Object datas = null)
- {
- SetPop(PopType.Reconnect, true);
- }
- private void ShowImagePop(System.Object datas)
- {
- SetPop(PopType.Image, true, datas);
- }
- private void HIdeImagePop(System.Object datas)
- {
- SetPop(PopType.Image, false);
- }
- private void ShowMsgPop(System.Object datas = null)
- {
- SetPop(PopType.Msg, true, datas);
- }
- //切换房主
- private void ShowChangeConfirm(System.Object datas = null)
- {
- SetPop(PopType.ChangeMaster, true, datas);
- }
- private void ShowLogOut(System.Object data = null)
- {
- SetPop(PopType.Login, true, true);
- SetPop(PopType.Msg, true, "账号登出");
- SetPop(PopType.RoomList, false);
- SetPop(PopType.CourseList, false);
- }
- public void ShowResetLogin(System.Object data = null)
- {
- SetPop(PopType.Login, true, true);
- SetPop(PopType.RoomList, false);
- SetPop(PopType.CourseList, false);
- }
- private void ShowNotice(System.Object data = null)
- {
- //CDebug.Log("ShowNotice-->" + data.ToString());
- SetPop(PopType.BadConnecting, true, data);
- }
- private void HideNotice(System.Object data = null)
- {
- //CDebug.Log("HideNotice-->");
- SetPop(PopType.BadConnecting, false, data);
- }
- private void ShowAnswerPop(System.Object datas = null)
- {
- SetPop(PopType.Answer, true, datas);
- }
- private void HideAnswerPop(System.Object datas = null)
- {
- SetPop(PopType.Answer, false);
- }
- private void HidePop(System.Object data = null)
- {
- PopType t = (PopType)data;
- SetPop(t, false);
- }
- private void ShowPop(System.Object data = null)
- {
- ShowPopData t = data as ShowPopData;
- SetPop(t.t, true, t.data);
- }
- }
|