/// <summary> /// ゲームを中断する。 /// </summary> private void RequestedShutOutGame(NetworkConnection connection, ShutOutGame.Request request) { var msg = new ShutOutGame.Response(); var id = connection.connectionId; RoomData roomData; try { // プレイヤーが存在しているかどうかチェック if (!playerDataHolder.ExistPlayerData(id)) { Debug.LogWarningFormat("[RequestedShutOutGame] 存在しないプレイヤーが指定されました\nid : {0}", id); msg.Result = ShutOutGame.Result.FailureNonExistPlayer; connection.Send(msg); return; } // 部屋が存在しているかどうかチェック if (!roomDataHolder.ExistRoomByHostPlayer(id)) { Debug.LogWarningFormat("[RequestedShutOutGame] 指定したプレイヤーがホストである部屋が存在しません\nid : {0}", id); msg.Result = ShutOutGame.Result.FailureNonHost; connection.Send(msg); return; } // ゲームを開始しているかどうかチェック roomData = roomDataHolder.GetRoomDataByHostPlayer(id); if (!roomData.IsPlaying) { Debug.LogWarningFormat("[RequestedShutOutGame] ゲームは開始されていません\nid : {0}", id); msg.Result = ShutOutGame.Result.FailureNoPlaying; connection.Send(msg); return; } msg.Result = ShutOutGame.Result.Succeed; connection.Send(msg); } catch (Exception e) { Debug.LogErrorFormat("[RequestedShutOutGame] 予期せぬエラーが発生しました\nid : {0}", id); Debug.LogException(e); msg.Result = ShutOutGame.Result.FailureUnknown; msg.Exception = e; connection.Send(msg); return; } // ホストの場合だけゲームを止めて一斉送信する if (id == roomData.HostConnectionId) { roomData.StopGame(); SendRoomShutOutGame(roomData); } }
private void ResponseShutOutGame(NetworkConnection connection, ShutOutGame.Response response) { OnShutOutGameResponseEvent?.Invoke(response); }