private GridNodeData GetNodeData(int x, int y)
            {
                var idx = GridGraphUtilities.GetIndexByPosition(this.graphSize, new Vector3Int(y, 0, x));

                if (idx < 0 || idx >= this.arr.Length)
                {
                    return(default);
            private bool IsSuitable(int x, int y)
            {
                var idx = GridGraphUtilities.GetIndexByPosition(this.graphSize, new Vector3Int(y, 0, x));

                if (idx < 0 || idx >= this.arr.Length)
                {
                    return(false);
                }

                return(this.arr[idx].IsSuitable(this.burstConstraint, this.arr, this.graphSize, this.graphCenter));
            }
Example #3
0
        public void SetupConnectionByDirection(int sourceIndex, Direction direction)
        {
            var connection = Node.Connection.NoConnection;
            var node       = this.GetNodeByIndex <GridNode>(sourceIndex);
            var target     = GridGraphUtilities.GetIndexByDirection(this, sourceIndex, direction);

            if (target >= 0)
            {
                var targetNode = this.GetNodeByIndex <GridNode>(target);
                var cost       = (node.worldPosition - targetNode.worldPosition).sqrMagnitude;
                connection.cost  = cost * (GridGraphUtilities.IsDiagonalDirection(direction) == true ? this.diagonalCostFactor : 1f) + targetNode.penalty;
                connection.index = target;
            }

            node.connections[(int)direction] = connection;
        }
            private int GetIndex(int x, int y)
            {
                var idx = GridGraphUtilities.GetIndexByPosition(this.graphSize, new Vector3Int(y, 0, x));

                return(idx);
            }