예제 #1
0
        public bool IsTrue(GameObject subject, GameObject target)
        {
            if (string.IsNullOrEmpty(callMethod) || string.IsNullOrWhiteSpace(callMethod))
            {
                Debug.LogWarning("Call Method is blank...");
                return(false);
            }

            GameObject obj = subject;

            switch (runTarget)
            {
            case RunTarget.Subject: obj = subject; break;

            case RunTarget.Target: obj = target; break;

            case RunTarget.Reference: obj = referenceTarget; break;

            case RunTarget.Static: obj = null; break;
            }

            if (obj == null && runTarget != RunTarget.Static)
            {
                Debug.LogWarning("RunTarget: " + runTarget.ToString() + " is null, can't call condition method: " + callMethod);
                return(false);
            }

            object[] suppliedParameters = new object[0];

            if (parameters.Length > 0)
            {
                List <object> parametersList = new List <object>();
                for (int i = 0; i < parameters.Length; i++)
                {
                    if (parameters[i] != null)
                    {
                        parametersList.Add(parameters[i].GetParamObject());
                    }
                }
                suppliedParameters = parametersList.ToArray();
            }

            float returnValue;

            if (runTarget == RunTarget.Static)
            {
                if (!SystemTools.CallStaticMethod(callMethod, suppliedParameters, out returnValue))
                {
                    return(false);
                }
            }
            else
            {
                if (!obj.CallMethod(callMethod, suppliedParameters, out returnValue))
                {
                    return(false);
                }
            }

            float checkThreshold = threshold;

            if (useGlobalValueThreshold)
            {
                checkThreshold = GlobalGameValues.GetGlobalValue(globalValueThresholdName);
            }

            return(CheckValue(returnValue, threshold));
        }