Exemplo n.º 1
0
            /// <summary>
            /// 根据获取的服务器信息来进行登陆
            /// </summary>
            public void LoginServer(ServerInfo serverInfo)
            {
                if (serverInfo == null)
                {
                    GameDebug.LogError("Error, server info is null!!!");
                    UINotice.GetInstance().ShowMessage(DBConstText.GetText("PLEASE_SELECT_ONE_SERVER"));
                    return;
                }

                if (m_LoadingIcon != null)
                {
                    m_LoadingIcon.SetActive(true);
                }

                ServerListHelper.GetInstance().CheckServerStateAndEnter(serverInfo, (ServerInfo retServerInfo, bool canEnter) =>
                {
                    if (canEnter == false)
                    {
                        UIManager.Instance.ShowWaitScreen(false);
                        if (m_LoadingIcon != null)
                        {
                            m_LoadingIcon.SetActive(false);
                        }
                    }
                });

                // 点击登录按钮
                ControlServerLogHelper.Instance.PostPlayerFollowRecord(PlayerFollowRecordSceneId.ClickLoginButton);
            }
Exemplo n.º 2
0
        public void GetServerDataFinished(List <RegionInfo> regionList, List <ServerInfo> serverList, int lastLoginServerId)
        {
            UIManager.Instance.ShowWaitScreen(false);

            if (serverList != null)
            {
                foreach (ServerInfo serverInfo in ServerListHelper.GetHaveRoleServerList(serverList))
                {
                    InsertOneHaveRoleServerItem(serverInfo);
                }
            }
        }
Exemplo n.º 3
0
            /// <summary>
            /// 获取上次登陆服务器的回调
            /// </summary>
            public void OnGetLastLoginServerFinished(ServerInfo serverInfo)
            {
                if (serverInfo != null)
                {
                    SetSelectedServerInfo(serverInfo);

                    // 获取服务器列表
                    ControlServerLogHelper.Instance.PostPlayerFollowRecord(PlayerFollowRecordSceneId.GetServerList);
                    ControlServerLogHelper.Instance.PostCloudLadderEventAction(CloudLadderMarkEnum.list_gs);
                }
                else
                {
                    ServerListHelper.GetInstance().GetAllRecommServer(OnGetAllRecommServerFinished);
                }
            }
Exemplo n.º 4
0
        void LoginServer(ServerInfo serverInfo)
        {
            if (serverInfo == null)
            {
                GameDebug.LogError("Error, server info is null!!!");
                return;
            }

            //UIManager.Instance.ShowWaitScreen(true);
            mLoadingIcon.SetActive(true);

            ServerListHelper.GetInstance().CheckServerStateAndEnter(serverInfo, (ServerInfo retServerInfo, bool canEnter) =>
            {
                if (canEnter == false)
                {
                    UIManager.Instance.ShowWaitScreen(false);
                    mLoadingIcon.SetActive(false);
                }
            });

            // 点击登录按钮
            ControlServerLogHelper.Instance.PostPlayerFollowRecord(PlayerFollowRecordSceneId.ClickLoginButton);
        }
