Ejemplo n.º 1
0
        /// <summary>
        /// Spawn a mini asteroid on te death of a bit asteroid
        /// </summary>
        /// <param name="prefab">The mini asteroid prefab</param>
        /// <param name="position">The position of the new asteroid</param>
        /// <param name="count">The number of mini asteroids to spawn</param>
        public void SpawnMiniAsteroid(GameObject prefab, Vector3 position, int count)
        {
            for (int i = 0; i < count; ++i)
            {
                Camera cam = Camera.main;

                Quaternion rotation = Quaternion.identity;
                GameObject spawn    = utils.Pool.Instance.Create(prefab, position, transform);
                spawn.transform.rotation = rotation;

                entity.Asteroid asteroid = spawn.GetComponent <entity.Asteroid>();
                asteroid.ConstantVelocity = asteroid.ConstantVelocity * GetVelocityScalar();
                asteroid.Spawner          = null; // set the spawner to null so we dont spawn more asteroids on death

                spawn.SpawnOffset offset = spawn.GetComponent <spawn.SpawnOffset>();
                if (offset)
                {
                    float xOffset = i == 0 || i == 1 ? -1.0f : 1.0f;
                    float yOffset = i == 1 || i == 2 ? -1.0f : 1.0f;

                    offset.ApplyOffset(xOffset, yOffset, (float)i);
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Called when a new asteroid is spawned
 /// </summary>
 /// <param name="spawn">The spawned asteroid</param>
 override protected void OnSpawn(GameObject spawn)
 {
     entity.Asteroid asteroid = spawn.GetComponent <entity.Asteroid>();
     asteroid.ConstantVelocity = asteroid.ConstantVelocity * GetVelocityScalar();
     asteroid.Spawner          = this;
 }