Ejemplo n.º 1
0
    void SpawnEnemy(int indiceDoMinion = -1)
    {
        if (oJogador)
        {
            //spawn numa pos aleatoria
            Vector2 spawnPos = oJogador.position;
            while (Vector2.Distance(spawnPos, oJogador.position) < minAcceptableDistFromPlayer)
            {
                spawnPos = new Vector2(Random.Range(-maxSpawnDistFromCenter, maxSpawnDistFromCenter),
                                       Random.Range(-maxSpawnDistFromCenter, maxSpawnDistFromCenter));
            }
            GameObject spawnedEnemy = null;
            if (indiceDoMinion == -1)
            {
                spawnedEnemy =
                    (GameObject)Instantiate(enemyPrefabs[Random.Range(0, enemyPrefabs.Length)],
                                            spawnPos, Random.rotation);
            }
            else
            {
                spawnedEnemy =
                    (GameObject)Instantiate(enemyPrefabs[indiceDoMinion],
                                            spawnPos, Random.rotation);
            }
            InimigoController enemyScript = spawnedEnemy.GetComponent <InimigoController>();

            enemyScript.mySummoner = this;

            if (enemyScript.GetType() == typeof(MagoProtetorController))
            {
                MagoProtetorController magoScript = ((MagoProtetorController)enemyScript);
                magoScript.oTotem            = totemTransform.GetComponent <TotemScript>();
                magoScript.fleeFromTransform = oJogador;
                magoScript.myTarget          = totemTransform;
            }
            else
            {
                enemyScript.myTarget = oJogador;
            }
            ParticlesController.instancia.EmitirParticulas("spawnEffect", 20, spawnPos);
            SoundMan.instancia.EmitirSom("spawnz", 0.2f, spawnPos);
            if (autoSpawnEnemies)
            {
                Invoke("SpawnEnemy", Random.Range(0.8f, 7.0f));
            }

            minionsAtivos++;
        }
        else
        {
            this.enabled = false;
        }
    }
Ejemplo n.º 2
0
    public void DesligarMago(MagoProtetorController oMago)
    {
        if (magosLigados.Contains(oMago))
        {
            magosLigados.Remove(oMago);
            oMago.ToggleLaser(false);

            if (magosLigados.Count == 0)
            {
                ToggleShield(false);
            }
        }
    }
Ejemplo n.º 3
0
    public void AtualizarLigacaoDoMago(MagoProtetorController oMago)
    {
        if (!magosLigados.Contains(oMago))
        {
            magosLigados.Add(oMago);
            oMago.ToggleLaser(true);

            if (!shielded)
            {
                ToggleShield(true);
            }
        }
    }