Exemplo n.º 5
0
        public void InsertOneNormalServerItem(GameObject parent, GameObject obj, ServerInfo serverInfo)
        {
            GameObject item = GameObject.Instantiate(obj);

            item.SetActive(true);
            item.name = "Server_" + serverInfo.ServerId;
            Transform itemTrans = item.transform;

            itemTrans.SetParent(parent.transform);
            itemTrans.localScale    = Vector3.one;
            itemTrans.localPosition = Vector3.zero;

            // 名字
            Text nameText = itemTrans.Find("NameText").GetComponent <Text>();

            nameText.text = serverInfo.Name;

            // 状态
            Image stateImage = itemTrans.Find("StateImage").GetComponent <Image>();

            stateImage.sprite = GetSpriteByState(serverInfo.State);

            // 类型
            GameObject tag = itemTrans.Find("Tag").gameObject;

            if (serverInfo.Type == EServerType.New || serverInfo.Type == EServerType.RecommendAndNew)
            {
                tag.SetActive(true);
            }
            else
            {
                tag.SetActive(false);
            }

            // 角色数量
            Text roleNumText = itemTrans.Find("Role").Find("Text").GetComponent <Text>();

            if (serverInfo.RoleList == null || serverInfo.RoleList.Count == 0)
            {
                roleNumText.text = "x0";
                roleNumText.transform.parent.gameObject.SetActive(false);
            }
            else
            {
                roleNumText.text = "x" + serverInfo.RoleList.Count;
                roleNumText.transform.parent.gameObject.SetActive(true);
            }

            // cd
            Text cdText = itemTrans.Find("CDText").GetComponent <Text>();

            if ((serverInfo.State == EServerState.WillOpen || serverInfo.State == EServerState.Maintaining) && serverInfo.CountDownTime > 0)
            {
                cdText.gameObject.SetActive(true);

                Utils.DecimalTimer timer = new Utils.DecimalTimer((decimal)(serverInfo.CountDownTime) * 1000, false, 1000, (decimal remainTime, Utils.DecimalTimer t) =>
                {
                    if (remainTime <= 0)
                    {
                        cdText.text = "";
                        // 维护倒计时完毕就默认为畅通吧
                        stateImage.sprite = GetSpriteByState(EServerState.Smooth);

                        t.Destroy();
                        mMaintainingServerTimers.Remove(t);
                    }
                    else
                    {
                        cdText.text = DBConstText.GetText("MAINTAINING_REMAIN_TIME") + TimeTraslateHMS.GetFMTTime(remainTime);
                    }
                }, null);
                mMaintainingServerTimers.Add(timer);
            }
            else
            {
                cdText.gameObject.SetActive(false);
            }

            // 按钮
            Button button = itemTrans.GetComponent <Button>();

            button.onClick.RemoveAllListeners();
            button.onClick.AddListener(() =>
            {
                if (ServerListHelper.Instance.CheckServerState(serverInfo, false) == true)
                {
                    SetSelectedServerInfo(serverInfo);
                    OnClickCloseServerListPanelButton();
                }
                else
                {
                    ServerListHelper.GetInstance().CheckServerStateAndEnter(serverInfo, (ServerInfo retServerInfo, bool canEnter) =>
                    {
                        if (canEnter == true)
                        {
                            SetSelectedServerInfo(serverInfo);
                            OnClickCloseServerListPanelButton();
                        }
                        else
                        {
                            ServerListHelper.Instance.CheckServerState(serverInfo, false);

                            // 推荐别的服务器需要关闭服务器列表界面
                            if (serverInfo != null && serverInfo.State == EServerState.NotRecomm)
                            {
                                OnClickCloseServerListPanelButton();
                            }
                        }
                    }, false);
                }
            });
        }
Exemplo n.º 6
0
        public void InsertOneWillOpenServerItem(ServerInfo serverInfo)
        {
            GameObject item = GameObject.Instantiate(mWillOpenServerItem);

            item.SetActive(true);
            item.name = "Server_" + serverInfo.ServerId;
            Transform itemTrans = item.transform;

            itemTrans.SetParent(mWillOpenServerListContent.transform);
            itemTrans.localScale    = Vector3.one;
            itemTrans.localPosition = Vector3.zero;

            // 名字
            Text nameText = itemTrans.Find("NameText").GetComponent <Text>();

            nameText.text = serverInfo.Name;

            // 时间
            Text timeText = itemTrans.Find("TimeText").GetComponent <Text>();

            if (serverInfo.CountDownTime > 0)
            {
                Utils.DecimalTimer timer = new Utils.DecimalTimer((decimal)(serverInfo.CountDownTime) * 1000, false, 1000, (decimal remainTime, Utils.DecimalTimer t) =>
                {
                    if (remainTime <= 0)
                    {
                        timeText.text = "";
                        t.Destroy();
                        mMaintainingServerTimers.Remove(t);

                        GameObject.DestroyImmediate(item);
                    }
                    else
                    {
                        timeText.text = DBConstText.GetText("MAINTAINING_REMAIN_TIME") + TimeTraslateHMS.GetFMTTime(remainTime);
                    }
                }, null);
                mMaintainingServerTimers.Add(timer);
            }
            else
            {
                timeText.text = "";
            }

            // 状态
            Image stateImage = itemTrans.Find("StateImage").GetComponent <Image>();

            stateImage.sprite = GetSpriteByState(serverInfo.State);

            // 按钮
            Button button = itemTrans.GetComponent <Button>();

            button.onClick.RemoveAllListeners();
            button.onClick.AddListener(() =>
            {
                if (ServerListHelper.Instance.CheckServerState(serverInfo, false) == true)
                {
                    SetSelectedServerInfo(serverInfo);
                    OnClickCloseServerListPanelButton();
                }
                else
                {
                    ServerListHelper.GetInstance().CheckServerStateAndEnter(serverInfo, (ServerInfo retServerInfo, bool canEnter) =>
                    {
                        if (canEnter == true)
                        {
                            SetSelectedServerInfo(serverInfo);
                            OnClickCloseServerListPanelButton();
                        }
                        else
                        {
                            ServerListHelper.Instance.CheckServerState(serverInfo, false);

                            // 推荐别的服务器需要关闭服务器列表界面
                            if (serverInfo != null && serverInfo.State == EServerState.NotRecomm)
                            {
                                OnClickCloseServerListPanelButton();
                            }
                        }
                    }, false);
                }
            });
        }
