Ejemplo n.º 1
0
        private void NewAsteroid(Asteroid a, int index)
        {
            int texIndex = random.Next (0, asteroidTextures.Count - 1);
            Asteroid tempAsteroid = new Asteroid (gameType == GameType.Facebook ? a.AsteroidTexture : asteroidTextures[texIndex]);
            float scale = index == 2 ? .75f : .42f;
            tempAsteroid.Scale *= scale;
            //Console.WriteLine(scale);
            tempAsteroid.Index = index;
            tempAsteroid.Position = a.Position;
            tempAsteroid.Velocity = RandomVelocity ();

            tempAsteroid.Rotation = (float)random.NextDouble () * MathHelper.Pi * 4 - MathHelper.Pi * 2;
            tempAsteroid.RotationSpin = (float)random.NextDouble ();
            //Console.WriteLine (tempSprite.Rotation);
            tempAsteroid.Create ();
            asteroids.Add (tempAsteroid);
        }
Ejemplo n.º 2
0
        private void CreateAsteroids()
        {
            if (IsTutorial)
                return;
            int value;
            var asteroidCount = baseAsteroids + System.Math.Floor ((double)level / 2);
            //asteroidCount = 1;
            Vector2 offset = ship.Position - new Vector2 (ScreenWidth / 2, ScreenHeight / 2);
            for (int i = 0; i < asteroidCount; i++) {
                Console.WriteLine ("Creating asteroid " + i + " of " + asteroidCount);
                int index = random.Next (0, asteroidTextures.Count - 1);
                Console.WriteLine(index + " of " + asteroidTextures.Count);
                Asteroid tempAsteroid = new Asteroid (asteroidTextures[index]);
                tempAsteroid.Index = 1;

                double xPos = 0;
                double yPos = 0;

                value = random.Next (0, 8);

                switch (value) {
                case 0:
                case 1:
                    xPos = tempAsteroid.Width + random.NextDouble () * 40;
                    yPos = random.NextDouble () * ScreenHeight;
                    break;
                case 2:
                case 3:
                    xPos = ScreenWidth - random.NextDouble () * 40;
                    yPos = random.NextDouble () * ScreenHeight;
                    break;
                case 4:
                case 5:
                    xPos = random.NextDouble () * ScreenWidth;
                    yPos = tempAsteroid.Height + random.NextDouble () * 40;
                    break;
                default:
                    xPos = random.NextDouble () * ScreenWidth;
                    yPos = ScreenHeight - random.NextDouble () * 40;
                    break;
                }
                tempAsteroid.Position = new Vector2 ((float)xPos, (float)yPos) + offset;

                Console.WriteLine ("New Asteroid " + value + " , " + tempAsteroid.Position);
                tempAsteroid.Velocity = RandomVelocity ();

                tempAsteroid.Rotation = (float)random.NextDouble () * MathHelper.Pi * 4 - MathHelper.Pi * 2;
                tempAsteroid.RotationSpin = (float)random.NextDouble () * random.Next (-1, 1);
                tempAsteroid.Create ();
                asteroids.Add (tempAsteroid);
            }
        }