예제 #1
0
        private IEnumerator PlayerChooseServerIdCoroutine()
        {
            if (!IsServerOpen())
            {
                UIManager.Instance.ShowMessage(MessageBoxType.Ok, 300832);
                yield break;
            }

            //using (new BlockingLayerHelper(1))
            var _block = new BlockingLayerHelper(1);
            {
                var _msg = NetManager.Instance.PlayerSelectServerId(mServerListDataModel.SelectedServer.ServerId);
                yield return(_msg.SendAndWaitUntilDone());

                Logger.Debug(_msg.State.ToString());
                if (_msg.State == MessageState.Reply)
                {
                    if (_msg.ErrorCode == (int)ErrorCodes.OK)
                    {
                        PlayerDataManager.Instance.ServerId          = _msg.Request.ServerId;
                        PlayerDataManager.Instance.LastLoginServerId = _msg.Request.ServerId;
                        PlayerDataManager.Instance.CharacterLists    = _msg.Response.Info;

                        if (PlayerDataManager.Instance.CharacterLists.Count <= 0 && GameSetting.Instance.ReviewState == 1)
                        {
                            var e = new UIEvent_CreateRole();
                            EventDispatcher.Instance.DispatchEvent(e);
                        }
                        else
                        {
                            PlayerDataManager.Instance.SelectedRoleIndex = _msg.Response.SelectId;
                            if (!string.IsNullOrEmpty(selectRoleName))
                            {
                                for (int i = 0; i < _msg.Response.Info.Count; i++)
                                {
                                    var player = _msg.Response.Info[i];
                                    if (player.Name.Equals(selectRoleName))
                                    {
                                        PlayerDataManager.Instance.SelectedRoleIndex = player.CharacterId;
                                    }
                                }
                            }

                            PlayerDataManager.Instance.ServerName = mServerListDataModel.SelectedServer.ServerName;

                            if (GameSetting.Instance.ReviewState == 1)
                            {
                                SoundManager.Instance.StopBGM(0.5f);
                                NetManager.Instance.CallEnterGame(PlayerDataManager.Instance.SelectedRoleIndex);
                            }
                            else
                            {
                                ResourceManager.PrepareScene(Resource.GetScenePath("SelectCharacter"), www =>
                                {
                                    ResourceManager.Instance.StartCoroutine(ResourceManager.LoadSceneImpl("SelectCharacter", www,
                                                                                                          () =>
                                    {
                                        /*
                                         * UIManager.Instance.ShowUI(UIConfig.SelectRoleUI,
                                         * new SelectRoleArguments
                                         * {
                                         *  CharacterSimpleInfos = PlayerDataManager.Instance.CharacterLists,
                                         *  SelectId = msg.Response.SelectId,
                                         *  ServerName = mServerListDataModel.SelectedServer.ServerName
                                         * });*/
                                        _block.Dispose();
                                    }));
                                });
                            }
                        }
                    }
                    else
                    {
                        GameUtils.ShowLoginTimeOutTip();
                        _block.Dispose();
                    }
                }
                else
                {
                    _block.Dispose();
                }
            }
        }
예제 #2
0
        //创建角色按钮
        public void OnClick_CreateRole()
        {
            var e = new UIEvent_CreateRole();

            EventDispatcher.Instance.DispatchEvent(e);
        }