Skip to content

Commit

Permalink
Fix Turn Error
Browse files Browse the repository at this point in the history
  • Loading branch information
minsikim-42 committed May 15, 2024
1 parent c5f864e commit 4983407
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
Binary file modified .DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions Assets/1Scenes/Intro.unity
Original file line number Diff line number Diff line change
Expand Up @@ -4632,8 +4632,8 @@ MonoBehaviour:
isResult: 0
result:
resultText:
isTestMode: 1
testCreateRoom: 1
isTestMode: 0
testCreateRoom: 0
testJoinRoom: 0
--- !u!4 &1657573346
Transform:
Expand Down
16 changes: 15 additions & 1 deletion Assets/2Scripts/InGameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Photon.Pun;
using Photon.Realtime;
using TMPro;
using Unity.Collections;
using UnityEngine;
using UnityEngine.SceneManagement;
using Random = UnityEngine.Random;
Expand Down Expand Up @@ -477,6 +478,11 @@ private void RPC_UpdateTimer(int time)
timerText.text = time.ToString();
}

public bool GetIsTurn(string nickName)
{
return turnList[turnIndex].nickName == nickName;
}

private void TurnOver()
{
EndTurn(); // 턴 종료
Expand Down Expand Up @@ -731,8 +737,9 @@ public void ExitInGame()
PV.RPC(nameof(RPC_ExitInGame), RpcTarget.All);
}
// 방장이 아닌 플레이어가 방을 나갈 경우
else
else // 나머지 클라이언트에게 알림
{
PV.RPC(nameof(RPC_LeaveUpdateTurn), RpcTarget.Others, PhotonNetwork.LocalPlayer.NickName);
LeaveRoom(); // 방 나가기
}
}
Expand All @@ -749,6 +756,13 @@ private void LeaveRoom()

PhotonNetwork.LoadLevel("Lobby"); // 로비 씬으로 이동
}

[PunRPC]
private void RPC_LeaveUpdateTurn(string nickName)
{
var turn = turnList.Find((t) => t.nickName == nickName);
turnList.Remove(turn);
}

public void Result(int t)
{
Expand Down
2 changes: 1 addition & 1 deletion Assets/2Scripts/NetworkManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ public override void OnPlayerLeftRoom(Player player)
}
else if (SceneManager.GetActiveScene().name == "Game")
{
if (PhotonNetwork.IsMasterClient)
if (InGameManager.IT.GetIsTurn(player.NickName) && PhotonNetwork.IsMasterClient)
InGameManager.IT.NextTurn(); // 다음 턴
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ MonoBehaviour:
- RPC_Result
- RPC_Die
- RPC_SetTeamNum
- RPC_SetTurn
- RPC_LeaveUpdateTurn
DisableAutoOpenWizard: 1
ShowSettings: 1
DevRegionSetOnce: 1

0 comments on commit 4983407

Please sign in to comment.