Example #1
0
        /// <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));
        }
Example #2
0
        ///	<summary>
        /// Check if action named actionName is still reachable inside the Petri net associated to this monitor
        /// </summary>
        public bool isStillReachable(string actionName)
        {
            List <List <string> > setOfLinksConcerned = getPossibleSetOfLinks(actionName);

            foreach (List <string> linksConcerned in setOfLinksConcerned)
            {
                if (MonitoringManager.getNextActionsToReach(this, actionName, int.MaxValue, linksConcerned.ToArray()).Count != 0)
                {
                    return(true);
                }
            }
            return(false);
        }
Example #3
0
        /// <summary>
        ///     Get next actions to perform in order to reach the player objective of the Petri net.
        /// </summary>
        /// <param name="pnName">The Petri net name to process.</param>
        /// <param name="maxActions">Maximum number of actions returned.</param>
        /// <returns>List of Pairs including a ComponentMonitoring and its associated game action useful to reach the player objective, the number of actions returned is less or equal to maxActions parameters.</returns>
        public static List <KeyValuePair <ComponentMonitoring, string> > getNextActionsToReachPlayerObjective(string pnName, int maxActions)
        {
            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);
            }

            if (!MonitoringManager.Instance.PetriNetsName.Contains(pnName))
            {
                throw new TraceAborted("No Petri net with name \"" + pnName + "\" found", null);
            }

            string internalName = "##playerObjectives##";

            return(MonitoringManager.getNextActionsToReach(pnName, internalName, maxActions));
        }