public static bool PrepareForMessageSend( string callMethod, RunTarget runTarget, Dictionary <string, object> runtimeSubjects, string runtimeSubjectName, // GameObject subject, // GameObject target, GameObject referenceTarget, Parameters parameters, // out GameObject obj, out object obj, out object[] suppliedParameters ) { suppliedParameters = new object[0]; obj = null;// subject; if (string.IsNullOrEmpty(callMethod) || string.IsNullOrWhiteSpace(callMethod)) { Debug.LogWarning("Call Method is blank..."); return(false); } if (runTarget == RunTarget.Player && !GameManager.playerExists) { Debug.LogWarning("Cant Call Method: " + callMethod + " on player, player doesnt exist yet!"); return(false); } switch (runTarget) { case RunTarget.Subject: if (!runtimeSubjects.TryGetValue(runtimeSubjectName, out obj)) { Debug.LogWarning("Supplied Runtime Subjects for '" + callMethod + "', does not include key: '" + runtimeSubjectName + "'"); return(false); } break; // case RunTarget.Subject: // obj = subject; // break; // case RunTarget.Target: // obj = target; // break; case RunTarget.Reference: obj = referenceTarget; break; case RunTarget.Static: obj = null; break; case RunTarget.Player: obj = GameManager.player.gameObject; break; } if (obj == null && runTarget != RunTarget.Static) { if (runTarget == RunTarget.Subject) { Debug.LogWarning("RunTarget: " + runTarget.ToString() + " [" + runtimeSubjectName + "] is null, can't call method: " + callMethod); } else { Debug.LogWarning("RunTarget: " + runTarget.ToString() + " is null, can't call method: " + callMethod); } return(false); } 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(); } return(true); }
public static bool PrepareForMessageSend( string callMethod, RunTarget runTarget, GameObject subject, GameObject target, GameObject referenceTarget, MessageParameters parameters, out GameObject obj, out object[] suppliedParameters ) { suppliedParameters = new object[0]; obj = subject; if (string.IsNullOrEmpty(callMethod) || string.IsNullOrWhiteSpace(callMethod)) { Debug.LogWarning("Call Method is blank..."); return(false); } if (runTarget == RunTarget.Player && !GameManager.playerExists) { Debug.LogWarning("Cant Call Method: " + callMethod + " on player, player doesnt exist yet!"); return(false); } 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; case RunTarget.Player: obj = GameManager.playerActor.gameObject; break; } if (obj == null && runTarget != RunTarget.Static) { Debug.LogWarning("RunTarget: " + runTarget.ToString() + " is null, can't call method: " + callMethod); return(false); } 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(); } return(true); }
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)); }