Beispiel #1
0
    public override void Run(string argString)
    {
        string[] args = GameConsoleUtility.SplitArgsAndTrim(argString);

        // We first need to make sure there is only one argument
        if (args.Length == 0)
        {
            DeveloperConsole.Instance.AddToTextLog("help: Please provide a command.");
        }
        else if (args.Length > 1)
        {
            DeveloperConsole.Instance.AddToTextLog("help: Please only enter one command argument.");
        }
        else
        {
            List <Command> commandList = DeveloperConsole.Instance.Console.CommandList;
            // Check whether the argument matches a keyword in the command list
            foreach (Command command in commandList)
            {
                foreach (string keyword in command.Keywords)
                {
                    if (args[0] == keyword)
                    {
                        DeveloperConsole.Instance.AddToTextLog(command.Help);
                        return;
                    }
                }
            }
            DeveloperConsole.Instance.AddToTextLog("help: The specified command was not found.");
        }
    }
Beispiel #2
0
    public override void Run(string argString)
    {
        string[] args   = GameConsoleUtility.SplitArgsAndTrim(argString);
        int      argLen = args.Length;

        // Give our objects a default Vector3 to spawn at if no position is specified.
        Vector3 position = new Vector3();

        if (args == null || args.Length == 0)
        {
            DeveloperConsole.Instance.AddToTextLog("spawn: Invalid GameObject.");
            return;
        }

        // Check for additional clauses, like the "at" keyword
        for (int i = 0; i < argLen; i++)
        {
            switch (args[i])
            {
            case "at":
                // This checks to see if there are enough arguments for the clause to work left in
                // the argument array.
                if (GameConsoleUtility.CheckValidNumOfArgs(i, 1, argLen))
                {
                    try
                    {
                        position = ParsePosition(args[i + 1], position);
                        i++;     // Since we already parse the next argument, we can skip it in the loop.
                    }
                    catch
                    {
                        DeveloperConsole.Instance.AddToTextLog("spawn: Invalid position. Please at least enter" +
                                                               " an x or y position.");
                        return;
                    }
                }
                else
                {
                    DeveloperConsole.Instance.AddToTextLog("spawn: No position specified.");
                    return;
                }
                break;
            }
        }

        // See which object to spawn
        switch (args[0])
        {
        case "Cube":
            GameObject go = GameObject.CreatePrimitive(PrimitiveType.Cube);
            go.transform.position = position;
            break;

        default:
            DeveloperConsole.Instance.AddToTextLog("GameObject " + args[0] + " was not found.");
            break;
        }
    }