/// <summary> /// Get next actions to perform in order to reach targeted game action. /// </summary> /// <param name="family">The monitored Family on which you want reach action.</param> /// <param name="targetedActionName">Action name you want to reach, this name has to match with a transition defined into associated Petri Net of the "family" parameter <see cref="ComponentMonitoring.PnmlFile"/> The special key word "##playerObjectives##" enable to target all player objective actions defined inside full Petri Net from which the monitor is part of (in this special case, "linksConcerned" parameter will be ignore).</param> /// <param name="maxActions">Maximum number of actions returned.</param> /// <param name="linksConcerned">links label concerned by this action. You can leave empty if only "*" operators are used in logic expression. Must be defined if logic expression associated to the action include "+" operators. For instance, if logic expression is "(l0+l1)*l3" you have to indicate which links to use to look for the trace: l0 and l3 OR l1 and l3 => <code>MonitoringManager.getNextActionToReach(..., "l0", "l3");</code> OR <code>MonitoringManager.getNextActionToReach(..., "l1", "l3");</code></param> /// <returns>List of Pairs including a ComponentMonitoring and its associated game action useful to reach the targeted action, the number of actions returned is less or equal to maxActions parameters.</returns> public static List <KeyValuePair <ComponentMonitoring, string> > getNextActionsToReach(Family family, string targetedActionName, int maxActions, params string[] linksConcerned) { System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame(1, true); // get caller stackFrame with informations string exceptionStackTrace = "(at " + stackFrame.GetFileName() + ":" + stackFrame.GetFileLineNumber().ToString() + ")"; // to point where this function was called if (MonitoringManager.Instance == null) { throw new TraceAborted("No MonitoringManager found. You must add MonitoringManager component to one of your GameObject first (the Main_Loop for instance).", null); } FamilyMonitoring fm = MonitoringManager.Instance.getFamilyMonitoring(family); if (fm == null) { throw new TraceAborted("No monitor found for this family", null); } string internalName = targetedActionName; if (!targetedActionName.Equals("##playerObjectives##")) { internalName = fm.getInternalName(targetedActionName, exceptionStackTrace, true, linksConcerned); } if (fm.fullPnSelected >= MonitoringManager.Instance.PetriNetsName.Count) { fm.fullPnSelected = 1; } string pnName = MonitoringManager.Instance.PetriNetsName[fm.fullPnSelected]; return(MonitoringManager.getNextActionsToReach(pnName, internalName, maxActions)); }
/// <summary> /// Trace game action. /// </summary> /// <param name="family">The monitored Family to use to build trace.</param> /// <param name="actionName">Action name you want to trace, this name has to match with a transition defined into associated Petri Net of the "family" parameter <see cref="ComponentMonitoring.PnmlFile"/>.</param> /// <param name="performedBy">Specify who perform this action, the player or the system. <see cref="MonitoringManager.Source"/></param> /// <param name="processLinks">Set to false if the logic expression associated to the action include "+" operators AND the action performed by the player is not allowed by the system. In this case fourth parameters will not be processed. True (default) means fourth parameter will be analysed.</param> /// <param name="linksConcerned">links label concerned by this action. You can leave empty if only "*" operators are used in logic expression. Must be defined if logic expression associated to the action include "+" operators. For instance, if logic expression is "(l0+l1)*l3" you have to indicate which links to use to build the trace: l0 and l3 OR l1 and l3 => <code>MonitoringManager.trace(..., "l0", "l3");</code> OR <code>MonitoringManager.trace(..., "l1", "l3");</code></param> /// <returns> labels found for this game action if in game analysis is enabled (see: MonitoringManager). return empty Array else </returns> public static string[] trace(Family family, string actionName, string performedBy, bool processLinks = true, params string[] linksConcerned) { System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame(1, true); // get caller stackFrame with informations string exceptionStackTrace = "(at " + stackFrame.GetFileName() + ":" + stackFrame.GetFileLineNumber().ToString() + ")"; // to point where this function was called if (MonitoringManager.Instance == null) { throw new TraceAborted("No MonitoringManager found. You must add MonitoringManager component to one of your GameObject first (the Main_Loop for instance).", null); } FamilyMonitoring fm = MonitoringManager.Instance.getFamilyMonitoring(family); if (fm == null) { throw new TraceAborted("No monitor found for this family.", null); } string internalName = fm.getInternalName(actionName, exceptionStackTrace, processLinks, linksConcerned); if (fm.fullPnSelected >= MonitoringManager.Instance.PetriNetsName.Count) { fm.fullPnSelected = 1; } string pnName = MonitoringManager.Instance.PetriNetsName[fm.fullPnSelected]; return(MonitoringManager.processTrace(pnName, internalName, performedBy)); }