Beispiel #1
0
 private void ProcessCommand(string[] _input)
 {
     //Command doesnt exist on dictionary
     if (DeveloperConsoleUtils.isInputInvalid(_input) || !Commands.ContainsKey(_input[0]))
     {
         Debug.LogWarning(DeveloperConsoleMessages.UnrecognizedCommandMessage);
     }
     else
     {
         IEnumerable <string> args = _input.Skip(1).Take(_input.Length - 1);
         Commands[_input[0]].RunCommand(args.ToArray());
     }
 }
        //Logic of the command
        public override void RunCommand(string[] args)
        {
            if (DeveloperConsoleUtils.noValidArguments(args))
            {
                DeveloperConsole.Instance.AddMessageToConsole(DeveloperConsoleMessages.MissingCommandArgumentsMessage);
                return;
            }

            if (DeveloperConsole.isValidCommand(args[0]))
            {
                DeveloperConsole.Instance.AddMessageToConsole(DeveloperConsole.Commands[args[0]].Description);
            }
            else
            {
                DeveloperConsole.Instance.AddMessageToConsole(DeveloperConsoleMessages.UnrecognizedCommandMessage);
            }
        }
        //Logic of the command
        public override void RunCommand(string[] args)
        {
            if(DeveloperConsoleUtils.noValidArguments(args))
            {
                DeveloperConsole.Instance.AddMessageToConsole("Avilable commands:");

                foreach (ConsoleCommand command in DeveloperConsole.Commands.Values)
                {
                    DeveloperConsole.Instance.AddMessageToConsole("- " + command.Name);
                }

                return;
            }

            if(DeveloperConsole.isValidCommand(args[0])){
                DeveloperConsole.Instance.AddMessageToConsole(DeveloperConsole.Commands[args[0]].Help);
            }
            else
            {
                DeveloperConsole.Instance.AddMessageToConsole(DeveloperConsoleMessages.UnrecognizedCommandMessage);
            }
        }