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);
         }
     }
 }
예제 #2
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);
                 }
             }
         }
     }
 }
예제 #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
 void CreateSubMagic(RoleBase caster, Space space, MagicArgs args, int index)
 {
     AnimationBase animation = new AnimationBase() { Code = args.ResCode,  Z = targets[index].Z + 1, Effect = shiftHue };
     double offsetStartY = (caster.State == States.Riding ? (caster.Profession == Professions.Taoist ? 130 : 110) : 60) * caster.Scale;
     double offsetEndY = (targets[index].State == States.Riding ? 100 : 50) * caster.Scale;
     Point from = index == 0 ? new Point(args.Position.X, args.Position.Y - offsetStartY) : temp;
     Point to = new Point(targets[index].Position.X, targets[index].Position.Y - offsetEndY);
     temp = to;
     RotateTransform rotateTransform = new RotateTransform() {
         CenterX = animation.Center.X,
         CenterY = animation.Center.Y,
         Angle = GlobalMethod.GetAngle(to.Y - from.Y, to.X - from.X)
     };
     ScaleTransform scaleTransform = new ScaleTransform() {
         CenterX = animation.Center.X,
         CenterY = animation.Center.Y,
         ScaleX = (GlobalMethod.GetDistance(index == 0 ? args.Position : targets[index - 1].Position, targets[index].Position) / 440), //440为其实体宽度,这里用了硬编码
         ScaleY = caster.Scale
     };
     TransformGroup transformGroup = new TransformGroup();
     transformGroup.Children.Add(scaleTransform);
     transformGroup.Children.Add(rotateTransform);
     animation.RenderTransform = transformGroup;
     animation.Position = from;
     space.AddUIElement(animation);
     EventHandler handler = null;
     animation.End += handler = delegate {
         animation.End -= handler;
         space.RemoveAnimation(animation);
         if (index == targets.Count) { targets.Clear(); }
     };
     animation.HeartStart();
 }
예제 #5
0
 void CreateSubMagic(RoleBase caster,RoleBase startTarget, RoleBase endTarget, Space space, MagicArgs args)
 {
     AnimationBase animation = new AnimationBase() { Code = args.ResCode, Z = startTarget.Z + 1 };
     double offsetStartY = (startTarget.State == States.Riding ? (startTarget.Profession == Professions.Taoist ? 130 : 110) : 60) * args.Scale;
     double offsetEndY = (endTarget.State == States.Riding ? 100 : 50) * args.Scale;
     Point from = new Point(startTarget.Position.X, startTarget.Position.Y - offsetStartY);
     Point to = new Point(endTarget.Position.X, endTarget.Position.Y - offsetEndY);
     RotateTransform rotateTransform = new RotateTransform() {
         CenterX = animation.Center.X,
         CenterY = animation.Center.Y,
         Angle = GlobalMethod.GetAngle(to.Y - from.Y, to.X - from.X)
     };
     ScaleTransform scaleTransform = new ScaleTransform() {
         CenterX = animation.Center.X,
         CenterY = animation.Center.Y,
         ScaleX = (GlobalMethod.GetDistance(startTarget.Position, endTarget.Position) / Convert.ToInt32(args.Tag)),
         ScaleY = args.Scale
     };
     TransformGroup transformGroup = new TransformGroup();
     transformGroup.Children.Add(scaleTransform);
     transformGroup.Children.Add(rotateTransform);
     animation.RenderTransform = transformGroup;
     animation.Position = from;
     space.AddUIElement(animation);
     EventHandler handler = null;
     animation.End += handler = delegate {
         animation.End -= handler;
         space.RemoveAnimation(animation);
     };
     animation.HeartStart();
 }
예제 #6
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)
 {
     int positionX = (int)args.Position.X, positionY = (int)args.Position.Y;
     int destinationX = (int)args.Destination.X, destinationY = (int)args.Destination.Y;
     int radius = (int)(100 * caster.Scale);
     for (int i = 0; i < args.Number; i++) {
         CircleMagic magic = new CircleMagic();
         args.Position = new Point(ObjectBase.RandomSeed.Next(positionX - radius, positionX + radius), ObjectBase.RandomSeed.Next(positionY - radius, positionY + radius));
         args.Destination = new Point(ObjectBase.RandomSeed.Next(destinationX - radius, destinationX + radius), ObjectBase.RandomSeed.Next(destinationY - radius, destinationY + radius));
         magic.Run(caster, space, args);
     }
 }
