//Constructs a board space on top of a provided node argument, obtained from the nodegrid //as well as a boardpiece, if placing boardpieces is required at instantiation public BoardSpace(BoardNode nodeArg, BoardPiece pieceArg) { mBoardNode = nodeArg; PieceAt = pieceArg; mPiecePresentBool = true; }
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); }
//Updates an empty board space to a new unit token public void SetNewPieceValue(BoardPiece mPieceArg) { if (!this.hasPiece) { mPiece = mPieceArg; mPiecePresentBool = true; } }
//Place a board piece at a coordinate, straightforward public void SetBoardPieceAt(BoardPiece pieceArg, SpaceCoordinate coordArg) { GetBoardSpace(coordArg).SetNewPieceValue(pieceArg); }
//Places a unit at a coordinate public void PlaceUnit(Unit unitArg, SpaceCoordinate coordArg) { BoardPiece placedPiece = new BoardPiece(unitArg); mBoardOfPlay.SetBoardPieceAt(placedPiece, coordArg); }