[Feat] 기보데이터 Next와 Undo 구현
화면상에서 돌 치우는 기능 구현 필효
This commit is contained in:
parent
4455ef085b
commit
63a3e12907
@ -105,13 +105,28 @@ public class GameManagerTestLIN : Singleton<GameManagerTestLIN>
|
||||
{
|
||||
_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)
|
||||
{
|
||||
_gameType = gameType;
|
||||
|
@ -33,21 +33,24 @@ public class ReplayManager : Singleton<ReplayManager>
|
||||
{
|
||||
private ReplayRecord _recordingReplayData;
|
||||
|
||||
#region 기보 시작 후 데이터를 컨트롤하기 위한 변수
|
||||
#region 기보 시작 후 데이터를 컨트롤하기
|
||||
|
||||
private ReplayRecord _replayRecord;
|
||||
private Stack<Move> _plavedStoneStack;
|
||||
|
||||
//DO, Undo를 위한 스택
|
||||
private Stack<Move> _placedStoneStack;
|
||||
private Stack<Move> _undoStack;
|
||||
private int _moveIndex;
|
||||
|
||||
#endregion
|
||||
|
||||
public void InitReplayBoard(ReplayRecord replayRecord)
|
||||
{
|
||||
_replayRecord = replayRecord;
|
||||
_moveIndex = 0;
|
||||
}
|
||||
|
||||
_placedStoneStack = new Stack<Move>();
|
||||
_undoStack = new Stack<Move>();
|
||||
}
|
||||
|
||||
public Move GetNextMove()
|
||||
{
|
||||
@ -62,6 +65,26 @@ public class ReplayManager : Singleton<ReplayManager>
|
||||
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 게임 플레이중 기보 데이터 저장
|
||||
///<summary>
|
||||
/// 게임 시작에 호출해서 기보 데이터 초기화
|
||||
|
Loading…
x
Reference in New Issue
Block a user