Home   Cover Cover Cover Cover
 

Microsoft Agent

/csbook/solutions/17/A01.cs
using System;
using AgentNET;

class AgentDemo {
  public static void Main() {
    Agent agent = new AgentNET.AgentClass();
    agent.Connected = true;
    agent.Characters.Load("merlin", "merlin.acs");
    IAgentCtlCharacter merlin = agent.Characters["merlin"];
    merlin.Show(true);
    merlin.MoveTo(300, 200, 1000);
    merlin.Play("Greet");
    merlin.Speak("Hallo, ich bin Merlin", null);
    merlin.Play("Announce");
    IAgentCtlRequest req = merlin.Speak("Und jetzt kommt mein Freund Peedy!", null);
    merlin.Hide(false);
    
    agent.Characters.Load("peedy", "peedy.acs");
    IAgentCtlCharacter peedy = agent.Characters["peedy"];
    peedy.Wait(req); // waits until merlin has finished his sentence
    peedy.Show(false);
    peedy.MoveTo(500, 500, 2000);
    peedy.MoveTo(500, 300, 1000);
    peedy.Speak("Hallo, ich bin Peedy", null);
    peedy.MoveTo(500, 400, 1000);
    peedy.Play("GestureRight");
    peedy.Speak("Ich muss jetzt dringend fort", null);
    peedy.Hide(false);

    System.Console.Out.WriteLine("Hit Enter to stop the program");
    System.Console.In.Read();
  }
}

In order to be able to execute this program you must download the MS Agent Character file Peedy.exe from here and install the Peedy Character by executing this file.