void DetectDeadRaison()
    {
        dead   = true;
        attack = 0;
        HumanController human = GetComponent <HumanController> ();

        if (human)
        {
            human.dead = true;
        }
        Rigidbody2D body = GetComponent <Rigidbody2D> ();

        if (body)
        {
            Rigidbody2D.Destroy(body);
        }
        if (sounds)
        {
            sounds.Play("Dead");
        }
        if (animator)
        {
            animator.SetTrigger("Dead");
        }
        if (sounds || animator)
        {
            Invoke("Kill", 2.5f);
        }
        else
        {
            Kill();
        }
    }
Exemple #2
0
    private void OnTriggerEnter2D(Collider2D BalaCollider)

    {
        GameObject bala = BalaCollider.gameObject;

        Rigidbody2D.Destroy(bala);
    }
Exemple #3
0
    int i = 0; //variable contador

    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (i < 2)
        {
            if (i == 0)                                               //si recibe el primer golpe...
            {
                escudo.transform.localScale = new Vector3(4f, 2f, 0); //escalamos el escudo a un tamaño menor
            }
            if (i == 1)                                               //si recibe el segundo golpe...
            {
                escudo.transform.localScale = new Vector3(2f, 1f, 0); //lo volvemos a escalar a un tamaño menor
            }
            GameObject balaEnemigo = collision.gameObject;
            Rigidbody2D.Destroy(balaEnemigo); //cada vez que reciba un golpe los escudos, destruimos las balas enemigas.


            i++;
        }
        else   // y si recibe el tercer golpe...
        {
            GameObject balaEnemigo = collision.gameObject;
            Rigidbody2D.Destroy(balaEnemigo);
            Rigidbody2D.Destroy(escudo);
        }
    }
Exemple #4
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        Rigidbody2D.Destroy(bala);
        GameObject balaEnemigo = collision.gameObject;

        Rigidbody2D.Destroy(balaEnemigo);
    }
 // Update is called once per frame
 void Update()
 {
     attack_timer += Time.deltaTime;
     if (is_human_castle && !game_over && hit_points < 1)
     {
         game_over = true;
         Debug.Log("The Orc Team wins.");
         GetComponent <unit_sounds>().Play("Acknowledge");
         CircleCollider2D.Destroy(GetComponent <CircleCollider2D>());
         SpriteRenderer.Destroy(GetComponent <SpriteRenderer>());
         Invoke("Restart", 5);
     }
     if (is_orc_castle && !game_over && hit_points < 1)
     {
         game_over = true;
         Debug.Log("The Human Team wins.");
         GetComponent <unit_sounds>().Play("Acknowledge");
         CircleCollider2D.Destroy(GetComponent <CircleCollider2D>());
         SpriteRenderer.Destroy(GetComponent <SpriteRenderer>());
         Invoke("Restart", 5);
     }
     if ((is_human_castle || is_orc_castle) && game_over)
     {
         return;
     }
     if (hit_points < 1 && dead == false)
     {
         dead   = true;
         attack = 0;
         footman_ex01 footman = GetComponent <footman_ex01>();
         if (footman)
         {
             footman.dead = true;
         }
         Rigidbody2D body = GetComponent <Rigidbody2D>();
         if (body)
         {
             Rigidbody2D.Destroy(body);
         }
         unit_sounds sounds = GetComponent <unit_sounds>();
         if (sounds)
         {
             sounds.Play("Dead");
         }
         Animator animator = GetComponent <Animator>();
         if (animator)
         {
             animator.SetTrigger("Dead");
         }
         if (sounds || animator)
         {
             Invoke("Kill", 2.5f);
         }
         else
         {
             Kill();
         }
     }
 }
Exemple #6
0
    private void OnCollisionEnter2D(Collision2D ballCollision)
    {
        Rigidbody2D.Destroy(marciano);



        GameObject bala = ballCollision.gameObject;

        Rigidbody2D.Destroy(bala);
    }
Exemple #7
0
    //Сдох
    void Die()
    {
        //Debug.Log(myName + ": Die(): " + checkDie_bot);
        //Если checkDie истина, то.........
        if (checkDie_bot)
        {
            //Debug.Log(myName + ": Die(): " + checkDie_bot);
            //GUI.Label(new Rect(10, 10, 100, 20), "Hello World!");
            //Делаем её ложной, чтобы не дохнуть 1000+ раз в секунду, а только один раз.
            checkDie_bot = false;

            BoxCollider2D col = GetComponent <BoxCollider2D>();
            col.GetComponent <BoxCollider2D>();
            col.enabled = false;

            Rigidbody2D.Destroy(GetComponent <Rigidbody2D>());

            Debug.Log(myName + ": I am die...");
        }
        //Debug.Log(myName + ": Die()_2: " + checkDie_bot);
    }
Exemple #8
0
    private void OnCollisionEnter2D(Collision2D collision) //metodo para detectar las colisiones de la nave
    {
        if (i < 2)
        {
            if (i == 0)                    // si recibimos el primer golpe...
            {
                GameObject.Destroy(Vida1); //quitamos una vida
            }

            if (i == 1)                    //si recibimos el segundo golpe...
            {
                GameObject.Destroy(Vida2); // quitamos otra vida
            }

            if (sonidoGolpe)
            {
                AudioSource.PlayClipAtPoint(sonidoGolpe, transform.position, Volumen);
            }

            GameObject balaEnemigo = collision.gameObject;
            Rigidbody2D.Destroy(balaEnemigo); //y cada vez que recibamos un golpe, vamos destruyendo las balas enemigas
            i++;
        }
        else                                                                            //y cuando recibamos el tercer golpe...
        {
            GameObject.Destroy(Vida3);                                                  //quitamos la ultima vida
            GameObject balaEnemigo = collision.gameObject;
            Rigidbody2D.Destroy(balaEnemigo);                                           //destruimos la bala enemiga
            Rigidbody2D.Destroy(Nave);                                                  //destruimos la nave
            Time.timeScale      = 0;                                                    //pausamos el juego
            gameOver.text       = "GAME OVER";                                          //ponemos por pantalla "Game Over"
            reiniciar.reiniciar = true;                                                 //Activamos que se pueda reiniciar
            if (sonidoMuerte)                                                           // y si hay sonido añadido...
            {
                AudioSource.PlayClipAtPoint(sonidoMuerte, transform.position, Volumen); //reproducimos el sonido de la cabra gritando
            }
            camara.GetComponent <AudioSource>().mute = true;
        }
    }
Exemple #9
0
    private void OnTriggerEnter2D(Collider2D collision) // con un trigguer en la parte inferior
    {
        GameObject balaEnemigo = collision.gameObject;

        Rigidbody2D.Destroy(balaEnemigo);
    }