예제 #1
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        // Get The laser object
        GameObject laser = collider.gameObject;
        // Get the projectile
        Projectile projectile = laser.GetComponent <Projectile> ();

        // If not a projectile, return
        if (!projectile)
        {
            return;
        }

        // Remove Health
        health -= projectile.Dammage;

        // Destroy laser
        projectile.Hit();

        // Check the remining health
        if (health <= 0)
        {
            ScoreKeeper.AddPoints(scoreValue);
            GameObject.Destroy(gameObject);
        }
    }
예제 #2
0
    void OnTriggerEnter(Collider coll)
    {
        PointsPickup pu = coll.GetComponent <PointsPickup> ();

        if (pu != null)
        {
            GameObject.Destroy(pu.gameObject);
            _pointsHUD.AddPoints(pu.points);
        }
    }
예제 #3
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Projectile missle = collision.gameObject.GetComponent <Projectile>();

        if (missle)
        {
            health -= missle.GetDamage();
            missle.Hit();
            if (health <= 0)
            {
                Destroy(gameObject);
                scoreKeeper.AddPoints(pointePerEnemy);
                AudioSource.PlayClipAtPoint(enemyDies, transform.position);
            }
        }
    }
예제 #4
0
    void OnTriggerEnter2D(Collider2D collision)
    {
        Projectile missile = collision.gameObject.GetComponent <Projectile>();

        if (missile)
        {
            AudioSource.PlayClipAtPoint(hit, transform.position);
            Instantiate(smallExplosion, transform.position, Quaternion.identity);
            missile.Hit();
            health -= missile.GetDamage();
            if (health <= 0)
            {
                Destroy(gameObject);
                //highScore.AddPoints();

                ScoreKeeper.AddPoints(scoreValue);
                AudioSource.PlayClipAtPoint(die, transform.position);
                Instantiate(bigExplosion, transform.position, Quaternion.identity);
            }
            //Debug.Log("Hit by projectile");
        }
    }