コード例 #1
0
        /// <summary>
        /// お題を表示する。
        /// </summary>
        private void RequestedShowTheme(NetworkConnection connection, ShowTheme.Request request)
        {
            var      msg = new ShowTheme.Response();
            var      id  = connection.connectionId;
            RoomData roomData;

            try {
                // プレイヤーが存在しているかどうかチェック
                if (!playerDataHolder.ExistPlayerData(id))
                {
                    Debug.LogWarningFormat("[RequestedShowTheme] 存在しないプレイヤーが指定されました\nid : {0}", id);
                    msg.Result = ShowTheme.Result.FailureNonExistPlayer;
                    connection.Send(msg);
                    return;
                }

                // 部屋が存在しているかどうかチェック
                if (!roomDataHolder.ExistRoomByHostPlayer(id))
                {
                    Debug.LogWarningFormat("[RequestedShowTheme] 指定したプレイヤーがホストである部屋が存在しません\nid : {0}", id);
                    msg.Result = ShowTheme.Result.FailureNonHost;
                    connection.Send(msg);
                    return;
                }

                // ゲームを開始しているかどうかチェック
                roomData = roomDataHolder.GetRoomDataByHostPlayer(id);
                if (roomData.IsPlaying)
                {
                    Debug.LogWarningFormat("[RequestedShowTheme] 既にゲームが開始されています\nid : {0}", id);
                    msg.Result = ShowTheme.Result.FailurePlaying;
                    connection.Send(msg);
                    return;
                }

                msg.Result = ShowTheme.Result.Succeed;
                connection.Send(msg);
            } catch (Exception e) {
                Debug.LogErrorFormat("[RequestedShowTheme] 予期せぬエラーが発生しました\nid : {0}", id);
                Debug.LogException(e);
                msg.Result    = ShowTheme.Result.FailureUnknown;
                msg.Exception = e;
                connection.Send(msg);
                return;
            }

            SendRoomShowTheme(roomData);
        }
コード例 #2
0
 private void ResponseShowTheme(NetworkConnection connection, ShowTheme.Response response)
 {
     OnShowThemeResponseEvent?.Invoke(response);
 }