Ejemplo n.º 1
0
    public GameObject SpawnSlime(Slime slimeSettings)
    {
        GameObject mob = mobPooler.GetPooledObject();

        mob.GetComponent <SlimeController>().patrolPoints  = GetTilesLocations(3);
        mob.GetComponent <SlimeController>().enemySettings = slimeSettings;


        //Vector2 randomPosition = tilemapLocations[Random.Range(0, tilemapLocations.Count)];
        Vector3 randomPosition = Random.insideUnitCircle.normalized * Random.Range(spawningInnerRadius, spawningOuterRadius);

        mob.transform.position = transform.position + randomPosition;
        mob.SetActive(true);
        if (instantiatedSlimes.Count < maxSpawnedMobs)
        {
            _spawnedSlimes++;
            instantiatedSlimes.Add(mob);
        }
        //update graph :
        return(mob);
    }
Ejemplo n.º 2
0
    private void SpawnEnemy()
    {
        Transform randomLocation = spawnLocations[Random.Range(0, spawnLocations.Length)];
        Vector3   spawnPos       = randomLocation.position;
        int       random         = Random.Range(0, 3);
        Enemy     enemy          = null;

        if (random == 0)
        {
            enemy = enemyAPooler.GetPooledObject();
        }
        else if (random == 1)
        {
            enemy = enemyBPooler.GetPooledObject();
        }
        else
        {
            enemy = enemyCPooler.GetPooledObject();
        }

        enemy.transform.position = spawnPos;
        enemy.Spawn();
    }