示例#1
0
    private void EnterGameServerResp()
    {
        Account_EnterGameRespProto proto = new Account_EnterGameRespProto();
        bool isSuccess = true;  //暂时写死

        proto.IsSuccess = isSuccess;
        if (isSuccess == false)
        {
            proto.MsgCode = Constant.ENTER_GAME_FAIL;
        }
        SocketManagerServer.Instance.SendMessageToClient(proto.ToArray());
    }
    public static Account_EnterGameRespProto GetProto(byte[] buffer)
    {
        Account_EnterGameRespProto proto = new Account_EnterGameRespProto();

        using (MemoryStreamUtil ms = new MemoryStreamUtil(buffer))
        {
            proto.IsSuccess = ms.ReadBool();
            if (!proto.IsSuccess)
            {
                proto.MsgCode = ms.ReadInt();
            }
        }
        return(proto);
    }
    /// <summary>
    /// 服务器返回进入游戏是否成功消息
    /// </summary>
    /// <param name="buffer"></param>
    private void OnEnterGameServerResp(byte[] buffer)
    {
        Account_EnterGameRespProto proto = Account_EnterGameRespProto.GetProto(buffer);

        if (proto.IsSuccess)
        {
            //TODO:成功就获取角色信息
            Debug.Log("进入游戏成功!,开始获取角色信息");
            Account_RoleInfoReqProto infoProto = new Account_RoleInfoReqProto();
            infoProto.RoldId = mCurrentSelectedRoleId;
            SocketManager.Instance.SendMessageToLocalServer(infoProto.ToArray());
        }
        else
        {
            UIDialogController.Instance.Show("进入游戏失败!" + proto.MsgCode);
        }
    }
    private void OnDeleteRoleServerResp(byte[] buffer)
    {
        Account_EnterGameRespProto proto = Account_EnterGameRespProto.GetProto(buffer);

        if (proto.IsSuccess)
        {
            //TODO:把当前选择的角色重置为-1,UI上删除面板、删除按钮、角色头像去掉,创建角色按钮打开,场景里把角色prefab删除,
            mCurrentSelectedRoleId = -1;
            GlobalCache.Instance.Role_CurrentRoleId = mCurrentSelectedRoleId;
            mUISelectRoleView.DeleteView.Close();
            mUISelectRoleView.DeleteRoleChangeUI();
            DeleteMyRolePrefab();
            Debug.Log("删除角色成功!");
        }
        else
        {
            UIDialogController.Instance.Show("删除角色失败!" + proto.MsgCode);
        }
    }