Beispiel #1
0
        public void DrawGlowmask(PlayerDrawInfo info)
        {
            Player player = info.drawPlayer;

            if (player.heldProj > -1 && Main.projectile[player.heldProj].type == mod.ProjectileType("VitricBowProjectile"))
            {
                Projectile held = Main.projectile[player.heldProj];
                Vector2    off  = Vector2.Normalize(held.velocity) * 16;

                var data = new DrawData(GetTexture(Texture), player.Center + off - Main.screenPosition, null, Lighting.GetColor((int)player.Center.X / 16, (int)player.Center.Y / 16), off.ToRotation(), item.Size / 2, 1, 0, 0);
                Main.playerDrawData.Add(data);

                if (held.modProjectile != null && held.modProjectile is VitricBowProjectile)
                {
                    float fraction = held.ai[0] / VitricBowProjectile.MaxCharge;
                    Color colorz   = Color.Lerp(Lighting.GetColor((int)player.Center.X / 16, (int)player.Center.Y / 16), Color.Aquamarine, fraction) * Math.Min(held.timeLeft / 20f, 1f);

                    var data2 = new DrawData(GetTexture(Texture), player.Center + off - Main.screenPosition, null, colorz, off.ToRotation(), item.Size / 2, 1, 0, 0);
                    Main.playerDrawData.Add(data2);
                }
            }
        }
        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            Vector2 mountedCenter = Main.player[projectile.owner].MountedCenter;
            Color   color25       = Lighting.GetColor((int)(projectile.position.X + (projectile.width * 0.5)) / 16, (int)((projectile.position.Y + (projectile.height * 0.5)) / 16.0));

            if (projectile.hide && !ProjectileID.Sets.DontAttachHideToAlpha[projectile.type])
            {
                color25 = Lighting.GetColor((int)mountedCenter.X / 16, (int)(mountedCenter.Y / 16f));
            }
            Vector2 projPos = projectile.position;

            projPos = (new Vector2(projectile.width, projectile.height) / 2f) + (Vector2.UnitY * projectile.gfxOffY) - Main.screenPosition; //f**k it
            Texture2D texture2D22 = Main.projectileTexture[projectile.type];

            Microsoft.Xna.Framework.Color alpha3 = projectile.GetAlpha(color25);
            if (projectile.velocity == Vector2.Zero)
            {
                return(false);
            }
            float   num230  = projectile.velocity.Length() + 16f;
            bool    flag24  = num230 < 100f;
            Vector2 value28 = Vector2.Normalize(projectile.velocity);

            Microsoft.Xna.Framework.Rectangle rectangle8 = new Microsoft.Xna.Framework.Rectangle(0, 0, texture2D22.Width, 36); //2 and 40
            Vector2 value29    = new Vector2(0f, Main.player[projectile.owner].gfxOffY);
            float   rotation24 = projectile.rotation + 3.14159274f;

            Main.spriteBatch.Draw(texture2D22, projectile.Center.Floor() - Main.screenPosition + value29, new Microsoft.Xna.Framework.Rectangle?(rectangle8), alpha3, rotation24, (rectangle8.Size() / 2f) - (Vector2.UnitY * 4f), projectile.scale, SpriteEffects.None, 0f);
            num230 -= 40f * projectile.scale;
            Vector2 vector31 = projectile.Center.Floor();

            vector31  += value28 * projectile.scale * 24f;
            rectangle8 = new Microsoft.Xna.Framework.Rectangle(0, 62, texture2D22.Width, 18); //68 and 18
            if (num230 > 0f)
            {
                float num231 = 0f;
                while (num231 + 1f < num230)
                {
                    if (num230 - num231 < rectangle8.Height)
                    {
                        rectangle8.Height = (int)(num230 - num231);
                    }
                    Main.spriteBatch.Draw(texture2D22, vector31 - Main.screenPosition + value29, new Microsoft.Xna.Framework.Rectangle?(rectangle8), alpha3, rotation24, new Vector2(rectangle8.Width / 2, 0f), projectile.scale, SpriteEffects.None, 0f);
                    num231   += rectangle8.Height * projectile.scale;
                    vector31 += value28 * rectangle8.Height * projectile.scale;
                }
            }
            Vector2 value30 = vector31;

            vector31   = projectile.Center.Floor();
            vector31  += value28 * projectile.scale * 24f;
            rectangle8 = new Rectangle(0, 40, texture2D22.Width, 20); //46 and 18
            int num232 = 18;

            if (flag24)
            {
                num232 = 9;
            }
            float num233 = num230;

            if (num230 > 0f)
            {
                float num234 = 0f;
                float num235 = num233 / num232;
                num234   += num235 * 0.25f;
                vector31 += value28 * num235 * 0.25f;
                for (int num236 = 0; num236 < num232; num236++)
                {
                    float num237 = num235;
                    if (num236 == 0)
                    {
                        num237 *= 0.75f;
                    }
                    Main.spriteBatch.Draw(texture2D22, vector31 - Main.screenPosition + value29, new Microsoft.Xna.Framework.Rectangle?(rectangle8), alpha3, rotation24, new Vector2(rectangle8.Width / 2, 0f), projectile.scale, SpriteEffects.None, 0f);
                    num234   += num237;
                    vector31 += value28 * num237;
                }
            }
            rectangle8 = new Microsoft.Xna.Framework.Rectangle(0, 84, texture2D22.Width, 56); //90 and 48
            Main.spriteBatch.Draw(texture2D22, value30 - Main.screenPosition + value29, new Microsoft.Xna.Framework.Rectangle?(rectangle8), alpha3, rotation24, texture2D22.Frame(1, 1, 0, 0).Top(), projectile.scale, SpriteEffects.None, 0f);
            return(false);
        }
Beispiel #3
0
 public override void PostDraw(SpriteBatch spriteBatch, Color drawColor)
 {
     if (npc.ai[3] < 0f && npc.ai[3] >= -60f)
     {
         float angle = npc.ai[3] / 30f * (float)Math.PI;
         spriteBatch.Draw(mod.GetTexture("NPCs/Seal"), npc.Center - Main.screenPosition + new Vector2(0f, 10f), null, Lighting.GetColor((int)(npc.Center.X / 16f), (int)(npc.Center.Y / 16f)) * 0.9f, angle, new Vector2(16f, 16f), 1f, SpriteEffects.None, 0f);
     }
 }
Beispiel #4
0
        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            SpriteEffects effects1 = SpriteEffects.None;

            if (projectile.direction == 1)
            {
                effects1 = SpriteEffects.FlipHorizontally;
            }
            Microsoft.Xna.Framework.Color color3 = Lighting.GetColor((int)((double)projectile.position.X + (double)projectile.width * 0.5) / 16, (int)(((double)projectile.position.Y + (double)projectile.height * 0.5) / 16.0));
            {
                Texture2D texture = Main.projectileTexture[projectile.type];
                Texture2D glow    = Main.projectileTexture[projectile.type];
                int       height  = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type];
                Microsoft.Xna.Framework.Rectangle r = new Microsoft.Xna.Framework.Rectangle(0, height * projectile.frame, texture.Width, height);
                Vector2 origin = r.Size() / 2f;
                int     num2   = 5;
                int     num3   = 1;
                int     num4   = 1;
                float   num5   = 1f;
                float   num6   = 0.0f;
                num3 = 1;
                num5 = 3f;
                int index1 = num4;
                while (num3 > 0 && index1 < num2 || num3 < 0 && index1 > num2)
                {
                    Microsoft.Xna.Framework.Color newColor = color3;
                    newColor = Microsoft.Xna.Framework.Color.Lerp(newColor, Microsoft.Xna.Framework.Color.White, 2.5f);
                    Microsoft.Xna.Framework.Color color1 = projectile.GetAlpha(newColor);
                    float num7 = (float)(num2 - index1);
                    if (num3 < 0)
                    {
                        num7 = (float)(num4 - index1);
                    }
                    Microsoft.Xna.Framework.Color color2 = color1 * (num7 / ((float)ProjectileID.Sets.TrailCacheLength[projectile.type] * 1.5f));
                    Vector2       oldPo    = projectile.oldPos[index1];
                    float         rotation = projectile.rotation;
                    SpriteEffects effects2 = effects1;
                    if (ProjectileID.Sets.TrailingMode[projectile.type] == 2)
                    {
                        rotation = projectile.oldRot[index1];
                        effects2 = projectile.oldSpriteDirection[index1] == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
                    }
                    Main.spriteBatch.Draw(glow, oldPo + projectile.Size / 2f - Main.screenPosition + new Vector2(0.0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(r), color2, rotation + projectile.rotation * num6 * (float)(index1 - 1) * (float)-effects1.HasFlag((Enum)SpriteEffects.FlipHorizontally).ToDirectionInt(), origin, MathHelper.Lerp(projectile.scale, num5, (float)index1 / 15f), effects2, 0.0f);
label_709:
                    index1 += num3;
                }

                Microsoft.Xna.Framework.Color color4 = projectile.GetAlpha(color3);
                Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0.0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(r), new Color(255 - projectile.alpha, 255 - projectile.alpha, 255 - projectile.alpha, 175), projectile.rotation, origin, projectile.scale, effects1, 0.0f);
            }
            for (int a = 0; a < 1; a++)
            {
                SpriteEffects spriteEffects = SpriteEffects.None;
                if (projectile.spriteDirection == 1)
                {
                    spriteEffects = SpriteEffects.FlipHorizontally;
                }
                Texture2D texture   = Main.projectileTexture[projectile.type];
                Vector2   vector2_3 = new Vector2((float)(Main.projectileTexture[projectile.type].Width / 2), (float)(Main.projectileTexture[projectile.type].Height / 1 / 2));
                int       height    = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type];
                Microsoft.Xna.Framework.Rectangle r = new Microsoft.Xna.Framework.Rectangle(0, height * projectile.frame, texture.Width, height);
                float addY      = 0f;
                float addHeight = 0f;
                int   num7      = 5;
                float num9      = (float)(Math.Cos((double)Main.GlobalTime % 2.40000009536743 / 2.40000009536743 * 6.28318548202515) / 2.0 + 0.5);
                float num99     = (float)(Math.Cos((double)Main.GlobalTime % 2.40000009536743 / 2.40000009536743 * 6.28318548202515) / 4.0 + 0.5);
                float num8      = 0f;
                Microsoft.Xna.Framework.Color secondColor = Microsoft.Xna.Framework.Color.White;

                float   num10 = 0.0f;
                Vector2 bb    = projectile.Center - Main.screenPosition - new Vector2((float)texture.Width, (float)(texture.Height / 1)) * projectile.scale / 2f + vector2_3 * projectile.scale + new Vector2(0.0f, addY + addHeight + projectile.gfxOffY);
                Microsoft.Xna.Framework.Color color2 = new Microsoft.Xna.Framework.Color((int)sbyte.MaxValue - projectile.alpha, (int)sbyte.MaxValue - projectile.alpha, (int)sbyte.MaxValue - projectile.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.White);
                for (int index2 = 0; index2 < 4; ++index2)
                {
                    Microsoft.Xna.Framework.Color newColor2 = color2;
                    Microsoft.Xna.Framework.Color faa       = projectile.GetAlpha(newColor2) * (1f - num99);
                    Vector2 position2 = projectile.Center + ((float)((double)index2 / (double)4 * 6.28318548202515) + projectile.rotation + num10).ToRotationVector2() * (float)(8.0 * (double)num99 + 2.0) - Main.screenPosition - new Vector2((float)texture.Width, (float)(texture.Height / 1)) * projectile.scale / 2f + vector2_3 * projectile.scale + new Vector2(0.0f, addY + addHeight + projectile.gfxOffY);
                    Main.spriteBatch.Draw(Main.projectileTexture[projectile.type], position2, new Microsoft.Xna.Framework.Rectangle?(r), faa, projectile.rotation, vector2_3, projectile.scale, spriteEffects, 0.0f);
                }
            }
            return(false);
        }
Beispiel #5
0
        public override bool PreDraw(int i, int j, SpriteBatch spriteBatch)
        {
            if (Main.tile[i, j].frameX == 0 && Main.tile[i, j].frameY == 0)
            {
                Tile tile  = Main.tile[i, j];
                int  left  = i - (tile.frameX / 18);
                int  top   = j - (tile.frameY / 18);
                int  index = ModContent.GetInstance <WispSwitchEntity>().Find(left, top);

                if (index == -1)
                {
                    return(true);
                }
                WispSwitchEntity altarentity = (WispSwitchEntity)TileEntity.ByID[index];

                int     timer = altarentity.timer;
                Vector2 pos   = (new Vector2(i, j) + Helper.TileAdj) * 16 - Main.screenPosition;
                Color   color = Color.White * (0.2f + (timer / 300f * 0.8f));

                spriteBatch.Draw(ModContent.GetTexture("StarlightRiver/Tiles/Interactive/WispSwitchReal"), pos, Lighting.GetColor(i, j));
                spriteBatch.Draw(ModContent.GetTexture("StarlightRiver/Tiles/Interactive/WispSwitchGlow0"), pos - Vector2.One, Color.White * (float)Math.Sin(LegendWorld.rottime));
                spriteBatch.Draw(ModContent.GetTexture("StarlightRiver/Tiles/Interactive/WispSwitchGlow1"), pos, color);
                if (timer > 0)
                {
                    spriteBatch.Draw(ModContent.GetTexture("StarlightRiver/Tiles/Interactive/WispSwitchGlow2"), pos + Vector2.One * 16, new Rectangle(0, 0, 96, 96), Color.LightYellow * (timer / 300f), 0, new Vector2(48, 48), timer * 0.002f, 0, 0);
                }
            }

            return(true);
        }
