Exemplo n.º 1
0
    /// <summary>
    /// Xử lý khi request lên server để lấy về danh sách những người đang online trong Lobby ngoài
    /// </summary>
    public void OnPluginMessageOnProcess(string command, string action, Electrotank.Electroserver5.Api.EsObject eso)
    {
        if (command == Fields.REQUEST.GET_USER_ONLINE)
        {
            #region Lấy danh sách những người chơi đang online khi vào room
            Electrotank.Electroserver5.Api.EsObject[] children = eso.getEsObjectArray(Fields.PLAYER.USERS);

            lstUser.Clear();
            System.Array.ForEach <Electrotank.Electroserver5.Api.EsObject>(children, u => lstUser.Add(new User(u)));
            createListUserOnline(lstUser);

            #endregion
        }
    }
Exemplo n.º 2
0
    public void SetDataUser(Electrotank.Electroserver5.Api.EsObject obj)
    {
        if (obj.variableExists("id"))
        {
            id = obj.getInteger("id");
        }

        if (obj.variableExists("username"))
        {
            username = obj.getString("username");
        }
        else if (obj.variableExists(Fields.PLAYER.USERNAME))
        {
            username = obj.getString(Fields.PLAYER.USERNAME);
        }

        if (obj.variableExists("email"))
        {
            email = obj.getString("email");
        }
        if (obj.variableExists("first_name"))
        {
            firstName = obj.getString("first_name");
        }
        if (obj.variableExists("middle_name"))
        {
            middleName = obj.getString("middle_name");
        }
        if (obj.variableExists("last_name"))
        {
            lastName = obj.getString("last_name");
        }
        if (obj.variableExists("birthday"))
        {
            System.DateTime.TryParse(obj.getString("birthday").Replace(":", "-"), out brithday);
        }
        if (obj.variableExists("gender"))
        {
            gender = obj.getString("gender");
        }
        if (obj.variableExists("address"))
        {
            address = obj.getString("address");
        }
        if (obj.variableExists("identity_card_number"))
        {
            cmtnd = obj.getString("identity_card_number");
        }
        if (obj.variableExists("mobile"))
        {
            phone = obj.getString("mobile");
        }
        if (obj.variableExists("avatar"))
        {
            if (obj.getDataType("avatar") == DataType.String)
            {
                avatarUrl = obj.getString("avatar");
            }
            else if (obj.getDataType("avatar") == DataType.Integer)
            {
                ServerWeb.GetAvatarFromId(obj.getInteger("avatar"), delegate(Texture _texture) { _avatarTexture = _texture; });
            }
        }

        if (obj.variableExists("create_time"))
        {
            System.DateTime.TryParse(obj.getString("create_time"), out createTime);
        }
        if (obj.variableExists("time_request"))
        {
            System.DateTime.TryParse(obj.getString("time_request"), out timeRequest);
        }
        if (obj.variableExists("numBuddies"))
        {
            numberBuddies = obj.getInteger("numBuddies");
        }
        if (obj.variableExists("role"))
        {
            role = (ERole)obj.getInteger("role");
        }
        if (obj.variableExists("level"))
        {
            level = obj.getInteger("level");
        }
        if (obj.variableExists("experience"))
        {
            experience = obj.getInteger("experience");
        }
        if (obj.variableExists("expMinCurrentLevel"))
        {
            expMinCurrentLevel = obj.getInteger("expMinCurrentLevel");
        }
        if (obj.variableExists("expMinNextLevel"))
        {
            expMinNextLevel = obj.getInteger("expMinNextLevel");
        }

        if (obj.variableExists("buddies"))
        {
            if (buddies != null && buddies.Count > 0)
            {
                buddies.Clear();
            }
            EsObject[] array = obj.getEsObjectArray("buddies");
            Array.ForEach <EsObject>(array, o => { buddies.Add(new User(o)); });
        }
        if (obj.variableExists("pendingBuddies"))
        {
            if (pendingBuddies != null && pendingBuddies.Count > 0)
            {
                pendingBuddies.Clear();
            }
            EsObject[] array = obj.getEsObjectArray("pendingBuddies");
            Array.ForEach <EsObject>(array, o => { pendingBuddies.Add(new User(o)); });
        }
        if (obj.variableExists("requestBuddies"))
        {
            EsObject[] array = obj.getEsObjectArray("requestBuddies");
            Array.ForEach <EsObject>(array, o => { requestBuddies.Add(new User(o)); });
        }

        if (obj.variableExists("chip"))
        {
            if (obj.getDataType("chip") == DataType.String)
            {
                long.TryParse(obj.getString("chip"), out chip);
            }
            else if (obj.getDataType("chip") == DataType.Long)
            {
                chip = obj.getLong("chip");
            }
        }

        if (obj.variableExists("gold"))
        {
            if (obj.getDataType("gold") == DataType.String)
            {
                long.TryParse(obj.getString("gold"), out gold);
            }
            else if (obj.getDataType("gold") == DataType.Long)
            {
                gold = obj.getLong("gold");
            }
        }

        if (obj.variableExists("accessToken"))
        {
            accessToken = obj.getString("accessToken");
        }
    }