예제 #1
0
        public List <BoardPiece> ReturnPossibleTargets(Unit attackingUnitArg)
        {
            List <BoardPiece> targetPieces = new List <BoardPiece>();

            Board.BoardSpace     startLocation = mBoardOfPlay.GetBoardSpaceOfToken(attackingUnitArg);
            Board                testB         = mBoardOfPlay;
            NodeGrid             testG         = testB.NodeGrid;
            List <SpaceMovement> allDir        = testG.ALL_DIRECTIONS;

            foreach (SpaceMovement iDir in allDir)
            {
                Board.BoardSpace spaceWalker = startLocation;
                for (int i = 0; i < attackingUnitArg.AttackRange + 1; i++)
                {
                    spaceWalker = mBoardOfPlay.SpaceAtMove(spaceWalker.GetCoords(), iDir);
                    BoardPiece lPiece = spaceWalker.PieceAt;
                    bool       test1  = lPiece != null;
                    if (test1)
                    {
                        bool test2 = lPiece.Token.TokenID.IDChar != attackingUnitArg.TokenID.IDChar;
                    }


                    if (lPiece != null && lPiece.Token.TokenID.IDChar != attackingUnitArg.TokenID.IDChar)
                    {
                        if (lPiece.Targetable)
                        {
                            targetPieces.Add(spaceWalker.PieceAt);
                        }
                    }
                }
            }
            return(targetPieces);
        }
예제 #2
0
        //Nodes need to know what their neighbors are for pathfinding to be efficient
        public static List <BoardNode> IdentifyNeighbors(NodeGrid gridArg, SpaceCoordinate coordArg)
        {
            List <BoardNode> lNeighbors = new List <BoardNode>();

            foreach (SpaceMovement iMove in gridArg.ALL_DIRECTIONS)
            {
                SpaceCoordinate possNeighborCoord = coordArg.CoordAtMove(iMove);
                BoardNode       lNode             = gridArg.BoardNodes.Find(x => x.Coordinates.Equals(coordArg));
                if (lNode != null)
                {
                    lNeighbors.Add(lNode);
                }
            }
            return(lNeighbors);
        }
예제 #3
0
 //===========
 //== Board ==
 //===========
 public Board(int minXArg, int maxXArg, int minYArg, int maxYArg)
 {
     mNodeGrid    = new NodeGrid(minXArg, maxXArg, minYArg, maxYArg);
     mBoardSpaces = new List <BoardSpace>();
     ConstructSpaces();
 }