Пример #1
0
    void OnCollisionEnter(Collision collision)
    {
        // the Collision contains a lot of info, but it’s the colliding
        // object we’re most interested in.
        Collider collider = collision.collider;

        if (collider.CompareTag("Astroids"))
        {
            Astroid roid = collider.gameObject.GetComponent <Astroid>();
            // let the other object handle its own death throes
            roid.Die();
            // Destroy the Bullet which collided with the Asteroid
            Destroy(gameObject);
        }
        else if (collider.CompareTag("UFO"))
        {
            UFO foe = collider.gameObject.GetComponent <UFO>();
            foe.Die();
            Destroy(gameObject);
        }
        else
        {
            //TODO
            // if we collided with something else, print to console
            // what the other thing was
            Debug.Log("Collided with " + collider.tag);
        }
    }
Пример #2
0
    void OnCollisionEnter(Collision collision)
    {
        Collider collider = collision.collider;

        if (collider.CompareTag("Penemy1"))
        {
            enemy1cs e1 = collider.gameObject.GetComponent <enemy1cs>();
            e1.Die();
            Destroy(gameObject);
        }
        if (collider.CompareTag("Penemy2"))
        {
            enemy2cs e2 = collider.gameObject.GetComponent <enemy2cs>();
            e2.Die();
            Destroy(gameObject);
        }
        if (collider.CompareTag("Penemy3"))
        {
            enemy3cs e3 = collider.gameObject.GetComponent <enemy3cs>();
            e3.Die();
            Destroy(gameObject);
        }
        if (collider.CompareTag("bunker"))
        {
            bunker eb = collider.gameObject.GetComponent <bunker>();
            eb.Die();
            Destroy(gameObject);
        }
        if (collider.CompareTag("UFO"))
        {
            UFO uf = collider.gameObject.GetComponent <UFO>();
            uf.Die();
            Destroy(gameObject);
        }
        if (collider.CompareTag("boss"))
        {
            Global gbs = GameObject.FindGameObjectWithTag("FGlobal").GetComponent <Global>();
            boss   bs  = GameObject.FindGameObjectWithTag("boss").GetComponent <boss>();
            AudioSource.PlayClipAtPoint(hitclipboss, bs.transform.position, 10);
            Instantiate(explosion, bs.transform.position, Quaternion.identity);
            gbs.bosslives--;
        }
        if (collider.CompareTag("Fplayer"))
        {
        }
        else
        {
            Destroy(gameObject);
        }
    }
Пример #3
0
    //Used to destroy ships
    void OnCollisionEnter(Collision collision)
    {
        // the Collision contains a lot of info, but it’s the colliding
        // object we’re most interested in.
        GameObject obj      = GameObject.Find("GlobalObject");
        Global     g        = obj.GetComponent <Global>();
        Collider   collider = collision.collider;

        if (collider.CompareTag("Ship"))
        {
            Ship ourShip = collider.gameObject.GetComponent <Ship>();
            ourShip.Die();
            //g.score += pointValue;
            g.currNumAstr--;
            Destroy(gameObject);
        }
        else if (collider.CompareTag("UFO"))
        {
            UFO foe = collider.gameObject.GetComponent <UFO>();
            foe.Die();
            Destroy(gameObject);
            g.currNumAstr--;
        }
    }