コード例 #1
0
 public override void Run(RoleBase caster, Space space, MagicArgs args)
 {
     args.Position = args.MagicPosition == MagicPositions.Position ? args.Position : args.Destination;
     Point p = space.Terrain.GetCoordinateFromPosition(args.Position);
     if (space.Terrain.InEffectiveRange(p)) {
         if ((args.SpaceLayer == SpaceLayers.Ground && space.Terrain.Matrix[(int)p.X, (int)p.Y] != 0) || args.SpaceLayer == SpaceLayers.Sky) {
             AnimationBase magic = new AnimationBase() { Code = args.ResCode, SpaceLayer = args.SpaceLayer, Position = args.Position, Z = args.MagicLayer == MagicLayers.Ground ? -1 : (int)args.Position.Y, Loop = true };
             //magic.RenderTransform = new RotateTransform() {
             //    CenterX = magic.Center.X,
             //    CenterY = magic.Center.Y,
             //    Angle = GlobalMethod.GetAngle(args.Position.Y - caster.Position.Y, args.Position.X - caster.Position.X)
             //};
             EventHandler handler = null;
             magic.Disposed += handler = delegate {
                 magic.Disposed -= handler;
                 space.RemoveAnimation(magic);
             };
             space.AddAnimation(magic);
             int count = 0;
             DispatcherTimer timer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(Convert.ToInt32(args.Tag)) };
             EventHandler timerHandler = null;
             timer.Tick += timerHandler = delegate {
                 if (count == args.Number) {
                     timer.Stop();
                     timer.Tick -= timerHandler;
                     magic.Dispose(magic, null);
                 } else {
                     for (int i = space.AllRoles().Count - 1; i >= 0; i--) {
                         RoleBase target = space.AllRoles()[i];
                         if (caster.IsHostileTo(target) && target.InCircle(args.Position, args.Radius * args.Scale)) {
                             //Targets.Add(target);
                             caster.CastingToEffect(target, args);
                         }
                     }
                 }
                 count++;
             };
             timer.Start();
         }
     }
 }
コード例 #2
0
 /// <summary>
 /// 移除动画(完成后需要配合清除animationList对应的项)
 /// </summary>
 /// <param name="animation"></param>
 void Remove(AnimationBase animation)
 {
     space.Children.Remove(animation);
     if (animation.ID != 0) { RemoveShadow(animation.ID); }
     animation.Dispose(animation, null);
 }