예제 #1
0
 public override List<Vector2> getValidMoveList(controllerBoard board)
 {
     if(_validMoves == null)
     {
         _validMoves = _pieceType.generateMoveList(board, this, canAttackOwnUnits);
     }
     return _validMoves;
 }
예제 #2
0
 private List<Vector2> getCanAttackList(controllerBoard board, chessPiece piece)
 {
     if (_canAttackCache == null)
     {
         _canAttackCache = generateMoveList(board, piece, true);
     }
     return _canAttackCache;
 }
예제 #3
0
    void Awake()
    {
        _txtCurrentTurn = objCurrentTurn.GetComponent<Text>();
        _txtVictory = objVictory.GetComponent<Text>();
        _txtGameMode = objGameMode.GetComponent<Text>();

        _cbCanAttackSelf = objCanAttackSelf.GetComponent<Toggle>();

        _board = gameObject.GetComponent<controllerBoard>();
    }
예제 #4
0
    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;
    }
예제 #5
0
 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;
 }
예제 #6
0
    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;
    }
예제 #7
0
    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);
            }
        }
    }
예제 #8
0
 public override bool hasValidMoveAt(int x, int y, controllerBoard board)
 {
     getValidMoveList(board);
     return base.hasValidMoveAt(x, y, board);
 }
예제 #9
0
 public bool canAttack(int x, int y, controllerBoard board)
 {
     return _pieceType.canAttack(x, y, board, this);
 }
예제 #10
0
 public virtual void moveTo(int x, int y, controllerBoard board)
 {
     _x = x;
     _y = y;
 }
예제 #11
0
 public virtual List<Vector2> getValidMoveList(controllerBoard board)
 {
     return _validMoves;
 }
예제 #12
0
 public virtual bool canMoveTo(int x, int y, controllerBoard board)
 {
     return false;
 }
예제 #13
0
    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>();
    }
예제 #14
0
 //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;
 }
예제 #15
0
 public override bool execute(controllerBoard board)
 {
     return true;
 }
예제 #16
0
 public override bool execute(controllerBoard board)
 {
     board.addPieceToList(_actor);
     board.setPieceLocation(_actor, _x, _y);
     return true;
 }