コード例 #1
0
        protected override InvPacket ToObject(string value, Type type, IConversionFactory factory)
        {
            string[] split = value.Split(' ');

            var subs    = new List <IvnSubPacket>();
            var bagType = (BagType)Convert.ToInt32(split[0]);

            for (int i = 1; i < split.Length; i++)
            {
                string[] itemData = split[i].Split('.');

                int slot = Convert.ToInt32(itemData[0]);
                int vnum = Convert.ToInt32(itemData[1]);

                var sub = new IvnSubPacket
                {
                    Slot = slot,
                    VNum = vnum
                };

                if (bagType == BagType.EQUIPMENT)
                {
                    short rarity  = Convert.ToInt16(itemData[2]);
                    byte  upgrade = Convert.ToByte(itemData[3]);

                    sub.RareAmount    = rarity;
                    sub.UpgradeDesign = upgrade;
                }
                else
                {
                    int amount = Convert.ToInt32(itemData[2]);
                    sub.RareAmount = amount;
                }

                subs.Add(sub);
            }

            return(new InvPacket
            {
                BagType = bagType,
                SubPackets = subs
            });
        }
コード例 #2
0
        protected override IvnPacket ToObject(string value, Type type, IConversionFactory factory)
        {
            string[] values   = value.Split(' ');
            string[] itemData = values[1].Split('.');

            var bagType = (BagType)Convert.ToInt32(values[0]);

            int slot = Convert.ToInt32(itemData[0]);
            int vnum = Convert.ToInt32(itemData[1]);

            var sub = new IvnSubPacket
            {
                Slot = slot,
                VNum = vnum
            };

            if (bagType == BagType.EQUIPMENT)
            {
                short rarity  = Convert.ToInt16(itemData[2]);
                byte  upgrade = Convert.ToByte(itemData[3]);

                sub.RareAmount    = rarity;
                sub.UpgradeDesign = upgrade;
            }
            else
            {
                int amount = Convert.ToInt32(itemData[2]);
                sub.RareAmount = amount;
            }

            return(new IvnPacket
            {
                BagType = bagType,
                SubPacket = sub
            });
        }