コード例 #1
0
    public void GenerateEnemies(int min = 2, int max = 6)
    {
        GameManager gm = GameManager.singleton;

        // 2-6 enemies - unless facing the singular Dragon
        int numEntities = Random.Range(min, max + 1);

        if (gm.enemyTier == GameManager.bossTier)
        {
            numEntities = 1;
        }

        var prevLocations = new List <Vector3>();

        for (int i = 0; i < numEntities; i++)
        {
            var location = GetRandomLocation(3, prevLocations);
            prevLocations.Add(location);

            var enemyInfo = EnemyDatabase.GetEnemyOfTier(gm.enemyTier);

            if (enemyInfo != null)
            {
                Enemy enemy = Instantiate(enemyRef, location, Quaternion.identity).GetComponent <Enemy>();
                enemy.SetEnemy(enemyInfo);
                GameManager.singleton.RegisterEntity(enemy);
            }
            else
            {
                Debug.Log($"Enemy info null. Tier {gm.enemyTier}");
            }
        }
    }