Ejemplo n.º 1
0
        public PathFinderFast(byte[] grid, byte gridBit, int gridWidth, int gridHeight, int[] customCosts)
        {
            if (grid == null)
            {
                throw new Exception("Grid cannot be null");
            }

            mGrid        = grid;
            mCustomCosts = customCosts;
            mGridBit     = gridBit;
            mGridX       = (ushort)gridWidth;                                                                               // (ushort) (mGrid.GetUpperBound(0) + 1);
            mGridY       = (ushort)gridHeight;                                                                              // (ushort) (mGrid.GetUpperBound(1) + 1);
            mGridXMinus1 = (ushort)(mGridX - 1);
            mGridYLog2   = (ushort)Math.Log(mGridX, 2);

            // This should be done at the constructor, for now we leave it here.
            if (Math.Log(mGridX, 2) != (int)Math.Log(mGridX, 2) ||
                Math.Log(mGridY, 2) != (int)Math.Log(mGridY, 2))
            {
                throw new Exception("Invalid Grid, size in X and Y must be power of 2");
            }

            if (mCalcGrid == null || mCalcGrid.Length != (mGridX * mGridY))
            {
                mCalcGrid = new PathFinderNodeFast[mGridX * mGridY];
            }

            mOpen = new PriorityQueueB <int> (new ComparePFNodeMatrix(mCalcGrid));
        }
        public PathFinderAdminEntity(AdminEntity[] entities)
        {
            if (entities == null)
            {
                throw new Exception("entities cannot be null");
            }

            mEntities = entities;

            if (mCalcGrid == null || mCalcGrid.Length != mEntities.Length)
            {
                mCalcGrid = new PathFinderNodeAdmin[mEntities.Length];
            }

            mOpen = new PriorityQueueB <int> (new ComparePFNodeMatrix(mCalcGrid));
        }
Ejemplo n.º 3
0
        public PathFinderCells(CellCosts[] grid, int gridWidth, int gridHeight)
        {
            if (grid == null)
            {
                throw new Exception("Grid cannot be null");
            }

            mGrid  = grid;
            mGridX = (ushort)gridWidth;
            mGridY = (ushort)gridHeight;

            if (mCalcGrid == null || mCalcGrid.Length != (mGridX * mGridY))
            {
                mCalcGrid = new PathFinderNodeFast[mGridX * mGridY];
            }

            mOpen = new PriorityQueueB <int>(new ComparePFNodeMatrix(mCalcGrid));
        }