Пример #1
0
 // External Functions
 public void Spawn()
 {
     isSpawned      = true;
     _asteroidClass = (AsteroidClass)Random.Range(0, 3); // use '3' because rand 'int' not float.
     //Logger.Log(Channel.Asteroid, "Spawning type " + _asteroidClass);
     if (_asteroidClass != AsteroidClass.AC_LARGE)       // change scale
     {
         float scale = AC_MEDIUM_SIZE;
         _Value = 20;
         if (_asteroidClass == AsteroidClass.AC_SMALL)
         {
             scale  = AC_SMALL_SIZE;
             _Value = 40;
         }
         this.gameObject.transform.localScale = new Vector3(scale, scale, 0);
     }
 }
        private void InitalizeAsteroid()
        {
            for (int i = 0; i < NUM_ASTEROIDS; ++i)
            {

                AsteroidClass Asteroid = new AsteroidClass();

                Asteroid.Position = new Vector2(RandNum.Next(graphics.PreferredBackBufferWidth),
                    RandNum.Next(graphics.PreferredBackBufferHeight));
                Asteroid.Velocity = new Vector2(RandNum.Next(-3, 3), RandNum.Next(-3, 3));
                Asteroid.RotationDelta = RandNum.Next(-100, 100);

                int RandSize = RandNum.Next(32, 256);
                Asteroid.Size = new Vector2(RandSize, RandSize);

                Asteroid.MaxLimit = new Vector2(graphics.PreferredBackBufferWidth + (Asteroid.Size.X + 100),
                    graphics.PreferredBackBufferHeight + (Asteroid.Size.Y + 100));
                Asteroid.MinLimit = new Vector2(0 - (Asteroid.Size.X - 100), 0 - (Asteroid.Size.Y - 100));

                MyAsteroids.Add(Asteroid);
            }
        }