void Awake()
 {
     spaceshipAnimator            = GetComponent <Animator> ();
     spriteRendererOfTheSpaceship = GetComponent <SpriteRenderer> ();
     spaceshipMovementScript      = GetComponent <SpaceshipMovement> ();
     specialMovementScript        = GetComponent <SpecialMovement> ();
 }
Exemple #2
0
    public override SpecialMovement[] GetSpecialMoves(ChessBoard chessBoard)
    {
        IntVector2 currentTile = chessBoard.GetTileCoordinates(this);

        if ((pieceColor == PieceColor.BLACK && currentTile.y != 3) || (pieceColor == PieceColor.WHITE && currentTile.y != 4))
        {
            return(new SpecialMovement[0]);
        }
        SpecialMovement special1 = null;
        SpecialMovement special2 = null;
        ChessPiece      left     = chessBoard.GetChessPieceAt(currentTile.x - 1, currentTile.y);
        ChessPiece      right    = chessBoard.GetChessPieceAt(currentTile.x + 1, currentTile.y);
        IntVector2      forward  = currentTile + (pieceColor == PieceColor.BLACK ? -IntVector2.up : IntVector2.up);

        if (left != null && left.movementsMade == 1 && chessBoard.GetNumberOfLastMove(left) == chessBoard.pieceMovementCount && left.pieceColor != pieceColor && left.pieceType == PieceType.PAWN)
        {
            special1 = new SpecialMovement(forward - IntVector2.right, left);
        }
        if (right != null && right.movementsMade == 1 && chessBoard.GetNumberOfLastMove(right) == chessBoard.pieceMovementCount && right.pieceColor != pieceColor && right.pieceType == PieceType.PAWN)
        {
            special2 = new SpecialMovement(forward + IntVector2.right, right);
        }
        if (special1 != null)
        {
            // Both specials
            if (special2 != null)
            {
                return(new SpecialMovement[] { special1, special2 });
            }
            // Just special1
            else
            {
                return(new SpecialMovement[] { special1 });
            }
        }
        // Just special2
        else if (special2 != null)
        {
            return(new SpecialMovement[] { special2 });
        }
        return(new SpecialMovement[0]);
    }
Exemple #3
0
            public virtual void ReadChildData(BinaryReader reader)
            {
                int x = 0;

                for (x = 0; (x < _specialMovement.Count); x = (x + 1))
                {
                    SpecialMovement.Add(new SpecialMovementBlockBlock());
                    SpecialMovement[x].Read(reader);
                }
                for (x = 0; (x < _specialMovement.Count); x = (x + 1))
                {
                    SpecialMovement[x].ReadChildData(reader);
                }
                for (x = 0; (x < _behaviorList.Count); x = (x + 1))
                {
                    BehaviorList.Add(new BehaviorNamesBlockBlock());
                    BehaviorList[x].Read(reader);
                }
                for (x = 0; (x < _behaviorList.Count); x = (x + 1))
                {
                    BehaviorList[x].ReadChildData(reader);
                }
            }
 private void HandleDashMove()
 {
     SpecialMovement.DashMove(movementController, PlayerTimings.PLAYER_DASH_SPEED);
 }
Exemple #5
0
    public override SpecialMovement[] GetSpecialMoves(ChessBoard chessBoard)
    {
        if (movementsMade > 0)
        {
            return(new SpecialMovement[0]);
        }
        ChessPiece leftCorner  = null;
        ChessPiece rightCorner = null;

        switch (pieceColor)
        {
        case PieceColor.BLACK:
            leftCorner  = chessBoard.GetChessPieceAt(0, chessBoard.height - 1);
            rightCorner = chessBoard.GetChessPieceAt(chessBoard.width - 1, chessBoard.height - 1);
            break;

        case PieceColor.WHITE:
            leftCorner  = chessBoard.GetChessPieceAt(0, 0);
            rightCorner = chessBoard.GetChessPieceAt(chessBoard.width - 1, 0);
            break;

        default:
            Debug.LogError("Unhandled chess piece color in switch case:" + (int)pieceColor);
            return(new SpecialMovement[0]);
        }
        if (leftCorner == null && rightCorner == null)
        {
            return(new SpecialMovement[0]);
        }
        SpecialMovement special1       = null;
        SpecialMovement special2       = null;
        IntVector2      currentTile    = chessBoard.GetTileCoordinates(this);
        Bitboard        piecePositions = chessBoard.GetPiecePositions();

        if (
            leftCorner != null &&
            !chessBoard.HasPieceMoved(leftCorner) &&
            leftCorner.pieceType == PieceType.ROOK &&
            piecePositions.IsLineUniform(
                currentTile - IntVector2.right,
                new IntVector2(1, pieceColor == PieceColor.BLACK ? chessBoard.height - 1 : 0),
                false
                ))
        {
            special1 = new SpecialMovement(currentTile - 2 * IntVector2.right, leftCorner, currentTile - IntVector2.right);
        }
        if (
            rightCorner != null &&
            !chessBoard.HasPieceMoved(rightCorner) &&
            rightCorner.pieceType == PieceType.ROOK &&
            piecePositions.IsLineUniform(
                currentTile + IntVector2.right,
                new IntVector2(chessBoard.width - 2, pieceColor == PieceColor.BLACK ? chessBoard.height - 1 : 0),
                false
                ))
        {
            special2 = new SpecialMovement(currentTile + 2 * IntVector2.right, rightCorner, currentTile + IntVector2.right);
        }
        if (special1 != null)
        {
            // Both specials
            if (special2 != null)
            {
                return(new SpecialMovement[] { special1, special2 });
            }
            // Just special1
            else
            {
                return(new SpecialMovement[] { special1 });
            }
        }
        // Just special2
        else if (special2 != null)
        {
            return(new SpecialMovement[] { special2 });
        }
        return(new SpecialMovement[0]);
    }