예제 #1
0
        public void OnEvent(EventKey key, object[] args)
        {
            if (key == EventKey.OnLoginSuccessfully)
            {
                Debug.Log($"登录成功");
                Game.EventSystem.Run(EventIdType.LoadSceneLobby);
            }
            else if (key == EventKey.onCreateAccountResult)
            {
                UInt16 retcode = (UInt16)args[0];
                if (retcode == 0)
                {
                    TipPanelEntity.ShowTip("注册成功!");
                    string username = mRegisterUsernameInput.text.Trim();
                    string password = mRegisterPasswordInput.text.Trim();

                    if (username.Length == 0 || password.Length == 0)
                    {
                        TipPanelEntity.ShowTip("注册失败:用户名或密码为空!");
                        return;
                    }

                    KBEngine.Event.fireIn(EventInTypes.login, username, password, System.Text.Encoding.UTF8.GetBytes(Application.platform.ToString()));
                }
                else
                {
                    TipPanelEntity.ShowTip("注册失败!");
                }
            }
            else if (key == EventKey.onLoginFailed)
            {
                UInt16 retcode = (UInt16)args[0];
                Debug.Log($"登录失败: {retcode}");
            }
        }
예제 #2
0
        public void Start()
        {
            #region Event

            this.Register(EventKey.OnLoginSuccessfully, OnEvent);
            this.Register(EventKey.onCreateAccountResult, OnEvent);

            #endregion

            #region UI

            mToLoginButton.onClick.Add(() =>
            {
                IsLogin = true;
            });

            mToRegisterButton.onClick.Add(() =>
            {
                IsLogin = false;
            });

            mLoginButton.onClick.Add(() =>
            {
                string username = mLoginUsernameInput.text.Trim();
                string password = mLoginPasswordInput.text.Trim();

                if (username.Length == 0 || password.Length == 0)
                {
                    TipPanelEntity.ShowTip("登录失败:用户名或密码为空!");
                    return;
                }

                KBEngine.Event.fireIn(EventInTypes.login, username, password, System.Text.Encoding.UTF8.GetBytes(Application.platform.ToString()));
            });

            mRegisterButton.onClick.Add(() =>
            {
                string username = mRegisterUsernameInput.text.Trim();
                string password = mRegisterPasswordInput.text.Trim();

                if (username.Length == 0 || password.Length == 0)
                {
                    TipPanelEntity.ShowTip("注册失败:用户名或密码为空!");
                    return;
                }

                KBEngine.Event.fireIn(EventInTypes.createAccount, username, password, System.Text.Encoding.UTF8.GetBytes(Application.platform.ToString()));
            });

            #endregion

            IsLogin = true;
        }
예제 #3
0
        public void OnEvent(EventKey key, object[] args)
        {
            if (key == EventKey.onPlayernameBaseChanged)
            {
                string playername = (string)args[0];
                mPlayernameText.text = playername;

                // 如果是在 MainBox 改的
                if (mSetNameBox.activeSelf == true)
                {
                    mMainBox.Enable();
                    mSetNameBox.Disable();
                }
            }
            else if (key == EventKey.onGoldBaseChanged)
            {
                uint gold = (uint)args[0];
                mGoldText.text = gold.ToString();
            }
            else if (key == EventKey.onJoinRoom)
            {
                byte retcode = (byte)args[0];
                if (retcode == 0)
                {
                    TipPanelEntity.ShowTip("加入房间成功");
                }
                else if (retcode == 1)
                {
                    TipPanelEntity.ShowTip("此房间不存在");
                }
                else if (retcode == 2)
                {
                    TipPanelEntity.ShowTip("此房间已满, 请选择另外一个房间");
                }
            }
        }