public void PhaseBegin(ILevelContext context)
        {
            flyingVFormationPrefab = ComponentBase.GetRequiredResource <GameObject>($"{ResourcePaths.PrefabsFolder}/Actors/Formations/{GameObjects.Formations.FlyingV}");

            GameObject asteroidPrefab = ComponentBase.GetRequiredResource <GameObject>($"{ResourcePaths.PrefabsFolder}/Projectiles/{GameObjects.Projectiles.Asteroid}");

            // Create an asteroid spawner which will generate a random asteroid ever buncha milliseconds
            asteroidSpawner = ComponentBase.InstantiateInLevel("AsteroidSpawner", Vector3.zero, typeof(AutoSpawnerComponent));
            ComponentBase.GetRequiredComponent <AutoSpawnerComponent>(asteroidSpawner).Initialize(500, asteroidPrefab);

            // This method is used to spawn enemies, initialize the phase, etc
            GameObject enemy = ComponentBase.GetRequiredResource <GameObject>($"{ResourcePaths.PrefabsFolder}/Actors/Enemies/Shooter_AI");

            GameObject inst = ComponentBase.InstantiateInLevel(enemy);

            inst.transform.position = new Vector3(-2, 3f, 3);
            GameObject inst2 = ComponentBase.InstantiateInLevel(enemy);

            inst2.transform.position = new Vector3(2, 3, 4);

            // A formation will spawn after a while
            intervalTimerObject = new GameObject("FormationSpawnTimer");

            intervalTimerObject.AddComponent <IntervalTimerComponent>();
            IntervalTimerComponent timer = ComponentBase.GetRequiredComponent <IntervalTimerComponent>(intervalTimerObject);

            timer.SetInterval(3000);
            timer.OnIntervalReached.AddListener(SpawnFormation);
            timer.SelfDestruct = true;
            timer.IsActive     = true;

            // Play some dank tunes
            ComponentBase.GetMusicPlayer().Loop(MusicPlayerComponent.Song.Prototype);
        }
Exemple #2
0
        public void PhaseBegin(ILevelContext context)
        {
            GameObject enemy = ComponentBase.GetRequiredResource <GameObject>($"{ResourcePaths.PrefabsFolder}/Actors/Enemies{GameObjects.Actors.Kamikaze}");

            GameObject enemy1 = ComponentBase.InstantiateInLevel(enemy);

            enemy1.transform.position = new Vector3(1, 2f, 0);

            GameObject enemy2 = ComponentBase.InstantiateInLevel(enemy);

            enemy2.transform.position = new Vector3(-1, 3f, 0);

            for (int i = 0; i < 5; i++)
            {
                var inst = ComponentBase.InstantiateInLevel(enemy);
                inst.transform.position = new Vector3(i * 0.5f, i * 0.5f);
            }
        }
        public void PhaseBegin(ILevelContext context)
        {
            GameObject asteroidPrefab = ComponentBase.GetRequiredResource <GameObject>($"{ResourcePaths.PrefabsFolder}/Projectiles/{GameObjects.Projectiles.Asteroid}");

            // Create an asteroid spawner which will generate a random asteroid every half second
            asteroidSpawner = ComponentBase.InstantiateInLevel("AsteroidSpawner", Vector3.zero, typeof(AutoSpawnerComponent));
            ComponentBase.GetRequiredComponent <AutoSpawnerComponent>(asteroidSpawner).Initialize(500, asteroidPrefab);


            // A formation will spawn after a while
            intervalTimerObject = new GameObject("FormationSpawnTimer");

            intervalTimerObject.AddComponent <IntervalTimerComponent>();
            IntervalTimerComponent timer = ComponentBase.GetRequiredComponent <IntervalTimerComponent>(intervalTimerObject);

            timer.SetInterval(15000); // 15 seconds
            timer.OnIntervalReached.AddListener(TimerDone);
            timer.SelfDestruct = true;
            timer.IsActive     = true;
        }
 // After the interval has completed, spawn a grunt formation
 private void SpawnFormation()
 {
     intervalReached = true;
     flyingVObject   = ComponentBase.InstantiateInLevel(flyingVFormationPrefab);
 }