コード例 #1
0
    public CellMarkupStructure GetLeftKnightFork(List <BoardCell> cellIdsList, int index)
    {
        int                 rowIndex              = (int)(index / 8) + 1;
        int                 lowBoundary           = ((rowIndex - 1) * 8);
        int                 hieBoundary           = ((rowIndex) * 8) - 1;
        FigureTeamType      figureTeamType        = figure.TeamType;
        CellMarkupStructure localCellMarkupStruct = new CellMarkupStructure().Init();
        int                 localIndex            = index - 2;

        if (localIndex > hieBoundary | localIndex < lowBoundary)
        {
            return(localCellMarkupStruct);
        }
        CellMarkupStructure forward  = GetForwardMoveCellSIdByCount(cellIdsList, localIndex, 1);
        CellMarkupStructure backward = GetBackwardMoveCellSIdByCount(cellIdsList, localIndex, 1);

        localCellMarkupStruct.canBeCapture = localCellMarkupStruct.canBeCapture
                                             .Concat(forward.canBeCapture)
                                             .Concat(backward.canBeCapture)
                                             .ToList();

        localCellMarkupStruct.canBeDreggedTo = localCellMarkupStruct.canBeDreggedTo
                                               .Concat(forward.canBeDreggedTo)
                                               .Concat(backward.canBeDreggedTo)
                                               .ToList();

        return(localCellMarkupStruct);
    }
コード例 #2
0
ファイル: Pawn.cs プロジェクト: andrewzb/3dchess
    public CellMarkupStructure GetCellIdsOnWithCanBeDraged(List <BoardCell> cellIdsList, BoardCell boardCell)
    {
        CellMarkupStructure localCellIdsListBYType = new CellMarkupStructure().Init();
        FigureTeamType      teamType      = figure.TeamType;
        BoardCellId         currentCellId = boardCell.CellId;
        int index = cellIdsList.FindIndex(c => c.CellId == boardCell.CellId);

        if (teamType == FigureTeamType.white)
        {
            CellMarkupStructure leftForward  = GetForwardLeftMoveCellsIdByCount(cellIdsList, index, 1, false, true);
            CellMarkupStructure rightForward = GetForwardRightMoveCellsIdByCount(cellIdsList, index, 1, false, true);
            CellMarkupStructure forward      = GetForwardMoveCellSIdByCount(cellIdsList, index, FirsMove ? 2 : 1, true, false);
            localCellIdsListBYType = forward;
            localCellIdsListBYType.canBeCapture = localCellIdsListBYType.canBeCapture.Concat(leftForward.canBeCapture).Concat(rightForward.canBeCapture).ToList();
        }
        else
        {
            CellMarkupStructure leftForward  = GetBackwardLeftMoveCellsIdByCount(cellIdsList, index, 1, false, true);
            CellMarkupStructure rightForward = GetBackwardRightMoveCellsIdByCount(cellIdsList, index, 1, false, true);
            CellMarkupStructure forward      = GetBackwardMoveCellSIdByCount(cellIdsList, index, FirsMove ? 2 : 1, true, false);
            localCellIdsListBYType = forward;
            localCellIdsListBYType.canBeCapture = localCellIdsListBYType.canBeCapture.Concat(leftForward.canBeCapture).Concat(rightForward.canBeCapture).ToList();
        }



        return(localCellIdsListBYType);
    }
コード例 #3
0
    public CellMarkupStructure GetBackwardKnightFork(List <BoardCell> cellIdsList, int index)
    {
        FigureTeamType      figureTeamType        = figure.TeamType;
        CellMarkupStructure localCellMarkupStruct = new CellMarkupStructure().Init();
        int localIndex = index - 16;

        if (localIndex < 0)
        {
            return(localCellMarkupStruct);
        }
        CellMarkupStructure right = GetRightMoveCellsIdByCount(cellIdsList, localIndex, 1);
        CellMarkupStructure left  = GetLeftMoveCellsIdByCount(cellIdsList, localIndex, 1);

        localCellMarkupStruct.canBeCapture = localCellMarkupStruct.canBeCapture
                                             .Concat(right.canBeCapture)
                                             .Concat(left.canBeCapture)
                                             .ToList();

        localCellMarkupStruct.canBeDreggedTo = localCellMarkupStruct.canBeDreggedTo
                                               .Concat(right.canBeDreggedTo)
                                               .Concat(left.canBeDreggedTo)
                                               .ToList();

        return(localCellMarkupStruct);
    }
コード例 #4
0
 public static void CallSwithToOtherPlayerTeamEvent(FigureTeamType figureTeamType)
 {
     if (SwithToOtherPlayerTeamEvent != null)
     {
         SwithToOtherPlayerTeamEvent(figureTeamType);
     }
 }
