public bool Execute()
        {
            bool executed = false;

            try
            {
                if (_cmdElements.Length != 2)
                {
                    throw new Exception($"wrong count of elements [{_cmdElements.Length}]");
                }

                bool show = false;

                if (_cmdElements[1].Equals("true", StringComparison.InvariantCultureIgnoreCase))
                {
                    show = true;
                }
                else
                if (_cmdElements[1].Equals("false", StringComparison.InvariantCultureIgnoreCase))
                {
                    show = false;
                }
                else
                {
                    throw new Exception($"incorrect command element [{_cmdElements[1]}]. Must be 'true' or 'false'!");
                }

                if (!MainGameHandler.CheckIfSceneActive(MainGameHandler.SceneType.LocalPlace, MainGameHandler.CurrentScene))
                {
                    throw new Exception("local place scene is not active!");
                }

                GameObject[] gameObjects = MainGameHandler.CurrentScene.GetRootGameObjects();
                LocalPlaceSceneManagerHandler handler = null;

                foreach (GameObject obj in gameObjects)
                {
                    if (obj.name.Equals("LocalPlaceSceneManager", StringComparison.InvariantCultureIgnoreCase))
                    {
                        handler = obj.GetComponent <LocalPlaceSceneManagerHandler>();
                        break;
                    }
                }

                if (handler == null)
                {
                    throw new Exception("cannot find scene manager handler!");
                }

                handler.ShowServerCollisionBoxes(show);
                executed = true;
            }
            catch (Exception exception)
            {
                _chat.UpdateLog($"Cannot execute command [{_keyWord}]: {exception.Message}");
            }

            return(executed);
        }
Ejemplo n.º 2
0
 void OnSceneLoaded(Scene scene, LoadSceneMode mode)
 {
     if (MainGameHandler.CheckIfSceneActive(MainGameHandler.SceneType.Startup, scene))
     {
         _timer   = 0f;
         _enabled = true;
     }
 }
Ejemplo n.º 3
0
        public bool Execute()
        {
            bool executed = false;

            try
            {
                LobbyCharactersHandler handler = MainGameHandler.GetLobbyCharactersHandler();
                if (handler == null)
                {
                    throw new Exception("lobby char. handler is NULL!");
                }

                if (_cmdElements.Length == 2 && _cmdElements[1].Equals("endlist", GlobalData.InputDataStringComparison))
                {
                    handler.ListConfirmed = true;

                    if (MainGameHandler.CheckIfSceneActive(MainGameHandler.SceneType.CharLobby, SceneManager.GetActiveScene()))
                    {
                        CharacterListPanelHandler.Reload();
                    }

                    MainGameHandler.HideLoadingScreen();
                    executed = true;
                }
                else
                if (_cmdElements.Length > 2 && _cmdElements[1].Equals("position", GlobalData.InputDataStringComparison))
                {
                    string           discardedText = $"{_keyWord} position";
                    LobbyCharDetails charDetails   = JsonConvert.DeserializeObject <LobbyCharDetails>(_rawText.Substring(discardedText.Length));
                    handler.Add(charDetails);
                    executed = true;
                }
            }
            catch (Exception exception)
            {
                _chat.UpdateLog($"Lobby char. command execution error: {exception.Message}");
            }

            return(executed);
        }