예제 #1
0
    private void SpawnMonsters()
    {
        for (int i = 0; i < 12; i++)
        {
            while (true)
            {
                int x = Random.Range(0, generatorInstance.GetWorldSize().x);
                int y = Random.Range(0, generatorInstance.GetWorldSize().y - 34);

                // Dont spawn on top of the player or right next to them
                if (generatorSpec.GetSpawn().x > x - 5 && generatorSpec.GetSpawn().x < x + 5)
                {
                    continue;
                }
                if (generatorInstance.IsValidMonsterSpawn(new Vector2Int(x, y)))
                {
                    SlimeEnemy slime = Instantiate(slimeEnemyPrefab, new Vector2(x, y), Quaternion.identity);
                    slime.SetLightColor(Random.ColorHSV());
                    break;
                }
            }
        }

        for (int i = 0; i < 6; i++)
        {
            while (true)
            {
                int x = Random.Range(0, generatorInstance.GetWorldSize().x);
                int y = Random.Range(0, generatorInstance.GetWorldSize().y - 34);

                // Dont spawn on top of the player or right next to them
                if (generatorSpec.GetSpawn().x > x - 5 && generatorSpec.GetSpawn().x < x + 5)
                {
                    continue;
                }
                if (generatorInstance.IsValidMonsterSpawn(new Vector2Int(x, y)))
                {
                    DopplerEnemy doppler = Instantiate(dopplerEnemyPrefab, new Vector2(x, y), Quaternion.identity);
                    doppler.gameManager = this;
                    break;
                }
            }
        }
        SpiderEnemy spider = Instantiate(spiderEnemyPrefab, new Vector2(31, 146), Quaternion.identity);

        spider.gameManager = this;
    }