Example #1
0
    // Update is called once per frame
    void Update()
    {
        InimigoController alvo = EscolheAlvo();

        if (alvo != null)
        {
            Atira(alvo);
        }
    }
Example #2
0
 private void OnTriggerEnter(Collider elementoColidido)
 {
     if (elementoColidido.CompareTag("Inimigo"))
     {
         Destroy(this.gameObject);
         // Destroy(elementoColidido.gameObject);
         InimigoController inimigo = elementoColidido.GetComponent <InimigoController>();
         inimigo.RecebeDano(pontosDeDano);
     }
 }
Example #3
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;
        }
    }
Example #4
0
    private void Atira(InimigoController inimigo)
    {
        float TempoAtual = Time.time;

        if (TempoAtual > momentoDoUltimoDisparo + tempoDeRecarga)
        {
            momentoDoUltimoDisparo = TempoAtual;

            GameObject pontoDeDisparo          = this.transform.Find("CanhaoDaTorre/PontoDeDisparo").gameObject;
            Vector3    posicaoDoPontoDeDisparo = pontoDeDisparo.transform.position;
            //Instantiate(projetilPrefab, posicaoDoPontoDeDisparo, Quaternion.identity);
            GameObject projetilObject = (GameObject)Instantiate(projetilPrefab, posicaoDoPontoDeDisparo, Quaternion.identity);

            Missil missil = projetilObject.GetComponent <Missil>();
            missil.DefineAlvo(inimigo);
        }
    }
Example #5
0
 public void DefineAlvo(InimigoController inimigo)
 {
     alvo = inimigo;
 }