Merge pull request #19 from Degulleo/DO-34-기보씬-진입을-위한-UI작업

DO-34-기보씬-진입을-위한-UI작업
This commit is contained in:
HaeinLEE117 2025-03-19 13:16:54 +09:00 committed by GitHub
commit 23ddc0e439
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 21380 additions and 1330 deletions

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c43b10ec26b95c7428004596bf4bdf8a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -39,9 +39,6 @@ public class GameManagerTestLIN : Singleton<GameManagerTestLIN>
//게임 씬에서 확인하기 위한 임시 코드 //게임 씬에서 확인하기 위한 임시 코드
_stoneController = GameObject.FindObjectOfType<StoneController>();
_stoneController.InitStones();
_gameLogic = new GameLogic(_stoneController, _gameType);
} }
private void TryAutoSignin() private void TryAutoSignin()
@ -142,6 +139,12 @@ public class GameManagerTestLIN : Singleton<GameManagerTestLIN>
_stoneController.InitStones(); _stoneController.InitStones();
_gameLogic = new GameLogic(_stoneController, _gameType); _gameLogic = new GameLogic(_stoneController, _gameType);
} }
else if (scene.name == "Replay")
{
_stoneController = GameObject.FindObjectOfType<StoneController>();
_stoneController.InitStones();
_gameLogic = new GameLogic(_stoneController, Enums.GameType.Replay);
}
_canvas = GameObject.Find("Canvas").GetComponent<Canvas>(); _canvas = GameObject.Find("Canvas").GetComponent<Canvas>();
} }
} }

File diff suppressed because it is too large Load Diff

19517
Assets/Scenes/Replay.unity Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 393dbf55b04641847ae9b882a54856af
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -27,7 +27,7 @@ public abstract class Singleton<T> : MonoBehaviour where T : Component
} }
} }
private void Awake() protected void Awake()
{ {
if (_instance == null) if (_instance == null)
{ {

View File

@ -50,17 +50,17 @@ public class GameManager : Singleton<GameManager>
//게임 씬에서 확인하기 위한 임시 코드 //게임 씬에서 확인하기 위한 임시 코드
_gameType = Enums.GameType.SinglePlay; _gameType = Enums.GameType.SinglePlay;
if (_canvas == null) if (_canvas == null)
{ {
_canvas = GameObject.Find("Canvas").GetComponent<Canvas>(); _canvas = GameObject.Find("Canvas").GetComponent<Canvas>();
} }
// 로딩 화면 추가(자동 로그인 응답 전까지) // 로딩 화면 추가(자동 로그인 응답 전까지)
OpenLoadingPanel(false, false, true); OpenLoadingPanel(false, false, true);
// 자동 로그인 // 자동 로그인
TryAutoSignin(); TryAutoSignin();
//게임 씬에서 확인하기 위한 임시 코드 //게임 씬에서 확인하기 위한 임시 코드
// _canvas = canvas.GetComponent<Canvas>(); // _canvas = canvas.GetComponent<Canvas>();
// _stoneController = GameObject.FindObjectOfType<StoneController>(); // _stoneController = GameObject.FindObjectOfType<StoneController>();
@ -203,15 +203,18 @@ public class GameManager : Singleton<GameManager>
{ {
if (scene.name == "Game") if (scene.name == "Game")
{ {
if (_gameType == Enums.GameType.Replay)
{
//TODO: 리플레이를 위한 초기화
}
_stoneController = GameObject.FindObjectOfType<StoneController>(); _stoneController = GameObject.FindObjectOfType<StoneController>();
_stoneController.InitStones(); _stoneController.InitStones();
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);
}
_canvas = GameObject.Find("Canvas").GetComponent<Canvas>(); _canvas = GameObject.Find("Canvas").GetComponent<Canvas>();
} }
//임시 재시작 재대결 //임시 재시작 재대결
@ -266,4 +269,40 @@ public class GameManager : Singleton<GameManager>
settingsPanelObject.GetComponent<ReplayPanelController>().Show(); settingsPanelObject.GetComponent<ReplayPanelController>().Show();
} }
} }
#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
} }

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Text; using System.Text;
using TMPro; using TMPro;
using UnityEngine; using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI; using UnityEngine.UI;
public class ReplayCell : MonoBehaviour public class ReplayCell : MonoBehaviour
@ -83,8 +84,10 @@ public class ReplayCell : MonoBehaviour
//TODO: storedReplayRecord를 가지고 게임 씬으로 전환 //TODO: storedReplayRecord를 가지고 게임 씬으로 전환
public void OnClickReplayButton() public void OnClickReplayButton()
{ {
Debug.Log($"Replay Start with {_opponentNickname}\nDate: {_storedReplayRecord.gameDate}\n" + //TODO: 확인 패널 띄우고 밑의 내용 콜백 함수로 옮기기
$"Moves: {_storedReplayRecord.moves}"); // GameManager.Instance.OpenConfirmPanel($"{_opponentNickname}님 과의 대결을 다시 보시겠습니까?", () => { });
ReplayManager.Instance.SetReplayData(_storedReplayRecord);
SceneManager.LoadScene("Replay");
} }
} }

