Exemplo n.º 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);
        }
    }
Exemplo n.º 2
0
        private void btn_LoadWaypoints_Click(object sender, EventArgs e)
        {
            // Reads the file generated from the Save function and loads them into the list
            XmlSerializer serializer = new XmlSerializer(typeof(WaypointSaver));
            TextReader    reader     = new StreamReader("SavedWaypoints.xml");

            points.Clear();

            WaypointSaver ws = (WaypointSaver)serializer.Deserialize(reader);

            points = ws.savedPoints;

            reader.Close();


            DataTable table = ConvertListToDataTable(points);

            dgv_Waypoints.DataSource = table;

            // Draws the newly acquired Waypoints onto the map
            g.Clear(Color.White);

            Bitmap image = new Bitmap(map.image, new Size(pb_Map.Width, pb_Map.Height));

            g.DrawImage(image, 0, 0);

            DrawGrid();
            DrawWaypoints();
        }
Exemplo n.º 3
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;
                }
            }
        }
    }
Exemplo n.º 4
0
        private void btn_SaveWaypoints_Click(object sender, EventArgs e)
        {
            // Uses a XML Serialiser to store the list of Waypoints and their positions on the map
            XmlSerializer serializer = new XmlSerializer(typeof(WaypointSaver));
            TextWriter    writer     = new StreamWriter("SavedWaypoints.xml");

            WaypointSaver ws = new WaypointSaver();

            ws.savedPoints = points;

            serializer.Serialize(writer, ws);

            writer.Close();
        }
Exemplo n.º 5
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);
    }
Exemplo n.º 6
0
    //Unity methods
    void Awake()
    {
        if (instance != null)
        {
            Destroy(gameObject);
        }
        else
        {
            DontDestroyOnLoad(gameObject);
        }

        instance = this;

        waypoints = WaypointSaver.loadWaypoints();
    }