public override void Run(RoleBase caster, Space space, MagicArgs args) { double distance = GlobalMethod.GetDistance(args.Position, args.Destination); double speed = 2; caster.LinearShuttle(args.Destination, distance * speed); int count = 0; EventHandler timerHandler = null; DispatcherTimer timer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(100) }; timer.Tick += timerHandler = delegate { caster.Target = null; if (count == args.Number || caster.Action != Actions.Attack) { timer.Tick -= timerHandler; timer.Stop(); } else { WriteableBitmap writeableBitmap = new WriteableBitmap((int)caster.OverallSize.X, (int)caster.OverallSize.Y); writeableBitmap.Render(caster.EquipEntity(EquipTypes.Overall), null); writeableBitmap.Invalidate(); EntityObject chasingShadow = new EntityObject() { RenderTransform = caster.RenderTransform, ImageSource = writeableBitmap, Center = caster.Center, Position = caster.Position, Z = caster.Z - 20 }; space.Children.Add(chasingShadow); Storyboard storyboard = new Storyboard(); storyboard.Children.Add(GlobalMethod.CreateDoubleAnimation(chasingShadow,"Opacity",0.9,0,TimeSpan.FromMilliseconds(caster.HeartInterval * 3),null)); EventHandler handler = null; storyboard.Completed += handler = delegate { storyboard.Completed -= handler; storyboard.Stop(); space.Children.Remove(chasingShadow); }; storyboard.Begin(); //每200毫秒伤害一次 if (count % 2 == 0) { for (int i = space.AllRoles().Count - 1; i >= 0; i--) { RoleBase target = space.AllRoles()[i]; if (caster.IsHostileTo(target) && target.InCircle(caster.Position, args.Radius * args.Scale)) { caster.CastingToEffect(target, args); } } } count++; } }; timer.Start(); }