Beispiel #1
0
// read from proto
        public void FromProto(netproto.TestList pdata)
        {
            if (pdata.id != null)
            {
                this.id        = ProtoUtil.OptVal(pdata.id);
                this.isDirtyid = true;
            }
            for (int i = 0; i < pdata.ListPrimitiveInt.Count; i++)
            {
                var val = pdata.ListPrimitiveInt[i];
                if (this.ListPrimitiveInt.Count <= val.key)
                {
                    for (int j = this.ListPrimitiveInt.Count; j <= val.key; j++)
                    {
                        this.ListPrimitiveInt.Add(ProtoUtil.DefVal(ProtoUtil.OptVal(val.val)));
                    }
                }
                this.ListPrimitiveInt[ProtoUtil.OptVal(val.key)] = ProtoUtil.OptVal(val.val);
            }
            this.isDirtyListPrimitiveInt = true;
            for (int i = 0; i < pdata.ListPrimitiveStr.Count; i++)
            {
                var val = pdata.ListPrimitiveStr[i];
                if (this.ListPrimitiveStr.Count <= val.key)
                {
                    for (int j = this.ListPrimitiveStr.Count; j <= val.key; j++)
                    {
                        this.ListPrimitiveStr.Add(ProtoUtil.DefVal(ProtoUtil.OptVal(val.val)));
                    }
                }
                this.ListPrimitiveStr[ProtoUtil.OptVal(val.key)] = ProtoUtil.OptVal(val.val);
            }
            this.isDirtyListPrimitiveStr = true;
            for (int i = 0; i < pdata.ListPrimitiveCom.Count; i++)
            {
                var val = pdata.ListPrimitiveCom[i];
                if (this.ListPrimitiveCom.Count <= val.key)
                {
                    for (int j = this.ListPrimitiveCom.Count; j <= val.key; j++)
                    {
                        this.ListPrimitiveCom.Add(new PlayerData());
                    }
                }
                if (val.val == null)
                {
                    this.ListPrimitiveCom[ProtoUtil.OptVal(val.key)] = null;
                }
                else
                {
                    this.ListPrimitiveCom[ProtoUtil.OptVal(val.key)].FromProto(val.val);
                }
            }
            this.isDirtyListPrimitiveCom = true;
        }
Beispiel #2
0
// read from proto
        public void FromProto(netproto.Chapter pdata)
        {
            for (int i = 0; i < pdata.heros.Count; i++)
            {
                var val = pdata.heros[i];
                if (this.heros.Count <= val.key)
                {
                    for (int j = this.heros.Count; j <= val.key; j++)
                    {
                        this.heros.Add(ProtoUtil.DefVal(ProtoUtil.OptVal(val.val)));
                    }
                }
                this.heros[ProtoUtil.OptVal(val.key)] = ProtoUtil.OptVal(val.val);
            }
            this.isDirtyheros = true;
            if (pdata.level != null)
            {
                this.level        = ProtoUtil.OptVal(pdata.level);
                this.isDirtylevel = true;
            }
            if (pdata.prizeCheckTime != null)
            {
                this.prizeCheckTime        = ProtoUtil.OptVal(pdata.prizeCheckTime);
                this.isDirtyprizeCheckTime = true;
            }
            for (int i = 0; i < pdata.prizeEquip.Count; i++)
            {
                var val = pdata.prizeEquip[i];
                if (this.prizeEquip.Count <= val.key)
                {
                    for (int j = this.prizeEquip.Count; j <= val.key; j++)
                    {
                        this.prizeEquip.Add(new Equip());
                    }
                }
                if (val.val == null)
                {
                    this.prizeEquip[ProtoUtil.OptVal(val.key)] = null;
                }
                else
                {
                    this.prizeEquip[ProtoUtil.OptVal(val.key)].FromProto(val.val);
                }
            }
            this.isDirtyprizeEquip = true;
        }