コード例 #1
0
    /// <summary> Reset this objects position and materials. </summary>
    public virtual void ResetObject()
    {
        SenseGlove_Interactable senseScript = this.wholeObject.GetComponent <SenseGlove_Interactable>(); //TODO: Move this to init.

        if (senseScript != null)
        {
            senseScript.EndInteraction(senseScript.GrabScript());
            senseScript.ResetObject();
        }

        if (this.brokenObject != null)
        {
            senseScript = this.brokenObject.GetComponent <SenseGlove_Interactable>();
            if (senseScript != null)
            {
                senseScript.EndInteraction(senseScript.GrabScript());
                senseScript.ResetObject();
            }
        }
        this.UnBreak();
    }
コード例 #2
0
    /// <summary> Reset the object to before its broken state. </summary>
    public virtual void UnBreak()
    {
        //remove the broken object if we have one.
        if (this.brokenObject != null)
        {
            SenseGlove_Interactable senseScript = this.brokenObject.GetComponent <SenseGlove_Interactable>();
            if (senseScript)
            {
                senseScript.EndInteraction(senseScript.GrabScript());
            }
            this.brokenObject.gameObject.SetActive(false);
            if (this.brokenMaterial)
            {
                this.brokenMaterial.UnBreak();
            }
            if (this.brokenDeform)
            {
                this.brokenDeform.ResetMesh();
            }
            //Debug.Log("WholeObject is now on the position of the broken object");
            this.wholeObject.transform.position = this.brokenObject.transform.position;
            this.wholeObject.transform.rotation = this.brokenObject.transform.rotation;
        }

        //stop the particle effect(s)
        if (this.breakParticles)
        {
            this.breakParticles.Stop();
        }

        if (this.breakSound)
        {
            this.breakSound.Stop();
        }

        //unbreak the whole object
        if (this.wholeMaterial)
        {
            this.wholeMaterial.UnBreak();
        }
        this.wholeObject.gameObject.SetActive(true);

        this.resetTime = 0;
    }
コード例 #3
0
    /// <summary> Break the object: Hide the whole object, show the broken one and play the particle effect(s) </summary>
    public virtual void Break()
    {
        SenseGlove_Interactable senseScript = this.wholeObject.GetComponent <SenseGlove_Interactable>();

        if (senseScript)
        {
            senseScript.EndInteraction(senseScript.GrabScript());
        }

        if (this.wholeDeform)
        {
            this.wholeDeform.ResetMesh();
        }
        this.wholeObject.gameObject.SetActive(false);

        if (this.brokenObject)
        {
            this.brokenObject.transform.position = this.wholeObject.transform.position;
            this.brokenObject.transform.rotation = this.wholeObject.transform.rotation;
            this.brokenObject.gameObject.SetActive(true);
        }

        if (this.breakParticles)
        {
            this.breakParticles.gameObject.transform.position = this.wholeObject.transform.position;
            this.breakParticles.gameObject.transform.rotation = this.wholeObject.transform.rotation;
            this.breakParticles.Play();
        }

        if (this.breakSound)
        {
            this.breakSound.Play();
        }

        if (this.resets)
        {
            this.resetTime = 0;
        }
    }