diff --git a/Assets/Script/Game/GameManager.cs b/Assets/Script/Game/GameManager.cs index 628fb66..0ec77d4 100644 --- a/Assets/Script/Game/GameManager.cs +++ b/Assets/Script/Game/GameManager.cs @@ -75,12 +75,6 @@ public class GameManager : Singleton var fioTimer = FindObjectOfType(); _gameLogic = new GameLogic(_stoneController, _gameType, fioTimer); } - else if (scene.name == "Replay") - { - _stoneController = GameObject.FindObjectOfType(); - _stoneController.InitStones(); - _gameLogic = new GameLogic(_stoneController, Enums.GameType.Replay); - } } //임시 재시작 재대결 public void RetryGame() @@ -90,39 +84,4 @@ public class GameManager : Singleton _gameLogic.SetState(_gameLogic.firstPlayerState); } - #region ReplayControll - - public void ReplayNext(Move nextMove ) - { - // 보드에 돌을 설정하기 위해 gameLogic의 SetNewBoardValue호출 - if (nextMove.stoneType.Equals(Enums.StoneType.Black.ToString())) - { - _gameLogic.SetNewBoardValue(Enums.PlayerType.PlayerA, nextMove.columnIndex, nextMove.rowIndex); - - } - else if (nextMove.stoneType.Equals(Enums.StoneType.White.ToString())) - { - _gameLogic.SetNewBoardValue(Enums.PlayerType.PlayerB, nextMove.columnIndex, nextMove.rowIndex); - } - // 돌이 놓인 내역을 ReplayManager에도 반영 - ReplayManager.Instance.PushMove(nextMove); - } - - public void ReplayUndo(Move targetMove) - { - if (targetMove.stoneType.Equals(Enums.StoneType.Black.ToString())) - { - _gameLogic.SetNewBoardValue(Enums.PlayerType.PlayerA, targetMove.columnIndex, targetMove.rowIndex); - - } - else if (targetMove.stoneType.Equals(Enums.StoneType.White.ToString())) - { - _gameLogic.SetNewBoardValue(Enums.PlayerType.PlayerB, targetMove.columnIndex, targetMove.rowIndex); - } - ReplayManager.Instance.PushUndoMove(targetMove); - //TODO: 화면상에서 돌 치우기 - } - - - #endregion } \ No newline at end of file diff --git a/Assets/Script/Replay/ReplayController.cs b/Assets/Script/Replay/ReplayController.cs index e4ba097..dcc32b6 100644 --- a/Assets/Script/Replay/ReplayController.cs +++ b/Assets/Script/Replay/ReplayController.cs @@ -24,7 +24,7 @@ public class ReplayController : MonoBehaviour Move targetMove = ReplayManager.Instance.PopMove(); if (targetMove != null) { - GameManager.Instance.ReplayUndo(targetMove); + ReplayManager.Instance.ReplayUndo(targetMove); } } @@ -33,7 +33,7 @@ public class ReplayController : MonoBehaviour Move nextMove = ReplayManager.Instance.GetNextMove(); if (nextMove != null) { - GameManager.Instance.ReplayNext(nextMove); + ReplayManager.Instance.ReplayNext(nextMove); } } diff --git a/Assets/Script/Replay/ReplayManager.cs b/Assets/Script/Replay/ReplayManager.cs index 6365f35..8309925 100644 --- a/Assets/Script/Replay/ReplayManager.cs +++ b/Assets/Script/Replay/ReplayManager.cs @@ -42,6 +42,8 @@ public class ReplayManager : Singleton private Stack _undoStack; private int _moveIndex; + private GameLogic _gameLogic; + private StoneController _stoneController; public void InitReplayBoard(ReplayRecord replayRecord) { @@ -196,11 +198,51 @@ public class ReplayManager : Singleton InitReplayBoard(_selectedReplayRecord); } + //게임 매니저에서 가져온 코드입니다. + _stoneController = GameObject.FindObjectOfType(); + _stoneController.InitStones(); + _gameLogic = new GameLogic(_stoneController, Enums.GameType.Replay); + // TODO: 데이터 잘못 가져왔을 때 어떻게 처리할지 고민하기 // Main으로 강제 전환 ? } } + #region ReplayControll + + public void ReplayNext(Move nextMove ) + { + // 보드에 돌을 설정하기 위해 gameLogic의 SetNewBoardValue호출 + if (nextMove.stoneType.Equals(Enums.StoneType.Black.ToString())) + { + _gameLogic.SetNewBoardValue(Enums.PlayerType.PlayerA, nextMove.columnIndex, nextMove.rowIndex); + + } + else if (nextMove.stoneType.Equals(Enums.StoneType.White.ToString())) + { + _gameLogic.SetNewBoardValue(Enums.PlayerType.PlayerB, nextMove.columnIndex, nextMove.rowIndex); + } + // 돌이 놓인 내역을 ReplayManager에도 반영 + ReplayManager.Instance.PushMove(nextMove); + } + + public void ReplayUndo(Move targetMove) + { + if (targetMove.stoneType.Equals(Enums.StoneType.Black.ToString())) + { + _gameLogic.SetNewBoardValue(Enums.PlayerType.PlayerA, targetMove.columnIndex, targetMove.rowIndex); + + } + else if (targetMove.stoneType.Equals(Enums.StoneType.White.ToString())) + { + _gameLogic.SetNewBoardValue(Enums.PlayerType.PlayerB, targetMove.columnIndex, targetMove.rowIndex); + } + ReplayManager.Instance.PushUndoMove(targetMove); + //TODO: 화면상에서 돌 치우기 + } + + + #endregion #region for tests public void OnClickSaveButton(string winnerPlayerType = "PlayerA")