Esempio n. 1
0
    void OnTriggerEnter(Collider col)
    {
        //Check to see if ship collided with redlaser
        if (col.name == "redlaser(Clone)" || col.tag == "PlayersLaser")
        {
            //Destroy red laser
            Destroy(col.gameObject);
            buildingHealth -= 10f;

            //Check if enemy health is 0 or less
            if (buildingHealth <= 0)
            {
                Instantiate(explosion, transform.position, transform.rotation);
                Destroy(gameObject);
            }
        }

        //Check to see if ship collided with torpedo
        if (col.name == "protonTorpedo(Clone)")
        {
            Destroy(col.gameObject);
            buildingHealth -= 50f;

            //Check if enemy health is 0 or less
            if (buildingHealth <= 0)
            {
                Instantiate(explosion, transform.position, transform.rotation);
                Destroy(gameObject);
            }
        }

        //Check to see if ship collided with redlaser
        if (col.name == "atatlaser(Clone)")
        {
            //Destroy red laser
            Instantiate(explosion, col.gameObject.transform.position, col.gameObject.transform.rotation);
            Destroy(col.gameObject);
            buildingHealth -= 75f;


            //Check if enemy health is 0 or less
            if (buildingHealth <= 0)
            {
                if (transform.name == "ShieldGenerator")
                {
                    hothScript hScript = GameObject.Find("LevelManager").GetComponent <hothScript>();
                    hScript.shieldDown = true;
                }
                Instantiate(explosion, transform.position, transform.rotation);
                Destroy(gameObject);
            }
        }
    }
Esempio n. 2
0
    void OnTriggerEnter(Collider col)
    {
        //Check to see if ship collided with redlaser
        if (col.name == "redlaser(Clone)" || col.tag == "PlayersLaser")
        {
            //Destroy red laser
            Instantiate(sparks, col.transform.position, col.transform.rotation);
            Destroy(col.gameObject);
            //Set enemy health back 20 points
            enemyHealth -= 10f;

            //Check if enemy health is 0 or less
            if (enemyHealth <= 0)
            {
                hothScript hScript = GameObject.Find("LevelManager").GetComponent <hothScript>();
                hScript.atatsDestroyed += 1;
                Instantiate(explosion, transform.position, transform.rotation);
                Destroy(gameObject);
            }
        }

        //Check to see if ship collided with torpedo
        if (col.name == "protonTorpedo(Clone)")
        {
            //Destroy torpedo
            Destroy(col.gameObject);
            enemyHealth -= 75f;
            //Check if enemy health is 0 or less
            if (enemyHealth <= 0)
            {
                Instantiate(explosion, transform.position, transform.rotation);
                hothScript hScript = GameObject.Find("LevelManager").GetComponent <hothScript>();
                hScript.atatsDestroyed += 1;
                Instantiate(explosion, transform.position, transform.rotation);
                Destroy(gameObject);
            }
        }

        //unit reached destination point
        if (col.tag == "AiCheckpoint")
        {
            //stop walking
            canWalk = false;
            walkSound.Stop();
            target = ShieldGenerator;
        }
    }