public PlayerImageBullet(UserSprite pa, CoroutineFunction<UserSprite, PlayerBullet> op, int i, int s) { Parent = pa; SpecialOperation = op(Parent, this); Image = i; IsImageLoaded = true; Strength = s; CollisionRadius = 8; }
private static IEnumerator<bool> Linear(UserSprite par, PlayerBullet b, double angle, double speed, int time) { for (int i = 0; i < time; i++) { b.X += Math.Cos(angle) * speed; b.Y += Math.Sin(angle) * speed; yield return true; } b.IsDead = true; yield break; }
private static IEnumerator<bool> LinearLaserMarisaStyle(UserSprite par, PlayerLinearLaser laser) { laser.BrightR = (byte)((long)par.SourceUser.Id & 0xFF); laser.BrightG = (byte)((long)(par.SourceUser.Id >> 8) & 0xFF); laser.BrightB = (byte)((long)(par.SourceUser.Id >> 16) & 0xFF); while (true) { if (laser.Length < 800) laser.Length += 20; yield return true; } }
private static IEnumerator<bool> LazyHoming(UserSprite par, Bullet b, double startAngle, double startSpeed, int delay, UserSprite target, double homingSpeed) { for (int i = 0; i < delay; i++) { b.X += Math.Cos(startAngle) * startSpeed; b.Y += Math.Sin(startAngle) * startSpeed; yield return true; } var ha = Math.Atan2(target.Y - b.Y, target.X - b.X); while (true) { b.X += Math.Cos(ha) * homingSpeed; b.Y += Math.Sin(ha) * homingSpeed; yield return true; } }
public static CoroutineFunction<CoroutineSprite> MissStar(double angle, UserSprite p) { return (sp) => MissStarOperation(sp, angle, p); }
private static IEnumerator<bool> MissStarOperation(CoroutineSprite sp, double angle, UserSprite p) { for (int i = 0; i < 60; i++) { sp.X += Math.Cos(angle) * 4; sp.Y += Math.Sin(angle) * 4; sp.ScaleX -= 0.01; sp.ScaleY -= 0.01; sp.Alpha -= 0.01; yield return true; } }
private static IEnumerator<bool> HomingFunction(UserSprite us, PlayerBullet b) { var speed = 12.0; var curve = 0.03; var tl = us.ParentManager.OfType<EnemyUser>() .OrderBy(p => { var x = p.X - b.X; var y = p.Y - b.Y; return Math.Sqrt(x * x + y * y); }).FirstOrDefault(); var hm = tl != null; while (true) { if (hm && !tl.IsDead) { var ta = Math.Atan2(tl.Y - b.Y, tl.X - b.X) - b.Angle; if (ta <= 0) { b.Angle -= curve; } else { b.Angle += curve; } } b.X += Math.Cos(b.Angle) * speed; b.Y += Math.Sin(b.Angle) * speed; yield return true; } }
private static IEnumerator<bool> Worm(UserSprite parent, LinearLaser laser, double length, double speed) { laser.BrightR = (byte)((long)parent.SourceUser.Id & 0xFF); laser.BrightG = (byte)((long)(parent.SourceUser.Id >> 8) & 0xFF); laser.BrightB = (byte)((long)(parent.SourceUser.Id >> 16) & 0xFF); while (true) { while (laser.Length < length) { laser.Length += speed; yield return true; } while (laser.Length > 0.1) { laser.X += Math.Cos(laser.Angle) * speed; laser.Y += Math.Sin(laser.Angle) * speed; laser.Length -= speed; yield return true; } } }
public static IEnumerator<bool> Normal(UserSprite parent, CurveLaser laser) { laser.BrightR = (byte)((long)parent.SourceUser.Id & 0xFF); laser.BrightG = (byte)((long)(parent.SourceUser.Id >> 8) & 0xFF); laser.BrightB = (byte)((long)(parent.SourceUser.Id >> 16) & 0xFF); var curve = laser.Curve; while (laser.DrawLength < laser.LaserImage.Length) { laser.DrawLength++; yield return true; } while (true) { laser.Index++; if (laser.Curve.Count - laser.Index <= laser.LaserImage.Length) { curve.Add(new Point { X = curve[curve.Count - 1].X * 2 - curve[curve.Count - 2].X, Y = curve[curve.Count - 1].Y * 2 - curve[curve.Count - 2].Y }); } yield return true; } }
public static CoroutineFunction<UserSprite, Bullet> LazyHoming(double startAngle, double startSpeed, int delay, UserSprite target, double homingSpeed) { return (par, b) => LazyHoming(par, b, startAngle, startSpeed, delay, target, homingSpeed); }
public static IEnumerator<bool> Homing(UserSprite parent, CurveLaser laser, UserSprite target, int homingFrame, double homingSpeed, double homingCurveMax) { laser.BrightR = (byte)((long)parent.SourceUser.Id & 0xFF); laser.BrightG = (byte)((long)(parent.SourceUser.Id >> 8) & 0xFF); laser.BrightB = (byte)((long)(parent.SourceUser.Id >> 16) & 0xFF); var curve = laser.Curve; while (laser.DrawLength < laser.LaserImage.Length) { laser.DrawLength++; yield return true; } while (true) { laser.Index++; if (laser.Curve.Count - laser.Index <= laser.LaserImage.Length) { var px = curve[curve.Count - 2].X; var py = curve[curve.Count - 2].Y; var lx = curve[curve.Count - 1].X; var ly = curve[curve.Count - 1].Y; var ma = Math.Atan2(ly - py, lx - px); var ta = Math.Atan2(ly - target.Y, lx - target.X); if (homingFrame > 0) { var su = ((ta - ma) + Math.PI * 2) % (Math.PI * 2); var ca = Math.Min(Math.Abs(ta - ma), homingCurveMax); if (su <= Math.PI) { //右サイド curve.Add(new Point { X = lx + Math.Cos(ma - ca) * homingSpeed, Y = ly + Math.Sin(ma - ca) * homingSpeed }); } else { //左サイド curve.Add(new Point { X = lx + Math.Cos(ma + ca) * homingSpeed, Y = ly + Math.Sin(ma + ca) * homingSpeed }); } homingFrame--; } else { curve.Add(new Point { X = lx + Math.Cos(ma) * homingSpeed, Y = ly + Math.Sin(ma) * homingSpeed }); } } yield return true; } }
public static CoroutineFunction<UserSprite, CurveLaser> Homing(UserSprite target, int homingFrame, double homingSpeed, double homingCurveMax) { return (sp, laser) => Homing(sp, laser, target, homingFrame, homingSpeed, homingCurveMax); }
public PlayerLinearLaser(UserSprite par, CoroutineFunction<UserSprite, PlayerLinearLaser> op, double thickness, int img) { Parent = par; Image = img; CollisionRadius = thickness; Thickness = thickness; SpecialOperation = op(par, this); }