示例#1
0
        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;
                }
            }
        }
示例#2
0
        static IEnumerable<IRenderable> DrawZapWandering(WorldRenderer wr, float2 from, float2 to, Sequence s, string pal)
        {
            var z = float2.Zero;	/* hack */
            var dist = to - from;
            var norm = (1f / dist.Length) * new float2(-dist.Y, dist.X);

            var renderables = new List<IRenderable>();
            if (Game.CosmeticRandom.Next(2) != 0)
            {
                var p1 = from + (1 / 3f) * dist + WRange.FromPDF(Game.CosmeticRandom, 2).Range * dist.Length / 4096 * norm;
                var p2 = from + (2 / 3f) * dist + WRange.FromPDF(Game.CosmeticRandom, 2).Range * dist.Length / 4096 * norm;

                renderables.AddRange(DrawZap(wr, from, p1, s, out p1, pal));
                renderables.AddRange(DrawZap(wr, p1, p2, s, out p2, pal));
                renderables.AddRange(DrawZap(wr, p2, to, s, out z, pal));
            }
            else
            {
                var p1 = from + (1 / 2f) * dist + WRange.FromPDF(Game.CosmeticRandom, 2).Range * dist.Length / 4096 * norm;

                renderables.AddRange(DrawZap(wr, from, p1, s, out p1, pal));
                renderables.AddRange(DrawZap(wr, p1, to, s, out z, pal));
            }

            return renderables;
        }
示例#3
0
        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;
        }
示例#4
0
文件: TeslaZap.cs 项目: Tsher/OpenRA
        static IEnumerable<Renderable> DrawZapWandering(WorldRenderer wr, PPos from, PPos to, Sequence s)
        {
            var z = float2.Zero;	/* hack */
            var dist = to - from;
            var norm = (1f / dist.Length) * new float2(-dist.Y, dist.X);

            var renderables = new List<Renderable>();
            if (Game.CosmeticRandom.Next(2) != 0)
            {
                var p1 = from.ToFloat2() + (1 / 3f) * dist.ToFloat2() + Game.CosmeticRandom.Gauss1D(1) * .2f * dist.Length * norm;
                var p2 = from.ToFloat2() + (2 / 3f) * dist.ToFloat2() + Game.CosmeticRandom.Gauss1D(1) * .2f * dist.Length * norm;

                renderables.AddRange(DrawZap(wr, from.ToFloat2(), p1, s, out p1));
                renderables.AddRange(DrawZap(wr, p1, p2, s, out p2));
                renderables.AddRange(DrawZap(wr, p2, to.ToFloat2(), s, out z));
            }
            else
            {
                var p1 = from.ToFloat2() + (1 / 2f) * dist.ToFloat2() + Game.CosmeticRandom.Gauss1D(1) * .2f * dist.Length * norm;

                renderables.AddRange(DrawZap(wr, from.ToFloat2(), p1, s, out p1));
                renderables.AddRange(DrawZap(wr, p1, to.ToFloat2(), s, out z));
            }

            return renderables;
        }
示例#5
0
文件: TeslaZap.cs 项目: Tsher/OpenRA
        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;
        }
示例#6
0
        int timeUntilRemove = 2; // # of frames

        #endregion Fields

        #region Constructors

        public TeslaZap(TeslaZapInfo info, ProjectileArgs args)
        {
            Args = args;
            tesla = SequenceProvider.GetSequence("litning", "bright");
        }