void OnCollisionEnter(Collision collision)
 {
     BoxRef.isTrigger = false;
     ScriptRef.Play();
     Object.Destroy(gameObject, 2.0f);
     Destroy(transform.parent.gameObject, 2.0f);
     ScriptRef.Loop = false;
 }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        if (isTicking == true)
        {
            delay            += Time.deltaTime;
            TimeSinceCadence += Time.deltaTime;
            if (TimeSinceCadence > Cadence)
            {
                Sound.clip = A[0];
                Sound.Play();
                Cadence          = Cadence * .8f;
                TimeSinceCadence = 0;
                if (Cadence < .25f)
                {
                    Cadence = 200f;
                }
            }
            TimeSinceCadence += Time.deltaTime;
        }

        if (isTicking == true && delay < 2)
        {
            Reference.material.color = Color.grey;
        }
        else if (delay > 2 && delay < 4)
        {
            Reference.material.color = Color.yellow;
        }
        else if (delay > 4)
        {
            Reference.material.color = Color.red;
        }

        if (delay > 6 && isTicking == true && once == false)
        {
            isTicking = false;
            once      = true;
            ScriptRef.Play();
            Objects    = Physics.OverlapSphere(transform.position, radius);
            Sound.clip = A[1];
            Sound.Play();

            foreach (Collider each in Objects)
            {
                Debug.Log("Here starts " + each);
                if (each.GetComponent <Rigidbody>() != null && each.tag == "coin")
                {
                    each.GetComponent <Rigidbody>().AddExplosionForce(200f, transform.position, radius, 10f, ForceMode.Impulse);
                    Debug.Log("Here Ends" + each);
                }
            }

            gameObject.GetComponentInChildren <MeshRenderer>().enabled = false;
            Destroy(gameObject, 2);
        }
    }
示例#3
0
    private IEnumerator Boom()
    {
        isExploding = true;
        rocket.SetActive(false);
        trail.SetActive(false);
        explosion.Play();

        yield return(new WaitForSeconds(explosion.Duration));

        if (PhotonNetwork.connected)
        {
            if (photonView.isMine)
            {
                PhotonNetwork.Destroy(gameObject);
            }
        }
        else
        {
            Destroy(gameObject);
        }
    }