diff --git a/Assets/LIN/Scripts/GameManagerTestLIN.cs b/Assets/LIN/Scripts/GameManagerTestLIN.cs index d37140b..fda1963 100644 --- a/Assets/LIN/Scripts/GameManagerTestLIN.cs +++ b/Assets/LIN/Scripts/GameManagerTestLIN.cs @@ -26,13 +26,15 @@ public class GameManagerTestLIN : Singleton GameObject userManagerObj = new GameObject("UserManager"); _userManager = userManagerObj.AddComponent(); - //게임 씬에서 확인하기 위한 임시 코드 - _gameType = Enums.GameType.SinglePlay; + //TODO: 게임 내에서 기보 타입 적용하기 + _gameType = Enums.GameType.Replay; } } private void Start() { + //TODO: 기보 타입으로 들어왔을 때 데이터 로드 테스트 수정할것 + ReplayManager.Instance.InitReplayBoard(ReplayManager.Instance.LoadReplayDatas()[9]); //게임 씬에서 확인하기 위한 임시 코드 @@ -88,7 +90,28 @@ public class GameManagerTestLIN : Singleton _gameLogic.SetNewBoardValue(_gameLogic.currentTurn, _gameLogic.selectedRow,_gameLogic.selectedCol); } - + + public void OnClickReplayNextButton() + { + Move nextMove = ReplayManager.Instance.GetNextMove(); + if (nextMove != null) + { + 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); + } + } + } + + public void OnClickReplayUndoButton() + { + + } private void ChangeToGameScene(Enums.GameType gameType) { _gameType = gameType; diff --git a/Assets/Script/Game/Enums.cs b/Assets/Script/Game/Enums.cs index e36974e..3f8d258 100644 --- a/Assets/Script/Game/Enums.cs +++ b/Assets/Script/Game/Enums.cs @@ -8,5 +8,5 @@ public class Enums public enum StoneState{ None, Selected, Blocked, LastPositioned } - public enum GameType{ None, SinglePlay, MultiPlay } + public enum GameType{ None, SinglePlay, MultiPlay, Replay } } diff --git a/Assets/Script/Game/GameLogic.cs b/Assets/Script/Game/GameLogic.cs index ab4a325..fef13db 100644 --- a/Assets/Script/Game/GameLogic.cs +++ b/Assets/Script/Game/GameLogic.cs @@ -27,6 +27,9 @@ public class GameLogic : MonoBehaviour currentTurn = Enums.PlayerType.PlayerA; SetState(currentTurn); + + //TODO: 기보 매니저에게 플레이어 닉네임 넘겨주기 + ReplayManager.Instance.InitReplayData("PlayerA","nicknameB"); } private void SetState(Enums.PlayerType player) @@ -60,6 +63,8 @@ public class GameLogic : MonoBehaviour LastNSelectedSetting(row, col); SetState(Enums.PlayerType.PlayerB); + + ReplayManager.Instance.RecordStonePlaced(Enums.StoneType.Black, row, col); //기보 데이터 저장 } if (playerType == Enums.PlayerType.PlayerB) { @@ -69,6 +74,8 @@ public class GameLogic : MonoBehaviour LastNSelectedSetting(row, col); SetState(Enums.PlayerType.PlayerA); + + ReplayManager.Instance.RecordStonePlaced(Enums.StoneType.White, row, col); } } } diff --git a/Assets/Script/Replay/ReplayManager.cs b/Assets/Script/Replay/ReplayManager.cs index 7a945b2..0c8d03a 100644 --- a/Assets/Script/Replay/ReplayManager.cs +++ b/Assets/Script/Replay/ReplayManager.cs @@ -32,8 +32,37 @@ public class Move public class ReplayManager : Singleton { private ReplayRecord _recordingReplayData; + + #region 기보 시작 후 데이터를 컨트롤하기 위한 변수 + + private ReplayRecord _replayRecord; + private Stack _plavedStoneStack; + private Stack _undoStack; + private int _moveIndex; + + #endregion + + public void InitReplayBoard(ReplayRecord replayRecord) + { + _replayRecord = replayRecord; + _moveIndex = 0; + } + public Move GetNextMove() + { + if (_undoStack.Count > 0) + return _undoStack.Pop(); + + if(_moveIndex >= _replayRecord.moves.Count) + return null; + + Move move = _replayRecord.moves[_moveIndex]; + _moveIndex++; + return move; + } + + #region 게임 플레이중 기보 데이터 저장 /// /// 게임 시작에 호출해서 기보 데이터 초기화 /// @@ -81,7 +110,8 @@ public class ReplayManager : Singleton } } - + #endregion + //폴더내 기보 파일을 전부 읽어옵니다. public List LoadReplayDatas() {