Esempio n. 1
0
 public EnemyNPC PickAnEnemy(EnemyNPCTemplate template)
 {
     for (int i = 0; i < currentRoom.enemiesInRoom.Count; i++)
     {
         if (currentRoom.enemiesInRoom[i].myTemplate.npcName == template.npcName)
         {
             return(currentRoom.enemiesInRoom[i]);
         }
     }
     return(null);
 }
Esempio n. 2
0
    private void CreateEnemies()
    {
        int howManyEnemies = 0;

        for (int i = 0; i < currentRoom.npcTemplatesInRoom.Count; i++)
        {
            if (currentRoom.npcTemplatesInRoom[i].GetType() == typeof(EnemyNPCTemplate))
            {
                howManyEnemies++;
            }
        }

        if (howManyEnemies < 1)
        {
            return;
        }

        int exhaust = 0;

        int maxEnemies = Random.Range(1, 2);

        int randomCheck = Random.Range(0, (currentRoom.npcTemplatesInRoom.Count - 1));

        while (currentRoom.enemiesInRoom.Count < maxEnemies && exhaust < 50)
        {
            if (currentRoom.npcTemplatesInRoom[randomCheck].GetType() == typeof(EnemyNPCTemplate))
            {
                EnemyNPCTemplate enemy = currentRoom.npcTemplatesInRoom[randomCheck] as EnemyNPCTemplate;
                enemy.currentVisibility = enemy.defaultVisibility;

                GameObject newEnemy = Instantiate(enemy.enemyGameObject, currentRoom.roomPosition, Quaternion.identity);

                newEnemy.name = enemy.npcName;
                newEnemy.GetComponent <EnemyNPC>().myTemplate = enemy;
                currentRoom.enemiesInRoom.Add(newEnemy.GetComponent <EnemyNPC>());
            }
            randomCheck = Random.Range(0, (currentRoom.npcTemplatesInRoom.Count - 1));
            exhaust++;
        }
    }