public void SetMethod(Object target, MethodInfo method)
        {
            ParameterInfo[] parameters = method.GetParameters();
            switch (parameters.Length)
            {
            case 0:
                voidMethod = () => method.Invoke(target, new object[] { });
                break;

            case 1:
                if (parameters[0].ParameterType == typeof(bool))
                {
                    boolMethod = (bool b) => method.Invoke(target, new object[] { b });
                }
                else if (parameters[0].ParameterType == typeof(float))
                {
                    floatMethod = (float f) => method.Invoke(target, new object[] { f });
                }
                else if (parameters[0].ParameterType == typeof(int))
                {
                    intMethod = (int x) => method.Invoke(target, new object[] { x });
                }
                break;
            }
        }
示例#2
0
 public State SetUtility(FloatMethod s)
 {
     if (s != null)
     {
         _getUtility = s;
     }
     return(this);
 }
 public void SetMethod(FloatMethod method, EventType _eventType = EventType.Always)
 {
     eventType            = _eventType;
     floatMethod          = method;
     methodParameterCount = 1;
     if (method != null)
     {
         SetMethodParameters(method.Target, method.Method);
     }
 }
示例#4
0
文件: Utils.cs 项目: franciscofm/TFG
    /// <summary>
    /// Executes an action once per frame, method called has the time passed as parameter in % (Range 0f to 1f).
    /// </summary>
    /// <returns>Routine iterator.</returns>
    /// <param name="f">Duration in seconds.</param>
    /// <param name="a">Action callback, can NOT be null.</param>
    public static IEnumerator DoWhile(float f, FloatMethod a)
    {
        float t = 0f;

        while (t < f)
        {
            yield return(null);

            t += Time.deltaTime;
            a(t / f);
        }
    }
示例#5
0
 public AttentionMode SetUtility(FloatMethod utilityMethod)
 {
     this._utilityMethod = utilityMethod;
     return(this);
 }
示例#6
0
 public State SetUtility(float s)
 {
     _getUtility = () => s;
     return(this);
 }
示例#7
0
 public State SetUtility(FloatMethod s)
 {
     getUtility = s;
     return(this);
 }