コード例 #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
ファイル: Sheriff.cs プロジェクト: slicedpan/AutonomousAgents
 public override void OnUnsense(Agent other)
 {
     if (!(other is Outlaw))
     {
         Printer.Print(this, "So long, " + other.Name);
     }
 }
コード例 #3
0
ファイル: Outlaw.cs プロジェクト: slicedpan/AutonomousAgents
 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
ファイル: Printer.cs プロジェクト: slicedpan/AutonomousAgents
 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
ファイル: Sheriff.cs プロジェクト: slicedpan/AutonomousAgents
 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
ファイル: Agent.cs プロジェクト: slicedpan/AutonomousAgents
 public virtual void OnUnsense(Agent other)
 {
 }