예제 #8
0
 public override void Run(RoleBase caster, Space space, MagicArgs args)
 {
     EventHandler handler = null;
     AnimationBase animation = new AnimationBase() {
         Code = (int)args.ResCode,
         Position = args.Target.Center,
         Z = -1,
     };
     animation.Disposed += handler = delegate {
         animation.Disposed -= handler;
         args.Target.RemoveEffect(EffectTypes.Cure);
     };
     args.Target.AddEffect(animation, EffectTypes.Cure);
     caster.CastingToEffect(args.Target, 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();
 }
예제 #10
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; }
             }
         }
     }
 }
예제 #11
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();
         }
     }
 }
예제 #14
0
 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;
     double width = args.Radius * args.Scale;
     int count = 0;
     EventHandler handler = null;
     DispatcherTimer timer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(Convert.ToInt32(args.Tag)) };
     timer.Tick += handler = delegate {
         if (count == args.Number) {
             timer.Tick -= handler;
             timer.Stop();
         } else {
             createSubMagic(caster, space, args, angle, width);
             timer.Interval = TimeSpan.FromMilliseconds(timer.Interval.Milliseconds-10);
             count++;
             width += args.Radius * args.Scale;
         }
     };
     timer.Start();
 }
 public override void Run(RoleBase caster, Space space, MagicArgs args)
 {
     int count = 0;
     int positionX = (int)args.Position.X, positionY = (int)args.Position.Y;
     int destinationX = (int)args.Destination.X, destinationY = (int)args.Destination.Y;
     int radius = (int)(130 * caster.Scale);
     EventHandler handler = null;
     DispatcherTimer timer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(150) };
     timer.Tick += handler = delegate {
         if (count == args.Number) {
             timer.Tick -= handler;
             timer.Stop();
         } else {
             CircleMagic magic = new CircleMagic();
             args.Position = new Point(ObjectBase.RandomSeed.Next(positionX - radius, positionX + radius), ObjectBase.RandomSeed.Next(positionY - radius, positionY + radius));
             args.Destination = new Point(ObjectBase.RandomSeed.Next(destinationX - radius, destinationX + radius), ObjectBase.RandomSeed.Next(destinationY - radius, destinationY + radius));
             magic.Run(caster, space, args);
             if (args.SpecialEffect == SpecialEffects.Shake) { space.Shake(Convert.ToInt32(args.Tag)); }
             count++;
         }
     };
     timer.Start();
 }
 /// <summary>
 /// 创建子魔法元素
 /// </summary>
 void createSubMagic(Space space, MagicArgs args, double number, double angle, double width)
 {
     for (int i = 0; i < number; i++) {
         double tempAngle = angle + i * (360 / number);
         double tempRadian = GlobalMethod.GetRadian(tempAngle);
         double x = width * Math.Cos(tempRadian) + args.Position.X;
         double y = width * Math.Sin(tempRadian) + 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);
             }
         }
     }
 }
예제 #17
0
 void CreateSubMagic(RoleBase caster, Space space, MagicArgs args)
 {
     Bullet bullet = new Bullet(new BulletDatas() { Code = args.ResCode, Type = BulletTypes.Animation,Loop = true }) {
         SpaceLayer = caster.SpaceLayer,
         Z = (int)args.Destination.Y,
     };
     double offsetX = bullet.Offset.X * bullet.Scale;
     double offsetStartY = (caster.State == States.Riding ? (caster.Profession == Professions.Taoist ? 130 : 110) : 60) * bullet.Scale;
     double offsetEndY = (targets[index].State == States.Riding ? 100 : 70) * bullet.Scale;
     EventHandler handler = null;
     bullet.MoveCompleted += handler = delegate {
         bullet.MoveCompleted -= handler;
         space.RemoveUIElement(bullet);
         if (caster.IsHostileTo(targets[index])) { caster.CastingToEffect(targets[index], args); }
         index++;
         if (index == targets.Count) {
             targets.Clear();
         } else {
             CreateSubMagic(caster, space, args);
         }
     };
     space.AddUIElement(bullet);
     bullet.Move(new Point((index == 0 ? args.Position.X : targets[index - 1].Position.X) - offsetX, (index == 0 ? args.Position.Y : targets[index - 1].Position.Y) - offsetStartY), new Point(targets[index].Position.X - offsetX, targets[index].Position.Y - offsetEndY), 0.9 / bullet.Scale, MoveModes.Normal);
 }
