public GameLogic(int i_Rows, int i_Cols, eGameMode i_NewGameMode, string i_Name1, string i_Name2) { m_Player1 = new Player(i_Name1); if (i_Name2 != null) { m_Player2 = new Player(i_Name2); } else { m_Player2 = new Player("PC"); } m_Data = new Node[i_Rows, i_Cols]; for (int i = 0; i < i_Rows; i++) { for (int j = 0; j < i_Cols; j++) { m_Data[i, j] = new Node(); } } resetArray(i_Rows, i_Cols); m_Turn = 0; m_GameMode = i_NewGameMode; }
public void InitzalizeMatrix() { int k = 0; if (!m_IsBotPlay) { m_Player2.Score = 2; } m_GameIsFinishGame = false; Board.Text = "Othello - White's Turn"; m_Turn = eTurn.Player1; m_Player1.Score = 2; for (int i = 0; i < r_MatrixSize; i++) { for (int j = 0; j < r_MatrixSize; j++) { m_Buttons[i, j] = (Button)m_FormOfPlay.Controls[k++]; m_Buttons[i, j].Text = string.Empty; m_Buttons[i, j].BackColor = Color.Empty; } } m_Buttons[(r_MatrixSize / 2) - 1, (r_MatrixSize / 2) - 1].BackColor = Color.White; m_Buttons[(r_MatrixSize / 2) - 1, (r_MatrixSize / 2) - 1].Text = "O"; m_Buttons[(r_MatrixSize / 2) - 1, r_MatrixSize / 2].BackColor = Color.Black; m_Buttons[(r_MatrixSize / 2) - 1, r_MatrixSize / 2].Text = "O"; m_Buttons[r_MatrixSize / 2, (r_MatrixSize / 2) - 1].BackColor = Color.Black; m_Buttons[r_MatrixSize / 2, (r_MatrixSize / 2) - 1].Text = "O"; m_Buttons[r_MatrixSize / 2, r_MatrixSize / 2].BackColor = Color.White; m_Buttons[r_MatrixSize / 2, r_MatrixSize / 2].Text = "O"; }
public void SwitchTurn() { if (m_IsBotPlay == false) { if (m_Turn == eTurn.Player1) { Board.Text = "Othello - Black's Turn"; m_Turn = eTurn.Player2; } else { Board.Text = "Othello - White's Turn"; m_Turn = eTurn.Player1; } } else { if (m_Turn == eTurn.Player1) { m_Turn = eTurn.Computer; } else { m_Turn = eTurn.Player1; } } }
private void gameRoutineAndKeepScore(GameBoard io_Board) { eTurn playerTurn = eTurn.PlayerOne; while (io_Board.checkIfGamehasFinished() == false) { playerMakeMoveHisTurn(io_Board, playerTurn); switchTurn(ref playerTurn); } }
private void switchTurn(ref eTurn o_PlayerCurrentTurn) { if (o_PlayerCurrentTurn == eTurn.PlayerOne) { o_PlayerCurrentTurn = eTurn.PlayerTwo; } else { o_PlayerCurrentTurn = eTurn.PlayerOne; } }
/// <summary> /// 게임 리스타트 /// </summary> public void Reset() { m_eTurn = eTurn.E_TURN_MY; m_eState = eState.E_STATE_NONE; m_nMyCount = 0; m_nYouCount = 0; m_bMyTurn = false; Debug.Log("GameRestart"); }
public static eTurn GetTurn() { eTurn symbol = eTurn.X; if (Program.TurnNum % 2 == 1) { symbol = eTurn.O; } return(symbol); }
private void switchTurn() { if (Turn == eTurn.Player1) { Turn = eTurn.Player2; } else { Turn = eTurn.Player1; } }
public void SwitchTurn() { if (m_Turn == eTurn.PlayerOne) { m_Turn = eTurn.PlayerTwo; } else if (m_Turn == eTurn.PlayerTwo) { m_Turn = eTurn.PlayerOne; } }//מתודה שמחליפה תור בין שחקן לשחקן
/// <summary> /// 게임시작 /// </summary> public void GameStart() { m_eState = eState.E_STATE_READY; m_eTurn = eTurn.E_TURN_MY; HL_SoundMng.I.FadeOut("BGM", "bgm3"); HL_SoundMng.I.Play("SFX", "stinger"); HL_SoundMng.I.SetVolue("SFX", "stinger", 0.7f); HL_SoundMng.I.Play("SFX", "connect"); HL_SoundMng.I.SetVolue("SFX", "connect", 1.2f); HL_SoundMng.I.Play("AMB", "amb_bgm", true); HL_SoundMng.I.SetVolue("AMB", "amb_bgm", 0.35f); HL_SoundMng.I.Play("AMB", "amb" + NGUITools.RandomRange(1, 4)); JAManager.I.SoundBGMMute(JAManager.I.m_bSoundBGMMute); JAManager.I.SoundSFXMute(JAManager.I.m_bSoundSFXMute); Debug.Log("Client Send : " + JAManager.I.m_sMyAccount); byte[] buffers = Encoding.UTF8.GetBytes(JAManager.I.m_sMyAccount); TransportTCP.I.Send(buffers, buffers.Length); if (TransportTCP.I.IsServer() == true) { m_eTurn_Local = eTurn.E_TURN_MY; m_eTurn_Remote = eTurn.E_TURN_YOU; } else { byte[] buffer = new byte[1024]; int nRecvSize = TransportTCP.I.Receive(ref buffer, buffer.Length); Debug.Log(Encoding.UTF8.GetString(buffer)); JAManager.I.m_sYouAccount = Encoding.UTF8.GetString(buffer).ToString(); m_eTurn_Local = eTurn.E_TURN_YOU; m_eTurn_Remote = eTurn.E_TURN_MY; } m_pTurnUI.SetNameSet(JAManager.I.m_sMyAccount, JAManager.I.m_sYouAccount); m_pTurnUI.SetRateSet(JAManager.I.m_sMyAccount, JAManager.I.m_sYouAccount); m_nMyCount = 0; m_nYouCount = 0; m_bMyTurn = false; m_bCurrTime = false; StartCoroutine(Cor_Ready()); m_bGameOver = false; Debug.Log("GameStart"); }
private void switchTurn() { if (m_PlayerTurn == eTurn.PlayerOne) { m_PlayerTurn = eTurn.PlayerTwo; m_FormGame.switchCurrentPlayerTo(m_PlayerTwo.NameOfPlayer); } else { m_PlayerTurn = eTurn.PlayerOne; m_FormGame.switchCurrentPlayerTo(m_PlayerOne.NameOfPlayer); } }
}//בודק חוקיות של ניסיון אכילה private eTurn getOpositeTurn(BoardButton i_Button) { eTurn opossiteTurn = new eTurn(); if (i_Button.MyTurn == eTurn.PlayerOne) { opossiteTurn = eTurn.PlayerTwo; } else if (i_Button.MyTurn == eTurn.PlayerTwo) { opossiteTurn = eTurn.PlayerOne; } return(opossiteTurn); }
public void PlayMatchGame() { bool v_WantToPlayAnotherGame = true; do { MakeNewGame(); m_PlayerOne.ResetGame(null, null); m_PlayerTwo.ResetGame(m_GameBoard.NumOfRows, m_GameBoard.NumOfCols); m_PlayerTurn = eTurn.PlayerOne; gameRoutineAndKeepScore(); m_FormGame.WinnerAnnouncment(m_PlayerOne, m_PlayerTwo); v_WantToPlayAnotherGame = m_FormGame.AskForAnotherGame(); m_FormGame.Close(); }while (v_WantToPlayAnotherGame == true); }
private void playerMakeMoveHisTurn(GameBoard io_Board, eTurn i_PlayingPlayer) { eMoveNum moveNum = eMoveNum.FirstMove; Coordinate firstMoveCoordinate = askPlayingPlayerForMoveCheckMoveAndMakeCoordinate(io_Board, i_PlayingPlayer, moveNum, null); int symbolOfFirstMove; symbolOfFirstMove = m_Ui.representTheBoardWithMove(io_Board, firstMoveCoordinate); moveNum = eMoveNum.SecondMove; Coordinate secondMoveCoordinate = askPlayingPlayerForMoveCheckMoveAndMakeCoordinate(io_Board, i_PlayingPlayer, moveNum, symbolOfFirstMove); int symbolOfSecondMove; symbolOfSecondMove = m_Ui.representTheBoardWithMove(io_Board, secondMoveCoordinate); if (symbolOfSecondMove != symbolOfFirstMove) { System.Threading.Thread.Sleep(2000); cancelLastPlayingPlayerPlay(io_Board, firstMoveCoordinate, secondMoveCoordinate); } else { if (i_PlayingPlayer == eTurn.PlayerOne) { m_PlayerOne.GivePlayerOnePoint(); } else { m_PlayerTwo.GivePlayerOnePoint(); } } if (m_PlayerTwo.IsAi() == true) { m_PlayerTwo.AiBrain.SetCardRevealedFromLastMove(firstMoveCoordinate, symbolOfFirstMove, secondMoveCoordinate, symbolOfSecondMove); } }
/// <summary> /// 턴 체크 /// </summary> void TurnUpdate() { bool bSetMark = false; if (m_eTurn == m_eTurn_Local) { bSetMark = GetTurn_My(); } else { bSetMark = GetTurn_Your(); } if (bSetMark == false) { return; } else { GameResult(); } m_eTurn = (m_eTurn == eTurn.E_TURN_MY) ? eTurn.E_TURN_YOU : eTurn.E_TURN_MY; }
public Move(int i_row, int i_column) { m_Row = i_row; m_Column = i_column; m_Turn = GetTurn(); }
public Logics() { m_Turn = eTurn.PlayerOne; }
private Coordinate askPlayingPlayerForMoveCheckMoveAndMakeCoordinate(GameBoard io_Board, eTurn io_PlayingPlayer, eMoveNum i_MoveNum, int?i_SymbolOfFirstMoveCardRevealed) { Coordinate moveCoordinate; bool v_AlreadyExposed; do { m_Ui.printMakeAMove(m_PlayerOne.NameOfPlayer, m_PlayerTwo.NameOfPlayer, io_PlayingPlayer); moveCoordinate = askPlayingPlayerForMoveAndMakeCoordinate(io_Board, io_PlayingPlayer, i_MoveNum, i_SymbolOfFirstMoveCardRevealed); v_AlreadyExposed = CheckInput.IssueErrorMessageExposedCube(CheckIfCoordinateisExposed(io_Board, moveCoordinate)); }while (v_AlreadyExposed == true); return(moveCoordinate); }
private Coordinate askPlayingPlayerForMoveAndMakeCoordinate(GameBoard io_Board, eTurn io_PlayingPlayer, eMoveNum io_MoveNum, int?i_SymbolOfFirstMoveCardRevealed) { Coordinate moveCoordinate; if (io_PlayingPlayer == eTurn.PlayerOne) { moveCoordinate = getMoveFromHumanPlayerAndMakeCoordinate(io_Board); } else { if (m_PlayerTwo.IsAi() == true) { UI.printComputerMakingAMove(); if (io_MoveNum == eMoveNum.FirstMove) { moveCoordinate = m_PlayerTwo.AiBrain.MakingFirstMove(); } else { moveCoordinate = m_PlayerTwo.AiBrain.MakingSecondMove(i_SymbolOfFirstMoveCardRevealed.Value); } System.Console.Write(UI.sr_ColSymbol[moveCoordinate.Col]); System.Console.WriteLine(UI.sr_RowSymbol[moveCoordinate.Row]); System.Threading.Thread.Sleep(2000); } else { moveCoordinate = getMoveFromHumanPlayerAndMakeCoordinate(io_Board); } } return(moveCoordinate); }