Beispiel #6
0
        public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor)
        {
            Texture2D shadowChain = mod.GetTexture("NPCs/WallOfShadowChain");
            Texture2D shadowWall  = mod.GetTexture("NPCs/WallOfShadow_Wall");

            for (int i = 0; i < 255; i++)
            {
                if (Main.player[i].active && Main.player[i].tongued && !Main.player[i].dead)
                {
                    float   num      = npc.position.X + (npc.width / 2);
                    float   num2     = npc.position.Y + (npc.height / 2);
                    Vector2 vector   = new Vector2(Main.player[i].position.X + Main.player[i].width * 0.5f, Main.player[i].position.Y + Main.player[i].height * 0.5f);
                    float   num3     = num - vector.X;
                    float   num4     = num2 - vector.Y;
                    float   rotation = (float)Math.Atan2(num4, num3) - 1.57f;
                    bool    flag     = true;
                    while (flag)
                    {
                        float num5 = (float)Math.Sqrt(num3 * num3 + num4 * num4);
                        if (num5 < 40f)
                        {
                            flag = false;
                        }
                        else
                        {
                            num5      = shadowChain.Height / num5;
                            num3     *= num5;
                            num4     *= num5;
                            vector.X += num3;
                            vector.Y += num4;
                            num3      = num - vector.X;
                            num4      = num2 - vector.Y;
                            Color color = Lighting.GetColor((int)vector.X / 16, (int)(vector.Y / 16f));
                            spriteBatch.Draw(shadowChain, new Vector2(vector.X - Main.screenPosition.X, vector.Y - Main.screenPosition.Y), new Rectangle(0, 0, shadowChain.Width, shadowChain.Height), color, rotation, new Vector2(shadowChain.Width * 0.5f, shadowChain.Height * 0.5f), 1f, SpriteEffects.None, 0f);
                        }
                    }
                }
            }
            for (int j = 0; j < 200; j++)
            {
                if (Main.npc[j].active && Main.npc[j].type == mod.NPCType("ShadowHand"))
                {
                    float num6  = npc.position.X + (npc.width / 2);
                    float num7  = npc.position.Y;
                    float num8  = (Main.wofB - Main.wofT);
                    bool  flag2 = false;
                    if (Main.npc[j].frameCounter > 7.0)
                    {
                        flag2 = true;
                    }
                    num7 = Main.wofT + num8 * Main.npc[j].ai[0];
                    Vector2 vector2   = new Vector2(Main.npc[j].position.X + (Main.npc[j].width / 2), Main.npc[j].position.Y + (Main.npc[j].height / 2));
                    float   num9      = num6 - vector2.X;
                    float   num10     = num7 - vector2.Y;
                    float   rotation2 = (float)Math.Atan2(num10, num9) - 1.57f;
                    bool    flag3     = true;
                    while (flag3)
                    {
                        SpriteEffects effects1 = SpriteEffects.None;
                        if (flag2)
                        {
                            effects1 = SpriteEffects.FlipHorizontally;
                            flag2    = false;
                        }
                        else
                        {
                            flag2 = true;
                        }
                        int   height = 28;
                        float num11  = (float)Math.Sqrt(num9 * num9 + num10 * num10);
                        if (num11 < 40f)
                        {
                            height = (int)num11 - 40 + 28;
                            flag3  = false;
                        }
                        num11      = 28f / num11;
                        num9      *= num11;
                        num10     *= num11;
                        vector2.X += num9;
                        vector2.Y += num10;
                        num9       = num6 - vector2.X;
                        num10      = num7 - vector2.Y;
                        Color color2 = Lighting.GetColor((int)vector2.X / 16, (int)(vector2.Y / 16f));
                        spriteBatch.Draw(shadowChain, new Vector2(vector2.X - Main.screenPosition.X, vector2.Y - Main.screenPosition.Y), new Rectangle(0, 0, shadowChain.Width, height), color2, rotation2, new Vector2(shadowChain.Width * 0.5f, shadowChain.Height * 0.5f), 1f, effects1, 0f);
                    }
                }
            }
            int   num12 = 140;
            float num13 = Main.wofT;
            float num14 = Main.wofB;

            num14 = Main.screenPosition.Y + Main.screenHeight;
            float num15 = (int)((num13 - Main.screenPosition.Y) / num12) + 1;

            num15 *= num12;
            if (num15 > 0f)
            {
                num13 -= num15;
            }
            float         num16    = num13;
            float         num17    = npc.position.X;
            float         num18    = num14 - num13;
            bool          flag4    = true;
            SpriteEffects effects2 = SpriteEffects.None;

            if (npc.spriteDirection == 1)
            {
                effects2 = SpriteEffects.FlipHorizontally;
            }
            if (npc.direction > 0)
            {
                num17 -= 80f;
            }
            int num19 = 0;

            if (!Main.gamePaused)
            {
                Main.wofF++;
            }
            if (Main.wofF > 12)
            {
                num19 = 280;
                if (Main.wofF > 17)
                {
                    Main.wofF = 0;
                }
            }
            else if (Main.wofF > 6)
            {
                num19 = 140;
            }
            while (flag4)
            {
                num18 = num14 - num16;
                if (num18 > num12)
                {
                    num18 = num12;
                }
                bool flag5 = true;
                int  num20 = 0;
                while (flag5)
                {
                    int x = (int)(num17 + shadowWall.Width / 2) / 16;
                    int y = (int)(num16 + num20) / 16;
                    Main.spriteBatch.Draw(shadowWall, new Vector2(num17 - Main.screenPosition.X, num16 + num20 - Main.screenPosition.Y), new Rectangle(0, num19 + num20, shadowWall.Width, 16), Lighting.GetColor(x, y), 0f, default(Vector2), 1f, effects2, 0f);
                    num20 += 16;
                    if (num20 >= num18)
                    {
                        flag5 = false;
                    }
                }
                num16 += num12;
                if (num16 >= num14)
                {
                    flag4 = false;
                }
            }

            Texture2D drawTexture = Main.npcTexture[npc.type];
            Vector2   origin      = new Vector2((drawTexture.Width / 2) * 0.5F, (drawTexture.Height / Main.npcFrameCount[npc.type]) * 0.5F);

            Vector2 drawPos = new Vector2(
                npc.position.X - Main.screenPosition.X + (npc.width / 2) - (Main.npcTexture[npc.type].Width / 2) * npc.scale / 2f + origin.X * npc.scale,
                npc.position.Y - Main.screenPosition.Y + npc.height - Main.npcTexture[npc.type].Height * npc.scale / Main.npcFrameCount[npc.type] + 4f + origin.Y * npc.scale + npc.gfxOffY);

            SpriteEffects effects = npc.spriteDirection == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;

            spriteBatch.Draw(drawTexture, drawPos, npc.frame, drawColor, npc.rotation, origin, npc.scale, effects, 0);


            return(false);
        }
        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            Texture2D texture2D13 = Main.npcTexture[npc.type];
            //int num156 = Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type]; //ypos of lower right corner of sprite to draw
            //int y3 = num156 * npc.frame.Y; //ypos of upper left corner of sprite to draw
            Rectangle rectangle = npc.frame;//new Rectangle(0, y3, texture2D13.Width, num156);
            Vector2   origin2   = rectangle.Size() / 2f;

            Color color26 = lightColor;

            color26 = npc.GetAlpha(color26);

            SpriteEffects effects = npc.spriteDirection > 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;

            float scale = (Main.mouseTextColor / 200f - 0.35f) * 0.4f + 0.8f;

            Main.spriteBatch.Draw(texture2D13, npc.Center - Main.screenPosition + new Vector2(0f, npc.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), npc.GetAlpha(lightColor) * 0.5f, npc.rotation, origin2, npc.scale * scale, effects, 0f);
            Main.spriteBatch.Draw(texture2D13, npc.Center - Main.screenPosition + new Vector2(0f, npc.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), npc.GetAlpha(lightColor), npc.rotation, origin2, npc.scale, effects, 0f);

            for (int i = 0; i < Main.maxNPCs; i++)
            {
                if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType <NatureChampionHead>() && Main.npc[i].ai[1] == npc.whoAmI)
                {
                    if (npc.Distance(Main.LocalPlayer.Center) <= 1200)
                    {
                        string    neckTex      = "NPCs/Champions/NatureChampion_Neck";
                        Texture2D neckTex2D    = mod.GetTexture(neckTex);
                        Vector2   connector    = Main.npc[i].Center;
                        Vector2   neckOrigin   = npc.Center + new Vector2(54 * npc.spriteDirection, -10);
                        float     chainsPerUse = 0.05f;
                        for (float j = 0; j <= 1; j += chainsPerUse)
                        {
                            if (j == 0)
                            {
                                continue;
                            }
                            Vector2 distBetween = new Vector2(X(j, neckOrigin.X, (neckOrigin.X + connector.X) / 2, connector.X) -
                                                              X(j - chainsPerUse, neckOrigin.X, (neckOrigin.X + connector.X) / 2, connector.X),
                                                              Y(j, neckOrigin.Y, (neckOrigin.Y + 50), connector.Y) -
                                                              Y(j - chainsPerUse, neckOrigin.Y, (neckOrigin.Y + 50), connector.Y));
                            if (distBetween.Length() > 36 && chainsPerUse > 0.01f)
                            {
                                chainsPerUse -= 0.01f;
                                j            -= chainsPerUse;
                                continue;
                            }
                            float   projTrueRotation = distBetween.ToRotation() - (float)Math.PI / 2;
                            Vector2 lightPos         = new Vector2(X(j, neckOrigin.X, (neckOrigin.X + connector.X) / 2, connector.X), Y(j, neckOrigin.Y, (neckOrigin.Y + 50), connector.Y));
                            spriteBatch.Draw(neckTex2D, new Vector2(X(j, neckOrigin.X, (neckOrigin.X + connector.X) / 2, connector.X) - Main.screenPosition.X, Y(j, neckOrigin.Y, (neckOrigin.Y + 50), connector.Y) - Main.screenPosition.Y),
                                             new Rectangle(0, 0, neckTex2D.Width, neckTex2D.Height), npc.GetAlpha(Lighting.GetColor((int)lightPos.X / 16, (int)lightPos.Y / 16)), projTrueRotation,
                                             new Vector2(neckTex2D.Width * 0.5f, neckTex2D.Height * 0.5f), 1f, connector.X < neckOrigin.X ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0f);
                        }
                    }

                    /*Texture2D texture = mod.GetTexture("NPCs/Champions/NatureChampion_Neck");
                     * Vector2 position = Main.npc[i].Center;
                     * Vector2 mountedCenter = npc.Center + new Vector2(54 * npc.spriteDirection, -10);
                     * Rectangle? sourceRectangle = new Rectangle?();
                     * Vector2 origin = new Vector2(texture.Width * 0.5f, texture.Height * 0.5f);
                     * float num1 = texture.Height;
                     * Vector2 vector24 = mountedCenter - position;
                     * float rotation = (float)Math.Atan2(vector24.Y, vector24.X) - 1.57f;
                     * bool flag = true;
                     * if (float.IsNaN(position.X) && float.IsNaN(position.Y))
                     *  flag = false;
                     * if (float.IsNaN(vector24.X) && float.IsNaN(vector24.Y))
                     *  flag = false;
                     * while (flag)
                     *  if (vector24.Length() < num1 + 1.0)
                     *  {
                     *      flag = false;
                     *  }
                     *  else
                     *  {
                     *      Vector2 vector21 = vector24;
                     *      vector21.Normalize();
                     *      position += vector21 * num1;
                     *      vector24 = mountedCenter - position;
                     *      Color color2 = Lighting.GetColor((int)position.X / 16, (int)(position.Y / 16.0));
                     *      color2 = npc.GetAlpha(color2);
                     *      Main.spriteBatch.Draw(texture, position - Main.screenPosition, sourceRectangle, color2, rotation, origin, 1f,
                     *          position.X < mountedCenter.X ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0.0f);
                     *  }*/

                    DrawHead(spriteBatch, Lighting.GetColor((int)Main.npc[i].Center.X / 16, (int)Main.npc[i].Center.Y / 16), Main.npc[i]);
                }
            }
            return(false);
        }
