Ejemplo n.º 1
0
 //closes the console
 public override void RunCommand()
 {
     devConsole = GameObject.Find("Console Canvas").GetComponent <DeveloperConsole>();
     devConsole.consoleCanvas.enabled = false;
     devConsole.consoleInput.DeactivateInputField();
     devConsole.consoleInput.enabled = false;
 }
        public override int RunCommand(string[] input)
        {

            string direction = input[1];

            if (direction == "left")
            {
                playerMovement.command_running = true;
                playerMovement.dX = -playerMovement.speed;
                DeveloperConsole.AddStaticMessageToConsole("[USER] Moving the robot left....");
            }
            else if (direction == "right")
            {
                playerMovement.command_running = true;
                playerMovement.dX = playerMovement.speed;
                DeveloperConsole.AddStaticMessageToConsole("[USER] Moving the robot right....");
            }
            else if (direction == "up")
            {
                playerMovement.command_running = true;
                playerMovement.dZ = playerMovement.speed;
                DeveloperConsole.AddStaticMessageToConsole("[USER] Moving the robot up....");
            }
            else if (direction == "down")
            {
                playerMovement.command_running = true;
                playerMovement.dZ = -playerMovement.speed;
                DeveloperConsole.AddStaticMessageToConsole("[USER] Moving the robot down....");
            }
            else
                return 1;

            return -1;

        }
Ejemplo n.º 3
0
 public void AddCommandToConsole()
 {
     // Adds command to the list of commands
     DeveloperConsole.AddCommandsToConsole(CommandText, this);
     // Prints in the console that it has done this
     DeveloperConsole.AddMessageToConsole(Name + " has been added to the console");
 }
Ejemplo n.º 4
0
        public void AddCommandToConsole()
        {
            string addMessage = " command has been added to the console.";

            DeveloperConsole.AddCommandsToConsole(Command, this);
            //GameSystemManager.GetSystem<DeveloperConsole>().AddMessageToConsole(Name + addMessage);
        }
Ejemplo n.º 5
0
        public void AddCommandToConsole()
        {
            string addMessage = " command has been added to the console.";

            DeveloperConsole.AddCommandsToConsole(Command, this);
            Debug.Log(Name + addMessage);
        }
 public override int RunCommand(string[] input)
 {
     playerMovement.dX = 0;
     playerMovement.dY = 0;
     playerMovement.dZ = 0;
     DeveloperConsole.AddStaticMessageToConsole("[USER] Stopping Robot....");
     return(-1);
 }
Ejemplo n.º 7
0
        public override void RunCommand()
        {
            //Command logic
            DeveloperConsole.Instance.consoleText.text = "";

            //CommandLog
            DeveloperConsole.AddCommandToCommandLog(Command);
        }
        public override void RunCommand()
        {
            //Command logic
            DeveloperConsole.AddStaticMessageToConsole("Hello World Test");

            //CommandLog
            DeveloperConsole.AddCommandToCommandLog(Command);
        }
Ejemplo n.º 9
0
        public override bool Process(string[] args, DeveloperConsole console)
        {
            foreach (ConsoleCommand command in console.commands)
            {
                console.uiCanvas.text += "\n" + command.CommandWord;
            }

            return(true);
        }
Ejemplo n.º 10
0
        private void Awake()
        {
            if (instance != null)
            {
                return;
            }

            instance = this;
            Commands = new Dictionary <string, ConsoleCommand>();
        }
Ejemplo n.º 11
0
        public void DisplayCommand()
        {
            string display = $"\n         Overview of Command {Name}            \n" +
                             $"************************************************\n" +
                             $"Name        : {Name}\n" +
                             $"Command:    : {Command}\n" +
                             $"Description : {Description}\n" +
                             $"Help        : {Help}\n" +
                             $"**************************************************";

            DeveloperConsole.AddStaticMessageToConsole(display);
        }
Ejemplo n.º 12
0
        public override bool Process(string[] args, DeveloperConsole console)
        {
            console.uiCanvas.text += "\n" + $"{console.currentNode.nodeName} {console.currentNode.nodeIP}";

            foreach (Node node in console.currentNode.connectedNodes)
            {
                console.uiCanvas.text += "\n" + $"{node.nodeName} {node.nodeIP}";
            }


            return(true);
        }
        public override void RunCommand()
        {
            //Command logic
            DeveloperConsole.AddStaticMessageToConsole("Previously entered commands: ");
            commandLog = DeveloperConsole.Instance.GetCommandLog();
            foreach (var CommandName in commandLog)
            {
                DeveloperConsole.AddStaticMessageToConsole(CommandName);
            }

            //CommandLog
            DeveloperConsole.AddCommandToCommandLog(Command);
        }
