コード例 #1
0
        /// <summary>
        /// プレイヤー名を適用する。
        /// </summary>
        private void RequestedApplyPlayerName(NetworkConnection connection, ApplyPlayerName.Request request)
        {
            var msg = new ApplyPlayerName.Response();
            var id  = connection.connectionId;

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

                var playerData = playerDataHolder.GetPlayerData(id);
                playerData.ApplyPlayerName(request.PlayerName);

                msg.Result = ApplyPlayerName.Result.Succeed;
                connection.Send(msg);
            } catch (Exception e) {
                Debug.LogErrorFormat("[RequestedApplyPlayerName] 予期せぬエラーが発生しました\nid : {0}", id);
                Debug.LogException(e);
                msg.Result    = ApplyPlayerName.Result.FailureUnknown;
                msg.Exception = e;
                connection.Send(msg);
            }
        }
コード例 #2
0
 private void ResponseApplyPlayerName(NetworkConnection connection, ApplyPlayerName.Response response)
 {
     OnApplyPlayerNameResponseEvent?.Invoke(response);
 }