Ejemplo n.º 1
0
        //default parameters interval = -1, start = true
        public void addBehavior(string behaviorName, double interval, bool start)
        {
            if (getBehaviorByBame(behaviorName) != null)
            {
                return;
            }

            AgentBehavior behavior = new AgentBehavior(behaviorName);
            Dictionary <string, ValueSpecification> param = new Dictionary <string, ValueSpecification>();


            BehaviorExecution be = behavior.createBehaviorExecution((InstanceSpecification)this, param, false);

            //if(be as OneShotBehaviorExecution !=null && start)
            {
                be = BehaviorScheduler.Instance.executeBehavior((Behavior)behavior, (InstanceSpecification)this, param, false);
                if (interval > 0.00)
                {
                    SimpleBehaviorExecution sbe = (SimpleBehaviorExecution)be;
                    if (sbe != null)
                    {
                        sbe.Interval = interval;
                    }
                }
                behaviorsExecution.Add((AgentBehaviorExecution)be);
            }
            behaviors.Add(behavior);
        }
Ejemplo n.º 2
0
        public AgentBehaviorExecution executeOneShotBehavior(string behaviorName)
        {
            AgentBehavior behavior = getBehaviorByBame(behaviorName);
            Dictionary <string, ValueSpecification> param = new Dictionary <string, ValueSpecification>();

            BehaviorExecution be = behavior.createBehaviorExecution((InstanceSpecification)this, param, false);

            if (be as OneShotBehaviorExecution != null)
            {
                be = BehaviorScheduler.Instance.executeBehavior((Behavior)behavior, (InstanceSpecification)this, param, false);
                return((AgentBehaviorExecution)be);
            }
            return(null);
        }
Ejemplo n.º 3
0
        //default parameters interval = -1, start = true
        public void addBehavior(string behaviorName, double interval, bool start)
        {
            if (getBehaviorByBame(behaviorName) != null)
                return;

            AgentBehavior behavior = new AgentBehavior(behaviorName);
            Dictionary<string, ValueSpecification> param = new Dictionary<string, ValueSpecification>();

            BehaviorExecution be = behavior.createBehaviorExecution((InstanceSpecification)this, param, false);
            //if(be as OneShotBehaviorExecution !=null && start)
            {
                be = BehaviorScheduler.Instance.executeBehavior((Behavior)behavior, (InstanceSpecification)this, param, false);
                if (interval > 0.00)
                {
                    SimpleBehaviorExecution sbe = (SimpleBehaviorExecution)be;
                    if (sbe != null)
                        sbe.Interval = interval;
                }
                behaviorsExecution.Add((AgentBehaviorExecution)be);
            }
            behaviors.Add(behavior);
        }