コード例 #1
0
        public void PlayerOperation(GamePlayer[] i_PlayersGame, Point i_SourcePoint, ref Point io_DestinationPoint, bool i_IsCapture, int i_PlayerTurn)
        {
            Soldier currentSoldier;
            Point   directionPoint;
            Point   differencePoint = new Point(io_DestinationPoint.X - i_SourcePoint.X, io_DestinationPoint.Y - i_SourcePoint.Y);
            int     enemyTurn       = (i_PlayerTurn + 1) % i_PlayersGame.Length;

            SetDirection(differencePoint, out directionPoint);
            currentSoldier   = i_PlayersGame[i_PlayerTurn].FindCurrentSoldier(i_SourcePoint);
            currentSoldier.X = io_DestinationPoint.X;
            currentSoldier.Y = io_DestinationPoint.Y;

            if (i_IsCapture == true)
            {
                removeEnemySoldier(i_PlayersGame[enemyTurn], i_SourcePoint, directionPoint);
            }

            if (checkKingUpdating(currentSoldier.Y) == true && currentSoldier.SoldierKind == eSoldierKind.MAN)
            {
                i_PlayersGame[i_PlayerTurn].AmountOfSoldiersValue += 3;
                currentSoldier.SoldierKind = eSoldierKind.KING;
                if (UpdateSoldierToKingNotifier != null)
                {
                    UpdateSoldierToKingNotifier.Invoke(currentSoldier);
                }
            }

            m_Board.UpdateSoldierPosition(i_SourcePoint, io_DestinationPoint, directionPoint, i_PlayerTurn, i_IsCapture);

            if (LogicOperationNotifier != null)
            {
                LogicOperationNotifier.Invoke(currentSoldier, i_SourcePoint, ref io_DestinationPoint, i_IsCapture);
            }
        }
コード例 #2
0
        public void ComputerOperation(
            GamePlayer i_ComputerPlayer,
            Soldier i_PlayerSolderStillAbleToCapture,
            ref Soldier io_CaptureSoldier,
            ref Point io_DestinationPoint,
            Point i_SourcePoint)
        {
            bool           isCaptureOption = false;
            List <Soldier> ableToCapture;

            if (i_PlayerSolderStillAbleToCapture != null)
            {
                isCaptureOption = true;
            }
            else
            {
                ableToCapture = soldiersAbleToCapture(i_ComputerPlayer);

                if (ableToCapture.Count > 0)
                {
                    isCaptureOption   = true;
                    io_CaptureSoldier = findMostCaptureSoldier(ableToCapture, ref io_DestinationPoint);
                }
                else
                {
                    io_CaptureSoldier = findSoldierCanBecomeKing(i_ComputerPlayer, ref io_DestinationPoint);
                    if (io_CaptureSoldier == null)
                    {
                        io_CaptureSoldier = findSoldierAbleToMove(i_ComputerPlayer, ref io_DestinationPoint);
                    }
                }
            }

            if (LogicOperationNotifier != null)
            {
                LogicOperationNotifier.Invoke(io_CaptureSoldier, i_SourcePoint, ref io_DestinationPoint, isCaptureOption);
            }
        }