Ejemplo n.º 14
0
 public override bool Process(string[] args, DeveloperConsole console)
 {
     if (args.Length == 1)
     {
         foreach (Node node in console.currentNode.connectedNodes)
         {
             if (node.nodeIP == args[0])
             {
                 console.currentNode = node;
                 return(true);
             }
         }
     }
     return(false);
 }
Ejemplo n.º 15
0
        public override int RunCommand(string[] input)
        {
            Dictionary <string, ConsoleCommand> .KeyCollection keys = Commands.Keys;
            string display = "\n             List of All Commands" +
                             "\n**************************************************";

            foreach (string key in keys)
            {
                display += string.Format("\n{0} : {1}\n", Commands[key].Command, Commands[key].Description);
            }

            DeveloperConsole.AddStaticMessageToConsole(display);

            return(-1);
        }
        //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);
            }
        }
Ejemplo n.º 17
0
        public void DrawCommandHints(Rect inputFieldRect, GUIStyle hintStyle)//Draw hint label on input field
        {
            DeveloperConsole developerConsole = DeveloperConsole.Instance;

            var input = developerConsole.input;

            if (_lastInput != input)
            {
                if (!String.IsNullOrEmpty(input))
                {
                    foreach (Command command in Commands.Instance.GetCommands())//Check every command and compare them to input
                    {
                        if (input == command.GetQueryIdentity())
                        {
                            string hintText = "";
                            for (int i = 0; i < command.GetQueryIdentity().Length; i++)
                            {
                                hintText += " ";
                            }
                            var parameterFields = command.GetType().GetFields();

                            foreach (FieldInfo fieldInfo in parameterFields)
                            {
                                if (fieldInfo.GetCustomAttribute <CommandParameterAttribute>() != null)
                                {
                                    hintText += " [" + fieldInfo.GetCustomAttribute <CommandParameterAttribute>().description + "]";
                                }
                            }
                            _hintText  = hintText;
                            _lastInput = input;

                            return;
                        }
                    }
                    _hintText = "";
                }
                _lastInput = input;
            }
            if (!String.IsNullOrEmpty(_hintText) && !String.IsNullOrEmpty(input))
            {
                GUI.Label(inputFieldRect, _hintText, hintStyle);
            }
        }
Ejemplo n.º 18
0
        public override int RunCommand(string[] input)
        {
            var enable = (string)input[1];

            if (enable.ToLower() == "true")
            {
                playerMovement.keys_disabled = true;
                DeveloperConsole.AddStaticMessageToConsole("[USER] Disabling Robot controls....");
            }
            else if (enable.ToLower() == "false")
            {
                playerMovement.keys_disabled = false;
                DeveloperConsole.AddStaticMessageToConsole("[USER] Enabling Robot controls....");
            }
            else
            {
                return(1);
            }

            return(-1);
        }
        //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);
            }
        }
 public override void UsedOnlyForAOTCodeGeneration()
 {
     base.UsedOnlyForAOTCodeGeneration();
     new CommandParameter <int>(null, null);
     DeveloperConsole.ParamQuery <int>(null);
 }
Ejemplo n.º 21
0
 public abstract bool Process(string[] args, DeveloperConsole console);