Beispiel #8
0
        public override bool PreDrawExtras(SpriteBatch spriteBatch)
        {
            Lighting.AddLight(projectile.Center, 0.7f, 0.9f, 0.6f);
            Player owner = null;

            if (projectile.owner != -1)
            {
                owner = Main.player[projectile.owner];
            }
            else if (projectile.owner == 255)
            {
                owner = Main.LocalPlayer;
            }
            Player player = owner;

            if (projectile.bobber && Main.player[projectile.owner].inventory[Main.player[projectile.owner].selectedItem].holdStyle > 0)
            {
                float pPosX = player.MountedCenter.X;
                float pPosY = player.MountedCenter.Y;
                pPosY += Main.player[projectile.owner].gfxOffY;
                int   type    = Main.player[projectile.owner].inventory[Main.player[projectile.owner].selectedItem].type;
                float gravDir = Main.player[projectile.owner].gravDir;

                if (type == ModContent.ItemType <GooFishingPole>())
                {
                    pPosX += 50 * Main.player[projectile.owner].direction;
                    if (Main.player[projectile.owner].direction < 0)
                    {
                        pPosX -= 13f;
                    }
                    pPosY -= 30f * gravDir;
                }

                if (gravDir == -1f)
                {
                    pPosY -= 12f;
                }
                Vector2 value = new Vector2(pPosX, pPosY);
                value = Main.player[projectile.owner].RotatedRelativePoint(value + new Vector2(8f), true) - new Vector2(8f);
                float projPosX = projectile.position.X + projectile.width * 0.5f - value.X;
                float projPosY = projectile.position.Y + projectile.height * 0.5f - value.Y;
                Math.Sqrt(projPosX * projPosX + projPosY * projPosY);
                float rotation2 = (float)Math.Atan2(projPosY, projPosX) - 1.57f;
                bool  flag2     = true;
                if (projPosX == 0f && projPosY == 0f)
                {
                    flag2 = false;
                }
                else
                {
                    float projPosXY = (float)Math.Sqrt(projPosX * projPosX + projPosY * projPosY);
                    projPosXY = 12f / projPosXY;
                    projPosX *= projPosXY;
                    projPosY *= projPosXY;
                    value.X  -= projPosX;
                    value.Y  -= projPosY;
                    projPosX  = projectile.position.X + projectile.width * 0.5f - value.X;
                    projPosY  = projectile.position.Y + projectile.height * 0.5f - value.Y;
                }
                while (flag2)
                {
                    float num  = 12f;
                    float num2 = (float)Math.Sqrt(projPosX * projPosX + projPosY * projPosY);
                    float num3 = num2;
                    if (float.IsNaN(num2) || float.IsNaN(num3))
                    {
                        flag2 = false;
                    }
                    else
                    {
                        if (num2 < 20f)
                        {
                            num   = num2 - 8f;
                            flag2 = false;
                        }
                        num2      = 12f / num2;
                        projPosX *= num2;
                        projPosY *= num2;
                        value.X  += projPosX;
                        value.Y  += projPosY;
                        projPosX  = projectile.position.X + projectile.width * 0.5f - value.X;
                        projPosY  = projectile.position.Y + projectile.height * 0.1f - value.Y;
                        if (num3 > 12f)
                        {
                            float num4 = 0.3f;
                            float num5 = Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y);
                            if (num5 > 16f)
                            {
                                num5 = 16f;
                            }
                            num5  = 1f - num5 / 16f;
                            num4 *= num5;
                            num5  = num3 / 80f;
                            if (num5 > 1f)
                            {
                                num5 = 1f;
                            }
                            num4 *= num5;
                            if (num4 < 0f)
                            {
                                num4 = 0f;
                            }
                            num5  = 1f - projectile.localAI[0] / 100f;
                            num4 *= num5;
                            if (projPosY > 0f)
                            {
                                projPosY *= 1f + num4;
                                projPosX *= 1f - num4;
                            }
                            else
                            {
                                num5 = Math.Abs(projectile.velocity.X) / 3f;
                                if (num5 > 1f)
                                {
                                    num5 = 1f;
                                }
                                num5 -= 0.5f;
                                num4 *= num5;
                                if (num4 > 0f)
                                {
                                    num4 *= 2f;
                                }
                                projPosY *= 1f + num4;
                                projPosX *= 1f - num4;
                            }
                        }
                        rotation2 = (float)Math.Atan2(projPosY, projPosX) - 1.57f;
                        Microsoft.Xna.Framework.Color color2 = Lighting.GetColor((int)value.X / 16, (int)(value.Y / 16f), new Microsoft.Xna.Framework.Color(207, 205, 192));                            //fishing line color

                        Main.spriteBatch.Draw(Main.fishingLineTexture, new Vector2(value.X - Main.screenPosition.X + (float)Main.fishingLineTexture.Width * 0.5f, value.Y - Main.screenPosition.Y + (float)Main.fishingLineTexture.Height * 0.5f), new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(0, 0, Main.fishingLineTexture.Width, (int)num)), color2, rotation2, new Vector2((float)Main.fishingLineTexture.Width * 0.5f, 0f), 1f, SpriteEffects.None, 0f);
                    }
                }
            }
            return(false);
        }
        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            Vector2 mountedCenter = Main.player[projectile.owner].MountedCenter;
            Color   color25       = Lighting.GetColor((int)((double)projectile.position.X + (double)projectile.width * 0.5) / 16, (int)(((double)projectile.position.Y + (double)projectile.height * 0.5) / 16.0));

            if (projectile.hide && !ProjectileID.Sets.DontAttachHideToAlpha[projectile.type])
            {
                color25 = Lighting.GetColor((int)mountedCenter.X / 16, (int)(mountedCenter.Y / 16f));
            }
            Vector2 projPos = projectile.position;

            projPos = new Vector2((float)projectile.width, (float)projectile.height) / 2f + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition; //f**k it
            Texture2D texture2D22 = Main.projectileTexture[projectile.type];
            Color     alpha3      = projectile.GetAlpha(color25);

            if (projectile.velocity == Vector2.Zero)
            {
                return(false);
            }
            // first segment
            float     num230     = projectile.velocity.Length() + 16f;
            bool      flag24     = num230 < 100f;
            Vector2   value28    = Vector2.Normalize(projectile.velocity);
            Rectangle rectangle8 = new Rectangle(0, 0, texture2D22.Width, 26);
            Vector2   value29    = new Vector2(0f, Main.player[projectile.owner].gfxOffY);
            float     rotation24 = projectile.rotation + 3.14159274f;

            Main.spriteBatch.Draw(texture2D22, projectile.Center.Floor() - Main.screenPosition + value29, new Rectangle?(rectangle8), alpha3, rotation24, rectangle8.Size() / 2f - Vector2.UnitY * 4f, projectile.scale, SpriteEffects.None, 0f);
            //chain
            num230 -= 40f * projectile.scale; // how long chains are? dont mess with this, it messes stuff up
            Vector2 vector31 = projectile.Center.Floor();

            vector31  += value28 * projectile.scale * 16f; // changes where the chain part starts
            rectangle8 = new Rectangle(0, 42, texture2D22.Width, 10);
            if (num230 > 0f)
            {
                float num231 = 0f;
                while (num231 + 1f < num230)
                {
                    if (num230 - num231 < (float)rectangle8.Height)
                    {
                        rectangle8.Height = (int)(num230 - num231);
                    }
                    Main.spriteBatch.Draw(texture2D22, vector31 - Main.screenPosition + value29, new Rectangle?(rectangle8), alpha3, rotation24, new Vector2((float)(rectangle8.Width / 2), 0f), projectile.scale, SpriteEffects.None, 0f);
                    num231   += (float)rectangle8.Height * projectile.scale;
                    vector31 += value28 * (float)rectangle8.Height * projectile.scale;
                }
            }
            //mid section
            Vector2 value30 = vector31;

            vector31   = projectile.Center.Floor();
            vector31  += value28 * projectile.scale * 24f;
            rectangle8 = new Rectangle(0, 28, texture2D22.Width, 12);
            int num232 = 6; // how many chains there are

            if (flag24)
            {
                num232 = 3;
            }
            float num233 = num230;

            if (num230 > 0f)
            {
                float num234 = 0f;
                float num235 = num233 / (float)num232;
                num234   += num235 * 0.25f;
                vector31 += value28 * num235 * 0.25f;
                for (int num236 = 0; num236 < num232; num236++)
                {
                    float num237 = num235;
                    if (num236 == 0)
                    {
                        num237 *= 0.75f;
                    }
                    Main.spriteBatch.Draw(texture2D22, vector31 - Main.screenPosition + value29, new Rectangle?(rectangle8), alpha3, rotation24, new Vector2((float)(rectangle8.Width / 2), 0f), projectile.scale, SpriteEffects.None, 0f);
                    num234   += num237;
                    vector31 += value28 * num237;
                }
            }

            rectangle8 = new Rectangle(0, 54, texture2D22.Width, 24); //end
            Main.spriteBatch.Draw(texture2D22, value30 - Main.screenPosition + value29, new Rectangle?(rectangle8), alpha3, rotation24, texture2D22.Frame(1, 1, 0, 0).Top(), projectile.scale, SpriteEffects.None, 0f);
            return(false);
        }
