Exemplo n.º 1
0
    void OnTriggerEnter2D(Collider2D col)
    {
        Projectile missile = col.gameObject.GetComponent <Projectile> ();

        if (missile)
        {
            health -= missile.GetDamage();
            missile.Hit();
            if (health <= 0)
            {
                AudioSource.PlayClipAtPoint(shipExplode, transform.position);
                Destroy(gameObject);
                scoreKeeper.Score(scoreValue);
            }
        }
    }
Exemplo n.º 2
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.GetComponent <Projectile>())
     {
         Projectile projectile = other.GetComponent <Projectile>();
         health -= projectile.GetDamage();
         if (health <= 0)
         {
             AudioSource.PlayClipAtPoint(destroyed, transform.position);
             Destroy(gameObject);
             scoreboard.Score(points);
         }
         projectile.hit();
         Debug.Log("Laser hit");
     }
 }
Exemplo n.º 3
0
    void OnTriggerEnter2D(Collider2D col)
    {
        PlayerController player = col.gameObject.GetComponent <PlayerController> ();

        if (player && !player.shield)
        {
            player.shield       = true;
            player.shieldObject = Instantiate(shieldPrefab, this.transform.position, Quaternion.identity) as GameObject;
            Destroy(gameObject);
        }
        else if (player && player.shield)
        {
            Scorekeeper scoreKeeper = GameObject.Find("Score").GetComponent <Scorekeeper> ();
            scoreKeeper.Score(50);
            Destroy(gameObject);
        }
    }
Exemplo n.º 4
0
 void Die()
 {
     AudioSource.PlayClipAtPoint(deathSound, transform.position);
     Scorekeeper.Score(10);
     Destroy(gameObject);
 }