View File

@ -0,0 +1,46 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ReplayController : MonoBehaviour
{
void Awake()
{
//TODO: 리플레이매니저 데이터로 화면 초기화
}
public void OnclickExitButton()
{
}
public void OnclickFirstButton()
{
}
public void OnclickUndoButton()
{
Move targetMove = ReplayManager.Instance.PopMove();
if (targetMove != null)
{
GameManager.Instance.ReplayUndo(targetMove);
}
}
public void OnclickNextButton()
{
Move nextMove = ReplayManager.Instance.GetNextMove();
if (nextMove != null)
{
GameManager.Instance.ReplayNext(nextMove);
}
}
public void OnClickFinishButton()
{
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bda9793c3fea2104199340f907378533
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -35,7 +35,7 @@ public class ReplayManager : Singleton<ReplayManager>
#region #region
private ReplayRecord _replayRecord; private ReplayRecord _selectedReplayRecord;
//DO, Undo를 위한 스택 //DO, Undo를 위한 스택
private Stack<Move> _placedStoneStack; private Stack<Move> _placedStoneStack;
@ -45,7 +45,7 @@ public class ReplayManager : Singleton<ReplayManager>
public void InitReplayBoard(ReplayRecord replayRecord) public void InitReplayBoard(ReplayRecord replayRecord)
{ {
_replayRecord = replayRecord; _selectedReplayRecord = replayRecord;
_moveIndex = 0; _moveIndex = 0;
_placedStoneStack = new Stack<Move>(); _placedStoneStack = new Stack<Move>();
@ -57,10 +57,10 @@ public class ReplayManager : Singleton<ReplayManager>
if (_undoStack.Count > 0) if (_undoStack.Count > 0)
return _undoStack.Pop(); return _undoStack.Pop();
if(_moveIndex >= _replayRecord.moves.Count) if(_moveIndex >= _selectedReplayRecord.moves.Count)
return null; return null;
Move move = _replayRecord.moves[_moveIndex]; Move move = _selectedReplayRecord.moves[_moveIndex];
_moveIndex++; _moveIndex++;
return move; return move;
} }
@ -89,7 +89,7 @@ public class ReplayManager : Singleton<ReplayManager>
///<summary> ///<summary>
/// 게임 시작에 호출해서 기보 데이터 초기화 /// 게임 시작에 호출해서 기보 데이터 초기화
/// </summary> /// </summary>
public void InitReplayData(string playerANickname, string playerBNickname) public void InitReplayData(string playerANickname="", string playerBNickname="")
{ {
_recordingReplayData = new ReplayRecord(); _recordingReplayData = new ReplayRecord();
_recordingReplayData.playerA = playerANickname; _recordingReplayData.playerA = playerANickname;
@ -181,10 +181,24 @@ public class ReplayManager : Singleton<ReplayManager>
Debug.LogError($"Replay Directory Error: {e.Message}"); Debug.LogError($"Replay Directory Error: {e.Message}");
} }
} }
public void SetReplayData(ReplayRecord replayRecord)
{
_selectedReplayRecord = replayRecord;
}
protected override void OnSceneLoaded(Scene scene, LoadSceneMode mode) protected override void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{ {
if (scene.name == "Replay")
{
if (_selectedReplayRecord != null)
{
InitReplayBoard(_selectedReplayRecord);
}
// TODO: 데이터 잘못 가져왔을 때 어떻게 처리할지 고민하기
// Main으로 강제 전환 ?
}
} }
#region for tests #region for tests

File diff suppressed because one or more lines are too long

View File

@ -11,4 +11,7 @@ EditorBuildSettings:
- enabled: 1 - enabled: 1
path: Assets/Scenes/Game.unity path: Assets/Scenes/Game.unity
guid: 90d8e06582d54504c8033aab27b15564 guid: 90d8e06582d54504c8033aab27b15564
- enabled: 1
path: Assets/Scenes/Replay.unity
guid: 393dbf55b04641847ae9b882a54856af
m_configObjects: {} m_configObjects: {}