Beispiel #10
0
        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            SpriteEffects spriteEffects = SpriteEffects.None;
            Color         color25       = Lighting.GetColor((int)(projectile.position.X + projectile.width * 0.5) / 16, (int)((projectile.position.Y + projectile.height * 0.5) / 16.0));
            Vector2       mountedCenter = Main.player[projectile.owner].MountedCenter;
            Vector2       vector45      = projectile.position + new Vector2(projectile.width, projectile.height) / 2f + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition;
            Texture2D     texture2D36   = Main.projectileTexture[projectile.type];
            Color         alpha6        = projectile.GetAlpha(color25);
            Vector2       vector46      = Main.player[projectile.owner].RotatedRelativePoint(mountedCenter, true) + Vector2.UnitY * Main.player[projectile.owner].gfxOffY;
            Vector2       vector47      = vector45 + Main.screenPosition - vector46;
            Vector2       value50       = Vector2.Normalize(vector47);
            float         num296        = vector47.Length();
            float         num297        = vector47.ToRotation() + 1.57079637f;
            float         num298        = -5f;
            float         num299        = num298 + 30f;

            new Vector2(2f, num296 - num299);
            Vector2 value51  = Vector2.Lerp(vector45 + Main.screenPosition, vector46 + value50 * num299, 0.5f);
            Vector2 vector48 = -Vector2.UnitY.RotatedBy(projectile.localAI[0] / 60f * 3.14159274f, default);

            Vector2[] array7 = new Vector2[]
            {
                vector48,
                vector48.RotatedBy(1.5707963705062866, default),
                vector48.RotatedBy(3.1415927410125732, default),
                vector48.RotatedBy(4.71238911151886, default)
            };
            if (num296 > num299)
            {
                for (int num300 = 0; num300 < 2; num300++)
                {
                    Color color65;
                    if (num300 % 2 == 0)
                    {
                        color65   = Color.Red;
                        color65.A = 128;
                        color65  *= 0.5f;
                    }
                    else
                    {
                        color65   = Color.DimGray;
                        color65.A = 128;
                        color65  *= 0.5f;
                    }
                    Vector2 value52 = new Vector2(array7[num300].X, 0f).RotatedBy(num297, default) * 4f;
                    Main.spriteBatch.Draw(Main.magicPixel, value51 - Main.screenPosition + value52, new Rectangle?(new Rectangle(0, 0, 1, 1)), color65, num297, Vector2.One / 2f, new Vector2(2f, num296 - num299), spriteEffects, 0f);
                }
            }
            Texture2D texture2D37 = Main.itemTexture[Main.player[projectile.owner].inventory[Main.player[projectile.owner].selectedItem].type];
            Color     color66     = Lighting.GetColor((int)vector46.X / 16, (int)vector46.Y / 16);

            Main.spriteBatch.Draw(texture2D37, vector46 - Main.screenPosition + value50 * num298, null, color66, projectile.rotation + 1.57079637f + ((spriteEffects == SpriteEffects.None) ? 3.14159274f : 0f), new Vector2((spriteEffects == SpriteEffects.None) ? 0 : texture2D37.Width, texture2D37.Height / 2f) + Vector2.UnitY * 1f, Main.player[projectile.owner].inventory[Main.player[projectile.owner].selectedItem].scale, spriteEffects, 0f);
            Main.spriteBatch.Draw(mod.GetTexture("Glowmasks/DoomiteMiningLaser_Glow"), vector46 - Main.screenPosition + value50 * num298, null, new Color(255, 255, 255, 0), projectile.rotation + 1.57079637f + ((spriteEffects == SpriteEffects.None) ? 3.14159274f : 0f), new Vector2((spriteEffects == SpriteEffects.None) ? 0 : texture2D37.Width, texture2D37.Height / 2f) + Vector2.UnitY * 1f, Main.player[projectile.owner].inventory[Main.player[projectile.owner].selectedItem].scale, spriteEffects, 0f);
            if (num296 > num299)
            {
                for (int num301 = 2; num301 < 4; num301++)
                {
                    Color color67;
                    if (num301 % 2 == 0)
                    {
                        color67   = Color.Red;
                        color67.A = 128;
                        color67  *= 0.5f;
                    }
                    else
                    {
                        color67   = Color.DimGray;
                        color67.A = 128;
                        color67  *= 0.5f;
                    }
                    Vector2 value53 = new Vector2(array7[num301].X, 0f).RotatedBy(num297, default) * 4f;
                    Main.spriteBatch.Draw(Main.magicPixel, value51 - Main.screenPosition + value53, new Rectangle?(new Rectangle(0, 0, 1, 1)), color67, num297, Vector2.One / 2f, new Vector2(2f, num296 - num299), spriteEffects, 0f);
                }
            }
            float num302 = projectile.localAI[0] / 60f;

            if (num302 > 0.5f)
            {
                num302 = 1f - num302;
            }
            Main.spriteBatch.Draw(texture2D36, vector45, null, alpha6 * num302 * 2f, projectile.rotation, new Vector2(texture2D36.Width, texture2D36.Height) / 2f, projectile.scale, spriteEffects, 0f);
            Main.spriteBatch.Draw(Main.projectileTexture[projectile.type], vector45, null, alpha6 * (0.5f - num302) * 2f, projectile.rotation, new Vector2(texture2D36.Width, texture2D36.Height) / 2f, projectile.scale, spriteEffects, 0f);
            return(false);
        }
        public override bool?DrawHealthBar(NPC npc, byte hbPosition, ref float scale, ref Vector2 position)
        {
            string ganicText = "";

            if (npc.Organic())
            {
                ganicText = "Organic";
            }
            else if (npc.Inorganic())
            {
                ganicText = "Inorganic";
            }

            if (!string.IsNullOrEmpty(ganicText) && CalamityChangesConfig.Instance.displayOrganicTextNPCs)
            {
                ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, Main.fontMouseText, ganicText, position - Main.screenPosition - new Vector2(Main.fontMouseText.MeasureString(ganicText).X / 2f, -(Main.fontMouseText.MeasureString(ganicText).Y / 2f)), Lighting.GetColor((int)(npc.position.X / 16), (int)(npc.position.Y / 16)), 0f, Vector2.Zero, Vector2.One);
            }

            return(base.DrawHealthBar(npc, hbPosition, ref scale, ref position));
        }
        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            Texture2D texture = Main.projectileTexture[projectile.type];
            Color     color   = lightColor;

            // Some rectangle presets for different parts of the chain.
            Rectangle chainHandle  = new Rectangle(0, 2, texture.Width, 40);
            Rectangle chainLinkEnd = new Rectangle(0, 68, texture.Width, 18);
            Rectangle chainLink    = new Rectangle(0, 46, texture.Width, 18);
            Rectangle chainHead    = new Rectangle(0, 90, texture.Width, 48);

            // If the chain isn't moving, stop drawing all of its components.
            if (projectile.velocity == Vector2.Zero)
            {
                return(false);
            }

            // These fields / pre-draw logic have been taken from the vanilla source code for the Solar Eruption.
            // They setup distances, directions, offsets, and rotations all so the chain faces correctly.
            float     chainDistance = projectile.velocity.Length() + 16f;
            bool      distanceCheck = chainDistance < 100f;
            Vector2   direction     = Vector2.Normalize(projectile.velocity);
            Rectangle rectangle     = chainHandle;
            Vector2   yOffset       = new Vector2(0f, Main.player[projectile.owner].gfxOffY);
            float     rotation      = direction.ToRotation() + MathHelper.ToRadians(-90f);
            // Draw the chain handle. This is the first piece in the sprite.
            Player player = Main.player[projectile.owner];

            if (player.direction == -1)
            {
                spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + yOffset, rectangle, color, rotation, rectangle.Size() / 2f - Vector2.UnitY * 4f, projectile.scale, SpriteEffects.FlipHorizontally, 0f);
            }
            else
            {
                spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + yOffset, rectangle, color, rotation, rectangle.Size() / 2f - Vector2.UnitY * 4f, projectile.scale, SpriteEffects.None, 0f);
            }
            chainDistance -= 40f * projectile.scale;
            Vector2 position = projectile.Center;

            position += direction * projectile.scale * 24f;
            rectangle = chainLinkEnd;
            if (chainDistance > 0f)
            {
                float chains = 0f;
                while (chains + 1f < chainDistance)
                {
                    if (chainDistance - chains < rectangle.Height)
                    {
                        rectangle.Height = (int)(chainDistance - chains);
                    }
                    // Draws the chain links between the handle and the head. This is the "line," or the third piece in the sprite.
                    if (player.direction == -1)
                    {
                        spriteBatch.Draw(texture, position - Main.screenPosition + yOffset, rectangle, Lighting.GetColor((int)position.X / 16, (int)position.Y / 16), rotation, new Vector2(rectangle.Width / 2, 0f), projectile.scale, SpriteEffects.FlipHorizontally, 0f);
                    }
                    else
                    {
                        spriteBatch.Draw(texture, position - Main.screenPosition + yOffset, rectangle, Lighting.GetColor((int)position.X / 16, (int)position.Y / 16), rotation, new Vector2(rectangle.Width / 2, 0f), projectile.scale, SpriteEffects.None, 0f);
                    }
                    chains   += rectangle.Height * projectile.scale;
                    position += direction * rectangle.Height * projectile.scale;
                }
            }
            Vector2 chainEnd = position;

            position  = projectile.Center;
            position += direction * projectile.scale * 24f;
            rectangle = chainLink;
            int   offset            = distanceCheck ? 9 : 18;
            float chainLinkDistance = chainDistance;

            if (chainDistance > 0f)
            {
                float chains    = 0f;
                float increment = chainLinkDistance / offset;
                chains   += increment * 0.25f;
                position += direction * increment * 0.25f;
                for (int i = 0; i < offset; i++)
                {
                    float spacing = increment;
                    if (i == 0)
                    {
                        spacing *= 0.75f;
                    }
                    // Draws the actual chain link spikes between the handle and the head. These are the "spikes," or the second piece in the sprite.
                    if (player.direction == -1)
                    {
                        spriteBatch.Draw(texture, position - Main.screenPosition + yOffset, rectangle, Lighting.GetColor((int)position.X / 16, (int)position.Y / 16), rotation, new Vector2(rectangle.Width / 2, 0f), projectile.scale, SpriteEffects.FlipHorizontally, 0f);
                    }
                    else
                    {
                        spriteBatch.Draw(texture, position - Main.screenPosition + yOffset, rectangle, Lighting.GetColor((int)position.X / 16, (int)position.Y / 16), rotation, new Vector2(rectangle.Width / 2, 0f), projectile.scale, SpriteEffects.None, 0f);
                    }
                    chains   += spacing;
                    position += direction * spacing;
                }
            }
            rectangle = chainHead;
            // Draw the chain head. This is the fourth piece in the sprite.
            if (player.direction == -1)
            {
                spriteBatch.Draw(texture, chainEnd - Main.screenPosition + yOffset, rectangle, Lighting.GetColor((int)chainEnd.X / 16, (int)chainEnd.Y / 16), rotation, texture.Frame().Top(), projectile.scale, SpriteEffects.FlipHorizontally, 0f);
            }
            else
            {
                spriteBatch.Draw(texture, chainEnd - Main.screenPosition + yOffset, rectangle, Lighting.GetColor((int)chainEnd.X / 16, (int)chainEnd.Y / 16), rotation, texture.Frame().Top(), projectile.scale, SpriteEffects.None, 0f);
            }
            // Because the chain head's draw position isn't determined in AI, it is set in PreDraw.
            // This is so the smoke-spawning dust and white light are at the proper location.
            chainHeadPosition = chainEnd;

            return(false);
        }
Beispiel #13
0
        private void WindForce(int index)//wind
        {
            int offset = (int)(projectile.position.X / 16 + projectile.position.Y / 16);

            float sin = (float)Math.Sin(StarlightWorld.rottime + offset - index / 3f);

            float cos  = (float)Math.Cos(projectile.ai[0]);
            float sin2 = (float)Math.Sin(StarlightWorld.rottime + offset + cos);

            Vector2 pos = new Vector2(Chain.ropeSegments[index].posNow.X + 0.2f + sin2 * 0.2f, Chain.ropeSegments[index].posNow.Y + sin * 0.3f);

            Color color = new Color(150, 10, 35).MultiplyRGB(Color.White * (1 - sin * 0.2f)).MultiplyRGB(Lighting.GetColor((int)pos.X / 16, (int)pos.Y / 16));

            Chain.ropeSegments[index].posNow = pos;
            Chain.ropeSegments[index].color  = color;
        }
Beispiel #14
0
        public void DrawGlowmask(PlayerDrawInfo info)
        {
            Player player = info.drawPlayer;

            float time  = Main.GameUpdateCount % 400f;
            float sin2  = (float)Math.Sin(time * 0.2f * 0.2f);
            float cos   = (float)Math.Cos(time * 0.2f);
            Color color = new Color(100 * (1 + sin2) / 255f, 140 * (1 + cos) / 255f, 180 / 255f);

            if (color.R < 80)
            {
                color.R = 80;
            }
            if (color.G < 80)
            {
                color.G = 80;
            }

            if (charge > 0 && charged)
            {
                Texture2D tex  = GetTexture("StarlightRiver/Assets/Items/Permafrost/AuroraAxeOut");
                Texture2D tex2 = GetTexture("StarlightRiver/Assets/Items/Permafrost/AuroraAxeOutGlow");

                DrawData data  = new DrawData(tex, (player.Center - Main.screenPosition - Vector2.UnitY * (2 - player.gfxOffY)).PointAccur(), null, Lighting.GetColor((int)player.Center.X / 16, (int)player.Center.Y / 16), 0, tex.Size() / 2, 1, info.spriteEffects, 0);
                DrawData data2 = new DrawData(tex2, (player.Center - Main.screenPosition - Vector2.UnitY * (2 - player.gfxOffY)).PointAccur(), null, color * charge * 0.5f, 0, tex.Size() / 2, 1, info.spriteEffects, 0);
                Main.playerDrawData.Add(data);
                Main.playerDrawData.Add(data2);
            }

            else
            {
                var      tex3  = GetTexture(Texture + "Glow");
                DrawData data3 = new DrawData(tex3, info.itemLocation - Main.screenPosition, null, color * charge * 0.5f, player.itemRotation, info.spriteEffects == 0 ? new Vector2(0, tex3.Height) : new Vector2(tex3.Width, tex3.Height), player.HeldItem.scale, info.spriteEffects, 0);
                Main.playerDrawData.Add(data3);
            }

            Lighting.AddLight(player.Center, color.ToVector3() * charge * 0.2f);
        }
