Example #1
0
    /// <summary>
    /// Randomly spawns given number of enemies on given spawn points.
    /// </summary>
    /// <param name="spawnPoints">Spawn points to use.</param>
    /// <param name="enemiesToSpawn">Number of enemies to spawn.</param>
    private void UseSpawnPoints(EnemySpawnPoint[] spawnPoints, int enemiesToSpawn)
    {
        int spCount = spawnPoints.Length;

        for (int i = 0; i < enemiesToSpawn; i++)
        {
            EnemySpawnPoint spawnPoint    = spawnPoints[random.Next(spCount)];
            GameObject      objectToSpawn = spawnPoint.SpawnEnemy();
            Debug.Log("Spawning: " + objectToSpawn.name + " at " + spawnPoint.gameObject.name);
            GameObject newObject = Instantiate(objectToSpawn, spawnPoint.transform.position, spawnPoint.transform.rotation);
        }
    }
Example #2
0
 void ShowNpc(bool doShow = true)
 {
     if (doShow)
     {
         if (_npc == null)
         {
             _npc = _npcSpawnPoint.SpawnEnemy();
         }
     }
     else
     {
         Destroy(_npc);
         _npc = null;
     }
 }