Пример #1
0
    private void OnChat(ChatData data)
    {
        // Parse the chat message into an array of strings and look for a "/gravity" command
        var cmds = data.Message.Split(new Char[] { ' ' });

        if (cmds[0] == "/gravity")
        {
            if (cmds.Length > 1)
            {
                // Attempt to interpret the text after the command as a number
                float value;
                if (float.TryParse(cmds[1], out value))
                {
                    ScenePrivate.Chat.MessageAllUsers("Attempting to set gravity to: " + value);
                    ScenePrivate.SetGravity(value);  // Assign the scene's gravity to the number
                }
                // Otherwise reset the scene to default gravity if specified
                else if (cmds[1] == "default")
                {
                    ScenePrivate.Chat.MessageAllUsers("Setting gravity back to default.");
                    ScenePrivate.SetGravity(ScenePrivate.DefaultGravity);
                }
            }
            // If no additional parameter was specified, print out the scene's current gravity
            else
            {
                ScenePrivate.Chat.MessageAllUsers("Gravity is set to: " + ScenePrivate.GetGravity());
            }
        }
    }