[Feat] 기보데이터 Next와 Undo 구현
화면상에서 돌 치우는 기능 구현 필효
This commit is contained in:
parent
4455ef085b
commit
63a3e12907
@ -105,12 +105,27 @@ public class GameManagerTestLIN : Singleton<GameManagerTestLIN>
|
|||||||
{
|
{
|
||||||
_gameLogic.SetNewBoardValue(Enums.PlayerType.PlayerB, nextMove.columnIndex, nextMove.rowIndex);
|
_gameLogic.SetNewBoardValue(Enums.PlayerType.PlayerB, nextMove.columnIndex, nextMove.rowIndex);
|
||||||
}
|
}
|
||||||
|
ReplayManager.Instance.PushMove(nextMove);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnClickReplayUndoButton()
|
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)
|
private void ChangeToGameScene(Enums.GameType gameType)
|
||||||
{
|
{
|
||||||
|
@ -33,21 +33,24 @@ public class ReplayManager : Singleton<ReplayManager>
|
|||||||
{
|
{
|
||||||
private ReplayRecord _recordingReplayData;
|
private ReplayRecord _recordingReplayData;
|
||||||
|
|
||||||
#region 기보 시작 후 데이터를 컨트롤하기 위한 변수
|
#region 기보 시작 후 데이터를 컨트롤하기
|
||||||
|
|
||||||
private ReplayRecord _replayRecord;
|
private ReplayRecord _replayRecord;
|
||||||
private Stack<Move> _plavedStoneStack;
|
|
||||||
|
//DO, Undo를 위한 스택
|
||||||
|
private Stack<Move> _placedStoneStack;
|
||||||
private Stack<Move> _undoStack;
|
private Stack<Move> _undoStack;
|
||||||
private int _moveIndex;
|
private int _moveIndex;
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
public void InitReplayBoard(ReplayRecord replayRecord)
|
public void InitReplayBoard(ReplayRecord replayRecord)
|
||||||
{
|
{
|
||||||
_replayRecord = replayRecord;
|
_replayRecord = replayRecord;
|
||||||
_moveIndex = 0;
|
_moveIndex = 0;
|
||||||
|
|
||||||
|
_placedStoneStack = new Stack<Move>();
|
||||||
|
_undoStack = new Stack<Move>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Move GetNextMove()
|
public Move GetNextMove()
|
||||||
{
|
{
|
||||||
@ -61,6 +64,26 @@ public class ReplayManager : Singleton<ReplayManager>
|
|||||||
_moveIndex++;
|
_moveIndex++;
|
||||||
return move;
|
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 게임 플레이중 기보 데이터 저장
|
#region 게임 플레이중 기보 데이터 저장
|
||||||
///<summary>
|
///<summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user