Exemplo n.º 1
0
    public int money;               // 金钱

    public void Init(NetMessage.UserData sud)
    {
        // 必选字段的required
        userId = sud.userid;
        name   = sud.name;
        icon   = sud.icon;
        score  = sud.score;
        level  = sud.level;
        //money           = sud.Money;

        // 非必选字段的optional
        online = false;
        if (sud.online)
        {
            online = sud.online;
        }
        onBattle = false;
        if (sud.onBattle)
        {
            onBattle = sud.onBattle;
        }

        scoreMod   = sud.score_mod;
        destroyNum = sud.destroy_num;
        surviveNum = sud.survive_num;
        if (sud.battle_race != null)
        {
            raceId = sud.battle_race.race;
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// 初始化
    /// </summary>
    /// <param name="data">Data.</param>
    public void Init(NetMessage.UserData data)
    {
        userId = data.userid;
        name   = data.name;
        //当网络同步成功时,立刻将服务器存储名字覆盖本地名字,并存储
        if (!string.IsNullOrEmpty(name))
        {
            LocalAccountStorage.Get().name = name;
            LocalStorageSystem.Instance.SaveLocalAccount( );
        }
        icon  = data.icon;
        score = data.score;
        //level           = data.Level;
        //money           = 0;
        //unionName       = "";
        //skillPower      = 0;

        if (data.battle_race != null)
        {
        }

        if (data.pack != null)
        {
            pack.Init(data.pack);
        }

        if (data.chest != null)
        {
            chesses = new ChessItem[ChessItem.CHESS_MAX];
            for (int i = 0; i < data.chest.items.Count; i++)
            {
                int slot = data.chest.items[i].slot;
                chesses[slot]    = new ChessItem();
                chesses[slot].id = data.chest.items[i].id;
                if ((chesses[slot].timeout = data.chest.items[i].timeout) > 0)
                {
                    chesses[slot].timefinish = new DateTime(1970, 1, 1).AddSeconds(data.chest.items[i].timeout);
                }
                chesses[slot].slot = data.chest.items[i].slot;
            }
            timechestid    = data.chest.chest_timeboxid;
            battlechestid  = data.chest.chest_winboxid;
            timechest      = data.chest.chest_gainpoint;
            timechestcost  = data.chest.chest_gainconsume;
            curbattlechest = data.chest.chest_winnum;
            maxbattlechest = data.chest.chest_neednum;
        }
    }