Ejemplo n.º 1
0
        public override bool PreDraw(int i, int j, SpriteBatch spriteBatch)
        {
            if (Main.tile[i, j].type == base.Type)
            {
                string texstr = "SGAmod/Items/Placeable/Relics/Tiles/RelicBase";                //"SGAmod/Tiles/BiomassBarTile"


                Texture2D tex = ModContent.GetTexture(texstr);

                Vector2 zerooroffset = Main.drawToScreen ? Vector2.Zero : new Vector2((float)Main.offScreenRange);
                Vector2 location     = (new Vector2(i, j) * 16) + zerooroffset + new Vector2(0, 2);

                if (Main.tile[i, j].frameX == 0 && Main.tile[i, j].frameY == 0)
                {
                    Main.spriteBatch.End();
                    Main.spriteBatch.Begin(SpriteSortMode.Texture, BlendState.NonPremultiplied, SamplerState.AnisotropicClamp, DepthStencilState.Default, RasterizerState.CullNone, null, Matrix.CreateScale(1, 1, 1));

                    //SGAmod.FadeInEffect.Parameters["fadeColor"].SetValue(Color.Goldenrod.ToVector3());
                    //SGAmod.FadeInEffect.CurrentTechnique.Passes["ColorToAlphaPass"].Apply();

                    //Action<SpriteBatch, Vector2> drawCode = delegate (SpriteBatch spriteBatch2, Vector2 location2)
                    //{
                    Texture2D star = ModContent.GetTexture("SGAmod/Extra_57b");

                    Terraria.Utilities.UnifiedRandom rando = new Terraria.Utilities.UnifiedRandom(i + j);

                    Vector2 starterloc = location + new Vector2(24, 32);

                    Vector2 sizeStar = star.Size() / 2f;

                    List <(Vector2, float, float)> entries = new List <(Vector2, float, float)>();

                    for (float ix = 0; ix < 1f; ix += 1 / 30f)
                    {
                        float   shiftOut    = -1f + ix * 2f;
                        float   timePercent = (Main.GlobalTime + (ix)) % 1f;
                        Vector2 newLoc      = new Vector2(rando.NextFloat(-8f, 8f) + shiftOut * 4f, -rando.NextFloat(6f, 28f)) * timePercent;
                        Vector2 newLoc2     = new Vector2(rando.NextFloat(-12f, 12f) + shiftOut * 8f, 4);
                        float   rotation    = Main.GlobalTime * (rando.NextFloat(-1f, 1f) * (rando.NextBool() ? 1f : -1f) * 0.025f);

                        entries.Add((newLoc + newLoc2, timePercent, rotation));
                    }

                    foreach ((Vector2, float, float)tuple in entries.OrderBy(testby => testby.Item1.Y))
                    {
                        spriteBatch.Draw(star, starterloc + tuple.Item1 - Main.screenPosition, null, Color.Goldenrod * (1f - tuple.Item2), tuple.Item3, sizeStar, new Vector2(1f, 1f) * 0.25f, SpriteEffects.None, 0f);
                    }

                    //Main.spriteBatch.End();
                    //Main.spriteBatch.Begin(SpriteSortMode.Texture, BlendState.NonPremultiplied, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone, null, Matrix.CreateScale(1, 1, 1));

                    Texture2D tex2 = ModContent.GetTexture("SGAmod/Extra_60b");
                    spriteBatch.Draw(tex2, starterloc - Main.screenPosition, null, Color.Goldenrod, 0f, tex2.Size() / 2f, new Vector2(0.80f, 1f), SpriteEffects.None, 0f);
                    //};

                    //CustomSpecialDrawnTiles cdt = new CustomSpecialDrawnTiles(location);
                    //cdt.CustomDraw = drawCode;
                    //SGAmod.BeforeTilesAdditive.Add(cdt);

                    Main.spriteBatch.End();
                    Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Matrix.CreateScale(1, 1, 1));
                }

                spriteBatch.Draw(tex, location - Main.screenPosition, new Rectangle(Main.tile[i, j].frameX, Main.tile[i, j].frameY + 18, 16, 16), Lighting.GetColor(i, j), 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
            }
            return(true);
        }
Ejemplo n.º 2
0
        public void PostEffectsDraw(SpriteBatch spriteBatch, float drawScale = 2f)
        {
            int framesTotal = 20;
            int frame       = 0;

            Texture2D texHead = Main.playerTextures[0, 0];
            Texture2D texBody = Main.playerTextures[0, 3];
            Texture2D texlegs = Main.playerTextures[0, 10];

            Vector2 drawPos = ((npc.Center - Main.screenPosition));

            Main.spriteBatch.End();
            Main.spriteBatch.Begin(SpriteSortMode.Texture, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.GameViewMatrix.TransformationMatrix);

            Texture2D[] texes = new Texture2D[] { texlegs, texBody, texHead };

            Terraria.Utilities.UnifiedRandom rand = new Terraria.Utilities.UnifiedRandom(npc.whoAmI);

            float trans  = MathHelper.Clamp(npc.localAI[0] / 64f, 0f, 1f);
            float smooth = MathHelper.SmoothStep(128f, 0f, trans);

            for (int i = 0; i < 3; i += 1)
            {
                Vector2   loc   = Vector2.UnitX.RotatedBy((rand.NextFloat(0.30f, 0.65f) * Main.GlobalTime * (rand.NextBool() ? 1f : -1f)) + rand.NextFloat(MathHelper.TwoPi)) * (rand.NextFloat(1f, 2f)) * (smooth);
                Texture2D tex   = texes[i];
                Rectangle rect  = new Rectangle(0, 0, tex.Width, tex.Height / 20);
                Rectangle rect2 = new Rectangle(0, frame * rect.Height, tex.Width, rect.Height);

                spriteBatch.Draw(tex, (drawPos + loc) / 2, rect2, Color.Black * trans, 0, rect.Size() / 2f, npc.scale / 2, SpriteEffects.FlipHorizontally, 0f);
            }

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