Ejemplo n.º 1
0
    /// <summary>
    /// Checks a player input delegate.
    /// </summary>
    /// <param name="inputFunction">The input delegate to check.</param>
    /// <returns>float: The output of the input delegate, as a float.</returns>
    float GetPlayerInputFloat(Delegate inputFunction)
    {
        var value = inputFunction.DynamicInvoke();

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