當前位置: 首頁>>代碼示例>>C#>>正文


C# Animation.Dispose方法代碼示例

本文整理匯總了C#中Animation.Dispose方法的典型用法代碼示例。如果您正苦於以下問題:C# Animation.Dispose方法的具體用法?C# Animation.Dispose怎麽用?C# Animation.Dispose使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Animation的用法示例。


在下文中一共展示了Animation.Dispose方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Run

 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();
 }
開發者ID:Gallardot,項目名稱:GallardotStorage,代碼行數:33,代碼來源:CrossMagic.cs

示例2: Run

 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();
 }
開發者ID:Gallardot,項目名稱:GallardotStorage,代碼行數:50,代碼來源:LinearShuttleMagic.cs

示例3: Run

 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();
 }
開發者ID:Gallardot,項目名稱:GallardotStorage,代碼行數:45,代碼來源:SectorMagic.cs


注:本文中的Animation.Dispose方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。