[Refactor] 게임매니저에서 리플레이 컨트롤러 분리
This commit is contained in:
parent
61248fe4d6
commit
465a575483
@ -75,12 +75,6 @@ public class GameManager : Singleton<GameManager>
|
|||||||
var fioTimer = FindObjectOfType<FioTimer>();
|
var fioTimer = FindObjectOfType<FioTimer>();
|
||||||
_gameLogic = new GameLogic(_stoneController, _gameType, fioTimer);
|
_gameLogic = new GameLogic(_stoneController, _gameType, fioTimer);
|
||||||
}
|
}
|
||||||
else if (scene.name == "Replay")
|
|
||||||
{
|
|
||||||
_stoneController = GameObject.FindObjectOfType<StoneController>();
|
|
||||||
_stoneController.InitStones();
|
|
||||||
_gameLogic = new GameLogic(_stoneController, Enums.GameType.Replay);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//임시 재시작 재대결
|
//임시 재시작 재대결
|
||||||
public void RetryGame()
|
public void RetryGame()
|
||||||
@ -90,39 +84,4 @@ public class GameManager : Singleton<GameManager>
|
|||||||
_gameLogic.SetState(_gameLogic.firstPlayerState);
|
_gameLogic.SetState(_gameLogic.firstPlayerState);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region ReplayControll
|
|
||||||
|
|
||||||
public void ReplayNext(Move nextMove )
|
|
||||||
{
|
|
||||||
// 보드에 돌을 설정하기 위해 gameLogic의 SetNewBoardValue호출
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
// 돌이 놓인 내역을 ReplayManager에도 반영
|
|
||||||
ReplayManager.Instance.PushMove(nextMove);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ReplayUndo(Move targetMove)
|
|
||||||
{
|
|
||||||
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: 화면상에서 돌 치우기
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
@ -24,7 +24,7 @@ public class ReplayController : MonoBehaviour
|
|||||||
Move targetMove = ReplayManager.Instance.PopMove();
|
Move targetMove = ReplayManager.Instance.PopMove();
|
||||||
if (targetMove != null)
|
if (targetMove != null)
|
||||||
{
|
{
|
||||||
GameManager.Instance.ReplayUndo(targetMove);
|
ReplayManager.Instance.ReplayUndo(targetMove);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ public class ReplayController : MonoBehaviour
|
|||||||
Move nextMove = ReplayManager.Instance.GetNextMove();
|
Move nextMove = ReplayManager.Instance.GetNextMove();
|
||||||
if (nextMove != null)
|
if (nextMove != null)
|
||||||
{
|
{
|
||||||
GameManager.Instance.ReplayNext(nextMove);
|
ReplayManager.Instance.ReplayNext(nextMove);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,6 +42,8 @@ public class ReplayManager : Singleton<ReplayManager>
|
|||||||
private Stack<Move> _undoStack;
|
private Stack<Move> _undoStack;
|
||||||
private int _moveIndex;
|
private int _moveIndex;
|
||||||
|
|
||||||
|
private GameLogic _gameLogic;
|
||||||
|
private StoneController _stoneController;
|
||||||
|
|
||||||
public void InitReplayBoard(ReplayRecord replayRecord)
|
public void InitReplayBoard(ReplayRecord replayRecord)
|
||||||
{
|
{
|
||||||
@ -196,11 +198,51 @@ public class ReplayManager : Singleton<ReplayManager>
|
|||||||
InitReplayBoard(_selectedReplayRecord);
|
InitReplayBoard(_selectedReplayRecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//게임 매니저에서 가져온 코드입니다.
|
||||||
|
_stoneController = GameObject.FindObjectOfType<StoneController>();
|
||||||
|
_stoneController.InitStones();
|
||||||
|
_gameLogic = new GameLogic(_stoneController, Enums.GameType.Replay);
|
||||||
|
|
||||||
// TODO: 데이터 잘못 가져왔을 때 어떻게 처리할지 고민하기
|
// TODO: 데이터 잘못 가져왔을 때 어떻게 처리할지 고민하기
|
||||||
// Main으로 강제 전환 ?
|
// Main으로 강제 전환 ?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region ReplayControll
|
||||||
|
|
||||||
|
public void ReplayNext(Move nextMove )
|
||||||
|
{
|
||||||
|
// 보드에 돌을 설정하기 위해 gameLogic의 SetNewBoardValue호출
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
// 돌이 놓인 내역을 ReplayManager에도 반영
|
||||||
|
ReplayManager.Instance.PushMove(nextMove);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ReplayUndo(Move targetMove)
|
||||||
|
{
|
||||||
|
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: 화면상에서 돌 치우기
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
#region for tests
|
#region for tests
|
||||||
|
|
||||||
public void OnClickSaveButton(string winnerPlayerType = "PlayerA")
|
public void OnClickSaveButton(string winnerPlayerType = "PlayerA")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user