示例#1
0
 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;
     }
 }
示例#2
0
        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;
            }
        }