示例#1
0
    // --------------------------------------------------
    // Called if the player enters a collider trigger (ie. collectible)
    // --------------------------------------------------
    void OnTriggerEnter(Collider other)
    {
        Collectible          coll = other.GetComponent <Collectible>();
        CollectibleExplosion exp  = other.GetComponent <CollectibleExplosion>();

        //Debug.Log(exp);
        // Debug.Log(coll);

        if (exp && exp.IsExploding())
        {
            if (mSlowMoveTimer <= 0f)
            {
                mCurrMoveSpeed /= 2f;
            }
            mSlowMoveTimer = 3f;
            mAnim.SetFloat("MoveSpeed", mCurrMoveSpeed);
        }

        if (coll && !coll.IsExploding())
        {
            int pointVal = coll.GetPointVal();
            SendMessage("UpdateScore", pointVal);

            // Play the pickup sound
            GameObject.Find("PickupSound").GetComponent <AudioSource>().Play();

            Destroy(other.gameObject);
        }
    }
示例#2
0
    // --------------------------------------------------
    // Called if the player is still in a collider trigger
    // --------------------------------------------------
    void OnTriggerStay(Collider other)
    {
        if (other.GetComponent <CollectibleExplosion>())
        {
            CollectibleExplosion exp = other.GetComponent <CollectibleExplosion>();

            //Debug.Log(exp);
            //Debug.Log(exp.IsExploding());

            if (exp.IsExploding())
            {
                if (mSlowMoveTimer <= 0f)
                {
                    mCurrMoveSpeed /= 2f;
                }
                mSlowMoveTimer = 3f;
                mAnim.SetFloat("MoveSpeed", mCurrMoveSpeed);
            }
        }
    }