Esempio n. 1
0
 private static void SetNodeHeightToCornerHeight(MapGraph.MapNode node, MapGraph.MapPoint targetCorner)
 {
     foreach (var corner in node.GetCorners())
     {
         corner.position = new Vector3(corner.position.x, targetCorner.position.y, corner.position.z);
     }
     node.centerPoint = new Vector3(node.centerPoint.x, targetCorner.position.y, node.centerPoint.z);
 }
Esempio n. 2
0
    private static void CreateLake(MapGraph.MapNode node)
    {
        var lowestCorner = node.GetLowestCorner();

        node.nodeType = MapGraph.MapNodeType.FreshWater;

        // Set all of the heights equal to where the water came in.
        SetNodeHeightToCornerHeight(node, lowestCorner);
    }
    public static MapGraph.MapNode isIn(Vector2 p)
    {
        MapGraph.MapNode result = null;
        foreach (var node in nowNodeList)
        {
            var r = node.GetBoundingRectangle();
            if (r.Contains(p))
            {
                result = node;
            }
        }

        return(result);
    }
Esempio n. 4
0
 private static void CreateLakes(MapGraph graph)
 {
     foreach (var node in graph.nodesByCenterPosition.Values)
     {
         var edges = node.GetEdges();
         if (!edges.Any(x => x.water == 0))
         {
             if (_firstLake == null)
             {
                 _firstLake = node;
             }
             CreateLake(node);
         }
     }
 }
Esempio n. 5
0
 private static void FloodFill(MapGraph.MapNode node, MapGraph.MapNodeType targetType, MapGraph.MapNodeType replacementType)
 {
     if (targetType == replacementType)
     {
         return;
     }
     if (node.nodeType != targetType)
     {
         return;
     }
     node.nodeType = replacementType;
     foreach (var neighbor in node.GetNeighborNodes())
     {
         FloodFill(neighbor, targetType, replacementType);
     }
 }
 private void check()
 {
     p.x = target.position.x;
     p.y = target.position.z;
     p   = p / K;
     if (inNode == null)
     {
         inNode = MapMeshGenerator.isIn(p);
     }
     else
     {
         if (!inNode.GetBoundingRectangle().Contains(p))
         {
             inNode = MapMeshGenerator.isIn(p);
             GameObject.Find("MapGenerator").SendMessage("changeCenter", inNode);
         }
     }
 }
Esempio n. 7
0
    private void addGrass(System.Object[] data)
    {
        MapGraph.MapNode node  = (MapGraph.MapNode)data[0];
        Vector3[]        roots = (Vector3[])data[1];

        if (node == null || roots.Length == 0 || nodeList.ContainsKey(node))
        {
            return;
        }

        int len          = roots.Length;
        var node_matrics = new Matrix4x4[len];
        var rec          = node.GetBoundingRectangle();



        for (int i = 0; i < roots.Length; i++)
        {
            var center = roots[i];
            madeGrass(node_matrics, center.x, center.y, center.z, i);
        }

        nodeList.Add(node, node_matrics);
    }
Esempio n. 8
0
 private void changeCenter(MapGraph.MapNode node)
 {
     MapGenerator.setCenter(node);
     OnMeshDataReceived(MapMeshGenerator.GenerateMesh(_mapGraph, _heightMap, meshSize));
 }
Esempio n. 9
0
 public static void setCenter(MapGraph.MapNode p)
 {
     _firstLake = p;
 }