示例#1
0
    private void OnTriggerEnter(Collider other)
    {
        if (barrel == null && other.tag == "Barrel")
        {
            barrelScript = other.GetComponent <Barrel>();
            if (!barrelScript.IsStuck && !barrelScript.IsBroken)
            {
                barrelScript.IsStuck = true;
                barrel    = other.transform;
                nowInsert = true;
            }
            else
            {
                barrelScript = null;
            }
        }

        if (bioTop == null && other.tag == "BioTop")
        {
            bioTopScript = other.GetComponent <BioTop>();
            if (!bioTopScript.IsStuck)
            {
                bioTopScript.IsStuck = true;
                bioTop  = other.transform;
                isTopOn = true;
            }
            else
            {
                bioTopScript = null;
            }
        }
    }
示例#2
0
    private void OnTriggerExit(Collider other)
    {
        if (barrel != null && other.gameObject.Equals(barrel.gameObject) && other.GetComponent <InteractionalObjects>().IsGrip)
        {
            barrel.GetComponent <Rigidbody>().isKinematic = false;
            barrel.GetComponent <Rigidbody>().WakeUp();

            barrelScript.IsStuck = false;
            barrelScript         = null;
            barrel    = null;
            nowInsert = false;
        }

        if (bioTop != null && other.gameObject.Equals(bioTop.gameObject) && other.GetComponent <InteractionalObjects>().IsGrip)
        {
            bioTop.GetComponent <Rigidbody>().isKinematic = false;
            bioTop.GetComponent <Rigidbody>().WakeUp();

            bioTopScript.IsStuck = false;
            bioTopScript         = null;
            bioTop  = null;
            isTopOn = false;
        }
    }