예제 #1
0
    void disconnectPoints()
    {
        List <Waypoint> list = WaypointSaver.loadWaypoints();

        if (points.x > -1 && points.x < list.Count && points.y > -1 && points.y < list.Count)
        {
            foreach (Waypoint p in list)
            {
                if (p.getNumber() == points.x)
                {
                    if (p.getConnections().Contains(points.y))
                    {
                        p.getConnections().Remove(points.y);
                    }
                }
                else if (p.getNumber() == points.y)
                {
                    if (p.getConnections().Contains(points.x))
                    {
                        p.getConnections().Remove(points.x);
                    }
                }
            }
            WaypointSaver.saveWaypoints(list);
        }
    }
예제 #2
0
    //Unity Methods
    void OnDrawGizmos()
    {
        if (creatingPoints)
        {
            Gizmos.color = Color.blue;
            Gizmos.DrawCube(currentLocation, Vector3.one);
        }

        if (debug)
        {
            if (showAllPoints)
            {
                Waypoint        lastPoint = null;
                List <Waypoint> points    = WaypointSaver.loadWaypoints();
                foreach (Waypoint p in points)
                {
                    Gizmos.color = Color.red;
                    Gizmos.DrawSphere(p.getLocation(), 1);

                    //Make the lines to waypoints
                    if (lastPoint != null)
                    {
                        Gizmos.color = Color.green;
                        Gizmos.DrawLine(p.getLocation(), lastPoint.getLocation());
                    }

                    lastPoint = p;
                }
            }
        }
    }
예제 #3
0
    void saveNewWaypoint()
    {
        Waypoint wp = new Waypoint();

        wp.setId(Guid.NewGuid().ToString());
        wp.setLocation(WaypointDebug.getCurrentLocation());

        lastPointId = wp.getId();

        List <Waypoint> list = WaypointSaver.loadWaypoints();

        wp.setNumber(list.Count);
        list.Add(wp);
        WaypointSaver.saveWaypoints(list);
    }
예제 #4
0
    //Unity methods
    void Awake()
    {
        if (instance != null)
        {
            Destroy(gameObject);
        }
        else
        {
            DontDestroyOnLoad(gameObject);
        }

        instance = this;

        waypoints = WaypointSaver.loadWaypoints();
    }