Esempio n. 1
0
 //create dictionary commands - change to logged out and logged in dictionaries
 public static void AddCommandsToConsole(string _name, ConsoleCommand _command)
 {
     if (DeveloperConsole.Instance.loggedIn == true)
     {
         if (!LoggedInCommands.ContainsKey(_name))
         {
             LoggedInCommands.Add(_name, _command);
         }
     }
     else
     {
         if (!LoggedOutCommands.ContainsKey(_name))
         {
             LoggedOutCommands.Add(_name, _command);
         }
     }
 }
Esempio n. 2
0
        //where run command is called - need a second one if logged in/out to check different dictionaries?
        private void ParseInput(string input)
        {
            if (loggedIn == true)
            {
                string[] _input = input.Split(null);

                if (_input.Length == 0 || _input == null)
                {
                    AddMessageToConsole("Command not recognized. Use Help to see a list of available commands");
                    return;
                }

                if (!LoggedInCommands.ContainsKey(_input[0]))
                {
                    AddMessageToConsole("Command not recognized. Use Help to see a list of available commands");
                }
                else
                {
                    LoggedInCommands[_input[0]].RunCommand();
                }
            }
            else
            {
                string[] _input = input.Split(null);

                if (_input.Length == 0 || _input == null)
                {
                    AddMessageToConsole("You are not logged in. Please login to continue.");
                    return;
                }

                if (!LoggedOutCommands.ContainsKey(_input[0]))
                {
                    AddMessageToConsole("Command not recognised");
                }
                else
                {
                    LoggedOutCommands[_input[0]].RunCommand();
                }
            }
        }