123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class PopRoomGroup : PopBase {
- [SerializeField]
- private TextMesh SchoolNameText;
- [SerializeField]
- private TextMesh IDNameText;
- [SerializeField]
- private TextMesh UserNameText;
- [SerializeField]
- private ItemListView ItemList;//本地课
- [SerializeField]
- private Game3DButton CreateBtn;//创建本校课按钮
- [SerializeField]
- private Game3DButton QuitBtn;//退出房间
- [SerializeField]
- private GameObject PrivateBg;
- [SerializeField]
- private GameObject PublicBg;
- protected override void Awake()
- {
- base.Awake();
- }
- protected override void Start () {
- base.Start();
- ItemList.InitClick(ItemClick);
- if (CreateBtn != null)
- CreateBtn.onClick.AddListener(CreateClick);
- QuitBtn.onClick.AddListener(QuitClick);
- MessageCenterController.Instance.Register(GameEnum.MESSAGE_REFRESH_ROOM_LIST_VIEW, RefreshListen);
- }
- protected override void OnDestroy()
- {
- base.OnDestroy();
- if (CreateBtn != null)
- CreateBtn.onClick.RemoveListener(CreateClick);
- QuitBtn.onClick.RemoveListener(QuitClick);
- MessageCenterController.Instance.UnRegister(GameEnum.MESSAGE_REFRESH_ROOM_LIST_VIEW, RefreshListen);
- }
- private string school_name_str = "{0}({1})";
- private string id_name_str = "用户id: {0}";
- private string user_name_str = "用户名: {0}";
- public override void Show()
- {
- base.Show();
- //这里要区别一下 当前是哪个服务器
- if (GameServerInfo.Instance.CurServer.serverType == ServerType.Public)
- {
- CreateBtn.gameObject.SetActive(GamePlayerData.Instance.RootCreatePublic);
- }
- else
- {
- CreateBtn.gameObject.SetActive(GamePlayerData.Instance.IsMaster);
- }
- string tipStr = GameServerInfo.Instance.CurServer.serverType == ServerType.Public ? "全国": "本地";
- if (PlayerPrefs.HasKey("SocketUrl"))
- {
- if (PlayerPrefs.GetInt("SocketUrl") == 1)
- {
- tipStr = "本地";
- }
- else
- {
- tipStr = "云端";
- }
- }
- SchoolNameText.text = string.Format(school_name_str, GamePlayerData.Instance.school_name, tipStr);
- IDNameText.text = string.Format(id_name_str, GamePlayerData.Instance.user_id);
- UserNameText.text = string.Format(user_name_str, GamePlayerData.Instance.user_name);
- InitItemList();
- PublicBg.SetActive(GameServerInfo.Instance.CurServer.serverType == ServerType.Public);
- PrivateBg.SetActive(GameServerInfo.Instance.CurServer.serverType == ServerType.Private);
- //IvChatManager.Instance.QueryRoom();//进来的时候需要刷新的
- }
- //框体类型
- public override PopType MType { get { return PopType.RoomList; } }
- private void TabClick()
- {
- RefreshItemList();
- }
- private void InitItemList()
- {
- if (ItemList != null)
- {
- if(GameServerInfo.Instance.CurServer.serverType == ServerType.Public)
- {
- ItemList.InitInfo(GamePlayerData.Instance.room_data.PublicList.ToArray());
- }
- else
- {
- ItemList.InitInfo(GamePlayerData.Instance.room_data.PrivateList.ToArray());
- }
- }
- }
- private void RefreshItemList()
- {
- if (ItemList != null)
- {
- if (GameServerInfo.Instance.CurServer.serverType == ServerType.Public)
- {
- ItemList.RefreshInfo(GamePlayerData.Instance.room_data.PublicList.ToArray());
- }
- else
- {
- ItemList.RefreshInfo(GamePlayerData.Instance.room_data.PrivateList.ToArray());
- }
- }
- }
- private void CreateClick()
- {
- this.Hide();
- GamePlayerData.Instance.CreateRoomdata = new SocketRoomItemData();
- MessageCenterController.Instance.Broadcast(GameEnum.MESSAGE_SHOW_POP_BY_TYPE, new ShowPopData(PopType.SubjectList, null));
- }
- private void RefreshListen(System.Object data = null)
- {
- RefreshItemList();
- //IvChatManager.Instance.QueryRoom();
- }
- private void ItemClick(ItemViewBase item)
- {
- var data = item.ItemData as SocketOnlineRoomItemData;
- if(data == null)
- {
- return;
- }
- RoomItemView view = item as RoomItemView;
- if(data.onlineCt >= view.CurMaxCt)
- {
- MessageCenterController.Instance.Broadcast(GameEnum.MESSAGE_SHOW_MSG_POP, "房间内人数已达到上限");
- return;
- }
- CDebug.Log("这里应该选择个弹出窗口 提示进入或者取消" + data.room_id);
- GamePlayerData.Instance.room_data.CurRoomId = data.room_id;
- //获取课程信息
- MessageCenterController.Instance.Register(GameEnum.MESSAGE_HTTP_COURSE_DATA_BACK, CourseLoadOK);
- HttpStaticMessage.SendHttpQuestion(GamePlayerData.Instance.user_id, GamePlayerData.Instance.room_data.CurOnlineData.course_id);
- //同时进入语音
- Debug.Log("data.owner_name" + data.owner_name);
- //IvChatManager.Instance.JoinRoomById(data.owner_name.ToString());
- }
- private void CourseLoadOK(System.Object datas)
- {
- MessageCenterController.Instance.UnRegister(GameEnum.MESSAGE_HTTP_COURSE_DATA_BACK, CourseLoadOK);
- MessageCenterController.Instance.Broadcast(GameEnum.MESSAGE_ENTER_COURSE);
- UIDataManager.Instance.ClearAll();//提前清除房间的数据
- GameNetManager.Instance.mSocketMsgCenter.PlayerEnterRoom(GamePlayerData.Instance.room_data.CurRoomId, true);
- }
- private void QuitClick()
- {
- this.Hide();
- //显示登陆的界面
- GameNetManager.Instance.mSocketMsgCenter.StopConnect();//主动断开
- MessageCenterController.Instance.Broadcast(GameEnum.MESSAGE_SHOW_POP_BY_TYPE, new ShowPopData(PopType.ServerList, null));
- }
- }
|