Beispiel #15
0
        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            Texture2D[] asteriods = new Texture2D[3] {
                ModContent.GetTexture("SGAmod/Dimensions/Space/GlowAsteriod"), ModContent.GetTexture("SGAmod/Dimensions/Space/GlowAsteriodalt"), ModContent.GetTexture("SGAmod/Dimensions/Space/GlowAsteriodalt2")
            };

            float alpha = MathHelper.Clamp((projectile.localAI[0] - 20) / 40f, 0f, 1f) * MathHelper.Clamp(projectile.timeLeft / 60f, 0f, 1f);

            Texture2D eyeTex  = Main.projectileTexture[projectile.type];
            Vector2   eyeSize = new Vector2(eyeTex.Width, eyeTex.Height);

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

            Effect fadeIn = SGAmod.FadeInEffect;

            foreach (MandalaArm arm in arms)
            {
                if (arm.chargeIn <= 0.01f)
                {
                    continue;
                }

                fadeIn.Parameters["strength"].SetValue(1f);
                fadeIn.Parameters["fadeColor"].SetValue(Color.Aqua.ToVector3());
                fadeIn.Parameters["blendColor"].SetValue(Color.White.ToVector3());

                for (float f = arm.chargeInDist; f > 0; f -= 0.5f)
                {
                    float percent     = (f / 10f);
                    float chargeScale = percent * 128f * arm.chargeIn;
                    fadeIn.Parameters["alpha"].SetValue((alpha * MathHelper.Clamp(arm.despawnTimer / 8f, 0f, 1f) * (1f - percent)) * 0.50f * (arm.chargeIn * 0.75f));
                    fadeIn.CurrentTechnique.Passes["FadeIn"].Apply();
                    arm.Draw(spriteBatch, this, 1f, arm.Position - Vector2.Normalize(arm.direction) * chargeScale);
                }
            }

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

            foreach (MandalaArm arm in arms)
            {
                arm.Draw(spriteBatch, this, alpha * MathHelper.Clamp(arm.despawnTimer / 8f, 0f, 1f));
            }

            foreach (Projectile Asteriod in Asteriods)
            {
                Color asteriodColor = Lighting.GetColor(((int)Asteriod.Center.X) >> 4, ((int)Asteriod.Center.Y) >> 4, Color.White);
                (Asteriod.modProjectile as MandalaAsteriodProj).DoDraw(spriteBatch, asteriodColor * alpha);
            }

            Texture2D tex  = asteriods[0];
            Vector2   size = new Vector2(tex.Width, tex.Height / 2);

            float lenToShow  = MathHelper.Clamp((float)Math.Pow(eyeCurrentLook.Length(), 0.36f) * 1.5f, 0, 16f);
            float lenToShow2 = MathHelper.Clamp((float)Math.Pow(eyeCurrentLook.Length(), 0.36f) * 1.5f, 0, 8f);

            Vector2 lookpos = (Vector2.Normalize(eyeCurrentLook) * lenToShow);

            spriteBatch.Draw(tex, DrawPosition - Main.screenPosition, new Rectangle(0, 0, (int)size.X, (int)size.Y), Color.White * alpha, projectile.velocity.X / 12f, size / 2f, projectile.scale, SpriteEffects.None, 0);

            for (float f = 0; f < 1f; f += 1 / 10f)
            {
                float scale = ((MathHelper.Clamp((float)Math.Sin(((projectile.localAI[0] + (f * 60f)) * MathHelper.TwoPi) / 60), 0f, 1f))) * ((f / 2f) + 0.75f);
                spriteBatch.Draw(eyeTex, DrawPosition + lookpos - Main.screenPosition, null, Color.White * alpha * (f / 2f) * 0.50f, projectile.velocity.X / 8f, eyeSize / 2f, (projectile.scale * 1f) + scale * 1f, SpriteEffects.None, 0);
            }

            spriteBatch.Draw(eyeTex, DrawPosition + lookpos - Main.screenPosition, null, Color.White * alpha, 0, eyeSize / 2f, projectile.scale * Main.essScale, SpriteEffects.None, 0);


            Main.spriteBatch.End();
            Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullNone, null, Main.GameViewMatrix.TransformationMatrix);


            return(false);
        }
        public override bool PreDraw(int i, int j, SpriteBatch spriteBatch)
        {
            Tile      tile = Main.tile[i, j];
            Texture2D texture;

            if (Main.canDrawColorTile(i, j))
            {
                texture = Main.tileAltTexture[Type, (int)tile.color()];
            }
            else
            {
                texture = Main.tileTexture[Type];
            }
            Vector2 zero = new Vector2(Main.offScreenRange, Main.offScreenRange);

            if (Main.drawToScreen)
            {
                zero = Vector2.Zero;
            }
            int height  = tile.frameY == 36 ? 18 : 16;
            int animate = 0;

            if (tile.frameY >= 56)
            {
                animate = Main.tileFrame[Type] * animationFrameHeight;
            }
            Main.spriteBatch.Draw(texture, new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero, new Rectangle(tile.frameX, tile.frameY + animate, 16, height), Lighting.GetColor(i, j), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
            Main.spriteBatch.Draw(mod.GetTexture("Tiles/VoidMonolith_Glow"), new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero, new Rectangle(tile.frameX, tile.frameY + animate, 16, height), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
            return(false);
        }
    public void DrawLine(SpriteBatch SP, Vector2 start, Vector2 end, Texture2D TEX, float S, Color C, float Jump)
    {
        float   TEXW = (float)TEX.Width;
        float   TEXH = (float)TEX.Height;
        Vector2 TC   = new Vector2(TEXW / 2f, TEXH / 2f);

        TC *= S;
        Vector2 Pstart = start;
        Vector2 Pend   = end;
        Vector2 dir    = Pend - Pstart;

        dir.Normalize();
        //dir/=dir.Length();
        bool screenSafety = true;

        if (screenSafety)
        {
            int alloRad = 16;
            #region pstart
            if (Pstart.X < Main.screenPosition.X - alloRad)
            {
                Pstart.Y += ((Main.screenPosition.X - alloRad - Pstart.X) / dir.X) * dir.Y;
                Pstart.X  = Main.screenPosition.X - alloRad;
            }
            if (Pstart.X > Main.screenPosition.X + Main.screenWidth + alloRad)
            {
                Pstart.Y -= ((Pstart.X - Main.screenPosition.X - Main.screenWidth - alloRad) / dir.X) * dir.Y;
                Pstart.X  = Main.screenPosition.X + Main.screenWidth + alloRad;
            }
            if (Pstart.Y < Main.screenPosition.Y - alloRad)
            {
                Pstart.X += ((Main.screenPosition.Y - alloRad - Pstart.Y) / dir.Y) * dir.X;
                Pstart.Y  = Main.screenPosition.Y - alloRad;
            }
            if (Pstart.Y > Main.screenPosition.Y + Main.screenHeight + alloRad)
            {
                Pstart.X -= ((Pstart.Y - Main.screenPosition.Y - Main.screenHeight - alloRad) / dir.Y) * dir.X;
                Pstart.Y  = Main.screenPosition.Y + Main.screenHeight + alloRad;
            }
            #endregion
            #region pend
            if (Pend.X < Main.screenPosition.X - alloRad)
            {
                Pend.Y += ((Main.screenPosition.X - alloRad - Pend.X) / dir.X) * dir.Y;
                Pend.X  = Main.screenPosition.X - alloRad;
            }
            if (Pend.X > Main.screenPosition.X + Main.screenWidth + alloRad)
            {
                Pend.Y -= ((Pend.X - Main.screenPosition.X - Main.screenWidth - alloRad) / dir.X) * dir.Y;
                Pend.X  = Main.screenPosition.X + Main.screenWidth + alloRad;
            }
            if (Pend.Y < Main.screenPosition.Y - alloRad)
            {
                Pend.X += ((Main.screenPosition.Y - alloRad - Pend.Y) / dir.Y) * dir.X;
                Pend.Y  = Main.screenPosition.Y - alloRad;
            }
            if (Pend.Y > Main.screenPosition.Y + Main.screenHeight + alloRad)
            {
                Pend.X -= ((Pend.Y - Main.screenPosition.Y - Main.screenHeight - alloRad) / dir.Y) * dir.X;
                Pend.Y  = Main.screenPosition.Y + Main.screenHeight + alloRad;
            }
            #endregion
        }
        float rot    = (float)Math.Atan2(dir.Y, dir.X) + (float)Math.PI / 2f;
        float length = Vector2.Distance(Pstart, Pend);
        float Way    = 0f;

        while (Way < length)
        {
            Vector2 v  = (Pstart + dir * Way) - Main.screenPosition + TC;
            Color   C2 = Lighting.GetColor((int)(v.X + Main.screenPosition.X) / 16, (int)(v.Y + Main.screenPosition.Y) / 16, C);
            SP.Draw(
                TEX,
                v,
                new Rectangle?(new Rectangle(0, 0, (int)TEXW, (int)TEXH)),
                C2,
                rot,
                TC,
                S,
                SpriteEffects.None, 0f
                );
            Way += Jump;
        }
    }
Beispiel #18
0
        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            Player owner = null;

            if (projectile.owner != -1)
            {
                owner = Main.player[projectile.owner];
            }
            else if (projectile.owner == 255)
            {
                owner = Main.LocalPlayer;
            }
            Player  player        = owner;
            Vector2 mountedCenter = player.MountedCenter;
            Color   color         = Lighting.GetColor((int)(projectile.position.X + projectile.width * 0.5) / 16, (int)((projectile.position.Y + projectile.height * 0.5) / 16.0));

            if (projectile.hide && !ProjectileID.Sets.DontAttachHideToAlpha[projectile.type])
            {
                color = Lighting.GetColor((int)mountedCenter.X / 16, (int)(mountedCenter.Y / 16.0));
            }
            SpriteEffects effects = SpriteEffects.None;

            if (projectile.spriteDirection == -1)
            {
                effects = SpriteEffects.FlipHorizontally;
            }
            Texture2D texture  = Main.projectileTexture[projectile.type];
            int       height   = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type];
            int       y        = height * projectile.frame;
            Vector2   position = (projectile.position + new Vector2(projectile.width, projectile.height) / 2f + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition).Floor();

            if (player.shroomiteStealth && player.inventory[player.selectedItem].ranged)
            {
                float num1 = player.stealth;
                if (num1 < 0.03)
                {
                    num1 = 0.03f;
                }
                double num2 = (1.0 + num1 * 10.0) / 11.0;
                color *= num1;
            }
            if (player.setVortex && player.inventory[player.selectedItem].ranged)
            {
                float num1 = player.stealth;
                if (num1 < 0.03)
                {
                    num1 = 0.03f;
                }
                double num2 = (1.0 + num1 * 10.0) / 11.0;
                color = color.MultiplyRGBA(new Color(Vector4.Lerp(Vector4.One, new Vector4(0.16f, 0.12f, 0.0f, 0.0f), 1f - num1)));
            }
            Main.spriteBatch.Draw(texture, position, new Rectangle?(new Rectangle(0, y, texture.Width, height)), projectile.GetAlpha(color), projectile.rotation, new Vector2(texture.Width / 2f, height / 2f), projectile.scale, effects, 0.0f);
            float num3 = (float)(Math.Cos(6.28318548202515 * (projectile.ai[0] / 30.0)) * 2.0 + 2.0);

            if (projectile.ai[0] > 120.0)
            {
                num3 = 4f;
            }
            for (float num1 = 0.0f; num1 < 4.0; ++num1)
            {
                Main.spriteBatch.Draw(texture, position + Vector2.UnitY.RotatedBy(num1 * 6.28318548202515 / 4.0, new Vector2()) * num3, new Rectangle?(new Rectangle(0, y, texture.Width, height)), projectile.GetAlpha(color).MultiplyRGBA(new Color(byte.MaxValue, byte.MaxValue, byte.MaxValue, 0)) * 0.03f, projectile.rotation, new Vector2(texture.Width / 2f, height / 2f), projectile.scale, effects, 0.0f);
            }
            return(false);
        }
Beispiel #19
0
        private void DrawSegment(SpriteBatch sb, int index, Vector2 pos)
        {
            if (Main.netMode == Terraria.ID.NetmodeID.Server)
            {
                return;
            }

            if (stopDrawingBody && index > 0)
            {
                return;
            }

            var tex     = GetTexture(AssetDirectory.VitricBoss + "VitricBossBody");
            var glowTex = GetTexture(AssetDirectory.VitricBoss + "VitricBossBodyGlow");

            float rot = 0;

            if (index != 0)
            {
                rot = (chain.ropeSegments[index].posNow - chain.ropeSegments[index - 1].posNow).ToRotation() - (float)Math.PI / 2;
            }

            Rectangle source;

            switch (index)
            {
            case 0: source = new Rectangle(0, 0, 0, 0); break;

            case 1: source = new Rectangle(0, 0, 114, 114); break;

            case 2: source = new Rectangle(18, 120, 78, 44); break;

            case 3:
            case 4:
                source = new Rectangle(26, 168, 62, 30); break;

            default: source = new Rectangle(40, 204, 34, 28); break;
            }

            int thisTimer = parent.twistTimer;
            int threshold = (int)(parent.maxTwistTimer / 8f * (index + 1)) - 1;

            bool shouldBeTwistFrame = false;

            if (Math.Abs(parent.lastTwistState - parent.twistTarget) == 2) //flip from 1 side to the other
            {
                int diff = parent.maxTwistTimer / 8 / 3;
                shouldBeTwistFrame = thisTimer <threshold - diff || thisTimer> threshold + diff;
            }

            if (Math.Abs(parent.twistTarget) == 1) //flip from front to side
            {
                shouldBeTwistFrame = thisTimer > threshold;
            }
            else if (parent.twistTarget == 0) //flip from side to front
            {
                shouldBeTwistFrame = thisTimer < threshold;
            }

            SpriteEffects flip = (
                (parent.twistTarget == -1 && parent.twistTimer > threshold) ||
                (parent.lastTwistState == -1)
                ) ? SpriteEffects.None : SpriteEffects.FlipHorizontally;

            if (Math.Abs(parent.lastTwistState) == Math.Abs(parent.twistTarget) && parent.lastTwistState != parent.twistTarget)
            {
                int dir = (int)flip;
                dir *= (parent.twistTimer > parent.maxTwistTimer / 2 ? 1 : -1);

                flip = dir == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
            }

            if (shouldBeTwistFrame)
            {
                source.X += 114;
            }

            if (index == 0 && parent.Phase != (int)VitricBoss.AIStates.Dying &&
                parent.Phase != (int)VitricBoss.AIStates.SpawnAnimation) //change this so the head is drawn from here later maybe? and move all visuals into this class?
            {
                parent.npc.spriteDirection = (int)flip;

                if (parent.npc.frame.Y == 0)
                {
                    if (Math.Abs(parent.lastTwistState) == Math.Abs(parent.twistTarget) && parent.lastTwistState != parent.twistTarget)
                    {
                        parent.npc.frame.X = parent.npc.frame.Width * (2 - (int)(Math.Sin(parent.twistTimer / (float)parent.maxTwistTimer * 3.14f) * 2));
                    }

                    else if (shouldBeTwistFrame) //this is dumb, mostly just to test
                    {
                        parent.npc.frame.X = parent.npc.frame.Width * (int)((parent.twistTimer / (float)parent.maxTwistTimer) * 2);
                    }
                    else
                    {
                        parent.npc.frame.X = parent.npc.frame.Width * (2 - (int)((parent.twistTimer / (float)parent.maxTwistTimer) * 2));
                    }
                }

                if (parent.npc.frame.Y == parent.npc.frame.Height * 2 || parent.npc.frame.Y == parent.npc.frame.Height * 3)
                {
                    parent.npc.frame.Y = parent.npc.frame.Height * (shouldBeTwistFrame ? 2 : 3);
                }
            }

            var brightness = (0.5f + (float)Math.Sin(StarlightWorld.rottime + index));

            if (index == 1)
            {
                brightness += 0.25f;
            }

            sb.Draw(tex, pos - Main.screenPosition, source, Lighting.GetColor((int)pos.X / 16, (int)pos.Y / 16), rot, source.Size() / 2, 1, flip, 0);
            sb.Draw(glowTex, pos - Main.screenPosition, source, Color.White * brightness, rot, source.Size() / 2, 1, flip, 0);

            var tile = Framing.GetTileSafely((int)pos.X / 16, (int)pos.Y / 16);

            if (!tile.active() && tile.wall == 0)
            {
                Lighting.AddLight(pos, new Vector3(1, 0.8f, 0.2f) * brightness * 0.4f);
            }
        }