Ejemplo n.º 22
0
        public void RegisterCommands()
        {
            var commands = Utility.GetTypesWithCommandAttribute(System.AppDomain.CurrentDomain.GetAssemblies());

            foreach (Command command in commands)
            {
                if (_commands.Contains(command))//Check multiple stocking with instance
                {
                    DeveloperConsole.WriteWarning("Multiple stocking of command '" + command.GetQueryIdentity() + "'. Command will be ignored.");
                    continue;
                }

                var fields = command.GetType().GetFields();//Set command options
                foreach (FieldInfo fieldInfo in fields)
                {
                    if (fieldInfo.GetCustomAttribute <CommandParameterAttribute>() != null)
                    {
                        var commandParameterType        = typeof(CommandParameter <>);
                        var commandParameterTypeGeneric = commandParameterType.MakeGenericType(fieldInfo.FieldType);
                        var commandParameter            = Activator.CreateInstance(commandParameterTypeGeneric, new object[] { command, fieldInfo });
                        var commandParameterAttribute   = fieldInfo.GetCustomAttribute <CommandParameterAttribute>();
                        command.commandParameters.Add(commandParameterAttribute.description, (CommandParameter)commandParameter);
                        commandParameterAttribute.commandParameter = (CommandParameter)commandParameter;
                    }
                }
                _commands.Add(command);
            }


            foreach (Command command in _commands.ToList())
            {
                if (String.IsNullOrEmpty(((ConsoleCommandAttribute)Attribute.GetCustomAttribute(command.GetType(), typeof(ConsoleCommandAttribute))).queryIdentity))
                {
                    var message = "Command " + command + "(" + command.GetHashCode() + ") doesn't has a query identity. Command will be ignored.";
                    Console.DeveloperConsole.WriteWarning(message);
                    _commands.Remove(command);
                }

                if (((ConsoleCommandAttribute)Attribute.GetCustomAttribute(command.GetType(), typeof(ConsoleCommandAttribute))).onlyAllowedOnDeveloperVersion && !Debug.isDebugBuild)
                {
                    _commands.Remove(command);
                }

                if (_commands.ToList().Exists(x => x.GetQueryIdentity() == command.GetQueryIdentity() && x != command))                  //Check multiple stocking with query identity
                {
                    var         stockingCommands  = _commands.ToList().FindAll(x => x.GetQueryIdentity() == command.GetQueryIdentity()); //Get overstocking commands
                    List <Type> commandParamTypes = new List <Type>();
                    foreach (CommandParameter value in command.commandParameters.Values)
                    {
                        commandParamTypes.Add(value.genericType);
                    }

                    foreach (Command overStockedCommand in stockingCommands)//Check does overstocked commands have the same invoke definition
                    {
                        if (overStockedCommand == command)
                        {
                            continue;
                        }
                        List <Type> _paramTypes = new List <Type>();
                        foreach (CommandParameter value in overStockedCommand.commandParameters.Values)
                        {
                            _paramTypes.Add(value.genericType);
                        }
                        if (Utility.CompareLists <Type>(commandParamTypes, _paramTypes))
                        {
                            DeveloperConsole.WriteWarning("Conflict between two invoke definitions of command'" + command.GetQueryIdentity() + "'. Command will be ignored.");
                            _commands.Remove(command);

                            continue;
                        }
                    }
                }
            }
        }
Ejemplo n.º 23
0
        public override void RunCommand(string[] param)
        {
            GitSystem        gitSystem = GameObject.Find("GitObject").GetComponent <GitSystem>();
            DeveloperConsole console   = GameObject.Find("DeveloperConsoleObject").GetComponent <DeveloperConsole>();

            if (param.Length == 1)
            {
                console.AddMessageToConsole("Error format");
                return;
            }
            if (param[1] == "init")
            {
                if (param.Length != 2)
                {
                    console.AddMessageToConsole("Error format");
                }
                else
                {
                    bool exist = GameObject.Find("GitObject").GetComponent <GitSystem>();
                    if (exist)
                    {
                        GameObject.Find("GitObject").GetComponent <GitSystem>().buildRepository();
                    }
                }
            }
            if (param[1] == "add")
            {
                if (param.Length != 3)
                {
                    console.AddMessageToConsole("Error format");
                }
                else
                {
                    gitSystem.trackFile(param[2], "test");
                }
            }
            if (param[1] == "remove")
            {
                if (param.Length != 3)
                {
                    console.AddMessageToConsole("Error format");
                }
                else
                {
                    gitSystem.untrackFile(param[2]);
                }
            }
            if (param[1] == "commit")
            {
                if (param.Length != 4 || param[2] != "-m")
                {
                    console.AddMessageToConsole("Error format");
                }
                else
                {
                    gitSystem.Commit(param[3]);
                }
            }
            if (param[1] == "remote")
            {
                if (param[2] == "add" && param.Length == 4)
                {
                    gitSystem.addRemote(param[3]);
                }
                else
                {
                    console.AddMessageToConsole("Error format");
                }
            }
            if (param[1] == "push")
            {
                if (param.Length != 2)
                {
                    console.AddMessageToConsole("Error format");
                }
                else
                {
                    gitSystem.Push();
                }
            }
            if (param[1] == "clone")
            {
                if (param.Length != 3)
                {
                    console.AddMessageToConsole("Error format");
                }
                bool clone = gitSystem.cloneRepository(param[2]);
                if (!clone)
                {
                    console.AddMessageToConsole("Cannot clone");
                }
            }
            if (param[1] == "branch")
            {
                if (param.Length == 2)
                {
                    Debug.Log(gitSystem.localRepository.branches.ToString());
                }
                else if (param.Length == 3)
                {
                    gitSystem.createBranch(param[2]);
                }
                else if (param.Length == 4 && param[2] == "-D")
                {
                    gitSystem.deleteBranch(param[3]);
                }
                else
                {
                    console.AddMessageToConsole("Error format");
                }
            }
            if (param[1] == "checkout")
            {
                if (param.Length != 3)
                {
                    console.AddMessageToConsole("Error format");
                }
                else
                {
                    gitSystem.checkout(param[2]);
                }
            }
            if (param[1] == "merge")
            {
                if (param.Length != 3)
                {
                    console.AddMessageToConsole("Error format");
                }
                else
                {
                    gitSystem.Merge(param[2]);
                }
            }
            if (param[1] == "pull")
            {
                if (param.Length != 4)
                {
                    console.AddMessageToConsole("Error format");
                }
                else
                {
                    gitSystem.Pull(param[2], param[3]);
                }
            }
        }
