Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        if (pasoActual <= m_points.Count)
        {
            if (m_points != null)
            {
                Debug.Log("TOTAL:" + m_points.Count);
                Debug.Log("Exte:" + (m_points.Count - 53));



                for (int i = 0; i < pasoActual; i++)
                {
                    //Gizmos.color = Color.blue;
                    var color = Color.blue;
                    if (i < m_points.Count - 48)
                    {
                        color = Color.magenta;
                    }
                    Vector3 pos = new Vector3(m_points[i].x, m_points[i].y, 0);
                    Gizmos.Sphere(pos, 0.15f, color);
                    //Gizmos.Circle(pos, 0.15f, mainCam, color);
                    //DrawString("("+i+")", pos, Color.white);
                }
            }
        }
        else
        {
            for (int i = 0; i < m_points.Count; i++)
            {
                //Gizmos.color = Color.blue;
                var color = Color.blue;
                if (i < m_points.Count - 48)
                {
                    color = Color.magenta;
                }
                Vector3 pos = new Vector3(m_points[i].x, m_points[i].y, 0);
                Gizmos.Sphere(pos, 0.15f, color);
            }
        }


        if (pasoActualDelaunay <= m_delaunayTriangulation.Count)
        {
            if (m_delaunayTriangulation != null)
            {
                for (int i = 0; i < pasoActualDelaunay; i++)
                {
                    var t     = m_delaunayTriangulation[i];
                    var vp0   = (Vector2)t.p0;
                    var vp1   = (Vector2)t.p1;
                    var left  = new Vector3(vp0.x, vp0.y, 0);
                    var right = new Vector3(vp1.x, vp1.y, 0);

                    Gizmos.Line(left, right, Color.black);
                }
            }
        }
        //gizmos.color = color.yellow;
    }
Esempio n. 2
0
    private void OnRenderObject()
    {
        //draw a line from the position of the object, to world center
        //with the color green, and dashed as well
        Gizmos.Line(transform.position, Vector3.one, Color.green, true);

        //draw a cube at the position of the object, with the correct rotation and scale
        Gizmos.Cube(transform.position, transform.rotation, transform.lossyScale);
    }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.F3))
        {
            Gizmos.Enabled = !Gizmos.Enabled;
        }

        //can also draw from update
        Gizmos.Cone(transform.position, transform.rotation, 15f, 45f, Color.green);
    }
Esempio n. 4
0
 static void DrawCircle(Circle s, Color c)
 {
     for (int i = 0; i < 360; i += 360 / CircleSubdivision)
     {
         Gizmos.Line(
             new Vector3(s.center.x + Mathf.Sin(Mathf.Deg2Rad * i) * s.radius, s.center.y + Mathf.Cos(Mathf.Deg2Rad * i) * s.radius),
             new Vector3(s.center.x + Mathf.Sin(Mathf.Deg2Rad * (i + (360 / CircleSubdivision))) * s.radius, s.center.y + Mathf.Cos(Mathf.Deg2Rad * (i + (360 / CircleSubdivision))) * s.radius),
             c,
             false
             );
     }
 }
Esempio n. 5
0
    static void DrawRect(Rectangle r, Color c)
    {
        Gizmos.Line(new Vector3(r.center.x - r.width / 2, r.center.y - r.height / 2), new Vector3(r.center.x - r.width / 2, r.center.y + r.height / 2), c, false);


        Gizmos.Line(new Vector3(r.center.x + r.width / 2, r.center.y - r.height / 2), new Vector3(r.center.x + r.width / 2, r.center.y + r.height / 2), c, false);


        Gizmos.Line(new Vector3(r.center.x - r.width / 2, r.center.y + r.height / 2), new Vector3(r.center.x + r.width / 2, r.center.y + r.height / 2), c, false);


        Gizmos.Line(new Vector3(r.center.x - r.width / 2, r.center.y - r.height / 2), new Vector3(r.center.x + r.width / 2, r.center.y - r.height / 2), c, false);
    }
Esempio n. 6
0
    static void DrawRect(Rectangle r, Color c)
    {
        //lb - lu
        Gizmos.Line(new Vector3(r.center.x - r.width / 2, r.center.y - r.height / 2), new Vector3(r.center.x - r.width / 2, r.center.y + r.height / 2), c, false);

        //rb - ru
        Gizmos.Line(new Vector3(r.center.x + r.width / 2, r.center.y - r.height / 2), new Vector3(r.center.x + r.width / 2, r.center.y + r.height / 2), c, false);

        //lu - ru
        Gizmos.Line(new Vector3(r.center.x - r.width / 2, r.center.y + r.height / 2), new Vector3(r.center.x + r.width / 2, r.center.y + r.height / 2), c, false);

        //lb - rb
        Gizmos.Line(new Vector3(r.center.x - r.width / 2, r.center.y - r.height / 2), new Vector3(r.center.x + r.width / 2, r.center.y - r.height / 2), c, false);
    }
Esempio n. 7
0
    void drawLines()
    {
        if (m_delaunayTriangulation != null)
        {
            for (int i = 0; i < m_delaunayTriangulation.Count; i++)
            {
                //Vector2 left = (Vector2)m_delaunayTriangulation[i].p0;
                // Vector2 right = (Vector2)m_delaunayTriangulation[i].p1;
                var t     = m_delaunayTriangulation[i];
                var vp0   = (Vector2)t.p0;
                var vp1   = (Vector2)t.p1;
                var left  = new Vector3(vp0.x, vp0.y, 0);
                var right = new Vector3(vp1.x, vp1.y, 0);

                Gizmos.Line(left, right, Color.green);
            }
        }
    }
Esempio n. 8
0
    private void ReflectLaser(Vector3 position, Vector3 direction)
    {
        if (Input.GetKey(KeyCode.Space))
        {
            Vector3 startingPosition = position;

            Ray        ray = new Ray(position, direction);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit, maxDist))
            {
                direction = Vector3.Reflect(direction, hit.normal);
                position  = hit.point;
            }
            else
            {
                position += direction * maxDist;
            }

            Gizmos.Enabled = true;
            Gizmos.Line(startingPosition, position, Color.green, false);
            if (hit.collider.tag == "Exit")
            {
                WinMenuUI.SetActive(true); // активує меню
                Time.timeScale = 0f;       //Зупиняє всі рухомі об'єкти на сцені, якщо вони є
            }

            if (hit.collider.tag == "Mirrors")
            {
                ReflectLaser(position, direction);
            }

            else
            {
                return;
            }
        }
    }