/// <summary>
 /// Create asteroid manager
 /// </summary>
 public PhysicsAsteroidManager(Level setLevel)
     : base(setLevel)
 {
     /*obs
     // Load all whosh sounds
     for (int num = 0; num < NumOfWhoshSounds; num++)
     {
         whoshSounds[num] = new Sample("Whosh" + (num + 1) + ".wav", 10);
     } // for (num)
     sideHitSound = new Sample("SideHit.wav");
      */
 }
        /// <summary>
        /// Create mission
        /// </summary>
        public Mission(Level level, GameAsteroidManager asteroidManager)
        {
            // Set level for asteroid manager.
            asteroidManager.CurrentLevel = level;

            // Start new game.
            Player.Reset(level.Name);
        }
        /// <summary>
        /// Create asteroid manager
        /// </summary>
        public BaseAsteroidManager(Level setLevel)
        {
            // Set level
            CurrentLevel = setLevel;

            // Load all available asteroids
            int asteroidNum = 1;
            while (File.Exists(Directories.ContentDirectory + "\\" +
                "Asteroid" + asteroidNum + "." + Directories.ContentExtension))
            {
                Model asteroidModel = new Model("Asteroid" + asteroidNum);
                asteroidModels.Add(asteroidModel);

                // Try to use low version of asteroid
                if (File.Exists(Directories.ContentDirectory + "\\" +
                    "Asteroid" + asteroidNum + "Low." + Model.Extension))
                    asteroidModelsLow.Add(new Model("Asteroid" + asteroidNum + "Low"));
                else
                    // If none is found, use normal one.
                    asteroidModelsLow.Add(asteroidModel);

                asteroidNum++;
            } // while (File.Exists)

            if (asteroidModels.Count == 0)
                throw new Exception("Unable to start game, no asteroid models were " +
                    "found, please check the Models directory!");

            // Load all small asteroids
            int smallAsteroidNum = 1;
            while (File.Exists(Directories.ContentDirectory + "\\" +
                "SmallAsteroid" + smallAsteroidNum + "." + Directories.ContentExtension))
            {
                smallAsteroidModels.Add(new Model("SmallAsteroid" + smallAsteroidNum));
                smallAsteroidNum++;
            } // while (File.Exists)

            // Create all asteroids
            for (int z = MinSector; z <= MaxSector; z++)
                for (int x = MinSector; x <= MaxSector; x++)
                {
                    int iz = z + MiddleSector,
                        ix = x + MiddleSector;
                    sectorAsteroids[iz, ix] = new List<Asteroid>();

                    GenerateSector(sectorAsteroids[iz, ix], x, z);
                } // for for for (int)

            // Create smaller asteroids
            for (int z = MinSmallSector; z <= MaxSmallSector; z++)
                //for (int y = MinSmallSector; y <= MaxSmallSector; y++)
                    for (int x = MinSmallSector; x <= MaxSmallSector; x++)
                    {
                        int iz = z + SmallMiddleSector,
                            //iy = y + SmallMiddleSector,
                            ix = x + SmallMiddleSector;
                        sectorSmallerAsteroids[iz, ix] = new List<SmallAsteroids>();

                        GenerateSmallerAsteroidsSector(
                            sectorSmallerAsteroids[iz, ix],
                            sectorAsteroids[iz + SmallSectorAdd,// iy + SmallSectorAdd,
                            ix + SmallSectorAdd].Count, x, z);
                    } // for for for (int)

            // Precalculate visible sector stuff
            for (int z = MinSector; z <= MaxSector; z++)
                for (int x = MinSector; x <= MaxSector; x++)
                {
                    int iz = z + MiddleSector,
                        ix = x + MiddleSector;

                    // Check if distance (that sqrt thingy) is smaller than
                    // the max view depth (in int this is MiddleSector) and add
                    // a small offset (0.25) to include nearly visible sectors.
                    sectorVisibleInRange[iz, ix] =
                        (float)Math.Sqrt(x * x + z * z) <
                        MiddleSector + 0.25f;

                    // Calculate direction (just normalize relative position)
                    sectorDirection[iz, ix] = -new Vector3(x, 0, z);
                    sectorDirection[iz, ix].Normalize();
                } // for for for (int)

            // Calculate sectors and visibility
            CalculateSectors();

            physicsThread = new Thread(new ThreadStart(PhysicsUpdate));
            physicsThread.Start();
        }
        /// <summary>
        /// Create asteroid manager
        /// </summary>
        public GameAsteroidManager(Level setLevel)
            : base(setLevel)
        {
            // Load all items
            for (int num = 0; num < Level.NumOfItemTypes; num++)
            {
                // All items are animated, load with help of AnimatedModel.
                itemModels[num] = new AnimatedModel(ItemModelFilenames[num]);
            } // for (num)

            // Load hit direction texture
            hitDirectionTexture = new Texture("HitDirection.dds");

            // Load goal model
            goalModel = new Model("Goal");
        }