Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var delaunay      = new DelaunayTriangulator();
            var points        = delaunay.GeneratePoints(2500, 512, 512);
            var triangulation = delaunay.BowyerWatson(points);

            newBitmap();
            var image = new Bitmap(Image.FromFile("map.png"));

            using (var g = Graphics.FromImage(image)) {
                foreach (var var in triangulation)
                {
                    g.DrawLines(White, var.Vertices.Select(var2 => new Point((int)var2.X, (int)var2.Y)).ToArray());
                }

                image.Save("map.png");
                image.Dispose();
                Console.WriteLine("world generated!");
            }
        }
Exemplo n.º 2
0
    void Start()
    {
        Cursor.lockState = CursorLockMode.None;
        Cursor.visible   = true;

        float minDistance             = pointPrefab.GetComponent <CircleCollider2D>().radius * 2;
        DelaunayTriangulator delaunay = new DelaunayTriangulator();
        var points        = delaunay.GeneratePoints(numberOfPoints, spawnArea, minDistance);
        var triangulation = delaunay.BowyerWatson(points);
        //remove junctions that are subjectively too long
        float maxDistanceBetweenPoints = Player.Instance.maxTravelDistance / 3;

        SpawnPOIs(pointPrefab, points, maxDistanceBetweenPoints, parentCanvas);
        Vector2 southernPoint = FindStartingPosition(points);

        playerToken.transform.SetPositionAndRotation(southernPoint, Quaternion.identity);
        playerToken.GetComponent <PlayerToken>().OnReachedDestination
            += GetComponent <RandomEventController>().StartEvent;

        OnPlayerReady?.Invoke(playerToken.transform.position);
    }