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); }
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; }