static IEnumerable<Renderable> DrawZap(WorldRenderer wr, float2 from, float2 to, Sequence s, out float2 p) { var dist = to - from; var q = new float2(-dist.Y, dist.X); var c = -float2.Dot(from, q); var rs = new List<Renderable>(); var z = from; while ((to - z).X > 5 || (to - z).X < -5 || (to - z).Y > 5 || (to - z).Y < -5) { var step = steps.Where(t => (to - (z + new float2(t[0],t[1]))).LengthSquared < (to - z).LengthSquared ) .OrderBy(t => Math.Abs(float2.Dot(z + new float2(t[0], t[1]), q) + c)).First(); rs.Add(new Renderable(s.GetSprite(step[4]), z + new float2(step[2], step[3]), wr.Palette("effect"), (int)from.Y)); z += new float2(step[0], step[1]); if( rs.Count >= 1000 ) break; } p = z; return rs; }
static IEnumerable<IRenderable> DrawZap(WorldRenderer wr, float2 from, float2 to, Sequence s, out float2 p, string palette) { var dist = to - from; var q = new float2(-dist.Y, dist.X); var c = -float2.Dot(from, q); var rs = new List<IRenderable>(); var z = from; var pal = wr.Palette(palette); while ((to - z).X > 5 || (to - z).X < -5 || (to - z).Y > 5 || (to - z).Y < -5) { var step = steps.Where(t => (to - (z + new float2(t[0], t[1]))).LengthSquared < (to - z).LengthSquared) .OrderBy(t => Math.Abs(float2.Dot(z + new float2(t[0], t[1]), q) + c)).First(); var pos = wr.Position((z + new float2(step[2], step[3])).ToInt2()); rs.Add(new SpriteRenderable(s.GetSprite(step[4]), pos, WVec.Zero, 0, pal, 1f, true)); z += new float2(step[0], step[1]); if (rs.Count >= 1000) break; } p = z; return rs; }
static IEnumerable<Renderable> DrawZap( int2 from, int2 to, Sequence tesla ) { int2 d = to - from; if( d.X < 8 ) { var prev = new int2( 0, 0 ); var y = d.Y; while( y >= prev.Y + 8 ) { yield return new Renderable( tesla.GetSprite( 2 ), (float2)( from + prev - new int2( 0, 8 ) ), "effect"); prev.Y += 8; } } else { var prev = new int2( 0, 0 ); for( int i = 1 ; i < d.X ; i += 8 ) { var y = i * d.Y / d.X; if( y <= prev.Y - 8 ) { yield return new Renderable(tesla.GetSprite(3), (float2)(from + prev - new int2(8, 16)), "effect"); prev.Y -= 8; while( y <= prev.Y - 8 ) { yield return new Renderable(tesla.GetSprite(2), (float2)(from + prev - new int2(0, 16)), "effect"); prev.Y -= 8; } } else if( y >= prev.Y + 8 ) { yield return new Renderable(tesla.GetSprite(0), (float2)(from + prev - new int2(8, 8)), "effect"); prev.Y += 8; while( y >= prev.Y + 8 ) { yield return new Renderable(tesla.GetSprite(2), (float2)(from + prev - new int2(0, 8)), "effect"); prev.Y += 8; } } else yield return new Renderable(tesla.GetSprite(1), (float2)(from + prev - new int2(8, 8)), "effect"); prev.X += 8; } } }