コード例 #1
0
 public override void Run(Sprite caster, Scene scene, MagicArgs args)
 {
     Animation magic = new Animation() { Code = args.Code, Coordinate = args.Coordinate, Z = args.Z };
     EventHandler handler = null;
     magic.Disposed += handler = delegate {
         magic.Disposed -= handler;
         scene.RemoveAnimation(magic);
     };
     scene.AddAnimation(magic);
     Animation animation = new Animation() { Code = 11, Coordinate = args.Coordinate };
     EventHandler animationHandler = null;
     animation.Disposed += animationHandler = delegate {
         animation.Disposed -= animationHandler;
         scene.RemoveAnimation(animation);
     };
     scene.AddAnimation(animation);
     //捕获圆范围内将要伤害的精灵表
     for (int i = 0; i < scene.sprites.Count; i++) {
         if (scene.sprites[i].IsVisible && caster.IsHostileTo(scene.sprites[i].Camp)) {
             if (scene.sprites[i].InCircle(Scene.GetGameCoordinate(args.Coordinate), args.Radius)) {
                 Targets.Add(scene.sprites[i]);
             }
         }
     }
     int count = 0;
     int number = args.Number;
     EventHandler timerHandler = null;
     DispatcherTimer timer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(350) };
     timer.Tick += timerHandler = delegate {
         if (count == args.Number) {
             timer.Tick -= timerHandler;
             timer.Stop();
             Targets.Clear();
         } else {
             count++;
             if (count > 1) {
                 args.SpecialEffect = SpecialEffects.None;
                 scene.Shake(15, 10);
             }
             //对精灵表中所有精灵进行魔法/技能伤害
             foreach (Sprite sprite in Targets) {
                 caster.CastingToHurt(sprite, args);
             }
         }
     };
     timer.Start();
 }