Beispiel #20
0
        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            Texture2D     tex     = Main.projectileTexture[projectile.type];
            SpriteEffects effects = SpriteEffects.None;

            if (projectile.spriteDirection == -1)
            {
                effects = SpriteEffects.FlipHorizontally;
            }
            Vector2 drawOrigin = new Vector2(Main.projectileTexture[projectile.type].Width * 0.5f, projectile.height * 0.5f);

            for (int k = 0; k < projectile.oldPos.Length; k++)
            {
                Vector2   drawPos = projectile.oldPos[k] - Main.screenPosition + drawOrigin + new Vector2(0f, projectile.gfxOffY);
                Color     color2  = projectile.GetAlpha(lightColor) * ((projectile.oldPos.Length - k) / (float)projectile.oldPos.Length);
                Rectangle?rect    = new Rectangle?(new Rectangle(0, (Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]) * projectile.frame, Main.projectileTexture[projectile.type].Width, Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]));
                spriteBatch.Draw(Main.projectileTexture[projectile.type], drawPos, rect, color2, projectile.oldRot[k], drawOrigin, projectile.scale, effects, 0f);
            }

            Texture2D texture  = ModContent.GetTexture("JoostMod/Projectiles/Flail_Chain");
            NPC       host     = Main.npc[(int)projectile.ai[0]];
            Vector2   position = projectile.Center;
            Vector2   arm      = host.Center + new Vector2(40 * host.direction, -31);
            Vector2   dir      = position - arm;

            dir.Normalize();
            arm += dir * 56;
            Rectangle?sourceRectangle = new Microsoft.Xna.Framework.Rectangle?();
            Vector2   origin          = new Vector2((float)texture.Width * 0.5f, (float)texture.Height * 0.5f);
            float     num1            = (float)texture.Height;
            Vector2   vector2_4       = arm - position;
            float     rotation        = (float)Math.Atan2((double)vector2_4.Y, (double)vector2_4.X) - 1.57f;
            bool      flag            = true;

            if (float.IsNaN(position.X) && float.IsNaN(position.Y))
            {
                flag = false;
            }
            if (float.IsNaN(vector2_4.X) && float.IsNaN(vector2_4.Y))
            {
                flag = false;
            }
            while (flag)
            {
                if ((double)vector2_4.Length() < (double)num1 + 1.0)
                {
                    flag = false;
                }
                else
                {
                    Vector2 vector2_1 = vector2_4;
                    vector2_1.Normalize();
                    position += vector2_1 * num1;
                    vector2_4 = arm - position;
                    Color color2 = Lighting.GetColor((int)position.X / 16, (int)((double)position.Y / 16.0));
                    color2 = projectile.GetAlpha(color2);
                    Main.spriteBatch.Draw(texture, position - Main.screenPosition, sourceRectangle, color2, rotation, origin, 1f, SpriteEffects.None, 0.0f);
                }
            }

            return(true);
        }
Beispiel #21
0
        public override void SpecialDraw(int i, int j, SpriteBatch spriteBatch)
        {
            Vector2 zero = new Vector2((float)Main.offScreenRange, (float)Main.offScreenRange);

            if (Main.drawToScreen)
            {
                zero = Vector2.Zero;
            }

            Tile t = Main.tile[i, j];
            //int style = t.frameX / 54;

            int index = GetInstance <BannerRackTE>().Find(i, j);

            if (index == -1)
            {
                return;
            }
            BannerRackTE bannerRackTE = (BannerRackTE)TileEntity.ByID[index];

            if (bannerRackTE.bannerItems.Count > 0)
            {
                bannerRackTE.ClientUpdate();
                int leftItemTrim  = bannerRackTE.counter / 2;
                int rightItemTrim = 16 - leftItemTrim;
                for (int drawItemNumber = 0; drawItemNumber < 3; drawItemNumber++)
                {
                    Color color = Lighting.GetColor(i + drawItemNumber, j + 1);
                    if (bannerRackTE.drawItemIndexs[drawItemNumber] < 0)
                    {
                        continue;
                    }

                    Item item = bannerRackTE.bannerItems[bannerRackTE.drawItemIndexs[drawItemNumber]];

                    //if(drawItemNumber > 0 && superBannerTE.drawItemIndexs[drawItemNumber] == superBannerTE.drawItemIndexs[drawItemNumber - 1])
                    //{
                    //	continue;
                    //}

                    int itemXOffset = 8 + (-bannerRackTE.counter / 2 + drawItemNumber * 16);

                    if (item != null && item.createTile > TileID.Dirt)                     // unloaded....spawn in world when you can.
                    {
                        var tod = TileObjectData.GetTileData(item.createTile, item.placeStyle);

                        int x = item.placeStyle * tod.CoordinateFullWidth;
                        int y = 0;
                        if (tod.StyleWrapLimit > 0)
                        {
                            x = (item.placeStyle % tod.StyleWrapLimit) * tod.CoordinateFullWidth;
                            y = (item.placeStyle / tod.StyleWrapLimit) * tod.CoordinateFullHeight;
                        }

                        Main.instance.LoadTiles(item.createTile);
                        Texture2D tileTexture         = Main.tileTexture[item.createTile];
                        int[]     heights             = tod.CoordinateHeights;
                        int       heightOffSet        = 0;
                        int       heightOffSetTexture = 0;
                        int       leftItemNudge       = 0;
                        for (int sub = 0; sub < heights.Length; sub++)
                        {
                            //Rectangle sourceRectangle = new Rectangle(x, y + heightOffSet, 1, 1);
                            Rectangle sourceRectangle = new Rectangle(x, y + heightOffSetTexture, tod.CoordinateWidth, tod.CoordinateHeights[sub]);
                            if (drawItemNumber == 0)
                            {
                                sourceRectangle.X     += leftItemTrim;
                                sourceRectangle.Width -= leftItemTrim;
                                leftItemNudge          = leftItemTrim;
                            }
                            if (drawItemNumber == 2)
                            {
                                sourceRectangle.Width -= rightItemTrim;
                            }
                            Main.spriteBatch.Draw(tileTexture,
                                                  new Vector2(
                                                      leftItemNudge + itemXOffset + (i * 16) - (int)Main.screenPosition.X + 0,
                                                      j * 16 - (int)Main.screenPosition.Y + 8 + heightOffSet) + zero,
                                                  sourceRectangle, color, 0f, Vector2.Zero, 1, SpriteEffects.None, 0f);
                            heightOffSet        += heights[sub];
                            heightOffSetTexture += heights[sub] + tod.CoordinatePadding;
                        }
                    }
                }
            }
        }
Beispiel #22
0
        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            Texture2D texture      = ModContent.GetTexture("JoostMod/Projectiles/TerraFury_Chain");
            Player    player       = Main.player[projectile.owner];
            Vector2   position     = projectile.Center;
            Vector2   playerCenter = player.MountedCenter;

            if (player.bodyFrame.Y == player.bodyFrame.Height * 3)
            {
                playerCenter.X += 8 * player.direction;
                playerCenter.Y += 2 * player.gravDir;
            }
            else if (player.bodyFrame.Y == player.bodyFrame.Height * 2)
            {
                playerCenter.X += 6 * player.direction;
                playerCenter.Y += -12 * player.gravDir;
            }
            else if (player.bodyFrame.Y == player.bodyFrame.Height * 4)
            {
                playerCenter.X += 6 * player.direction;
                playerCenter.Y += 8 * player.gravDir;
            }
            else if (player.bodyFrame.Y == player.bodyFrame.Height)
            {
                playerCenter.X += -10 * player.direction;
                playerCenter.Y += -14 * player.gravDir;
            }
            Rectangle?sourceRectangle = new Microsoft.Xna.Framework.Rectangle?();
            Vector2   origin          = new Vector2((float)texture.Width * 0.5f, (float)texture.Height * 0.5f);
            float     num1            = (float)texture.Height * projectile.scale;
            Vector2   vector2_4       = playerCenter - position;
            float     rotation        = (float)Math.Atan2((double)vector2_4.Y, (double)vector2_4.X) - 1.57f;
            bool      flag            = true;

            if (float.IsNaN(position.X) && float.IsNaN(position.Y))
            {
                flag = false;
            }
            if (float.IsNaN(vector2_4.X) && float.IsNaN(vector2_4.Y))
            {
                flag = false;
            }
            while (flag)
            {
                if ((double)vector2_4.Length() < (double)num1 + 1.0)
                {
                    flag = false;
                }
                else
                {
                    Vector2 vector2_1 = vector2_4;
                    vector2_1.Normalize();
                    position += vector2_1 * num1;
                    vector2_4 = playerCenter - position;
                    Color color2 = Lighting.GetColor((int)position.X / 16, (int)((double)position.Y / 16.0));
                    color2 = projectile.GetAlpha(color2);
                    Main.spriteBatch.Draw(texture, position - Main.screenPosition, sourceRectangle, color2, rotation, origin, projectile.scale, SpriteEffects.None, 0.0f);
                }
            }
            Texture2D     tex     = Main.projectileTexture[projectile.type];
            SpriteEffects effects = SpriteEffects.None;

            if (projectile.spriteDirection == -1)
            {
                effects = SpriteEffects.FlipHorizontally;
            }
            Color color = Lighting.GetColor((int)(projectile.Center.X / 16), (int)(projectile.Center.Y / 16.0));

            spriteBatch.Draw(tex, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Rectangle?(new Rectangle(0, 0, tex.Width, tex.Height)), color, projectile.rotation, new Vector2(tex.Width / 2, tex.Height / 2), projectile.scale, effects, 0f);
            return(false);
        }
