public void OnSelect(int index)
        {
            //等待响应
            if (this.isWaiting || this.IsDisposed)
            {
                return;
            }
            this.isWaiting = true;

            if (messageUser.Characters[index].Level == 0)
            {
                //有空闲角色位置 进入角色注册界面
                CreateCharacterFactory.Create(messageUser);
                CreateCharacterComponent creater = Game.Scene.GetComponent <FUIComponent>().Get(FUIType.CreateCharacter).GetComponent <CreateCharacterComponent>();
                creater.Seat = index + 1;
                Log.Debug("创建更多角色 位置:" + creater.Seat.ToString());

                Game.EventSystem.Run(EventIdType.SelectCharacterFinish);
            }
            else
            {
                Log.Debug("等待进入游戏世界");
                //请求使用指定角色进入游戏

                //加载透明界面 退出当前界面
                NoneFGUIFactory.Create();
                Game.EventSystem.Run(EventIdType.SekiaInitLobby);
                Game.EventSystem.Run(EventIdType.SelectCharacterFinish);
            }
        }
Beispiel #2
0
        public void OnSelect(int index)
        {
            //等待响应
            if (this.isWaiting || this.IsDisposed)
            {
                return;
            }
            this.isWaiting = true;

            if (messageUser.Characters[index].Level == 0)
            {
                //有空闲角色位置 进入角色注册界面
                CreateCharacterFactory.Create(messageUser);
                CreateCharacterComponent creater = Game.Scene.GetComponent <FUIComponent>().Get(FUIType.CreateCharacter).GetComponent <CreateCharacterComponent>();
                creater.Seat = index + 1;
                Log.Debug("创建更多角色 位置:" + creater.Seat.ToString());

                Game.EventSystem.Run(EventIdType.SelectCharacterFinish);
            }
            else
            {
                Log.Debug("等待进入游戏世界");
                //请求使用指定角色进入游戏
                //SekiaHelper.Register(this.AccountInput.Get("Input").GObject.asTextInput.text, this.PasswordInput.Get("Input").GObject.asTextInput.text).NoAwait();
            }
        }
        public static async ETVoid Login(string account, string password)
        {
            SekiaLoginComponent login = Game.Scene.GetComponent <FUIComponent>().Get(FUIType.SekiaLogin).GetComponent <SekiaLoginComponent>();

            Session         sessionRealm = Game.Scene.GetComponent <NetOuterComponent>().Create(GlobalConfigComponent.Instance.GlobalProto.Address);
            A0002_Login_R2C messageRealm = (A0002_Login_R2C)await sessionRealm.Call(new A0002_Login_C2R()
            {
                Account = account, Password = password
            });

            sessionRealm.Dispose();
            login.Prompt.GObject.asTextField.text = "正在登录中...";

            //判断Realm服务器返回结果
            if (messageRealm.Error == ErrorCode.ERR_AccountOrPasswordError)
            {
                login.Prompt.GObject.asTextField.text = "登录失败,账号或密码错误";
                login.AccountInput.Get("Input").GObject.asTextInput.text  = "";
                login.PasswordInput.Get("Input").GObject.asTextInput.text = "";
                login.isLogining = false;
                return;
            }
            //判断通过则登陆Realm成功

            //创建唯一Session
            Session sessionGate = Game.Scene.GetComponent <NetOuterComponent>().Create(messageRealm.GateAddress);

            if (SessionComponent.Instance == null)
            {
                //Log.Debug("创建唯一Session");
                Game.Scene.AddComponent <SessionComponent>().Session = sessionGate;
            }
            else
            {
                SessionComponent.Instance.Session = sessionGate;
            }

            A0003_LoginGate_G2C messageGate = (A0003_LoginGate_G2C)await sessionGate.Call(new A0003_LoginGate_C2G()
            {
                GateLoginKey = messageRealm.GateLoginKey
            });

            //判断登陆Gate服务器返回结果
            if (messageGate.Error == ErrorCode.ERR_ConnectGateKeyError)
            {
                login.Prompt.GObject.asTextField.text = "连接网关服务器超时";
                login.AccountInput.Get("Input").GObject.asTextInput.text  = "";
                login.PasswordInput.Get("Input").GObject.asTextInput.text = "";
                sessionGate.Dispose();
                login.isLogining = false;
                return;
            }
            //判断通过则登陆Gate成功

            login.Prompt.GObject.asTextField.text = "";
            User user = ComponentFactory.Create <User, long>(messageGate.UserID);

            GamerComponent.Instance.MyUser = user;
            //Log.Debug("登陆成功");

            //获取角色信息判断应该进入哪个界面
            A0008_GetUserInfo_G2C messageUser = (A0008_GetUserInfo_G2C)await sessionGate.Call(new A0008_GetUserInfo_C2G());

            //消息中包含了3个CharacterInfo

            //正常的角色等级为正整数
            if (messageUser.Characters.Count == 3 &&
                messageUser.Characters[0].Level == 0 &&
                messageUser.Characters[1].Level == 0 &&
                messageUser.Characters[2].Level == 0)
            {
                //进入创建角色界面
                CreateCharacterFactory.Create(messageUser);
                CreateCharacterComponent creater = Game.Scene.GetComponent <FUIComponent>().Get(FUIType.CreateCharacter).GetComponent <CreateCharacterComponent>();
                creater.Seat = 1; //创建第一个空位的角色
            }
            else if (messageUser.Characters.Count == 3 &&
                     (messageUser.Characters[0].Level > 0 ||
                      messageUser.Characters[1].Level > 0 ||
                      messageUser.Characters[2].Level > 0))
            {
                //进入角色选择界面
                SelectCharacterFactory.Create(messageUser);
            }

            Game.EventSystem.Run(EventIdType.SekiaLoginFinish);
        }