毋意 毋必 毋固 毋我

第一次发文章Agent应用类

using System;

namespace FlowCore
{
 
 public class AutoAgent
 {
  static System.Windows.Forms.Timer timer;
  static AgentObjects.Agent agentController;
  static AgentObjects.IAgentCtlCharacter agentCharater;
  static string[] actions = new string[]{"GetAttention","GetAttentionReturn","Explain","Congratulate","Announce","Congratulate_2","DontRecognize","Write","Surprised","Suggest","Wave"};
  static object obj;
  static AutoAgent()
  {
   agentController = new AgentObjects.AgentClass();
   agentController.Connected = true;
   agentController.Characters.Load("merlin","merlin.acs");
   agentCharater = agentController.Characters["merlin"];
   obj = Type.Missing;
   agentCharater.MoveTo(900,600,obj); 

   agentController.Click+=new AgentObjects._AgentEvents_ClickEventHandler(agentController_Click);
   
   timer = new System.Windows.Forms.Timer();
   timer.Interval = 3000;
   timer.Start();
   timer.Tick+=new EventHandler(timer_Tick);
  }
  public static void Show(Actions Action,string Speech)
  {
   agentCharater.Show(obj);
   agentCharater.Speak(Speech,obj);
   agentCharater.Play(actions[(int)Action]);
  }
  public static void Show(Actions Action,string Speech,short XPosition,short YPosision)
  {
   agentCharater.Show(obj); 
   agentCharater.MoveTo(XPosition,YPosision,obj); 
   agentCharater.Play(actions[(int)Action]);
   agentCharater.Speak(Speech,obj);
  }
  public static void Play(Actions Action)
  {
   agentCharater.Show(obj);
   agentCharater.Play(actions[(int)Action]);
  }
  public static void Speak(string Speech)
  {
   agentCharater.Show(obj);
   agentCharater.Play("Explain");
   agentCharater.Speak(Speech,obj);
  }
  public static void Hide()
  {
   agentCharater.Hide(obj);
  }

  private static void timer_Tick(object sender, EventArgs e)
  {
   agentCharater.MoveTo(900,600,obj);
  }
  
  private static void agentController_Click(string CharacterID, short Button, short Shift, short x, short y)
  {
   agentCharater.Play("Surprised");
   agentCharater.Speak("",obj);
  }
 }
 public enum Actions
 {
  GetAttention=0,
  GetAttentionReturn=1,
  Explain=2,
  Congratulate=3,
  Announce=4,
  Congratulate_2=5,
  DontRecognize=6,
  Write=7,
  Surprised=8,
  Suggest=9,
  Wave=10
 }
}

posted on 2005-08-15 10:02  毛毛  阅读(484)  评论(1)    收藏  举报

导航