Example #1
0
        /// <summary>Send to the player a new Scene if Loadable from his current scene.</summary>
        /// <param name="_desiredScene">Desired Scene Name recieved from the Client.</param>
        /// <param name="_currentUserSession">The Client SessionTokens, permit to check if he is still Authenticated</param>
        /// UPDATED 13/06/2020
        public void SwitchScene(string _desiredScene, UserSession _currentUserSession)
        {
            OnSessionExpiredRenewTokens(_currentUserSession);

            // For Valid Sessions, Send Collection to Player
            if (myUser.SessionTokens.IsValid())
            {
                Scene _sceneFound = SceneManager.FindSceneByName(_desiredScene);

                if (_sceneFound != null)
                {
                    if (player.playerCheckAccessDesiredScene(_sceneFound))
                    {
                        ServerSend.SwitchToScene(id, _sceneFound, player.currentScene);
                        // Update Current Scene
                        player.currentScene = _sceneFound;
                    }
                    else
                    {
                        NlogClass.target.WriteAsyncLogEvent(new AsyncLogEventInfo(new LogEventInfo(LogLevel.Warn, "SwitchScene", "PLayer [" + player.username + "] is trying to Access to a Scene wich is not Accessible. [Current Scene : " + player.currentScene.sceneName + " | Desired Scene : " + _desiredScene + "]"), NlogClass.exceptions.Add));
                    }
                }
                else
                {
                    NlogClass.target.WriteAsyncLogEvent(new AsyncLogEventInfo(new LogEventInfo(LogLevel.Warn, "SwitchScene", "Scene [" + _desiredScene + "] requested by [" + player.username + "] does not exist !"), NlogClass.exceptions.Add));
                }
            }
            else
            {
                NlogClass.target.WriteAsyncLogEvent(new AsyncLogEventInfo(new LogEventInfo(LogLevel.Error, "SwitchScene", "Client Username : "******" | myUser.SessionTokens is still not Valid"), NlogClass.exceptions.Add));
            }
        }