/// <summary> /// Add an Entity action to the sequence /// </summary> /// <param name="ent">Entity the action is executed on</param> /// <param name="action">Action to be executed in the sequence</param> public void AddAction(XmasEntity ent, EntityXmasAction action) { actionQueue.Enqueue(() => { this.SetupAction(action); ent.QueueAction(action); }); }
//this method will be called when an agent recieves a percept private void agent_perceptRecieved(object sender, UnaryValueEvent<PerceptCollection> evt) { //go through all percepts foreach (Percept percept in evt.Value.Percepts) { if (percept is VacuumVision) { //Check if the vacuum cleaner is in a tile with dirt then call suck //otherwise move the vacuum cleaner VacuumVision vision = percept as VacuumVision; if (vision.ContainsDirt) this.nextAction = new SuckAction(); else this.nextAction = new MoveVacuumCleanerAction(); } } }