Ejemplo n.º 1
0
    public void StartFall()
    {
        float val = Mathf.Abs(Vector3.Magnitude(player.transform.position - this.transform.position));

        if (val <= 20)
        {
            if (!down_estalagmite)
            {
                if (hited)
                {
                    state = STALACTITE_STATE.READY_TO_FALL_ST;
                }
                else
                {
                    hited = true;
                }
            }
        }
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (state == STALACTITE_STATE.READY_TO_FALL_ST)
        {
            cur_delay += Time.deltaTime;
            if (cur_delay >= fall_delay)
            {
                state     = STALACTITE_STATE.FALLING_ST;
                cur_delay = 0.0f;
                Fall();
            }
        }
        else if (state == STALACTITE_STATE.FALLING_ST)
        {
            float val = Mathf.Abs(Vector3.Magnitude(player.transform.position - this.transform.position));

            if (val >= 35)
            {
                stalagmite_a.SetActive(false);
                stalagmite_a.transform.position = stalagmite_a_init_pos;
                stalagmite_a.transform.rotation = stalagmite_a_init_rot;

                stalagmite_b.SetActive(false);
                stalagmite_b.transform.position = stalagmite_b_init_pos;
                stalagmite_b.transform.rotation = stalagmite_b_init_rot;

                stalagmite_c.SetActive(false);
                stalagmite_c.transform.position = stalagmite_c_init_pos;
                stalagmite_c.transform.rotation = stalagmite_c_init_rot;

                this.GetComponent <SpriteRenderer>().enabled = true;
                this.GetComponent <BoxCollider>().enabled    = true;

                hited = false;
            }
        }
    }
Ejemplo n.º 3
0
    public void Fall()
    {
        //Disable the main cube and instance the three childs
        this.GetComponent <SpriteRenderer>().enabled = false;
        this.GetComponent <BoxCollider>().enabled    = false;

        stalagmite_a.SetActive(true);
        stalagmite_a.GetComponent <Rigidbody>().isKinematic = true;
        stalagmite_a.GetComponent <Rigidbody>().isKinematic = false;
        stalagmite_b.SetActive(true);
        stalagmite_b.GetComponent <Rigidbody>().isKinematic = true;
        stalagmite_b.GetComponent <Rigidbody>().isKinematic = false;
        stalagmite_c.SetActive(true);
        stalagmite_c.GetComponent <Rigidbody>().isKinematic = true;
        stalagmite_c.GetComponent <Rigidbody>().isKinematic = false;


        /*this.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.None;
         * this.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezeRotationZ | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezePositionY;
         * this.GetComponent<Rigidbody>().useGravity = true;
         * this.GetComponent<Rigidbody>().isKinematic = false;*/

        state = STALACTITE_STATE.FALLING_ST;
    }