예제 #1
0
 /// <summary>
 /// 创建子魔法元素
 /// </summary>
 void createSubMagic(RoleBase caster, Space space, MagicArgs args, double angle, double width)
 {
     double radian = GlobalMethod.GetRadian(angle);
     double x = width * Math.Cos(radian) + args.Position.X;
     double y = width * Math.Sin(radian) + args.Position.Y;
     Point position = new Point(x, y);
     Point p = space.Terrain.GetCoordinateFromPosition(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 = position, Z = (int)y };
             EventHandler handler = null;
             magic.Disposed += handler = delegate {
                 magic.Disposed -= handler;
                 space.RemoveAnimation(magic);
             };
             space.AddAnimation(magic);
             //捕获圆范围内将要伤害的精灵表
             for (int i = space.AllRoles().Count - 1; i >= 0; i--) {
                 RoleBase target = space.AllRoles()[i];
                 if (caster.IsHostileTo(target) && target.InCircle(position, args.Radius * args.Scale)) {
                     caster.CastingToEffect(target, args);
                 }
             }
         }
     }
 }
 public override void Run(RoleBase caster, Space space, MagicArgs args)
 {
     args.Position = args.MagicPosition == MagicPositions.Position ? args.Position : args.Destination;
     double angle = GlobalMethod.GetAngle(GlobalMethod.GetRadian(args.Position, args.Destination)) + 180;
     int count = 0;
     int number = 4;
     double width = 110 * args.Scale;
     EventHandler handler = null;
     DispatcherTimer timer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(100) };
     timer.Tick += handler = delegate {
         if (count == args.Number) {
             timer.Tick -= handler;
             timer.Stop();
         } else {
             createSubMagic(space, args, number, angle, width);
             count++;
             number += 2;
             width += 110 * args.Scale;
         }
     };
     timer.Start();
     //捕获圆范围内将要伤害的精灵表
     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)) {
             caster.CastingToEffect(target, args);
         }
     }
 }
예제 #3
0
 public override void Run(RoleBase caster, Space space, MagicArgs args)
 {
     targets.Add(args.Target);
     for (int i = space.AllRoles().Count - 1; i >= 0; i--) {
         if (targets.Count == args.Number) { break; }
         RoleBase target = space.AllRoles()[i];
         if (caster.IsHostileTo(target) && target.InCircle(args.Destination, args.Radius * args.Scale)) {
             if (target != args.Target) { targets.Add(target); }
         }
     }
     int index = 0;
     CreateSubMagic(caster, space, args, index);
     DispatcherTimer timer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(200) };
     EventHandler handler = null;
     timer.Tick += handler = delegate {
         if (caster.IsHostileTo(targets[index])) { caster.CastingToEffect(targets[index], args); }
         index++;
         if (index == targets.Count) {
             timer.Stop();
             timer.Tick -= handler;
         } else {
             int newInterval = timer.Interval.Milliseconds - 30;
             if (newInterval <= 20) { newInterval = 20; }
             timer.Interval = TimeSpan.FromMilliseconds(newInterval);
             CreateSubMagic(caster, space, args, index);
         }
     };
     timer.Start();
 }
예제 #4
0
 public override void Run(RoleBase caster, Space space, MagicArgs args)
 {
     targets.Add(args.Target);
     for (int i = space.AllRoles().Count - 1; i >= 0; i--) {
         RoleBase target = space.AllRoles()[i];
         if (caster.IsHostileTo(target) && target.InCircle(args.Destination, args.Radius * args.Scale)) {
             if (target != args.Target) { targets.Add(target); }
             if (targets.Count == args.Number) { break; }
         }
     }
     CreateSubMagic(caster, space, args);
 }
 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();
 }
예제 #6
0
 public override void Run(RoleBase caster, Space space, MagicArgs args)
 {
     int count = 0;
     caster.AttackToHurt(args.Target);
     for (int i = space.AllRoles().Count - 1; i >= 0; i--) {
         RoleBase target = space.AllRoles()[i];
         if (caster.IsHostileTo(target) && target.InCircle(args.Target.Position, args.Radius * args.Scale)) {
             if (target != args.Target) {
                 CreateSubMagic(caster, args.Target, target, space, args);
                 caster.CastingToEffect(target, args);
                 count++;
                 if (count == args.Number) { break; }
             }
         }
     }
 }
예제 #7
0
 public override void Run(RoleBase caster, Space space, MagicArgs args)
 {
     args.Position = args.MagicPosition == MagicPositions.Position ? args.Position : args.Destination;
     AnimationBase magic = new AnimationBase() { Code = args.ResCode, SpaceLayer = args.SpaceLayer, Position = args.Position, Z = args.MagicLayer == MagicLayers.Ground ? -1 : (int)args.Position.Y };
     EventHandler handler = null;
     magic.Disposed += handler = delegate {
         magic.Disposed -= handler;
         space.RemoveAnimation(magic);
     };
     space.AddAnimation(magic);
     for (int i = space.AllRoles().Count - 1; i >= 0; i--) {
         RoleBase target = space.AllRoles()[i];
         if (target.InCircle(args.Position, args.Radius * args.Scale)) {
             caster.CastingToEffect(target, args);
         }
     }
 }
 public override void Run(RoleBase caster, Space space, MagicArgs args)
 {
     double angle = GlobalMethod.GetAngle(GlobalMethod.GetRadian(args.Position, args.Destination)) + 180;
     double singleAngle = 10;
     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;
         Bullet bullet = new Bullet(new BulletDatas() { Code = args.ResCode, Type = BulletTypes.Common }) {
             SpaceLayer = caster.SpaceLayer,
             Z = (int)args.Destination.Y,
         };
         double offsetX = bullet.Source.PixelWidth * bullet.Scale;
         double offsetStartY = (caster.State == States.Riding ? (caster.Profession == Professions.Taoist ? 130 : 110) : 60) * bullet.Scale;
         double offsetEndY = 80 * bullet.Scale;
         EventHandler handler = null;
         bullet.MoveCompleted += handler = delegate {
             bullet.MoveCompleted -= handler;
             space.RemoveUIElement(bullet);
         };
         space.AddUIElement(bullet);
         Point p = new Point(args.Destination.X + args.Radius * Math.Cos(GlobalMethod.GetRadian(otherAngle)), args.Destination.Y + args.Radius * Math.Sin(GlobalMethod.GetRadian(otherAngle)));
         bullet.Move(new Point(args.Position.X - offsetX, args.Position.Y - offsetStartY), new Point(p.X - offsetX, p.Y - offsetEndY), 0.6 / bullet.Scale, 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 = space.AllRoles().Count - 1; i >= 0; i--) {
         RoleBase target = space.AllRoles()[i];
         if (caster.IsHostileTo(target)) {
             double tempAngle = GlobalMethod.GetAngle(GlobalMethod.GetRadian(target.Position, args.Position));
             if ((tempAngle >= s0 && tempAngle <= e0) || (tempAngle >= s1 && tempAngle <= e1) || target.InCircle(args.Position, 50)) {
                 caster.CastingToEffect(target, args);
             }
         }
     }
 }
 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();
         }
     }
 }