기보 패널에 기보 데이터 불러오기 완료

This commit is contained in:
HaeinLEE 2025-03-13 20:24:35 +09:00
parent d317ec9fd2
commit 32f03cdb5c
2 changed files with 56 additions and 12 deletions

View File

@ -429,6 +429,50 @@ Transform:
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1094913819
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1094913821}
- component: {fileID: 1094913820}
m_Layer: 0
m_Name: ReplayManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1094913820
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1094913819}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b218eb93d916d6e4984534bd7c6b6f4c, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &1094913821
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1094913819}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 531.5, y: 1495.0004, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1660057539 &9223372036854775807 --- !u!1660057539 &9223372036854775807
SceneRoots: SceneRoots:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -437,3 +481,4 @@ SceneRoots:
- {fileID: 141845928} - {fileID: 141845928}
- {fileID: 513518722} - {fileID: 513518722}
- {fileID: 1017982171} - {fileID: 1017982171}
- {fileID: 1094913821}

View File

@ -37,26 +37,24 @@ public class Move
public class ReplayManager : Singleton<ReplayManager> public class ReplayManager : Singleton<ReplayManager>
{ {
private ReplayRecord recordingReplayData; private ReplayRecord _recordingReplayData;
///<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;
recordingReplayData.playerB = playerBNickname; _recordingReplayData.playerB = playerBNickname;
} }
public void RecordStonePlaced(StoneType stoneType,int row, int col) public void RecordStonePlaced(StoneType stoneType,int row, int col)
{ {
string stoneColor = stoneType == StoneType.Black ? "Black" : "White"; string stoneColor = stoneType == StoneType.Black ? "Black" : "White";
recordingReplayData.moves.Add(new Move(stoneColor, row, col)); _recordingReplayData.moves.Add(new Move(stoneColor, row, col));
} }
@ -66,10 +64,10 @@ public class ReplayManager : Singleton<ReplayManager>
public void SaveReplayData(string winnerPlayerType) public void SaveReplayData(string winnerPlayerType)
{ {
string time = DateTime.Now.ToString(("yyyy-MM-dd HH_mm_ss")); string time = DateTime.Now.ToString(("yyyy-MM-dd HH_mm_ss"));
recordingReplayData.gameDate = time; _recordingReplayData.gameDate = time;
recordingReplayData.winnerPlayerType = winnerPlayerType; _recordingReplayData.winnerPlayerType = winnerPlayerType;
string json = JsonUtility.ToJson(recordingReplayData, true); string json = JsonUtility.ToJson(_recordingReplayData, true);
string path = Path.Combine(Application.persistentDataPath, $"{time}.json"); string path = Path.Combine(Application.persistentDataPath, $"{time}.json");
@ -80,8 +78,8 @@ public class ReplayManager : Singleton<ReplayManager>
Debug.Log("기보 저장 완료: " + path); Debug.Log("기보 저장 완료: " + path);
} }
private List<ReplayRecord> LoadReplayDatas() public List<ReplayRecord> LoadReplayDatas()
{ {
List<ReplayRecord> records = new List<ReplayRecord>(); List<ReplayRecord> records = new List<ReplayRecord>();
string path = Application.persistentDataPath; string path = Application.persistentDataPath;
@ -90,6 +88,7 @@ public class ReplayManager : Singleton<ReplayManager>
{ {
records.Add(JsonUtility.FromJson<ReplayRecord>(File.ReadAllText(file))); records.Add(JsonUtility.FromJson<ReplayRecord>(File.ReadAllText(file)));
} }
return records; return records;
} }