public override List<Vector2> getValidMoveList(controllerBoard board) { if(_validMoves == null) { _validMoves = _pieceType.generateMoveList(board, this, canAttackOwnUnits); } return _validMoves; }
private List<Vector2> getCanAttackList(controllerBoard board, chessPiece piece) { if (_canAttackCache == null) { _canAttackCache = generateMoveList(board, piece, true); } return _canAttackCache; }
void Awake() { _txtCurrentTurn = objCurrentTurn.GetComponent<Text>(); _txtVictory = objVictory.GetComponent<Text>(); _txtGameMode = objGameMode.GetComponent<Text>(); _cbCanAttackSelf = objCanAttackSelf.GetComponent<Toggle>(); _board = gameObject.GetComponent<controllerBoard>(); }
public override bool canMoveTo(int x, int y, controllerBoard board) { getValidMoveList(board); foreach (Vector2 validMove in _validMoves) { if (((int)validMove.x == x) && ((int)validMove.y == y)) return true; } return false; }
public virtual bool hasValidMoveAt(int x, int y, controllerBoard board) { Vector2 move = new Vector2(x, y); foreach (Vector2 validMove in _validMoves) { if(move == validMove) { return true; } } return false; }
public override bool execute(controllerBoard board) { board.removePieceFromList(_captured); board.addPieceToCapturedList(_captured); int capturedX = ((_captured.getTeamColor() == chessPiece.TeamColor.BLACK)?(9):(-2)); int capturedY = board.getNumCapturedChess(_captured.getTeamColor()) - 1; if(capturedY >= controllerBoard.BOARD_HEIGHT) { capturedX += ((_captured.getTeamColor() == chessPiece.TeamColor.BLACK)?(1):(-1)); capturedY -= controllerBoard.BOARD_HEIGHT; } board.setPieceLocation(_captured, capturedX, capturedY, false); return true; }
public override void moveTo(int x, int y, controllerBoard board) { List<componentPiece> piecesAtDestination = board.getPiecesAtLocation(x, y); base.moveTo(x, y, board); clearValidMoves(); if(piecesAtDestination.Count > 0) { foreach (componentPiece piece in piecesAtDestination) { board.capturePiece((chessPiece)piece, this); } } }
public override bool hasValidMoveAt(int x, int y, controllerBoard board) { getValidMoveList(board); return base.hasValidMoveAt(x, y, board); }
public bool canAttack(int x, int y, controllerBoard board) { return _pieceType.canAttack(x, y, board, this); }
public virtual void moveTo(int x, int y, controllerBoard board) { _x = x; _y = y; }
public virtual List<Vector2> getValidMoveList(controllerBoard board) { return _validMoves; }
public virtual bool canMoveTo(int x, int y, controllerBoard board) { return false; }
void Awake() { #if UNITY_WEBPLAYER if (!Security.PrefetchSocketPolicy(Host, TcpPort, 500)) { Debug.LogError("Security Exception. Policy file loading failed!"); } #endif _inputGameName = objGameName.GetComponent<InputField>(); _inputUserName = objUserName.GetComponent<InputField>(); _board = gameObject.GetComponent<controllerBoard>(); }
//Utilizing the command pattern in order to set up for synchronous gameplay (if desired) as well as replays and other nifty dealie-ma-bobs public virtual bool execute(controllerBoard board) { return false; }
public override bool execute(controllerBoard board) { return true; }
public override bool execute(controllerBoard board) { board.addPieceToList(_actor); board.setPieceLocation(_actor, _x, _y); return true; }