// Attempt to send a message to a particular agent; called by the preceding two methods -- don't call this from your own agents private static void SendMessage(Agent agent, Telegram telegram) { if (!agent.HandleMessage(telegram)) { Printer.PrintMessageData("Message: " + telegram.messageType.ToString() + " not handled"); } }
public override void OnUnsense(Agent other) { if (!(other is Outlaw)) { Printer.Print(this, "So long, " + other.Name); } }
public override void OnSense(Agent other) { if (other is Sheriff) { Printer.Print(this, "You'll never take me alive, Sheriff!"); stateMachine.ChangeState(new OutlawGunfight()); } }
public static void Print(Agent agent, string message) { String completeMessage = agent.Name + ": " + message; System.Console.WriteLine(completeMessage + "\n"); top++; if (top >= max) { top = 0; } if (amount < 20) { amount++; } display[top] = completeMessage; displaytype[top] = agent.Id; }
// The constructor invokes the base class constructor, which then creates // an id for the new agent object and then creates and initalises the agent's // StateMachine public MinersWife(String name) : base(name) { stateMachine = new StateMachine<MinersWife>(this); stateMachine.CurrentState = new DoHouseWork(); stateMachine.GlobalState = new WifesGlobalState(); husband = AgentManager.GetAgent("Bob"); textureName = "minerswife"; location = Location.shack; }
public override void OnSense(Agent other) { if (other is Outlaw) { stateMachine.ChangeState(new SheriffGunfight(other)); } else { Printer.Print(this, "Howdy, " + other.Name); Message.DispatchMessage(0.0d, Id, other.Id, MessageType.Howdy); } }
public virtual void OnUnsense(Agent other) { }