//returns coordinate at a space movement from this
        public SpaceCoordinate CoordAtMove(SpaceMovement moveArg)
        {
            int             newX   = this.mXCoordinateInt + moveArg.XMovement;
            int             newY   = this.mYCoordinateInt + moveArg.YMovement;
            SpaceCoordinate lCoord = new SpaceCoordinate(newX, newY);

            return(lCoord);
        }
Exemple #2
0
        //Allows for the addition of two directions to calculate movement
        public static SpaceMovement operator +(SpaceMovement thisArg, SpaceMovement moveArg)
        {
            int           newRowMove = thisArg.XMovement + moveArg.XMovement;
            int           newColMove = thisArg.YMovement + moveArg.YMovement;
            int           newCost    = thisArg.MovementCost + moveArg.MovementCost;
            SpaceMovement lMove      = new SpaceMovement(newRowMove, newColMove, newCost);

            return(lMove);
        }
Exemple #3
0
        /**
         * Constructor - Instantiate a grid given the bounds to be used, allows for negative bounds
         * Though this isn't really used so may be unnecessary.
         * Note - As this version is not prepared for delivery, it only insantiates a rectangular board in which
         * all nodes are walkable and targetable
         */
        public NodeGrid(int minXCoordArg, int maxXCoordArg, int minYCoordArg, int maxYCoordArg)
        {
            mBoardNodes = new List <BoardNode>();
            for (int i = minXCoordArg; i < maxXCoordArg; i++)
            {
                for (int j = minYCoordArg; j < maxYCoordArg; j++)
                {
                    SpaceCoordinate lCoord     = new SpaceCoordinate(i, j);
                    BoardNode       lBoardNode = new BoardNode(lCoord, true, true);
                    mBoardNodes.Add(lBoardNode);
                }
            }
            mXBounds    = new int[2];
            mXBounds[0] = minXCoordArg;
            mXBounds[1] = maxXCoordArg;

            mYBounds    = new int[2];
            mYBounds[0] = minYCoordArg;
            mYBounds[1] = maxYCoordArg;

            //Instantiate all directions on the node grid, there may be a better place to put these
            //but this allowed me to begin testing other features
            SpaceMovement DIR_UP         = new SpaceMovement(-1, 0, 10);
            SpaceMovement DIR_DOWN       = new SpaceMovement(1, 0, 10);
            SpaceMovement DIR_RIGHT      = new SpaceMovement(0, 1, 10);
            SpaceMovement DIR_LEFT       = new SpaceMovement(0, -1, 10);
            SpaceMovement DIR_UP_RIGHT   = new SpaceMovement(1, 1, 14);
            SpaceMovement DIR_UP_LEFT    = new SpaceMovement(1, -1, 14);
            SpaceMovement DIR_DOWN_RIGHT = new SpaceMovement(-1, 1, 14);
            SpaceMovement DIR_DOWN_LEFT  = new SpaceMovement(-1, -1, 14);

            //Two lists for containing all directions
            mBaseDir = new List <SpaceMovement>();
            mAllDir  = new List <SpaceMovement>();

            //Add the cardinal directions to the base direction list, in clockwise order
            mBaseDir.Add(DIR_UP);
            mBaseDir.Add(DIR_RIGHT);
            mBaseDir.Add(DIR_DOWN);
            mBaseDir.Add(DIR_LEFT);

            //Add all 8 directions to the all direction list, in clockwise order
            mAllDir.Add(DIR_UP);
            mAllDir.Add(DIR_UP_RIGHT);
            mAllDir.Add(DIR_RIGHT);
            mAllDir.Add(DIR_DOWN_RIGHT);
            mAllDir.Add(DIR_DOWN);
            mAllDir.Add(DIR_DOWN_LEFT);
            mAllDir.Add(DIR_LEFT);
            mAllDir.Add(DIR_UP_LEFT);

            //Instatiate each node's neighbor list
            foreach (BoardNode iNode in this.BoardNodes)
            {
                iNode.Neighbors = BoardNode.IdentifyNeighbors(this, iNode.Coordinates);
            }
        }
Exemple #4
0
        //returns the board space that is at a particular movement from an initial coordinate
        public BoardSpace SpaceAtMove(SpaceCoordinate coordArg, SpaceMovement moveArg)
        {
            SpaceCoordinate lCoord = coordArg.CoordAtMove(moveArg);

            return(GetBoardSpace(lCoord));
        }