문자열 하드코딩 해서 들어가는 부분 수정했습니다

This commit is contained in:
HaeinLEE 2025-03-14 11:41:37 +09:00
parent 1925579508
commit 0d4b9f0521
3 changed files with 9 additions and 7 deletions

View File

@ -8,11 +8,12 @@ public class ReplayCell : MonoBehaviour
{ {
[SerializeField] private Image winImage; [SerializeField] private Image winImage;
[SerializeField] private Image loseImage; [SerializeField] private Image loseImage;
//TODO: TextMeshProUGI 수정하기
[SerializeField] private TMP_Text playerNicknameText; [SerializeField] private TMP_Text playerNicknameText;
[SerializeField] private TMP_Text recordDateText; [SerializeField] private TMP_Text recordDateText;
private ReplayRecord _storedReplayRecord; private ReplayRecord _storedReplayRecord;
private string _myPlayerType; private PlayerType _myPlayerType;
private string _opponentNickname; private string _opponentNickname;
@ -31,7 +32,7 @@ public class ReplayCell : MonoBehaviour
} }
} }
public void SetMyPlayerType(string myPlayerType) public void SetMyPlayerType(PlayerType myPlayerType)
{ {
_myPlayerType = myPlayerType; _myPlayerType = myPlayerType;
} }

View File

@ -55,7 +55,7 @@ public class ReplayManager : Singleton<ReplayManager>
/// </summary> /// </summary>
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.ToString();
_recordingReplayData.moves.Add(new Move(stoneColor, row, col)); _recordingReplayData.moves.Add(new Move(stoneColor, row, col));
} }
@ -69,7 +69,7 @@ public class ReplayManager : Singleton<ReplayManager>
{ {
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;
string winner = winnerPlayerType == PlayerType.PlayerA ? "PlayerA" : "PlayerB"; _recordingReplayData.winnerPlayerType = winnerPlayerType.ToString();
string json = JsonUtility.ToJson(_recordingReplayData, true); string json = JsonUtility.ToJson(_recordingReplayData, true);

View File

@ -32,11 +32,12 @@ public class ReplayPanelController : MonoBehaviour
{ {
var replayCellButtonObject = Instantiate(replayCellPrefab, contentTransform); var replayCellButtonObject = Instantiate(replayCellPrefab, contentTransform);
ReplayCell replayCell = replayCellButtonObject.GetComponent<ReplayCell>(); ReplayCell replayCell = replayCellButtonObject.GetComponent<ReplayCell>();
string myPlayerType = _myNickname.Equals(replayRecord.playerA)?"PlayerA":"PlayerB";
string opponentNickname = _myNickname.Equals(replayRecord.playerA)?replayRecord.playerB:replayRecord.playerA; PlayerType myPlayerType = _myNickname.Equals(replayRecord.playerA) ? PlayerType.PlayerA : PlayerType.PlayerB;
string opponentNickname = myPlayerType==PlayerType.PlayerA ? replayRecord.playerB : replayRecord.playerA;
replayCell.SetMyPlayerType(myPlayerType); replayCell.SetMyPlayerType(myPlayerType);
replayCell.SetWinImage(myPlayerType.Equals(replayRecord.winnerPlayerType)); replayCell.SetWinImage(myPlayerType.ToString().Equals(replayRecord.winnerPlayerType));
replayCell.SetOpponentPlayerNickname(opponentNickname); replayCell.SetOpponentPlayerNickname(opponentNickname);
replayCell.SetRecordDate(replayRecord.gameDate); replayCell.SetRecordDate(replayRecord.gameDate);
replayCell.SetReplayRecord(replayRecord); replayCell.SetReplayRecord(replayRecord);