コード例 #5
0
ファイル: Kninght.cs プロジェクト: andrewzb/3dchess
    public CellMarkupStructure GetCellIdsOnWithCanBeDraged(List <BoardCell> cellIdsList, BoardCell boardCell)
    {
        CellMarkupStructure localCellIdsListBYType = new CellMarkupStructure().Init();
        FigureTeamType      teamType      = figure.TeamType;
        BoardCellId         currentCellId = boardCell.CellId;
        int index = cellIdsList.FindIndex(c => c.CellId == boardCell.CellId);

        if (index != -1)
        {
            CellMarkupStructure forwardFork  = GetForwardKnightFork(cellIdsList, index);
            CellMarkupStructure backwardFork = GetBackwardKnightFork(cellIdsList, index);
            CellMarkupStructure rightFork    = GetRightKnightFork(cellIdsList, index);
            CellMarkupStructure leftFork     = GetLeftKnightFork(cellIdsList, index);

            localCellIdsListBYType.canBeCapture = localCellIdsListBYType.canBeCapture
                                                  .Concat(forwardFork.canBeCapture)
                                                  .Concat(backwardFork.canBeCapture)
                                                  .Concat(rightFork.canBeCapture)
                                                  .Concat(leftFork.canBeCapture)
                                                  .ToList();


            localCellIdsListBYType.canBeDreggedTo = localCellIdsListBYType.canBeDreggedTo
                                                    .Concat(forwardFork.canBeDreggedTo)
                                                    .Concat(backwardFork.canBeDreggedTo)
                                                    .Concat(rightFork.canBeDreggedTo)
                                                    .Concat(leftFork.canBeDreggedTo)
                                                    .ToList();
        }
        return(localCellIdsListBYType);
    }
コード例 #6
0
ファイル: FigureStructure.cs プロジェクト: andrewzb/3dchess
 public FigureStructure(BoardFirureId firureId, FigureType initialType, FigureType currentType, FigureTeamType teamType)
 {
     FirureId    = firureId;
     InitialType = initialType;
     CurrentType = currentType;
     TeamType    = teamType;
 }
コード例 #7
0
ファイル: Board.cs プロジェクト: andrewzb/3dchess
 protected override void Awake()
 {
     base.Awake();
     currentTeamTurn = FigureTeamType.black;
     SetMainCamera();
     defaultBoardStructure = new DefaultBoardConfig().defaultBoardListConfig;
     markCellsAsCanBeDragToList.Init();
 }
