Пример #1
0
 // 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");
     }
 }
Пример #2
0
 public override void OnUnsense(Agent other)
 {
     if (!(other is Outlaw))
     {
         Printer.Print(this, "So long, " + other.Name);
     }
 }
Пример #3
0
 public override void OnSense(Agent other)
 {
     if (other is Sheriff)
     {
         Printer.Print(this, "You'll never take me alive, Sheriff!");
         stateMachine.ChangeState(new OutlawGunfight());
     }
 }
Пример #4
0
 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;
 }
Пример #5
0
 // 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;
 }
Пример #6
0
 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);
     }
 }
Пример #7
0
 public virtual void OnUnsense(Agent other)
 {
 }