diff --git a/Assets/LIN/Scripts/GameManagerTestLIN.cs b/Assets/LIN/Scripts/GameManagerTestLIN.cs index fda1963..8e406d6 100644 --- a/Assets/LIN/Scripts/GameManagerTestLIN.cs +++ b/Assets/LIN/Scripts/GameManagerTestLIN.cs @@ -105,12 +105,27 @@ public class GameManagerTestLIN : Singleton { _gameLogic.SetNewBoardValue(Enums.PlayerType.PlayerB, nextMove.columnIndex, nextMove.rowIndex); } + ReplayManager.Instance.PushMove(nextMove); } } public void OnClickReplayUndoButton() { - + Move targetMove = ReplayManager.Instance.PopMove(); + if (targetMove != null) + { + 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: 화면상에서 돌 치우기 + } } private void ChangeToGameScene(Enums.GameType gameType) { diff --git a/Assets/Script/Replay/ReplayManager.cs b/Assets/Script/Replay/ReplayManager.cs index 0c8d03a..b6f70b2 100644 --- a/Assets/Script/Replay/ReplayManager.cs +++ b/Assets/Script/Replay/ReplayManager.cs @@ -33,21 +33,24 @@ public class ReplayManager : Singleton { private ReplayRecord _recordingReplayData; - #region 기보 시작 후 데이터를 컨트롤하기 위한 변수 + #region 기보 시작 후 데이터를 컨트롤하기 private ReplayRecord _replayRecord; - private Stack _plavedStoneStack; + + //DO, Undo를 위한 스택 + private Stack _placedStoneStack; private Stack _undoStack; private int _moveIndex; - #endregion - + public void InitReplayBoard(ReplayRecord replayRecord) { _replayRecord = replayRecord; _moveIndex = 0; + + _placedStoneStack = new Stack(); + _undoStack = new Stack(); } - public Move GetNextMove() { @@ -61,6 +64,26 @@ public class ReplayManager : Singleton _moveIndex++; return move; } + + public void PushMove(Move storedMove) + { + _placedStoneStack.Push(storedMove); + } + + public Move PopMove() + { + if (_placedStoneStack.Count == 0) + return null; + Move move = _placedStoneStack.Pop(); + return move; + } + + public void PushUndoMove(Move storedMove) + { + _undoStack.Push(storedMove); + } + + #endregion #region 게임 플레이중 기보 데이터 저장 ///