Esempio n. 1
0
    private void HandleTriggerUnClicked(object sender, ClickedEventArgs e)
    {
        //  Debug.Log("uncliceked trigger");
        if (editing)
        {
            if (start != far)                      //get one point to extrude;
            //   Debug.Log("current tag is " + objToextrude.tag);
            {
                if (objToextrude != null)
                {
                    if (objToextrude.CompareTag("Ecube"))
                    {
                        Vector3 triggerPoint = transform.position;
                        end = objToextrude.transform.InverseTransformPoint(triggerPoint);
                        Extrude_cube extrude = objToextrude.GetComponent <Extrude_cube>();
                        extrude.Extrude(start, end);
                        start = far;
                    }
                }
                else
                {
                    Debug.Log("obj to extrude is null");
                }
            }

            if (objToextrude != null && objToextrude.CompareTag("Cylinder"))
            {
                Vector3 triggerPoint = transform.position;
                end = objToextrude.transform.InverseTransformPoint(triggerPoint);
                Debug.Log("the end point to extrude is" + end);
                objToextrude.transform.localScale += new Vector3(Mathf.Abs(end.x) / 5, Mathf.Abs(end.y) / 10, Mathf.Abs(end.x) / 5);
            }
            start        = far;
            objToextrude = null;
            objToErease  = null;
        }
        else
        {
            ReleaseObject();
        }
    }
Esempio n. 2
0
    private void HandleTriggerClicked(object sender, ClickedEventArgs e)
    {
        // this object was clicked - do something
        //  Debug.Log("cliceked trigger");
        GameObject obj    = GameObject.Find("GlobalObject");
        Global     g      = obj.GetComponent <Global>();
        bool       status = g.selected;

        if (collidingObject != null && collidingObject.CompareTag("star"))
        {
            Debug.Log("hit the star````````````````````````````````00");
            collidingObject.GetComponent <AnimationScript>().Die();   //to collect the star
        }
        else if (editing)
        {
            if (collidingObject != null)
            {
                if (collidingObject.CompareTag("Ecube"))
                {
                    //Debug.Log ("trigger clicked extude cube");
                    //get the start point
                    Vector3 triggerplace = transform.position;
                    Vector3 localtrigger = collidingObject.transform.InverseTransformPoint(triggerplace);
                    Debug.Log("the trigger in cube space is" + localtrigger);
                    Extrude_cube extrude = collidingObject.GetComponent <Extrude_cube> ();

                    start = extrude.faces [0].center;
                    float distance = (localtrigger - start).magnitude;
                    for (int i = 1; i < extrude.faces.Count; i++)
                    {
                        float length = (extrude.faces [i].center - localtrigger).magnitude;
                        if (distance > length)
                        {
                            start    = extrude.faces [i].center;
                            distance = length;
                        }
                    }
                    Debug.Log("the start point to extrude is" + start);
                    objToextrude = collidingObject;
                    g.selected   = false;
                }

                else if (collidingObject.CompareTag("Cylinder"))
                {
                    Debug.Log("trigger clicked extude Cylinder");
                    //get the start point
                    objToextrude = collidingObject;
                    g.selected   = false;
                }

                else if (collidingObject.CompareTag("Dot"))
                {
                    //if (is_collide == true) {
                    if (status == false)
                    {
                        status = true;
                        //	Debug.Log ("status false");
                        g.selected = true;
                        g.start    = gameObject.transform.position;
                        // Destroy(gameObject);
                    }
                    else
                    {
                        //	Debug.Log ("status true");
                        g.end      = gameObject.transform.position;
                        g.selected = false;
                        g.color    = new Color(0.2f, 1, 0.4f);
                        g.DrawLine(g.start, g.end, g.color);
                        //	Debug.Log ("start is" + g.start + "and end is " + g.end);
                        if (g.count >= 4)
                        {
                            if (collidingObject.GetComponent <DotController>().cube.CompareTag("Ecube"))
                            {
                                collidingObject.GetComponent <DotController>().cube.GetComponent <Extrude_cube>().Die();
                            }
                            else if (collidingObject.GetComponent <DotController>().cube.CompareTag("Cylinder"))
                            {
                                collidingObject.GetComponent <DotController>().cube.GetComponent <Extrude_cylinder>().Die();
                            }
                            g.count         = 0;
                            collidingObject = null;
                            // Destroy(gameObject);
                        }
                    }
                    //}
                }
            }
            else
            {
                Debug.Log("trigger clicked but no colliding object");
            }
        }
        else
        {
            if (collidingObject != null)
            {
                GrabObject();
            }
        }
    }