示例#1
0
 public Node(bool _walkable, PathFinding.Int2 _worldPos, int _gridX, int _gridY)
 {
     walkable      = _walkable;
     worldPosition = _worldPos;
     gridX         = _gridX;
     gridY         = _gridY;
 }
示例#2
0
    public static float CalculateNoiseValue(PathFinding.Int2 pos, Vector2 offset, float scale)
    {
        float noiseX = Mathf.Abs((pos.x + offset.x) * scale);
        float noiseY = Mathf.Abs((pos.y + offset.y) * scale);

        //return Mathf.Max( 0, Noise.Generate( noiseX, noiseY ) );

        return(Mathf.Max(0, Mathf.PerlinNoise(noiseX, noiseY)));
        //Just remember we can change this to 1d noise later!
    }
示例#3
0
    public PathFinding.Int2 GetTileInt2(Vector3 position)
    {
        GridLayout gridLayout   = levels[currentLevel - 1].GetComponent <GridLayout>();
        Vector3Int cellPosition = gridLayout.WorldToCell(position);


        Debug.Log(string.Format("Cell Position {0}", cellPosition));

        PathFinding.Int2 pos = new PathFinding.Int2(cellPosition.x, cellPosition.y);

        return(pos);
    }
示例#4
0
 public void GenerateNodes(Vector3Int size)
 {
     for (int x = 0; x <= size.x; x++)
     {
         for (int y = 0; y <= size.y; y++)
         {
             Debug.Log(string.Format("X {0} Y {1}", x, y));
             //grid[x, y] = new Node(walkable, worldPoint, x, y, _reachableIndex);
             var _worldPos = new PathFinding.Int2(x, y);
             grid[x, y] = new Node(true, _worldPos, x, y);
         }
     }
 }
示例#5
0
    //void Start( ) {
    //    float _timer = .5f;
    //    InvokeRepeating( "TryProcessNext", _timer, _timer );
    //}

    public static void RequestPath(PathFinding.Int2 pathStart, PathFinding.Int2 pathEnd, Action <PathFinding.Int2[], bool> callback, bool walkableOverride)
    {
        if (pathStart != pathEnd)
        {
            Debug.Log(string.Format("Path Requested: Start {0} End {1}", pathStart, pathEnd));
            PathRequest newRequest = new PathRequest(pathStart, pathEnd, callback);
            instance.pathRequestQueue.Enqueue(newRequest);
            instance.TryProcessNext(walkableOverride);
        }
        else
        {
            Debug.Log("You can not request a path for the same hex as you are in");
        }
    }
示例#6
0
    public void TrackPlayer()
    {
        //Start = Enemy Position
        //End =  Players Position
        var posTile = gamemanager.instance.GetTile(transform.position);

        PathFinding.Int2 start = new PathFinding.Int2(posTile.x, posTile.y);

        var enPos = gamemanager.instance.GetTile(gamemanager.instance.player.transform.position);

        PathFinding.Int2 end = new PathFinding.Int2(enPos.x, enPos.y);
        bool             overrideWalkable = false;

        PathRequestManager.RequestPath(start, end, OnPathFound, overrideWalkable);
    }
示例#7
0
 public PathRequest(PathFinding.Int2 _start, PathFinding.Int2 _end, Action <PathFinding.Int2[], bool> _callback)
 {
     pathStart = _start;
     pathEnd   = _end;
     callback  = _callback;
 }
示例#8
0
 public Node NodeFromWorldPoint(PathFinding.Int2 worldPosition)
 {
     //return GameData.grid[worldPosition.x, worldPosition.y];
     return(new Node()); //THIS IS NOT RIGHT JUST PLACEHOLDER
 }