Ejemplo n.º 24
0
 public void AddCommandToConsole()
 {
     DeveloperConsole.AddCommandToConsole(Command, this);
 }
Ejemplo n.º 25
0
        private void CommandPredictionQuery() //Predict commands and print them
        {
            if (commands == null)
            {
                commands = Commands.Instance.GetCommandsSingle();
            }
            GUI.depth = -1;
            DeveloperConsole developerConsole = DeveloperConsole.Instance;
            var input = developerConsole.input;

            var  windowRect     = developerConsole.GetWindowRect();
            Rect inputFieldRect = new Rect(windowRect.x + 20, windowRect.y + windowRect.height - 45, windowRect.width - 160, 25);

            if (_lastPredictionQueryInput != input)
            {
                predictedCommandIdentities.Clear();
                foreach (Command command in commands)//Check every command and compare them to input
                {
                    if (input.Length < command.GetQueryIdentity().Length)
                    {
                        if (command.GetQueryIdentity().Substring(0, input.Length).ToLower() == input.ToLower())
                        {
                            predictedCommandIdentities.Add(command.GetQueryIdentity());
                        }
                    }
                }
                _lastPredictionQueryInput = input;
            }
            predictedCommandIdentities.Sort();
            int drawnFields = 0;

            if (Event.current.keyCode == KeyCode.DownArrow && Event.current.type == EventType.KeyUp)
            {
                predictionSelectionState++;
            }
            if (Event.current.keyCode == KeyCode.UpArrow && Event.current.type == EventType.KeyUp)
            {
                predictionSelectionState--;
                if (predictionSelectionState == 0)
                {
                    developerConsole.FocusOnInputField(false);
                }
            }

            predictionSelectionState = Mathf.Clamp(predictionSelectionState, 0, predictedCommandIdentities.Count);


            for (int i = Mathf.Clamp(predictionSelectionState - 5, 0, 128); i < Mathf.Clamp(predictionSelectionState - 5, 0, 128) + 5 && i < predictedCommandIdentities.Count; i++)
            {
                GUI.SetNextControlName("predictedCommand" + i);
                developerConsole.skin.GetStyle("prediction").font.RequestCharactersInTexture(predictedCommandIdentities[i], developerConsole.skin.GetStyle("prediction").fontSize, developerConsole.skin.GetStyle("prediction").fontStyle);

                if (GUI.Button(new Rect(inputFieldRect.x, inputFieldRect.y + 2 * inputFieldRect.height + ((0 - i + Mathf.Clamp(predictionSelectionState - 5, 0, 128) + 1) * -25), windowRect.width / 4, 25), predictedCommandIdentities[i], developerConsole.skin.GetStyle("prediction")))
                {
                    developerConsole.FocusOnInputField(true);
                    developerConsole.input = (predictedCommandIdentities[i]);
                }
                drawnFields++;
            }



            if (predictionSelectionState != 0)
            {
                GUI.FocusControl("predictedCommand" + (predictionSelectionState - 1).ToString());
            }
        }
Ejemplo n.º 26
0
        public override bool Process(string[] args, DeveloperConsole console)
        {
            console.uiCanvas.text = string.Empty;

            return(true);
        }