Beispiel #23
0
        public override bool PreDraw(SpriteBatch sb, Color drawColor)
        {
            if (ai_state <= SerrisState.Transforming)
            {
                Texture2D texHead     = mod.GetTexture("NPCs/Serris/Serris_Head"),
                          texJaw      = mod.GetTexture("NPCs/Serris/Serris_Jaw");
                Vector2 headOrig      = new Vector2(34, 31),
                        jawOrig1      = new Vector2(30, 11),
                        jawOrig2      = new Vector2(34, 1);
                int headHeight        = texHead.Height / 15,
                    jawHeight         = texJaw.Height / 5;
                SpriteEffects effects = SpriteEffects.None;
                if (npc.spriteDirection == -1)
                {
                    effects    = SpriteEffects.FlipVertically;
                    headOrig.Y = headHeight - headOrig.Y;
                    jawOrig1.Y = jawHeight - jawOrig1.Y;
                    jawOrig2.Y = jawHeight - jawOrig2.Y;
                }
                int frame = state - 1;
                if (state == 4)
                {
                    frame = sbFrame + 3;
                }

                sbFrameCounter++;
                if (sbFrameCounter > 5)
                {
                    sbFrame++;
                    sbFrameCounter = 0;
                }
                if (sbFrame > 1)
                {
                    sbFrame = 0;
                }

                float headRot = npc.rotation - 1.57f;

                Color   headColor = npc.GetAlpha(Lighting.GetColor((int)npc.Center.X / 16, (int)npc.Center.Y / 16));
                Vector2 jawOrig   = Vector2.Lerp(jawOrig1, jawOrig2, mouthFrame);
                int     jawFrame  = frame * jawHeight;
                sb.Draw(texJaw, npc.Center - Main.screenPosition, new Rectangle?(new Rectangle(0, jawFrame, texJaw.Width, jawHeight)),
                        headColor, headRot, jawOrig, 1f, effects, 0f);

                int headFrame = frame * (headHeight * 3);
                headFrame += headHeight * glowFrame;
                sb.Draw(texHead, npc.Center - Main.screenPosition, new Rectangle?(new Rectangle(0, headFrame, texHead.Width, headHeight)),
                        headColor, headRot, headOrig, 1f, effects, 0f);
            }
            else
            {
                Texture2D texCore  = mod.GetTexture("NPCs/Serris/SerrisCoreX"),
                          texShell = mod.GetTexture("NPCs/Serris/SerrisCoreX_Shell");
                int coreHeight     = texCore.Height / 8;
                int shellHeight    = texShell.Height / 4;

                coreFrameCounter++;
                if (coreFrameCounter > 5)
                {
                    coreFrame++;
                    coreFrameCounter = 0;
                }
                if (coreFrame >= 8)
                {
                    coreFrame = 0;
                }

                if (npc.localAI[1] == 2 || npc.localAI[3] > 0)
                {
                    flashFrameCounter++;
                    if (flashFrameCounter > 4)
                    {
                        flashFrame++;
                        flashFrameCounter = 0;
                    }
                    if (flashFrame > 1)
                    {
                        flashFrame = 0;
                    }
                }
                else
                {
                    flashFrame        = 0;
                    flashFrameCounter = 0;
                }

                int shellFrame = state - 5;
                if (flashFrame > 0)
                {
                    shellFrame = 3;
                }

                Color color = npc.GetAlpha(Lighting.GetColor((int)npc.Center.X / 16, (int)npc.Center.Y / 16));

                sb.Draw(texCore, npc.Center - Main.screenPosition, new Rectangle?(new Rectangle(0, coreHeight * coreFrame, texCore.Width, coreHeight)),
                        color, 0f, new Vector2(texCore.Width / 2, coreHeight / 2), 1f, SpriteEffects.None, 0f);

                sb.Draw(texShell, npc.Center - Main.screenPosition, new Rectangle?(new Rectangle(0, shellHeight * shellFrame, texShell.Width, shellHeight)),
                        color, 0f, new Vector2(texShell.Width / 2, shellHeight / 2), 1f, SpriteEffects.None, 0f);
            }

            return(false);
        }
Beispiel #24
0
        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            {
                SpriteEffects spriteEffects           = SpriteEffects.None;
                Microsoft.Xna.Framework.Color color25 = Lighting.GetColor((int)((double)projectile.position.X + (double)projectile.width * 0.5) / 16, (int)(((double)projectile.position.Y + (double)projectile.height * 0.5) / 16.0));
                Texture2D texture2D3 = Main.projectileTexture[projectile.type];
                int       num156     = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type];
                int       y3         = num156 * projectile.frame;
                Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle(0, y3, texture2D3.Width, num156);
                Vector2 origin2    = rectangle.Size() / 2f;
                int     arg_5ADA_0 = projectile.type;
                int     arg_5AE7_0 = projectile.type;
                int     arg_5AF4_0 = projectile.type;
                int     num157     = 8;
                int     num158     = 2;
                int     num159     = 1;
                float   value3     = 1f;
                float   num160     = 0f;

                {
                    //num157 = 3;
                    num158 = 1;
                    value3 = 8f;
                    //rectangle = new Microsoft.Xna.Framework.Rectangle(25 * projectile.frame, 0, 36, 14);
                    origin2 = rectangle.Size() / 2f;
                }


                int num161 = num159;
                while ((num158 > 0 && num161 < num157) || (num158 < 0 && num161 > num157))
                {
                    Microsoft.Xna.Framework.Color color26 = color25;
                    color26 = projectile.GetAlpha(color26);
                    {
                        goto IL_6899;
                    }

IL_6881:
                    num161 += num158;
                    continue;
IL_6899:
                    float num164 = (float)(num157 - num161);
                    if (num158 < 0)
                    {
                        num164 = (float)(num159 - num161);
                    }
                    color26 *= num164 / ((float)ProjectileID.Sets.TrailCacheLength[projectile.type] * 1.5f);
                    Vector2       value4  = projectile.oldPos[num161];
                    float         num165  = projectile.rotation;
                    SpriteEffects effects = spriteEffects;
                    if (ProjectileID.Sets.TrailingMode[projectile.type] == 2)
                    {
                        num165  = projectile.oldRot[num161];
                        effects = ((projectile.oldSpriteDirection[num161] == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None);
                    }
                    color26.A /= (byte)2;
                    Main.spriteBatch.Draw(texture2D3, value4 + projectile.Size / 2f - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), color26, num165 + projectile.rotation * num160 * (float)(num161 - 1) * -(float)spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), origin2, projectile.scale, effects, 0f);
                    goto IL_6881;
                }
            }

            {
                Texture2D texture2D3 = Main.projectileTexture[projectile.type];
                int       num156     = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type];
                int       y3         = num156 * projectile.frame;
                Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle(0, y3, texture2D3.Width, num156);
                Vector2 origin2 = rectangle.Size() / 2f;
                Main.spriteBatch.Draw(Main.projectileTexture[projectile.type], projectile.position + projectile.Size / 2f - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), Color.White, projectile.rotation, origin2, projectile.scale, SpriteEffects.None, 0f);
            }
            return(false);
        }
Beispiel #25
0
 private static void LoadLegacyHairdyes()
 {
     _ = Main.PixelShaderRef;
     GameShaders.Hair.BindShader(1977, new LegacyHairShaderData().UseLegacyMethod(delegate(Player player, Color newColor, ref bool lighting)
     {
         newColor.R = (byte)((float)player.statLife / (float)player.statLifeMax2 * 235f + 20f);
         newColor.B = 20;
         newColor.G = 20;
         return(newColor);
     }));
     GameShaders.Hair.BindShader(1978, new LegacyHairShaderData().UseLegacyMethod(delegate(Player player, Color newColor, ref bool lighting)
     {
         newColor.R = (byte)((1f - (float)player.statMana / (float)player.statManaMax2) * 200f + 50f);
         newColor.B = byte.MaxValue;
         newColor.G = (byte)((1f - (float)player.statMana / (float)player.statManaMax2) * 180f + 75f);
         return(newColor);
     }));
     GameShaders.Hair.BindShader(1979, new LegacyHairShaderData().UseLegacyMethod(delegate(Player player, Color newColor, ref bool lighting)
     {
         float num27    = (float)(Main.worldSurface * 0.45) * 16f;
         float num28    = (float)(Main.worldSurface + Main.rockLayer) * 8f;
         float num29    = (float)(Main.rockLayer + (double)Main.maxTilesY) * 8f;
         float num30    = (float)(Main.maxTilesY - 150) * 16f;
         Vector2 center = player.Center;
         if (center.Y < num27)
         {
             float num31 = center.Y / num27;
             float num32 = 1f - num31;
             newColor.R  = (byte)(116f * num32 + 28f * num31);
             newColor.G  = (byte)(160f * num32 + 216f * num31);
             newColor.B  = (byte)(249f * num32 + 94f * num31);
         }
         else if (center.Y < num28)
         {
             float num33 = num27;
             float num34 = (center.Y - num33) / (num28 - num33);
             float num35 = 1f - num34;
             newColor.R  = (byte)(28f * num35 + 151f * num34);
             newColor.G  = (byte)(216f * num35 + 107f * num34);
             newColor.B  = (byte)(94f * num35 + 75f * num34);
         }
         else if (center.Y < num29)
         {
             float num36 = num28;
             float num37 = (center.Y - num36) / (num29 - num36);
             float num38 = 1f - num37;
             newColor.R  = (byte)(151f * num38 + 128f * num37);
             newColor.G  = (byte)(107f * num38 + 128f * num37);
             newColor.B  = (byte)(75f * num38 + 128f * num37);
         }
         else if (center.Y < num30)
         {
             float num39 = num29;
             float num40 = (center.Y - num39) / (num30 - num39);
             float num41 = 1f - num40;
             newColor.R  = (byte)(128f * num41 + 255f * num40);
             newColor.G  = (byte)(128f * num41 + 50f * num40);
             newColor.B  = (byte)(128f * num41 + 15f * num40);
         }
         else
         {
             newColor.R = byte.MaxValue;
             newColor.G = 50;
             newColor.B = 10;
         }
         return(newColor);
     }));
     GameShaders.Hair.BindShader(1980, new LegacyHairShaderData().UseLegacyMethod(delegate(Player player, Color newColor, ref bool lighting)
     {
         int num15 = 0;
         for (int i = 0; i < 54; i++)
         {
             if (player.inventory[i].type == 71)
             {
                 num15 += player.inventory[i].stack;
             }
             if (player.inventory[i].type == 72)
             {
                 num15 += player.inventory[i].stack * 100;
             }
             if (player.inventory[i].type == 73)
             {
                 num15 += player.inventory[i].stack * 10000;
             }
             if (player.inventory[i].type == 74)
             {
                 num15 += player.inventory[i].stack * 1000000;
             }
         }
         float num16   = Item.buyPrice(0, 5);
         float num17   = Item.buyPrice(0, 50);
         float num18   = Item.buyPrice(2);
         Color color8  = new Color(226, 118, 76);
         Color color9  = new Color(174, 194, 196);
         Color color10 = new Color(204, 181, 72);
         Color color11 = new Color(161, 172, 173);
         if ((float)num15 < num16)
         {
             float num19 = (float)num15 / num16;
             float num20 = 1f - num19;
             newColor.R  = (byte)((float)(int)color8.R * num20 + (float)(int)color9.R * num19);
             newColor.G  = (byte)((float)(int)color8.G * num20 + (float)(int)color9.G * num19);
             newColor.B  = (byte)((float)(int)color8.B * num20 + (float)(int)color9.B * num19);
         }
         else if ((float)num15 < num17)
         {
             float num21 = num16;
             float num22 = ((float)num15 - num21) / (num17 - num21);
             float num23 = 1f - num22;
             newColor.R  = (byte)((float)(int)color9.R * num23 + (float)(int)color10.R * num22);
             newColor.G  = (byte)((float)(int)color9.G * num23 + (float)(int)color10.G * num22);
             newColor.B  = (byte)((float)(int)color9.B * num23 + (float)(int)color10.B * num22);
         }
         else if ((float)num15 < num18)
         {
             float num24 = num17;
             float num25 = ((float)num15 - num24) / (num18 - num24);
             float num26 = 1f - num25;
             newColor.R  = (byte)((float)(int)color10.R * num26 + (float)(int)color11.R * num25);
             newColor.G  = (byte)((float)(int)color10.G * num26 + (float)(int)color11.G * num25);
             newColor.B  = (byte)((float)(int)color10.B * num26 + (float)(int)color11.B * num25);
         }
         else
         {
             newColor = color11;
         }
         return(newColor);
     }));
     GameShaders.Hair.BindShader(1981, new LegacyHairShaderData().UseLegacyMethod(delegate(Player player, Color newColor, ref bool lighting)
     {
         Color color4 = new Color(1, 142, 255);
         Color color5 = new Color(255, 255, 0);
         Color color6 = new Color(211, 45, 127);
         Color color7 = new Color(67, 44, 118);
         if (Main.dayTime)
         {
             if (Main.time < 27000.0)
             {
                 float num5 = (float)(Main.time / 27000.0);
                 float num6 = 1f - num5;
                 newColor.R = (byte)((float)(int)color4.R * num6 + (float)(int)color5.R * num5);
                 newColor.G = (byte)((float)(int)color4.G * num6 + (float)(int)color5.G * num5);
                 newColor.B = (byte)((float)(int)color4.B * num6 + (float)(int)color5.B * num5);
             }
             else
             {
                 float num7 = 27000f;
                 float num8 = (float)((Main.time - (double)num7) / (54000.0 - (double)num7));
                 float num9 = 1f - num8;
                 newColor.R = (byte)((float)(int)color5.R * num9 + (float)(int)color6.R * num8);
                 newColor.G = (byte)((float)(int)color5.G * num9 + (float)(int)color6.G * num8);
                 newColor.B = (byte)((float)(int)color5.B * num9 + (float)(int)color6.B * num8);
             }
         }
         else if (Main.time < 16200.0)
         {
             float num10 = (float)(Main.time / 16200.0);
             float num11 = 1f - num10;
             newColor.R  = (byte)((float)(int)color6.R * num11 + (float)(int)color7.R * num10);
             newColor.G  = (byte)((float)(int)color6.G * num11 + (float)(int)color7.G * num10);
             newColor.B  = (byte)((float)(int)color6.B * num11 + (float)(int)color7.B * num10);
         }
         else
         {
             float num12 = 16200f;
             float num13 = (float)((Main.time - (double)num12) / (32400.0 - (double)num12));
             float num14 = 1f - num13;
             newColor.R  = (byte)((float)(int)color7.R * num14 + (float)(int)color4.R * num13);
             newColor.G  = (byte)((float)(int)color7.G * num14 + (float)(int)color4.G * num13);
             newColor.B  = (byte)((float)(int)color7.B * num14 + (float)(int)color4.B * num13);
         }
         return(newColor);
     }));
     GameShaders.Hair.BindShader(1982, new LegacyHairShaderData().UseLegacyMethod(delegate(Player player, Color newColor, ref bool lighting)
     {
         if (player.team >= 0 && player.team < Main.teamColor.Length)
         {
             newColor = Main.teamColor[player.team];
         }
         return(newColor);
     }));
     GameShaders.Hair.BindShader(1983, new LegacyHairShaderData().UseLegacyMethod(delegate(Player player, Color newColor, ref bool lighting)
     {
         Color color2 = default(Color);
         color2       = ((Main.waterStyle == 2) ? new Color(124, 118, 242) : ((Main.waterStyle == 3) ? new Color(143, 215, 29) : ((Main.waterStyle == 4) ? new Color(78, 193, 227) : ((Main.waterStyle == 5) ? new Color(189, 231, 255) : ((Main.waterStyle == 6) ? new Color(230, 219, 100) : ((Main.waterStyle == 7) ? new Color(151, 107, 75) : ((Main.waterStyle == 8) ? new Color(128, 128, 128) : ((Main.waterStyle == 9) ? new Color(200, 0, 0) : ((Main.waterStyle == 10) ? new Color(208, 80, 80) : ((Main.waterStyle == 12) ? new Color(230, 219, 100) : new Color(28, 216, 94)))))))))));
         Color color3 = player.hairDyeColor;
         if (color3.A == 0)
         {
             color3 = color2;
         }
         if (color3.R > color2.R)
         {
             color3.R--;
         }
         if (color3.R < color2.R)
         {
             color3.R++;
         }
         if (color3.G > color2.G)
         {
             color3.G--;
         }
         if (color3.G < color2.G)
         {
             color3.G++;
         }
         if (color3.B > color2.B)
         {
             color3.B--;
         }
         if (color3.B < color2.B)
         {
             color3.B++;
         }
         newColor = color3;
         return(newColor);
     }));
     GameShaders.Hair.BindShader(1984, new LegacyHairShaderData().UseLegacyMethod(delegate(Player player, Color newColor, ref bool lighting)
     {
         newColor = new Color(244, 22, 175);
         return(newColor);
     }));
     GameShaders.Hair.BindShader(1985, new LegacyHairShaderData().UseLegacyMethod(delegate(Player player, Color newColor, ref bool lighting)
     {
         newColor = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB);
         return(newColor);
     }));
     GameShaders.Hair.BindShader(1986, new LegacyHairShaderData().UseLegacyMethod(delegate(Player player, Color newColor, ref bool lighting)
     {
         float num  = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y);
         float num2 = 10f;
         if (num > num2)
         {
             num = num2;
         }
         float num3 = num / num2;
         float num4 = 1f - num3;
         newColor.R = (byte)(75f * num3 + (float)(int)player.hairColor.R * num4);
         newColor.G = (byte)(255f * num3 + (float)(int)player.hairColor.G * num4);
         newColor.B = (byte)(200f * num3 + (float)(int)player.hairColor.B * num4);
         return(newColor);
     }));
     GameShaders.Hair.BindShader(2863, new LegacyHairShaderData().UseLegacyMethod(delegate(Player player, Color newColor, ref bool lighting)
     {
         lighting    = false;
         int x       = (int)((double)player.position.X + (double)player.width * 0.5) / 16;
         int y       = (int)(((double)player.position.Y + (double)player.height * 0.25) / 16.0);
         Color color = Lighting.GetColor(x, y);
         newColor.R  = (byte)(color.R + newColor.R >> 1);
         newColor.G  = (byte)(color.G + newColor.G >> 1);
         newColor.B  = (byte)(color.B + newColor.B >> 1);
         return(newColor);
     }));
 }
