예제 #1
0
        private void ImproveMapData(VoronoiGraph voronoiMap, bool fix = false)
        {
            IFactory fact = new MapItemFactory();

            foreach (VoronoiEdge edge in voronoiMap.Edges)
            {
                if (fix)
                {
                    if (!newFix(edge))
                    {
                        continue;
                    }
                }

                Corner c1        = fact.CornerFactory(edge.VVertexA[0], edge.VVertexA[1]);
                Corner c2        = fact.CornerFactory(edge.VVertexB[0], edge.VVertexB[1]);
                Center cntrLeft  = fact.CenterFactory(edge.LeftData[0], edge.LeftData[1]);
                Center cntrRight = fact.CenterFactory(edge.RightData[0], edge.RightData[1]);

                c1.AddAdjacent(c2);
                c2.AddAdjacent(c1);

                cntrRight.AddCorner(c1);
                cntrRight.AddCorner(c2);

                cntrLeft.AddCorner(c1);
                cntrLeft.AddCorner(c2);

                Edge e = fact.EdgeFactory(c1, c2, cntrLeft, cntrRight);


                cntrLeft.AddBorder(e);
                cntrRight.AddBorder(e);

                cntrLeft.AddNeighbour(cntrRight);
                cntrRight.AddNeighbour(cntrLeft);

                c1.AddProtrudes(e);
                c2.AddProtrudes(e);
                c1.AddTouches(cntrLeft);
                c1.AddTouches(cntrRight);
                c2.AddTouches(cntrLeft);
                c2.AddTouches(cntrRight);
            }

            foreach (var c in App.AppMap.Centers)
            {
                c.Value.FixBorders();
                //c.SetEdgeAreas();
                c.Value.OrderCorners();
            }

            //IslandHandler.CreateIsland();
        }
예제 #2
0
        private void ImproveMapData(VoronoiGraph voronoiMap, bool fix = false)
        {
            IFactory fact = new MapItemFactory();

            foreach (VoronoiEdge edge in voronoiMap.Edges)
            {
                if (fix)
                {
                    if (!newFix(edge))
                        continue;
                }

                Corner c1 = fact.CornerFactory(edge.VVertexA[0], edge.VVertexA[1]);
                Corner c2 = fact.CornerFactory(edge.VVertexB[0], edge.VVertexB[1]);
                Center cntrLeft = fact.CenterFactory(edge.LeftData[0], edge.LeftData[1]);
                Center cntrRight = fact.CenterFactory(edge.RightData[0], edge.RightData[1]);

                c1.AddAdjacent(c2);
                c2.AddAdjacent(c1);

                cntrRight.AddCorner(c1);
                cntrRight.AddCorner(c2);

                cntrLeft.AddCorner(c1);
                cntrLeft.AddCorner(c2);

                Edge e = fact.EdgeFactory(c1, c2, cntrLeft, cntrRight);

                cntrLeft.AddBorder(e);
                cntrRight.AddBorder(e);

                cntrLeft.AddNeighbour(cntrRight);
                cntrRight.AddNeighbour(cntrLeft);

                c1.AddProtrudes(e);
                c2.AddProtrudes(e);
                c1.AddTouches(cntrLeft);
                c1.AddTouches(cntrRight);
                c2.AddTouches(cntrLeft);
                c2.AddTouches(cntrRight);
            }

            foreach (var c in App.AppMap.Centers)
            {
                c.Value.FixBorders();
                //c.SetEdgeAreas();
                c.Value.OrderCorners();
            }

            //IslandHandler.CreateIsland();
        }