예제 #18
0
 void Start(object sender, EventArgs e)
 {
     loginManager.Completed -= Start;
     LayoutRoot.Children.Remove(loginManager);
     loginManager = null;
     Application.Current.Host.Content.Resized -= loginManager_Resized;
     InitializeMouseController();
     InitializeHUDController();
     InitializeConsole();
     EventHandler gameInitHandler = null;
     initializer.ResReady += gameInitHandler = (code0, e0) => {
         initializer.ResReady -= gameInitHandler;
         LayoutRoot.MouseMove += LayoutRoot_MouseMove;
         leader = new Hero(terrain) {
             ID = 19820920,
             AttachID = 19820920,
             Code = (int)code0,
             Profession = Professions.Warrior,
             Camp = Camps.Eval,
             LifeMax = 18750000,
             Life = 16780000,
             ATK = 2000,
             DEF = 550,
             MAG = 900,
             DEX = 50,
         };
         leaderInfo.UpdateLife(leader.Life, leader.LifeMax);
         leader.SightRange = 3000;
         leader.ActionTrigger += role_ShadowSync;
         leader.DoAttack += role_DoAttack;
         leader.DoCasting += role_DoCasting;
         leader.PositionChanged += role_PositionChanged;
         leader.LifeChanged += role_LifeChanged;
         leader.LifeChanged += delegate { leaderInfo.UpdateLife(leader.Life, leader.LifeMax); };
         space = new Space(terrain, leader) { Z = -10 };
         space.ChangeCompleted += space_ChangeCompleted;
         space.RoleAdded += space_RoleAdded;
         LayoutRoot.Children.Add(space);
         cursor.CursorType = CursorTypes.Normal;
         cursor.HeartStart();
         EventHandler spaceInitHandler = null;
         initializer.ResReady += spaceInitHandler = (code1, e1) => {
             initializer.ResReady -= spaceInitHandler;
             //初始化空间
             space.Code = (int)code1;
             comboBox0.SelectedIndex = 1; //走/骑
             //comboBox11.SelectedIndex = 5; //天气
             comboBox12.SelectedIndex = 6;
             //comboBox13.SelectedIndex = 3;
             comboBox15.SelectedIndex = 1; //追影
             //comboBox16.SelectedIndex = 3; //流光
             comboBox19.SelectedIndex = 1;
             //comboBox27.SelectedIndex = 2; //粒子
             comboBox37.SelectedIndex = 1; //地形
             comboBox38.SelectedIndex = 4; //右键技能等级
             comboBox39.SelectedIndex = 21; //右键技能
             button5.IsEnabled = false;
             slider15.Value = 10;
             GlobalMethod.SetTimeout(delegate {
                 AddRoles(null ,new AddRolesEventArgs() { Num = 20, Mode = 0 });
                 button5.IsEnabled = true;
             }, 2000);
         };
         initializer.spaceInit(spaceCode);
     };
     initializer.GameInit(leaderCode);
 }
예제 #19
0
 /// <summary>
 /// 触发/运行
 /// </summary>
 public abstract void Run(List<RoleBase> players, Space space);
 /// <summary>
 /// 开始
 /// </summary>
 public override void Run(List<RoleBase> players, Space space)
 {
     this.space = space;
     this.players = players;
     players[0].PositionChanged += new DependencyPropertyChangedEventHandler(player0_PositionChanged);
     checkTimer.Start();
     //离开的传送门(测试用)
     space.AddAnimation(new AnimationBase() {
         ID = 0,
         Code = 81,
         Position = new Point(-1320, 1970),
         Z = 1970,
         Tip = "离开副本",
         Loop = true,
     });
     space.RunWeather(WeatherTypes.Cloud, 50);
 }
예제 #21
0
 /// <summary>
 /// 触发/运行
 /// </summary>
 /// <param name="caster">施法者</param>
 /// <param name="space">所在空间</param>
 /// <param name="args">魔法参数</param>
 public abstract void Run(RoleBase caster, Space space, MagicArgs args);
