Exemple #1
0
        /// <summary>
        /// Attach weapons to the current entity.
        /// </summary>
        /// <param name="weapons"></param>
        public void AddWeapon(params Weapon[] weapons)
        {
            if (Weapons == null)
            {
                Weapons = new List <Weapon>();
            }

            Weapons.AddRange(weapons);

            foreach (var weapon in weapons)
            {
                weapon.Parent = this;
                if (Category == "Player")
                {
                    var weaponName     = weapon.GetType().Name;
                    var currentWeapons = GameStateManager.CurrentState.Player.Weapons;
                    var allowedWeapons = GameStateManager.CurrentState.AllowWeapon;
                    if (!currentWeapons.Contains(weaponName))
                    {
                        currentWeapons.Add(weaponName);
                    }
                    if (!allowedWeapons.Contains(weaponName))
                    {
                        allowedWeapons.Add(weaponName);
                    }
                }
            }
        }
        private async Task InitializeAsync(HttpClient Http, WeaponTypeData weaponTypeData)
        {
            // Wait for WeaponTypeData to finish loading first so the UI can show faster.
            // Since weapons are only used in the background, we can wait.
            await weaponTypeData.Initialization;

            foreach (var uri in WeaponDataUris)
            {
                Weapons.AddRange(await Http.GetJsonAsync <List <Weapon> >(uri));
                Console.WriteLine($"Loaded {uri}");
            }

            Console.WriteLine($"Loaded {Weapons.Count} weapons.");
        }
Exemple #3
0
 public Getting()
 {
     Armors.AddRange(storage.Armors);
     Weapons.AddRange(storage.Weapons);
     Units.AddRange(storage.Units);
 }
 private void UpdateWeapons()
 {
     Weapons.Clear();
     Weapons.AddRange(weaponHolder.Value.GetAllChildren());
     WeaponAmmoManagment();
 }