public void runAway(string Location) { if (this.run != null) { RunArgs args = new RunArgs(); args.currentLocation = Location; args.preLocation = _location; _location = Location; this.run(this, args);//激发事件只能在事件所在类的内部进行。 } }
public void Pray(Robber husband, RunArgs args) { Console.WriteLine("愿在{0}的丈夫一切安好!", husband.Location);//拉模式 }
public void CatchRobber(Robber robber, RunArgs args) { Console.WriteLine("抢劫犯从{0}跑到{1}了,去抓!", args.preLocation, args.currentLocation);//推模式 }