/// <summary> /// Set server's PlayerMissionsProgress dictionary for simple state sync. /// </summary> /// <param name="matchID"></param> public void ConfigureForServer(string matchID, string professorID) { MatchID = matchID; var allPlayers = GameManager.Instance.Players.Values; PlayerMissionsProgress.Clear(); foreach (var player in allPlayers) { if (player.MatchID == matchID && player.PlayerId != professorID) { PlayerMissionsProgress.Add(player.PlayerId, false); } } }
//랜덤 Guid로 플레이어들을 정렬해서 미션을 분배하는 방식을 선택 private void AssignMissions(Guid orderId) { var players = GameManager.Instance.Players.Values.OrderBy(p => p.PlayerId).ToList(); for (int i = 0; i < players.Count; i++) { Player player = players[i]; //PlayerState might not be updated here. However, Missions assigned to Profesor has no meaning. if (player.State != PlayerState.Student) { continue; } PlayerMissionsProgress.Add(player.PlayerId, false); player.AssignMissions(AllMissions.Skip(i * MissionsPerPlayer).Take(MissionsPerPlayer)); } }
public void OnPlayerDisconnectGame(Player player) { PlayerMissionsProgress.Remove(player.PlayerId); if (player.State == PlayerState.Professor) { ServerCompleteMatch(MatchResult.StudentsWin, MatchID); } else if (player.State == PlayerState.Student) { //If all players exit the game, then professor wins. if (PlayerMissionsProgress.Count == 0) { ServerCompleteMatch(MatchResult.ProfessorWins, MatchID); return; } ServerEvaluateMissionState(); } }
/// <summary> /// Call this when a Player is caught by professor and becomes assistant. /// Or in case student exits game. /// </summary> public void RemovePlayer(string playerId) { PlayerMissionsProgress.Remove(playerId); }