Esempio n. 1
0
 // TODO: Cleanup serialization methods and move them to their own class
 public static WeaponLoadout Deserialize(AbstractData abstractData)
 {
     MemoryStream dataStream = new MemoryStream(abstractData.Data);
     BinaryReader reader = new BinaryReader(dataStream);
     WeaponLoadout weaponLoadout = new WeaponLoadout();
     weaponLoadout.ParseWeaponLoadoutSlots(reader);
     return weaponLoadout;
 }
Esempio n. 2
0
        // TODO: Cleanup serialization methods and move them to their own class
        public static WeaponLoadout Deserialize(AbstractData abstractData)
        {
            MemoryStream  dataStream    = new MemoryStream(abstractData.Data);
            BinaryReader  reader        = new BinaryReader(dataStream);
            WeaponLoadout weaponLoadout = new WeaponLoadout();

            weaponLoadout.ParseWeaponLoadoutSlots(reader);
            return(weaponLoadout);
        }
        public GetPublicDataResult GetPublicData(GetPublicDataRequest request)
        {
            AbstractData data;
            switch (request.ContainerName)
            {
                case DataContainerTypes.WeaponLoadouts:
                    var weaponLoadout = new WeaponLoadout
                    {
                        ActiveLoadoutSlotIndex = 0,
                        LoadoutSlots = Enumerable.Repeat(new WeaponLoadoutSlot
                        {
                            PrimaryWeapon = "assault_rifle",
                            SecondaryWeapon = "magnum",
                            Grenades = "frag_grenade",
                            Booster = "",
                            ConsumableFirst = "",
                            ConsumableSecond = "",
                            ConsumableThird = "",
                            ConsumableFourth = ""
                        }
                        , 5).ToList()
                    };
                    data = weaponLoadout.Serialize();
                    break;
                case DataContainerTypes.ArmorLoadouts:
                    var armorLoadout = new ArmorLoadout
                    {
                        ActiveLoadoutSlotIndex = 0,
                        PrimaryColor = "color_pri_13",
                        SecondaryColor = "color_sec_13",
                        VisorColor = "color_visor_5",
                        LightsColor = "color_lights_3",
                        HologramsColor = "color_holo_3",
                        Slots = Enumerable.Repeat(new ArmorLoadoutSlot
                        {
                            Head = "helmet_air_assault",
                            Shoulders = "shoulder_air_assault",
                            Torso = "chest_air_assault",
                            Hands = "arms_air_assault",
                            Legs = "legs_air_assault",
                            Accessory = ""
                        }, 5).ToList()
                    };
                    data = armorLoadout.Serialize();
                    break;
                case DataContainerTypes.Customizations:
                    var customization = new Customization
                    {
                        AccountLabel = "account_label"
                    };
                    data = customization.Serialize();
                    break;
                default:
                    throw new ArgumentException("ContainerName");
            }

            return new GetPublicDataResult
            {
                Result = new ServiceResult<List<PerUser>>
                {
                    Data = new List<PerUser>
                    {
                        new PerUser
                        {
                            User = new UserId
                            {
                                Id = 1
                            },
                            PerUserData = data
                        }
                    }
                }
            };
        }