Ejemplo n.º 1
0
 void createMagic(Sprite caster, Scene scene, MagicArgs args, int count, double angle, double width)
 {
     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);
     double radian = Global.GetRadian(angle);
     double x = width * Math.Cos(radian) + magic.Coordinate.X;
     double y = width * Math.Sin(radian) + magic.Coordinate.Y;
     magic.Coordinate = new Point(x, y);
     //捕获圆范围内将要伤害的精灵表
     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(magic.Coordinate), args.Radius)) {
                 Targets.Add(scene.sprites[i]);
             }
         }
     }
     //对精灵表中所有精灵进行魔法/技能伤害
     foreach (Sprite sprite in Targets) {
         caster.CastingToHurt(sprite, args);
     }
     Targets.Clear();
 }
Ejemplo n.º 2
0
 public override void Run(Sprite caster, Scene scene, MagicArgs args)
 {
     double angle = Global.GetAngle(Global.GetRadian(Scene.GetWindowCoordinate(caster.Coordinate), args.Target)) + 180;
     double singleAngle = 360 / args.Number;
     for (int i = 0; i < args.Number; i++) {
         Animation magic = new Animation() { Code = args.Code, Coordinate = args.Coordinate, Z = args.Z };
         EventHandler handler = null;
         magic.Disposed += handler = delegate {
             magic.Disposed -= handler;
             magic.Dispose();
             scene.RemoveAnimation(magic);
         };
         scene.AddAnimation(magic);
         magic.RenderTransform = new RotateTransform() {
             CenterX = magic.Center.X,
             CenterY = magic.Center.Y,
             Angle = angle + singleAngle * i
         };
     }
     //捕获十字(圆)范围内将要伤害的精灵表
     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]);
             }
         }
     }
     //对精灵表中所有精灵进行魔法/技能伤害
     foreach (Sprite sprite in Targets) {
         caster.CastingToHurt(sprite, args);
     }
     Targets.Clear();
 }
 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();
 }
 public override void Run(Sprite caster, Scene scene, MagicArgs args)
 {
     double angle = Global.GetAngle(Global.GetRadian(Scene.GetWindowCoordinate(caster.Coordinate), args.Target)) + 180;
     Point p0 = new Point(args.Coordinate.X, args.Coordinate.Y - 20);
     Point p1 = new Point(args.Coordinate.X + args.Radius * Math.Cos(Global.GetRadian(angle)), args.Coordinate.Y + args.Radius * Math.Sin(Global.GetRadian(angle)));
     int count = 0;
     int number = args.Number;
     EventHandler handler = null;
     DispatcherTimer timer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(80) };
     timer.Tick += handler = delegate {
         if (count == args.Number - 1) {
             timer.Tick -= handler;
             timer.Stop();
         } else {
             count++;
             Animation magic = new Animation() { Code = args.Code, Coordinate = args.Coordinate, Z = args.Z };
             EventHandler otherHandler = null;
             magic.Disposed += otherHandler = delegate {
                 magic.Disposed -= otherHandler;
                 scene.RemoveAnimation(magic);
             };
             scene.AddAnimation(magic);
             magic.RenderTransform = new RotateTransform() {
                 CenterX = magic.Center.X,
                 CenterY = magic.Center.Y,
                 Angle = angle
             };
             EventHandler moveHandler = null;
             magic.MoveCompleted += moveHandler = delegate {
                 magic.MoveCompleted -= moveHandler;
                 magic.Dispose();
             };
             magic.Move(p0, p1, 1, MoveModes.Normal);
         }
     };
     timer.Start();
     //捕获多边形范围内将要伤害的精灵表
     for (int i = 0; i < scene.sprites.Count; i++) {
         if (scene.sprites[i].IsVisible && caster.IsHostileTo(scene.sprites[i].Camp)) {
             if (scene.sprites[i].InPolygon(Global.GetRectRange(angle, p0, p1, args.Radius / 10))) {
                 Targets.Add(scene.sprites[i]);
             }
         }
     }
     //对精灵表中所有精灵进行魔法/技能伤害
     foreach (Sprite sprite in Targets) {
         caster.CastingToHurt(sprite, args);
     }
     Targets.Clear();
 }
Ejemplo n.º 5
0
 public override void Run(Sprite caster, Scene scene, MagicArgs args)
 {
     double angle = Global.GetAngle(Global.GetRadian(Scene.GetWindowCoordinate(caster.Coordinate), args.Target)) + 180;
     double singleAngle = 18;
     double startAngle = angle - ((args.Number - 1) / 2 * singleAngle);
     double endAngle = angle + ((args.Number - 1) / 2 * singleAngle);
     for (int i = 0; i < args.Number; i++) {
         double otherAngle = startAngle + singleAngle * i;
         Animation magic = new Animation() { Code = args.Code, Coordinate = args.Coordinate, Z = args.Z };
         EventHandler magicHandler = null;
         magic.Disposed += magicHandler = delegate {
             magic.Disposed -= magicHandler;
             scene.RemoveAnimation(magic);
         };
         scene.AddAnimation(magic);
         Point p = new Point(args.Coordinate.X + args.Radius * Math.Cos(Global.GetRadian(otherAngle)), args.Coordinate.Y + args.Radius * Math.Sin(Global.GetRadian(otherAngle)));
         EventHandler moveHandler = null;
         magic.MoveCompleted += moveHandler = delegate {
             magic.MoveCompleted -= moveHandler;
             magic.Dispose();
         };
         magic.Move(magic.Coordinate, p, 1.3, MoveModes.Normal);
     }
     double s0 = 0, s1 = 1, e0 = 0, e1 = 0;
     if (startAngle < 180 && endAngle > 180) {
         s0 = startAngle; e0 = 180; s1 = -180; e1 = endAngle - 360;
     } else if (startAngle >= 180) {
         s0 = startAngle - 360; e0 = endAngle - 360;
     } else {
         s0 = startAngle; e0 = endAngle;
     }
     for (int i = 0; i < scene.sprites.Count; i++) {
         if (scene.sprites[i].IsVisible && caster.IsHostileTo(scene.sprites[i].Camp)) {
             double spriteAngle = Global.GetAngle(Global.GetRadian(Scene.GetWindowCoordinate(scene.sprites[i].Coordinate), args.Coordinate));
             if ((spriteAngle >= s0 && spriteAngle <= e0) || (spriteAngle >= s1 && spriteAngle <= e1)) {
                 Targets.Add(scene.sprites[i]);
             }
         }
     }
     //对精灵表中所有精灵进行魔法/技能伤害
     foreach (Sprite sprite in Targets) {
         caster.CastingToHurt(sprite, args);
     }
     Targets.Clear();
 }
Ejemplo n.º 6
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);
     scene.Wave(args.Coordinate);
     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]);
             }
         }
     }
     //对精灵表中所有精灵进行魔法/技能伤害
     foreach (Sprite sprite in Targets) {
         caster.CastingToHurt(sprite, args);
     }
     Targets.Clear();
 }