Exemplo n.º 1
0
    void installEvents()
    {
        // common
        KBEvent.registerOut(KET.onKicked, this, onKicked);
        KBEvent.registerOut(KET.onDisconnected, this, onDisconnected);
        KBEvent.registerOut(KET.onConnectionState, this, onConnectionState);

        // login
        KBEvent.registerOut(KET.onCreateAccountResult, this, onCreateAccountResult);
        KBEvent.registerOut(KET.onLoginFailed, this, onLoginFailed);
        KBEvent.registerOut(KET.onVersionNotMatch, this, onVersionNotMatch);
        KBEvent.registerOut(KET.onScriptVersionNotMatch, this, onScriptVersionNotMatch);
        KBEvent.registerOut(KET.onLoginBaseappFailed, this, onLoginBaseappFailed);
        KBEvent.registerOut(KET.onLoginSuccessfully, this, onLoginSuccessfully);
        KBEvent.registerOut(KET.onReloginBaseappFailed, this, onReloginBaseappFailed);
        KBEvent.registerOut(KET.onReloginBaseappSuccessfully, this, onReloginBaseappSuccessfully);
        KBEvent.registerOut(KET.onLoginBaseapp, this, onLoginBaseapp);
        KBEvent.registerOut(KET.Loginapp_importClientMessages, this, Loginapp_importClientMessages);
        KBEvent.registerOut(KET.Baseapp_importClientMessages, this, Baseapp_importClientMessages);
        KBEvent.registerOut(KET.Baseapp_importClientEntityDef, this, Baseapp_importClientEntityDef);

        // select-avatars(register by scripts)
        KBEvent.registerOut(KET.onReqAvatarList, this, onReqAvatarList);
        KBEvent.registerOut(KET.onCreateAvatarResult, this, onCreateAvatarResult);
        KBEvent.registerOut(KET.onRemoveAvatar, this, onRemoveAvatar);
    }
Exemplo n.º 2
0
        public void onReqAvatarList(Dictionary <string, object> infos)
        {
            avatars.Clear();

            List <object> listinfos = (List <object>)infos["values"];

            Dbg.DEBUG_MSG("Account::onReqAvatarList: avatarsize=" + listinfos.Count);
            for (int i = 0; i < listinfos.Count; i++)
            {
                Dictionary <string, object> info = (Dictionary <string, object>)listinfos[i];
                Dbg.DEBUG_MSG("Account::onReqAvatarList: name" + i + "=" + (string)info["name"]);
                avatars.Add((UInt64)info["dbid"], info);
            }

            // ui event
            Dictionary <UInt64, Dictionary <string, object> > avatarList = new Dictionary <ulong, Dictionary <string, object> >(avatars);
            KBS_AvatarList e = new KBS_AvatarList();

            e.avatarList = avatarList;
            KBEvent.fireOut(KET.onReqAvatarList, e);

            if (listinfos.Count == 0)
            {
                return;
            }

            // selectAvatarGame(avatars.Keys.ToList()[0]);
        }
Exemplo n.º 3
0
        public void onRemoveAvatar(UInt64 dbid)
        {
            Dbg.DEBUG_MSG("Account::onRemoveAvatar: dbid=" + dbid);

            avatars.Remove(dbid);

            // ui event
            KBS_RemoveAvatarResp e = new KBS_RemoveAvatarResp();

            e.dbid       = dbid;
            e.avatarList = avatars;
            KBEvent.fireOut(KET.onRemoveAvatar, e);
        }
Exemplo n.º 4
0
        public override void __init__()
        {
            // 注册事件
            KBEvent.registerIn(KET.reqCreateAvatar, this, reqCreateAvatar);
            KBEvent.registerIn(KET.reqRemoveAvatar, this, reqRemoveAvatar);
            KBEvent.registerIn(KET.selectAvatarGame, this, selectAvatarGame);

            // 触发登陆成功事件
            KBS_LoginSuccess e = new KBS_LoginSuccess();

            e.rndUUID       = KBEngineApp.app.entity_uuid;
            e.eid           = id;
            e.accountEntity = this;
            KBEvent.fireOut(KET.onLoginSuccessfully, e);

            // 向服务端请求获得角色列表
            baseCall("reqAvatarList");
        }
Exemplo n.º 5
0
    public void EnterGame()
    {
        if (selAvatarDBID == 0)
        {
            err("Please select a Avatar!(请选择角色!)");
        }
        else
        {
            info("Please wait...(请稍后...)");

            KBS_EnterGame e = new KBS_EnterGame();
            e.dbid = selAvatarDBID;
            KBEvent.fireIn(KET.selectAvatarGame, e);

            SceneManager.LoadScene("world");
            UIStatus = MainUIStatus.WorldUI;
        }
    }
Exemplo n.º 6
0
    public void CreateAvatar()
    {
        string sAvatarName = mAvatarNameText.text;

        if (sAvatarName.Length > 1)
        {
            KBS_CreateAvatar e = new KBS_CreateAvatar();
            e.roleType = (Byte)1;
            e.name     = sAvatarName;
            KBEvent.fireIn(KET.reqCreateAvatar, e);

            UIStatus = MainUIStatus.SelAvatarUI;
        }
        else
        {
            err("avatar name is null(角色名称为空)!");
        }
    }
Exemplo n.º 7
0
        public void onCreateAvatarResult(Byte retcode, object info)
        {
            if (retcode == 0)
            {
                avatars.Add((UInt64)((Dictionary <string, object>)info)["dbid"], (Dictionary <string, object>)info);
                Dbg.DEBUG_MSG("Account::onCreateAvatarResult: name=" + (string)((Dictionary <string, object>)info)["name"]);
            }
            else
            {
                Dbg.ERROR_MSG("Account::onCreateAvatarResult: retcode=" + retcode);
            }

            // ui event
            KBS_CreateAvatarResult e = new KBS_CreateAvatarResult();

            e.retcode    = retcode;
            e.info       = info;
            e.avatarList = avatars;
            KBEvent.fireOut(KET.onCreateAvatarResult, e);
        }
Exemplo n.º 8
0
    public void createAccount()
    {
        string sAccount = mAccountText.text;
        string sPasswd  = mPasswordText.text;

        if (sAccount.Length < 0 || sPasswd.Length <= 5)
        {
            err("account or password is error, length < 6!(账号或者密码错误,长度必须大于5!)");
            return;
        }

        info("connect to server...(连接到服务端...)");

        KES_Login eventData = new KES_Login();

        eventData.username = sAccount;
        eventData.password = sPasswd;
        eventData.datas    = System.Text.Encoding.UTF8.GetBytes("kbengine_unity3d_demo");
        KBEvent.fireIn(KET.createAccount, eventData);
    }
Exemplo n.º 9
0
    public void RemoveAvatar()
    {
        if (selAvatarDBID == 0)
        {
            err("Please select a Avatar!(请选择角色!)");
        }
        else
        {
            info("Please wait...(请稍后...)");

            if (ui_avatarList != null && ui_avatarList.Count > 0)
            {
                Dictionary <string, object> avatarinfo = ui_avatarList[selAvatarDBID];
                KBS_RemoveAvatar            e          = new KBS_RemoveAvatar();
                e.name = (string)avatarinfo["name"];
                KBEvent.fireIn(KET.reqRemoveAvatar, e);

                UIStatus = MainUIStatus.SelAvatarUI;
            }
        }
    }