예제 #3
0
    /// <summary>
    /// Create the vector map from the voronoi information
    /// </summary>
    /// <param name="fix">If set to <c>true</c> fix.</param>
    static void CleanUpGraph(bool fix = false)
    {
        //initialize the factory
        IFactory fact = new MapItemFactory();

        //for all the edges, create corners and centers
        foreach (VoronoiEdge edge in WorldGen.voronoiMap.Edges)
        {
            if (fix)
            {
                if (!FixPoints(edge))
                {
                    continue;
                }
            }

            Corner c1        = fact.CornerFactory(edge.VVertexA[0], edge.VVertexA[1]);
            Corner c2        = fact.CornerFactory(edge.VVertexB[0], edge.VVertexB[1]);
            Center cntrLeft  = fact.CenterFactory(edge.LeftData[0], edge.LeftData[1]);
            Center cntrRight = fact.CenterFactory(edge.RightData[0], edge.RightData[1]);

            c1.AddAdjacent(c2);
            c2.AddAdjacent(c1);

            cntrRight.Corners.Add(c1);
            cntrRight.Corners.Add(c2);

            cntrLeft.Corners.Add(c1);
            cntrLeft.Corners.Add(c2);

            Edge e = fact.EdgeFactory(c1, c2, cntrLeft, cntrRight);


            cntrLeft.Borders.Add(e);
            cntrRight.Borders.Add(e);

            cntrLeft.Neighbours.Add(cntrRight);
            cntrRight.Neighbours.Add(cntrLeft);

            c1.AddProtrudes(e);
            c2.AddProtrudes(e);
            c1.AddTouches(cntrLeft);
            c1.AddTouches(cntrRight);
            c2.AddTouches(cntrLeft);
            c2.AddTouches(cntrRight);
        }


        foreach (Corner q in WorldGen.AppMap.Corners.Values)
        {
            if (!q.Border)
            {
                var point = new Vector2(0, 0);
                foreach (Center c in q.Touches)
                {
                    point.x += c.Point.x;
                    point.y += c.Point.y;
                }
                point.x = point.x / q.Touches.Count;
                point.y = point.y / q.Touches.Count;
                q.Point = point;
            }
        }

        //Once the vector grid is created, build the island from the datapoints
        WorldGen.IslandHandler.CreateIsland();
    }
        private void ImproveMapData(VoronoiGraph voronoiMap, bool fix = false)
        {
            IFactory fact = new MapItemFactory();

            foreach (VoronoiEdge edge in voronoiMap.Edges)
            {
                if (fix)
                {
                    if (!FixPoints(edge))
                        continue;
                }

                Corner c1 = fact.CornerFactory(edge.VVertexA[0], edge.VVertexA[1]);
                Corner c2 = fact.CornerFactory(edge.VVertexB[0], edge.VVertexB[1]);
                Center cntrLeft = fact.CenterFactory(edge.LeftData[0], edge.LeftData[1]);
                Center cntrRight = fact.CenterFactory(edge.RightData[0], edge.RightData[1]);

                if(c1 == null || c2 == null)
                {

                }

                c1.AddAdjacent(c2);
                c2.AddAdjacent(c1);

                cntrRight.Corners.Add(c1);
                cntrRight.Corners.Add(c2);

                cntrLeft.Corners.Add(c1);
                cntrLeft.Corners.Add(c2);

                Edge e = fact.EdgeFactory(c1, c2, cntrLeft, cntrRight);

                cntrLeft.Borders.Add(e);
                cntrRight.Borders.Add(e);

                cntrLeft.Neighbours.Add(cntrRight);
                cntrRight.Neighbours.Add(cntrLeft);

                c1.AddProtrudes(e);
                c2.AddProtrudes(e);
                c1.AddTouches(cntrLeft);
                c1.AddTouches(cntrRight);
                c2.AddTouches(cntrLeft);
                c2.AddTouches(cntrRight);
            }

            foreach (Corner q in App.AppMap.Corners.Values)
            {
                if (!q.Border)
                {
                    var point = new Point(0, 0);
                    foreach (Center c in q.Touches)
                    {
                        point.X += c.Point.X;
                        point.Y += c.Point.Y;
                    }
                    point.X = point.X / q.Touches.Count;
                    point.Y = point.Y / q.Touches.Count;
                    q.Point = point;
                }
            }

            //foreach (var c in App.AppMap.Centers)
            //{
            //    c.Value.FixBorders();
            //    c.SetEdgeAreas();
            //    c.Value.OrderCorners();
            //}

            IslandHandler.CreateIsland();
        }
예제 #5
0
        private void ImproveMapData(VoronoiGraph voronoiMap, bool fix = false)
        {
            IFactory fact = new MapItemFactory();

            foreach (VoronoiEdge edge in voronoiMap.Edges)
            {
                if (fix)
                {
                    if (!FixPoints(edge))
                    {
                        continue;
                    }
                }

                Corner c1        = fact.CornerFactory(edge.VVertexA[0], edge.VVertexA[1]);
                Corner c2        = fact.CornerFactory(edge.VVertexB[0], edge.VVertexB[1]);
                Center cntrLeft  = fact.CenterFactory(edge.LeftData[0], edge.LeftData[1]);
                Center cntrRight = fact.CenterFactory(edge.RightData[0], edge.RightData[1]);

                if (c1 == null || c2 == null)
                {
                }

                c1.AddAdjacent(c2);
                c2.AddAdjacent(c1);

                cntrRight.Corners.Add(c1);
                cntrRight.Corners.Add(c2);

                cntrLeft.Corners.Add(c1);
                cntrLeft.Corners.Add(c2);

                Edge e = fact.EdgeFactory(c1, c2, cntrLeft, cntrRight);


                cntrLeft.Borders.Add(e);
                cntrRight.Borders.Add(e);

                cntrLeft.Neighbours.Add(cntrRight);
                cntrRight.Neighbours.Add(cntrLeft);

                c1.AddProtrudes(e);
                c2.AddProtrudes(e);
                c1.AddTouches(cntrLeft);
                c1.AddTouches(cntrRight);
                c2.AddTouches(cntrLeft);
                c2.AddTouches(cntrRight);
            }

            foreach (Corner q in App.AppMap.Corners.Values)
            {
                if (!q.Border)
                {
                    var point = new Point(0, 0);
                    foreach (Center c in q.Touches)
                    {
                        point.X += c.Point.X;
                        point.Y += c.Point.Y;
                    }
                    point.X = point.X / q.Touches.Count;
                    point.Y = point.Y / q.Touches.Count;
                    q.Point = point;
                }
            }

            //foreach (var c in App.AppMap.Centers)
            //{
            //    c.Value.FixBorders();
            //    c.SetEdgeAreas();
            //    c.Value.OrderCorners();
            //}

            IslandHandler.CreateIsland();
        }