コード例 #1
0
        private void SelectWeaponWithAmmo()
        {
            var weapon = Lasers.FirstOrDefault(l => l.RemainingAmmo > 0);

            if (weapon != null)
            {
                LaserIndex = Lasers.IndexOf(weapon);
            }
        }
コード例 #2
0
        public void AddToInventory(Laser laser)
        {
            var existing = Lasers.FirstOrDefault(l => l.Name.ToLower().Equals(laser.Name.ToLower()));

            if (existing != null)
            {
                existing.RemainingAmmo += laser.StartingAmmo;
                LaserIndex              = Lasers.IndexOf(existing);
            }
            else
            {
                Lasers.Add(new WeaponInfo
                {
                    Texture        = laser.Texture,
                    Name           = laser.Name,
                    RemainingAmmo  = laser.StartingAmmo,
                    ProjectileName = laser.ProjectileName
                });

                // make this the current laser
                LaserIndex = Lasers.Count - 1;
            }
        }