示例#1
0
    // Low-Level Input Functions

    /// <summary>
    /// Checks a player input delegate.
    /// </summary>
    /// <param name="inputFunction">The input delegate to check.</param>
    /// <returns>bool :: The output of the input delegate, as a bool.</returns>
    bool GetPlayerInputBool(Delegate inputFunction)
    {
        var value = inputFunction.DynamicInvoke();

        // Validation
        if (value.GetType() == typeof(bool))
        {
            return((bool)value);
        }
        else if (value.GetType() == typeof(float))
        {
            return(TypeCast.FloatToBool((float)value));
        }
        else
        {
            Debug.LogError("GetPlayerInputBool: Unexpected return type from input delegate " + inputFunction + "; returning false.");
        }
        return(false);
    }