Exemplo n.º 7
0
        public void InsertOneHaveRoleServerItem(ServerInfo serverInfo)
        {
            GameObject item = GameObject.Instantiate(mHaveRoleServerItem);

            item.SetActive(true);
            item.name = "Server_" + serverInfo.ServerId;
            Transform itemTrans = item.transform;

            itemTrans.SetParent(mHaveRoleServerListContent.transform);
            itemTrans.localScale    = Vector3.one;
            itemTrans.localPosition = Vector3.zero;

            // 名字
            Text nameText = itemTrans.Find("NameText").GetComponent <Text>();

            nameText.text = serverInfo.Name;

            // 状态
            Image stateImage = itemTrans.Find("StateImage").GetComponent <Image>();

            stateImage.sprite = GetSpriteByState(serverInfo.State);

            // 类型
            GameObject tag = itemTrans.Find("Tag").gameObject;

            if (serverInfo.Type == EServerType.New || serverInfo.Type == EServerType.RecommendAndNew)
            {
                tag.SetActive(true);
            }
            else
            {
                tag.SetActive(false);
            }

            // 角色头像
            GameObject roleHead = itemTrans.Find("RoleHeadPanel").Find("RoleHead").gameObject;

            roleHead.SetActive(false);
            if (serverInfo.RoleList != null)
            {
                foreach (ServerRoleInfo serverRoleInfo in serverInfo.RoleList)
                {
                    InsertOneServerRoleHead(roleHead, serverRoleInfo);
                }
            }

            // 按钮
            Button button = itemTrans.GetComponent <Button>();

            button.onClick.RemoveAllListeners();
            button.onClick.AddListener(() =>
            {
                if (ServerListHelper.Instance.CheckServerState(serverInfo, false) == true)
                {
                    SetSelectedServerInfo(serverInfo);
                    OnClickCloseServerListPanelButton();
                }
                else
                {
                    ServerListHelper.GetInstance().CheckServerStateAndEnter(serverInfo, (ServerInfo retServerInfo, bool canEnter) =>
                    {
                        if (canEnter == true)
                        {
                            SetSelectedServerInfo(serverInfo);
                            OnClickCloseServerListPanelButton();
                        }
                        else
                        {
                            ServerListHelper.Instance.CheckServerState(serverInfo, false);

                            // 推荐别的服务器需要关闭服务器列表界面
                            if (serverInfo != null && serverInfo.State == EServerState.NotRecomm)
                            {
                                OnClickCloseServerListPanelButton();
                            }
                        }
                    }, false);
                }
            });
        }
Exemplo n.º 8
0
 public void StartGetServerInfos()
 {
     ServerListHelper.GetInstance().GetLastLoginServerInfo(OnGetLastLoginServerFinished);
 }