Пример #1
0
        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            Vector2 basepoint = new Vector2(projectile.ai[0], projectile.ai[1]);

            int width = 32; int height = 1000;

            Texture2D beam       = new Texture2D(Main.graphics.GraphicsDevice, width, height);
            var       dataColors = new Color[width * height];


            ///


            for (int y = 0; y < height; y++)
            {
                for (float x = 0f; x < 5f; x++)
                {
                    float offset2 = MathHelper.ToRadians((x / 5f) * 360f) + (y * 0.1f);
                    float adder   = (x * 9f) + (y * 3f);
                    float beamvar = width / 4f + (((float)Math.Sin((Main.GlobalTime * 23f) + adder)) * 2f);
                    int   output  = (width / 2) + (int)(Math.Sin((Main.GlobalTime * -32.25f) + (offset2)) * ((float)beamvar));
                    //output += 6;
                    //Main.NewText(output);


                    dataColors[output + y * width] = Color.Aquamarine;                    //;Main.hslToRgb(Main.rand.NextFloat(),0.75f,0.5f);
                }
            }


            ///


            beam.SetData(0, null, dataColors, 0, width * height);

            Main.spriteBatch.End();
            Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone, null, Main.GameViewMatrix.ZoomMatrix);

            Texture2D tex = ModContent.GetTexture("Terraria/Chain6");

            Vector2 drawOrigin = new Vector2(tex.Width, tex.Height / 4) / 2f;
            Vector2 drawPos    = ((projectile.Center - Main.screenPosition)) + new Vector2(0f, 4f);
            Color   color      = Color.Lerp((projectile.GetAlpha(lightColor) * 0.5f), Color.White, 0.5f);      //* ((float)(projectile.oldPos.Length - k) / (float)projectile.oldPos.Length);
            int     timing     = 0;

            timing *= ((tex.Height) / 5);
            float alpha = 1f;

            Idglib.DrawTether(beam, basepoint, projectile.Center, alpha, 1, 1, Color.White);
            //spriteBatch.Draw(tex, drawPos, new Rectangle(0, timing, tex.Width, (tex.Height - 1) / 5), color* alpha,0f, drawOrigin, projectile.scale, SpriteEffects.None, 0f);

            Main.spriteBatch.End();
            Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.GameViewMatrix.ZoomMatrix);

            return(false);
        }