예제 #22
0
 public override void Run(RoleBase caster, Space space, MagicArgs args)
 {
     caster.ClearAttacher();
     for (int i = 0; i < args.Number; i++) {
         Point p = new Point(caster.Coordinate.X + RandomSeed.Next(-5, 5), caster.Coordinate.Y + RandomSeed.Next(-5, 5));
         if (!space.Terrain.InEffectiveRange(p) || (args.SpaceLayer == SpaceLayers.Ground && space.Terrain.Matrix[(int)p.X, (int)p.Y] == 0)) {
             p = caster.Coordinate;
         }
         AnimationBase magic = new AnimationBase() { Code = args.ResCode, SpaceLayer = args.SpaceLayer, Position = space.Terrain.GetPositionFromCoordinate(p), 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);
         //解析配置
         XElement xMonster = Infos["Monster"].DescendantsAndSelf("Monsters").Elements().Single(X => X.Attribute("ID").Value == args.AdditionalEffect.ToString());
         Monster monster = new Monster(space.Terrain) {
             ID = (int)xMonster.Attribute("ID") + countID,
             AttachID = caster.AttachID,
             Code = (int)xMonster.Attribute("Code"),
             ArmorCode = (int)xMonster.Attribute("ArmorCode"),
             AttackRange = (int)xMonster.Attribute("AttackRange"),
             FullName = string.Format("{0}的召唤兽", caster.FullName),
             Profession = Professions.Monster,
             Direction = caster.Direction,
             State = States.Walking,
             Camp = caster.Camp,
             LifeMax = Convert.ToDouble(args.Tag),
             Life = Convert.ToDouble(args.Tag),
             SpaceLayer = caster.SpaceLayer,
             Coordinate = p,
             TacticAI = TacticAIs.GuardMaster,
             ActionAI = ActionAIs.Simple,
             FullNameColor = Colors.Orange,
             ATK = ObjectBase.RandomSeed.Next(1300, 1600),
             DEF = ObjectBase.RandomSeed.Next(600, 900),
             MAG = ObjectBase.RandomSeed.Next(400, 500),
             DEX = ObjectBase.RandomSeed.Next(0, 30),
         };
         if (xMonster.Attribute("LearnedMagic").Value != string.Empty) {
             string[] str = xMonster.Attribute("LearnedMagic").Value.Split(',');
             for (int j = 0; j < str.Count(); j++) {
                 string[] value = str[j].Split('_');
                 monster.LearnedMagic.Add(Convert.ToInt32(value[0]), Convert.ToInt32(value[1]));
             }
         }
         space.AddRole(monster, new RoleAddedEventArgs() {
             RegisterDisposedEvent = (bool)xMonster.Attribute("RegisterDisposedEvent"),
             RegisterIntervalTriggerEvent = (bool)xMonster.Attribute("RegisterIntervalTriggerEvent"),
             RegisterActionTriggerEvent = (bool)xMonster.Attribute("RegisterActionTriggerEvent"),
             RegisterDoAttackEvent = (bool)xMonster.Attribute("RegisterDoAttackEvent"),
             RegisterDoCastingEvent = (bool)xMonster.Attribute("RegisterDoCastingEvent"),
             RegisterPositionChangedEvent = (bool)xMonster.Attribute("RegisterPositionChangedEvent"),
             RegisterLifeChangedEvent = (bool)xMonster.Attribute("RegisterLifeChangedEvent"),
         });
         monster.Master = caster;
         caster.AttachRoles.Add(monster);
         countID++;
         if (countID == 10000) { countID = 0; }
     }
 }
예제 #23
0
 /// <summary>
 /// 在空间中战斗
 /// </summary>
 /// <param name="space">所处空间</param>
 public void DoAttackIn(Space space)
 {
     if (Target != null) {
         switch (weapon.AttackType) {
             case AttackTypes.Close:
                 AttackToHurt(Target);
                 break;
             case AttackTypes.LongRange:
                 Bullet bullet = new Bullet(weapon.BulletData) {
                     SpaceLayer = this.SpaceLayer,
                     Z = Target.Z,
                 };
                 double offsetX = bullet.Source.PixelWidth * bullet.Scale;
                 double offsetStartY = (this.State == States.Riding ? (this.Profession == Professions.Taoist ? 130 : 110) : 60) * bullet.Scale;
                 double offsetEndY = (Target.State == States.Riding ? 100 : 70) * bullet.Scale;
                 EventHandler handler = null;
                 bullet.MoveCompleted += handler = delegate {
                     bullet.MoveCompleted -= handler;
                     if (Target != null) {
                         double range = 10 * bullet.Scale;
                         //达到目标时如果在10*10范围内则算命中产生伤害
                         if (Target.Position.X - offsetX - range < bullet.Position.X && Target.Position.X - offsetX + range > bullet.Position.X && Target.Position.Y - offsetEndY - range < bullet.Position.Y && Target.Position.Y - offsetEndY + range > bullet.Position.Y) {
                             AttackToHurt(Target);
                         } else {
                             Target.ChangeLife(0, ValueEffects.Failure);
                         }
                     }
                     space.RemoveUIElement(bullet);
                 };
                 space.AddUIElement(bullet);
                 bullet.Move(new Point(this.Position.X - offsetX, this.Position.Y - offsetStartY), new Point(Target.Position.X - offsetX, Target.Position.Y - offsetEndY), weapon.BulletData.Speed / bullet.Scale, MoveModes.Normal);
                 break;
         }
     }
 }