From 63a3e1290722b4d0bb4802c0b743259f15797e2a Mon Sep 17 00:00:00 2001 From: HaeinLEE Date: Mon, 17 Mar 2025 14:30:30 +0900 Subject: [PATCH] =?UTF-8?q?[Feat]=20=EA=B8=B0=EB=B3=B4=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=20Next=EC=99=80=20Undo=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 화면상에서 돌 치우는 기능 구현 필효 --- Assets/LIN/Scripts/GameManagerTestLIN.cs | 17 +++++++++++- Assets/Script/Replay/ReplayManager.cs | 33 ++++++++++++++++++++---- 2 files changed, 44 insertions(+), 6 deletions(-) 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 게임 플레이중 기보 데이터 저장 ///