Ejemplo n.º 1
0
        private static IEnumerator<bool> GradiusLaserOption(PlayerOption option, OptionInitializationInformation info)
        {
            var sbc = 0;
            var sb = new Point[30];

            var sp = Point.FromDisplayObject(option.Parent);
            var threshold = info.UserDoubleValue1;
            var pp = sp;
            for (int i = 0; i < sb.Length; i++) sb[i] = sp;

            while (true)
            {
                option.PreventParentOperation();
                var np = Point.FromDisplayObject(option.Parent);
                if (pp.DistanceTo(np) >= threshold)
                {
                    sb[(sbc++) % sb.Length] = np;
                    option.ApplyPosition(sb[(sbc + sb.Length + 1) % sb.Length]);
                }
                pp = np;
                yield return true;
            }
        }
Ejemplo n.º 2
0
 private static IEnumerator<bool> FollwingAttackOption(PlayerOption option, OptionInitializationInformation info)
 {
     bool tg = false;
     EnemyUser target = null;
     var tl = option.ParentManager.OfType<EnemyUser>()
         .Where(p =>
         {
             var x = p.X - option.X;
             var y = p.Y - option.Y;
             return Math.Sqrt(x * x + y * y) <= 200;
         });
     while (true)
     {
         target = tl.FirstOrDefault();
         if (target == null && tg)
         {
             tg = false;
             var sx = option.X;
             var sy = option.Y;
             for (int i = 0; i < 30; i++)
             {
                 option.PreventParentOperation();
                 option.X = Easing.OutQuad(i, 30, sx, option.Parent.X - sx);
                 option.Y = Easing.OutQuad(i, 30, sy, option.Parent.Y - sy);
                 yield return true;
             }
         }
         else if (!tg && target != null)
         {
             tg = true;
             while (target != null)
             {
                 var sx = option.X;
                 var sy = option.Y;
                 //同じ敵から同時に帰ってくると見栄えしないのでランダム
                 var rw = rnd.Next(10);
                 for (int i = 0; i < rw; i++)
                 {
                     option.PreventParentOperation();
                     yield return true;
                 }
                 for (int i = 0; i < 30; i++)
                 {
                     option.PreventParentOperation();
                     option.X = Easing.OutQuad(i, 30, sx, target.X - sx);
                     option.Y = Easing.OutQuad(i, 30, sy, target.Y - sy);
                     yield return true;
                 }
                 while (!target.IsDead)
                 {
                     option.PreventParentOperation();
                     option.X = target.X;
                     option.Y = target.Y;
                     target.Damage(100);
                     yield return true;
                 }
                 tl = option.ParentManager.OfType<EnemyUser>()
                 .Where(p =>
                 {
                     var x = p.X - option.X;
                     var y = p.Y - option.Y;
                     return Math.Sqrt(x * x + y * y) <= 200;
                 });
                 target = tl.FirstOrDefault();
             }
         }
         else
         {
             yield return true;
         }
     }
 }