コード例 #8
0
    public CellMarkupStructure GetLeftCastleCellsId(List <BoardCell> cellIdsList, int index)
    {
        int                 rowIndex                 = (int)(index / 8) + 1;
        int                 lowBoundary              = ((rowIndex - 1) * 8);
        int                 hieBoundary              = ((rowIndex) * 8) - 1;
        FigureTeamType      figureTeamType           = figure.TeamType;
        CellMarkupStructure localCellMarkupStruct    = new CellMarkupStructure().Init();
        int                 localIndex               = index;
        BoardCellId         kingPosition             = cellIdsList[index].CellId;
        CellMarkupStructure endPositionOfKingAndRook = GetLeftMoveCellsIdByCount(cellIdsList, index, 2, true, false);

        if (endPositionOfKingAndRook.canBeDreggedTo.Count != 2)
        {
            return(localCellMarkupStruct);
        }
        BoardCellId kingEndPosition = endPositionOfKingAndRook.canBeDreggedTo[1];
        BoardCellId rookEndPosition = endPositionOfKingAndRook.canBeDreggedTo[0];

        do
        {
            BoardCell boardCell = GetLeftCell(cellIdsList, ref localIndex, lowBoundary, hieBoundary);
            if (boardCell != null)
            {
                if (boardCell.figureOnCell == null)
                {
                    continue;
                }
                else
                {
                    Rook localRook = boardCell.figureOnCell.GetComponent <Rook>();
                    if (localRook == null)
                    {
                        break;
                    }
                    if (localRook.FirsMove)
                    {
                        CastleStructure localCastleStructure = new CastleStructure();
                        localCastleStructure.Init(kingPosition, kingEndPosition, boardCell.CellId, rookEndPosition);
                        localCellMarkupStruct.canBeCastle.Add(localCastleStructure);
                        break;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            else
            {
                break;
            }
        } while (true);
        return(localCellMarkupStruct);
    }
コード例 #9
0
    public CellMarkupStructure GetCellIdsOnWithCanBeDraged(List <BoardCell> cellIdsList, BoardCell boardCell)
    {
        CellMarkupStructure localCellIdsListBYType = new CellMarkupStructure().Init();
        FigureTeamType      teamType      = figure.TeamType;
        BoardCellId         currentCellId = boardCell.CellId;
        int index = cellIdsList.FindIndex(c => c.CellId == boardCell.CellId);

        if (index != -1)
        {
            CellMarkupStructure forward       = GetForwardMoveCellSIdByCount(cellIdsList, index, 1);
            CellMarkupStructure backward      = GetBackwardMoveCellSIdByCount(cellIdsList, index, 1);
            CellMarkupStructure right         = GetRightMoveCellsIdByCount(cellIdsList, index, 1);
            CellMarkupStructure left          = GetLeftMoveCellsIdByCount(cellIdsList, index, 1);
            CellMarkupStructure forwardLeft   = GetForwardLeftMoveCellsIdByCount(cellIdsList, index, 1);
            CellMarkupStructure forwardRight  = GetForwardRightMoveCellsIdByCount(cellIdsList, index, 1);
            CellMarkupStructure backwardLeft  = GetBackwardLeftMoveCellsIdByCount(cellIdsList, index, 1);
            CellMarkupStructure backwardRight = GetBackwardRightMoveCellsIdByCount(cellIdsList, index, 1);

            localCellIdsListBYType.canBeCapture = localCellIdsListBYType.canBeCapture
                                                  .Concat(forward.canBeCapture)
                                                  .Concat(backward.canBeCapture)
                                                  .Concat(right.canBeCapture)
                                                  .Concat(left.canBeCapture)
                                                  .Concat(forwardLeft.canBeCapture)
                                                  .Concat(forwardRight.canBeCapture)
                                                  .Concat(backwardLeft.canBeCapture)
                                                  .Concat(backwardRight.canBeCapture)
                                                  .ToList();

            localCellIdsListBYType.canBeDreggedTo = localCellIdsListBYType.canBeDreggedTo
                                                    .Concat(forward.canBeDreggedTo)
                                                    .Concat(backward.canBeDreggedTo)
                                                    .Concat(right.canBeDreggedTo)
                                                    .Concat(left.canBeDreggedTo)
                                                    .Concat(forwardLeft.canBeDreggedTo)
                                                    .Concat(forwardRight.canBeDreggedTo)
                                                    .Concat(backwardLeft.canBeDreggedTo)
                                                    .Concat(backwardRight.canBeDreggedTo)
                                                    .ToList();

            if (FirsMove)
            {
                CellMarkupStructure castleLeft  = GetLeftCastleCellsId(cellIdsList, index);
                CellMarkupStructure castleRight = GetRightCastleCellsId(cellIdsList, index);

                localCellIdsListBYType.canBeCastle = localCellIdsListBYType.canBeCastle
                                                     .Concat(castleLeft.canBeCastle)
                                                     .Concat(castleRight.canBeCastle)
                                                     .ToList();
            }
        }
        return(localCellIdsListBYType);
    }
コード例 #10
0
 private void SwithToOtherPlayerManager(FigureTeamType figureTeamType)
 {
     if (figureTeamType == FigureTeamType.black)
     {
         playerTitle.text = "Player 1 (black)";
         //ToggleCamera(player2Camera, player2CameraAudioListner, false);
         //ToggleCamera(player1Camera, player1CameraAudioListner, true);
     }
     else
     {
         playerTitle.text = "Player 2 (white)";
         //ToggleCamera(player2Camera, player2CameraAudioListner, true);
         //ToggleCamera(player1Camera, player1CameraAudioListner, false);
     }
     //gameBoard.SetMainCamera();
     gameBoard.currentTeamTurn = figureTeamType;
 }
コード例 #11
0
    public CellMarkupStructure GetLeftMoveCellsIdByCount(List <BoardCell> cellIdsList, int index, int count, bool canBeDragged = true, bool canBeCapture = true)
    {
        int                 rowIndex              = (int)(index / 8) + 1;
        int                 lowBoundary           = ((rowIndex - 1) * 8);
        int                 hieBoundary           = ((rowIndex) * 8) - 1;
        FigureTeamType      figureTeamType        = figure.TeamType;
        CellMarkupStructure localCellMarkupStruct = new CellMarkupStructure().Init();
        int                 localIndex            = index;

        for (int i = 0; i < count; i++)
        {
            BoardCell boardCell = GetLeftCell(cellIdsList, ref localIndex, lowBoundary, hieBoundary);
            if (boardCell != null)
            {
                if (boardCell.figureOnCell != null)
                {
                    Figure localFigureOnCell = boardCell.figureOnCell.GetComponent <Figure>();
                    if (localFigureOnCell.TeamType == figureTeamType)
                    {
                        break;
                    }
                    else
                    {
                        if (canBeCapture)
                        {
                            localCellMarkupStruct.canBeCapture.Add(boardCell.CellId);
                        }
                        break;
                    }
                }
                else
                {
                    if (canBeDragged)
                    {
                        localCellMarkupStruct.canBeDreggedTo.Add(boardCell.CellId);
                    }
                }
            }
            else
            {
                break;
            }
        }
        return(localCellMarkupStruct);
    }
コード例 #12
0
    public CellMarkupStructure GetBackwardMoveCellSIdByCount(List <BoardCell> cellIdsList, int index, int count, bool canBeDragged = true, bool canBeCapture = true)
    {
        FigureTeamType      figureTeamType        = figure.TeamType;
        CellMarkupStructure localCellMarkupStruct = new CellMarkupStructure().Init();
        int localIndex = index;

        for (int i = 0; i < count; i++)
        {
            BoardCell boardCell = GetBackwardCell(cellIdsList, ref localIndex);
            if (boardCell != null)
            {
                if (boardCell.figureOnCell != null)
                {
                    Figure localFigureOnCell = boardCell.figureOnCell.GetComponent <Figure>();
                    if (localFigureOnCell.TeamType == figureTeamType)
                    {
                        break;
                    }
                    else
                    {
                        if (canBeCapture)
                        {
                            localCellMarkupStruct.canBeCapture.Add(boardCell.CellId);
                        }
                        break;
                    }
                }
                else
                {
                    if (canBeDragged)
                    {
                        localCellMarkupStruct.canBeDreggedTo.Add(boardCell.CellId);
                    }
                }
            }
            else
            {
                break;
            }
        }
        return(localCellMarkupStruct);
    }
コード例 #13
0
    public CellMarkupStructure GetLeftMoveCellsId(List <BoardCell> cellIdsList, int index)
    {
        int                 rowIndex              = (int)(index / 8) + 1;
        int                 lowBoundary           = ((rowIndex - 1) * 8);
        int                 hieBoundary           = ((rowIndex) * 8) - 1;
        FigureTeamType      figureTeamType        = figure.TeamType;
        CellMarkupStructure localCellMarkupStruct = new CellMarkupStructure().Init();
        int                 localIndex            = index;

        do
        {
            BoardCell boardCell = GetLeftCell(cellIdsList, ref localIndex, lowBoundary, hieBoundary);
            if (boardCell != null)
            {
                if (boardCell.figureOnCell != null)
                {
                    Figure localFigureOnCell = boardCell.figureOnCell.GetComponent <Figure>();
                    if (localFigureOnCell.TeamType == figureTeamType)
                    {
                        break;
                    }
                    else
                    {
                        localCellMarkupStruct.canBeCapture.Add(boardCell.CellId);
                        break;
                    }
                }
                else
                {
                    localCellMarkupStruct.canBeDreggedTo.Add(boardCell.CellId);
                }
            }
            else
            {
                break;
            }
        } while (true);
        return(localCellMarkupStruct);
    }
コード例 #14
0
ファイル: Figure.cs プロジェクト: andrewzb/3dchess
    public GameObject GetInitFigure(
        BoardFirureId firureId,
        FigureType initialType,
        FigureType currentType,
        FigureTeamType teamType
        )
    {
        FirureId    = firureId;
        InitialType = initialType;
        CurrentType = currentType;
        TeamType    = teamType;
        if (teamType == FigureTeamType.black)
        {
            figureMesh.GetComponent <MeshRenderer>().material = defaultBlackMaterial;
        }
        else
        {
            figureMesh.GetComponent <MeshRenderer>().material = defaultWhiteMaterial;
        }

        return(gameObject);
    }
コード例 #15
0
    public CellMarkupStructure GetBackwardLeftMoveCellsId(List <BoardCell> cellIdsList, int index)
    {
        FigureTeamType      figureTeamType        = figure.TeamType;
        CellMarkupStructure localCellMarkupStruct = new CellMarkupStructure().Init();
        int localIndex = index;

        do
        {
            BoardCell boardCell = GetBackwardLeftCell(cellIdsList, ref localIndex);
            if (boardCell != null)
            {
                if (boardCell.figureOnCell != null)
                {
                    Figure localFigureOnCell = boardCell.figureOnCell.GetComponent <Figure>();
                    if (localFigureOnCell.TeamType == figureTeamType)
                    {
                        break;
                    }
                    else
                    {
                        localCellMarkupStruct.canBeCapture.Add(boardCell.CellId);
                        break;
                    }
                }
                else
                {
                    localCellMarkupStruct.canBeDreggedTo.Add(boardCell.CellId);
                }
            }
            else
            {
                break;
            }
        } while (true);
        return(localCellMarkupStruct);
    }