Beispiel #26
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);
        }
Beispiel #27
0
        // chain voodoo
        public override bool PreDraw(ref Color lightColor)
        {
            Texture2D texture = ModContent.Request <Texture2D>("FargowiltasSouls/Projectiles/BossWeapons/MechFlailChain", ReLogic.Content.AssetRequestMode.ImmediateLoad).Value;

            Vector2   position        = Projectile.Center;
            Vector2   mountedCenter   = Main.player[Projectile.owner].MountedCenter;
            Rectangle?sourceRectangle = new Rectangle?();
            Vector2   origin          = new Vector2(texture.Width * 0.5f, texture.Height * 0.5f);
            float     num1            = texture.Height;
            Vector2   vector24        = mountedCenter - position;
            float     rotation        = (float)Math.Atan2(vector24.Y, vector24.X) - 1.57f;
            bool      flag            = true;

            if (float.IsNaN(position.X) && float.IsNaN(position.Y))
            {
                flag = false;
            }
            if (float.IsNaN(vector24.X) && float.IsNaN(vector24.Y))
            {
                flag = false;
            }
            while (flag)
            {
                if (vector24.Length() < num1 + 1.0)
                {
                    flag = false;
                }
                else
                {
                    Vector2 vector21 = vector24;
                    vector21.Normalize();
                    position += vector21 * num1;
                    vector24  = mountedCenter - position;
                    Color color2 = Lighting.GetColor((int)position.X / 16, (int)(position.Y / 16.0));
                    color2 = Projectile.GetAlpha(color2);
                    Main.EntitySpriteDraw(texture, position - Main.screenPosition, sourceRectangle, color2, rotation, origin, 1f, SpriteEffects.None, 0);
                }
            }


            Texture2D texture2D13 = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value;
            int       num156      = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value.Height / Main.projFrames[Projectile.type]; //ypos of lower right corner of sprite to draw
            int       y3          = num156 * Projectile.frame;                                                                                      //ypos of upper left corner of sprite to draw
            Rectangle rectangle   = new Rectangle(0, y3, texture2D13.Width, num156);
            Vector2   origin2     = rectangle.Size() / 2f;

            Color color26 = lightColor;

            color26 = Projectile.GetAlpha(color26);

            SpriteEffects effects = SpriteEffects.None;

            for (float i = 0; i < ProjectileID.Sets.TrailCacheLength[Projectile.type]; i += 0.5f)
            {
                Color color27 = color26 * Projectile.Opacity * 0.75f * 0.5f;
                color27 *= (float)(ProjectileID.Sets.TrailCacheLength[Projectile.type] - i) / ProjectileID.Sets.TrailCacheLength[Projectile.type];
                int max0 = (int)i - 1;//Math.Max((int)i - 1, 0);
                if (max0 < 0)
                {
                    continue;
                }
                Vector2 value4 = Vector2.Lerp(Projectile.oldPos[(int)i], Projectile.oldPos[max0], 1 - i % 1);
                float   num165 = MathHelper.Lerp(Projectile.oldRot[(int)i], Projectile.oldRot[max0], 1 - i % 1);
                Main.EntitySpriteDraw(texture2D13, value4 + Projectile.Size / 2f - Main.screenPosition + new Vector2(0, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), color27, num165, origin2, Projectile.scale, effects, 0);
            }

            Main.EntitySpriteDraw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), Projectile.GetAlpha(lightColor), Projectile.rotation, origin2, Projectile.scale, effects, 0);
            return(false);
        }
        public override bool PreDraw(int i, int j, SpriteBatch spriteBatch)
        {
            //Only draw behind if this is the top-left tile.  Otherwise, the things start drawing on top of other tiles
            if (MiscUtils.TryGetTileEntity(new Point16(i, j), out FluidTankEntity entity))
            {
                float curLiquidRatio = entity.LiquidEntries[0].current / entity.LiquidEntries[0].max;
                float curGasRatio    = entity.GasEntries[0].current / entity.GasEntries[0].max;

                Vector2 offset = MiscUtils.GetLightingDrawOffset();

                Vector2 drawPos = entity.Position.ToVector2() * 16 - Main.screenPosition + offset;

                int liquidOffsetX = 6;
                int liquidOffsetY = 6;
                int liquidHeight  = 52;

                Rectangle liquidRect = new Rectangle(liquidOffsetX, (int)(liquidOffsetY + liquidHeight * (1f - curLiquidRatio)), 14, (int)(liquidHeight * curLiquidRatio));

                if (curLiquidRatio > 0 && entity.LiquidEntries[0].id != MachineLiquidID.None)
                {
                    spriteBatch.Draw(this.GetEffectTexture("liquid"), drawPos + new Vector2(liquidRect.X, liquidRect.Y), liquidRect, MiscUtils.MixLightColors(Lighting.GetColor(i, j), Capsule.GetBackColor(entity.LiquidEntries[0].id)));
                }

                if (curGasRatio > 0 && entity.GasEntries[0].id != MachineGasID.None)
                {
                    spriteBatch.Draw(this.GetEffectTexture("gas"), drawPos, null, MiscUtils.MixLightColors(Lighting.GetColor(i, j), Capsule.GetBackColor(entity.GasEntries[0].id)) * (0.65f * curGasRatio));
                }
            }

            return(true);
        }
Beispiel #29
0
 public override Color getLineColor(Vector2 value)
 {
     return(Lighting.GetColor((int)value.X / 16, (int)(value.Y / 16f), new Color(50, 50, 50, 100)));
 }
Beispiel #30
0
        public static void DrawStatueExtras(int i, int j)
        {
            Tile tile = Framing.GetTileSafely(i, j);

            if (tile.frameY == 0)
            {
                switch (tile.frameX)
                {
                case 144:
                    DrawingHelper.TileDraw(ModContent.GetTexture(statueExtrasPath), i, j - 1, new Rectangle(0, 0, 32, 16), Lighting.GetColor(i, j - 1), default, Vector2.Zero);
                    break;

                case 180:
                    DrawingHelper.TileDraw(ModContent.GetTexture(statueExtrasPath), i, j - 1, new Rectangle(0, 0, 32, 16), Lighting.GetColor(i, j - 1), default, Vector2.Zero, 1f, SpriteEffects.FlipHorizontally);
                    break;

                case 216:
                    DrawingHelper.TileDraw(ModContent.GetTexture(statueExtrasPath), i, j + 1, new Rectangle(0, 16, 32, 16), Lighting.GetColor(i, j + 1), -MathHelper.PiOver2, Vector2.Zero, 1f, default, default, new Vector2(-16, 16));
                    DrawingHelper.TileDraw(ModContent.GetTexture(statueExtrasPath), i, j - 1, new Rectangle(0, 32, 32, 16), Lighting.GetColor(i, j - 1), default, Vector2.Zero);
                    break;

                case 252:
                    DrawingHelper.TileDraw(ModContent.GetTexture(statueExtrasPath), i, j + 1, new Rectangle(0, 16, 32, 16), Lighting.GetColor(i, j + 1), -MathHelper.PiOver2, Vector2.Zero, 1f, SpriteEffects.FlipVertically, default, new Vector2(32, 16));
                    DrawingHelper.TileDraw(ModContent.GetTexture(statueExtrasPath), i, j - 1, new Rectangle(0, 32, 32, 16), Lighting.GetColor(i, j - 1), default, Vector2.Zero, 1f, SpriteEffects.FlipHorizontally);
                    break;

                case 288:
                    DrawingHelper.TileDraw(ModContent.GetTexture(statueExtrasPath), i, j - 1, new Rectangle(0, 48, 32, 16), Lighting.GetColor(i, j - 1), default, Vector2.Zero);
                    break;

                case 324:
                    DrawingHelper.TileDraw(ModContent.GetTexture(statueExtrasPath), i, j - 1, new Rectangle(0, 48, 32, 16), Lighting.GetColor(i, j - 1), default, Vector2.Zero, 1f, SpriteEffects.FlipHorizontally);
                    break;

                case 576:
                    DrawingHelper.TileDraw(ModContent.GetTexture(statueExtrasPath), i, j + 1, new Rectangle(0, 880, 32, 16), Lighting.GetColor(i, j + 1), MathHelper.PiOver2, Vector2.Zero, 1f, SpriteEffects.None, default, new Vector2(-16, 16));
                    DrawingHelper.TileDraw(ModContent.GetTexture(statueExtrasPath), i, j - 1, new Rectangle(0, 864, 32, 16), Lighting.GetColor(i, j - 1), default, Vector2.Zero);
                    break;

                case 612:
                    DrawingHelper.TileDraw(ModContent.GetTexture(statueExtrasPath), i, j + 1, new Rectangle(0, 880, 32, 16), Lighting.GetColor(i, j + 1), MathHelper.PiOver2, Vector2.Zero, 1f, SpriteEffects.FlipHorizontally, default, new Vector2(32, 0));
                    DrawingHelper.TileDraw(ModContent.GetTexture(statueExtrasPath), i, j - 1, new Rectangle(0, 864, 32, 16), Lighting.GetColor(i, j - 1), default, Vector2.Zero, 1f, SpriteEffects.FlipHorizontally);
                    break;
                }
            }
        }