Ejemplo n.º 1
0
        public static void DrawToRenderTarget()
        {
            if (Main.dedServ || shadowParticlesDrawTime < 1)
            {
                return;
            }

            RenderTargetBinding[] binds = Main.graphics.GraphicsDevice.GetRenderTargets();


            //Draw additive white particles

            Main.graphics.GraphicsDevice.SetRenderTarget(shadowSurface);
            Main.graphics.GraphicsDevice.Clear(Color.Transparent);

            //Main.spriteBatch.End();
            Main.spriteBatch.Begin(SpriteSortMode.Texture, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.GameViewMatrix.TransformationMatrix);

            //Gains a different look when the Hellion Core spawns it
            int fogtype = NPC.CountNPCS(ModContent.NPCType <HellionCore>()) > 0 ? 0 : 1;

            Color fogTo      = Color.DarkMagenta;
            Color fogFrom    = Color.Black;
            float edging     = 0.10f;
            int   smokecount = fogtype == 0 ? 16 : 32;


            foreach (ShadowParticle particle in particles)
            {
                Vector2 size  = particle.CloudTexture.Size();
                float   alpha = (float)Math.Sin((particle.timeLeft / (float)particle.maxTimeLeft) * MathHelper.Pi);
                Main.spriteBatch.Draw(particle.CloudTexture, (particle.position - Main.screenPosition) / 2f, null, Color.White * MathHelper.Clamp(alpha * particle.alpha * particle.fadePercent, 0f, 1f), particle.rotation, size / 2f, particle.scale / 2f, SpriteEffects.None, 0f);
            }

            Main.spriteBatch.End();

            //Now, draw the interior effect using the above as texture mask

            Main.graphics.GraphicsDevice.SetRenderTarget(shadowSurfaceShaderApplied);
            Main.graphics.GraphicsDevice.Clear(Color.Transparent);

            //Main.spriteBatch.End();
            Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Matrix.Identity);

            ShadowEffect.Parameters["overlayTexture"].SetValue(shadowSurface);
            ShadowEffect.Parameters["colorAmmount"].SetValue(smokecount);
            ShadowEffect.Parameters["screenSize"].SetValue(shadowSurface.Size());
            //Color.DarkMagenta
            //Color.Black
            ShadowEffect.Parameters["colorFrom"].SetValue((fogTo).ToVector4() * (fogtype == 0 ? 1f : 0.01f));
            ShadowEffect.Parameters["colorTo"].SetValue((fogFrom).ToVector4() * 1f);
            ShadowEffect.Parameters["colorOutline"].SetValue((Color.Transparent).ToVector4() * 1f);

            ShadowEffect.Parameters["edgeSmooth"].SetValue(edging);
            ShadowEffect.Parameters["noiseTexture"].SetValue(shadowHellion);
            ShadowEffect.Parameters["invertLuma"].SetValue(false);
            ShadowEffect.Parameters["alpha"].SetValue(1f);


            //Show through
            float percent = 1f;

            ShadowEffect.Parameters["noisePercent"].SetValue(percent);
            ShadowEffect.Parameters["noiseScalar"].SetValue(new Vector4(0, 0, 1f, 1f));

            ShadowEffect.CurrentTechnique.Passes["ColorFilter"].Apply();

            Main.graphics.GraphicsDevice.SamplerStates[1] = SamplerState.PointClamp;
            Main.spriteBatch.Draw(shadowSurface, Vector2.Zero, new Rectangle(0, 0, Main.screenWidth / 2, Main.screenHeight / 2), Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0f);

            Main.spriteBatch.End();

            if (percent > 0)
            {
                Main.graphics.GraphicsDevice.SetRenderTarget(shadowHellion);
                Main.graphics.GraphicsDevice.Clear(Color.Transparent);

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

                Vector2 parallex = new Vector2(0, 0);

                Effect effect = SGAmod.TrailEffect;

                Terraria.Utilities.UnifiedRandom rando = new Terraria.Utilities.UnifiedRandom(1);

                float timer = rando.NextFloat(MathHelper.TwoPi);

                for (int i = 0; i < 12; i += 1)
                {
                    //Used to pulse in and out, didn't think it was needed in the end thou
                    float alpha = 1f * starAlpha;
                    #region oldcode
                    // MathHelper.Clamp(0.40f + (float)Math.Sin(((SGAWorld.modtimer / 35f) + rando.NextFloat(MathHelper.TwoPi)) * rando.NextFloat(0.25f, 0.75f))*0.80f, 0f, 1f);
                    //if (alpha <= 0 && i > 0)
                    //    continue;
                    #endregion

                    Matrix rotation  = Matrix.CreateRotationZ(timer);
                    Matrix rotation2 = Matrix.CreateRotationZ((-timer));
                    Matrix rotation3 = Matrix.CreateRotationZ((timer - MathHelper.Pi));

                    Matrix rotationOffset = Matrix.CreateTranslation(-shadowSurface.Width / 2, -shadowSurface.Height / 2, 0) * Matrix.CreateScale(3, 3f, 1f) * rotation * Matrix.CreateTranslation(shadowSurface.Width / 2, shadowSurface.Height / 2, 0);

                    if (i > 0)
                    {
                        Vector2 pos2            = ((Main.screenPosition / ((8000f + (i * 4000f))) * 1f) + new Vector2(rando.NextFloat(1f), rando.NextFloat(1f)));
                        Vector2 pos             = -Vector2.One + new Vector2(pos2.X % 1f, pos2.Y % 1f) * 2f;
                        Matrix  rotationOffset2 = Matrix.CreateTranslation(pos.X, pos.Y, 0) * rotation2;
                        parallex = Vector2.Transform(Vector2.One / 2f, rotationOffset2);
                    }
                    if (fogtype == 1)
                    {
                        effect.Parameters["rainbowCoordOffset"].SetValue(new Vector2(rando.NextFloat(1f), rando.NextFloat(1f)));
                        effect.Parameters["rainbowCoordMultiplier"].SetValue(new Vector2(1f, 1f));
                        effect.Parameters["rainbowColor"].SetValue(new Vector3(SGAWorld.modtimer / 300f, 1f, 0.75f));
                        effect.Parameters["rainbowScale"].SetValue(1f);
                        effect.Parameters["rainbowTexture"].SetValue(SGAmod.Instance.GetTexture("TiledPerlin"));
                    }

                    effect.Parameters["WorldViewProjection"].SetValue(WVP.View(Vector2.One) * WVP.Projection());
                    effect.Parameters["imageTexture"].SetValue(i < 1 ? SGAmod.Instance.GetTexture("TiledPerlin") : SGAmod.Instance.GetTexture("Space"));
                    effect.Parameters["coordOffset"].SetValue(parallex);
                    effect.Parameters["coordMultiplier"].SetValue(i < 1 ? new Vector2(2f, 1.5f) * 3f : (new Vector2(3f, 2f) + new Vector2(rando.NextFloat(-0.5f, 0.5f), rando.NextFloat(-0.5f, 0.5f))) * 3f);
                    effect.Parameters["strength"].SetValue(i == 0 ? 0.50f : (1.75f * alpha) / (1f + (i / 4f)));

                    VertexPositionColorTexture[] vertices = new VertexPositionColorTexture[6];
                    VertexBuffer vertexBuffer;

                    Vector3 screenPos = new Vector3(-16, 0, 0);

                    Color colorsa = fogtype == 0 ? Color.Lerp(fogFrom, fogTo, 0.50f) : Color.White;

                    if (i > 0)
                    {
                        colorsa = fogtype == 0 ? Color.Lerp(fogTo, fogFrom, (float)i / 16f) : Color.White * (1f - ((float)i / 48f));
                    }

                    vertices[0] = new VertexPositionColorTexture(Vector3.Transform(screenPos + new Vector3(-16, -16, 0), rotationOffset), colorsa, new Vector2(0, 0));
                    vertices[1] = new VertexPositionColorTexture(Vector3.Transform(screenPos + new Vector3(-16, Main.screenHeight + 16, 0), rotationOffset), colorsa, new Vector2(0, 1));
                    vertices[2] = new VertexPositionColorTexture(Vector3.Transform(screenPos + new Vector3(Main.screenWidth + 16, -16, 0), rotationOffset), colorsa, new Vector2(1, 0));

                    vertices[3] = new VertexPositionColorTexture(Vector3.Transform(screenPos + new Vector3(Main.screenWidth + 16, Main.screenHeight + 16, 0), rotationOffset), colorsa, new Vector2(1, 1));
                    vertices[4] = new VertexPositionColorTexture(Vector3.Transform(screenPos + new Vector3(-16, Main.screenHeight + 16, 0), rotationOffset), colorsa, new Vector2(0, 1));
                    vertices[5] = new VertexPositionColorTexture(Vector3.Transform(screenPos + new Vector3(Main.screenWidth + 16, -16, 0), rotationOffset), colorsa, new Vector2(1, 0));

                    vertexBuffer = new VertexBuffer(Main.graphics.GraphicsDevice, typeof(VertexPositionColorTexture), vertices.Length, BufferUsage.WriteOnly);
                    vertexBuffer.SetData <VertexPositionColorTexture>(vertices);

                    Main.graphics.GraphicsDevice.SetVertexBuffer(vertexBuffer);

                    RasterizerState rasterizerState = new RasterizerState();
                    rasterizerState.CullMode = CullMode.None;
                    Main.graphics.GraphicsDevice.RasterizerState = rasterizerState;

                    effect.CurrentTechnique.Passes[i < 1 ? (fogtype == 1 ? "RainbowEffectPass" : "BasicEffectPass") : (fogtype == 1 ? "RainbowEffectAlphaPass" : "BasicEffectAlphaPass")].Apply();
                    Main.graphics.GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, 2);
                }


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

                //originally, the worms were drawn INSIDE the rendertarget, but this has since been changed
                #region oldcode

                /*foreach(NPC hellionarm in Main.npc.Where(testby => testby.active && (testby.type == ModContent.NPCType<HellionCore>() || testby.type == ModContent.NPCType<HellionMonolog>())))
                 * {
                 *  Hellion.HellionTeleport(Main.spriteBatch, (Main.screenPosition+hellionarm.Center)/2f, 0.5f, 48);
                 *  //((HellionWorm)(hellionarm.modNPC as HellionWorm)).DrawMe(Main.spriteBatch,Color.White,0.5f);
                 * }*/

                //Main.spriteBatch.Draw(hellionTex, -reallyHellion.velocity + new Vector2(0, 10) + (reallyHellion.Center - Main.screenPosition) / 2f, null, Color.White * (settings != null ? settings.HelliontransparencyRate : 0.15f), 0, hellionTex.Size() / 2f, 0.50f, SpriteEffects.None, 0f);
                #endregion

                Main.spriteBatch.End();
            }

            Main.graphics.GraphicsDevice.SetRenderTargets(binds);
        }
        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            if (master != null)
            {
                float angle2 = master.rotation + projectile.velocity.ToRotation();
                angle2 -= master.direction * 0.1f;
                Vector2 vector2 = new Vector2((float)Math.Cos(angle2), (float)Math.Sin(angle2));
                Vector2 center2 = master.Center + vector2 * (projectile.ai[0]);                //+Math.Min(48,projectile.ai[0]/1.75f));

                Vector2 goto2  = center2;
                Vector2 prev2  = goto2;
                Vector2 point  = center2;
                Vector2 anglex = Vector2.Normalize(master.Center - center2).RotatedBy(MathHelper.Pi / 2f);
                float   length = (master.Center - center2).Length();
                float   div2   = 1f * (float)(length / 60f);
                float   div    = 1f / (float)(length / 80f);

                VertexBuffer vertexBuffer;

                basicEffect.World              = WVP.World();
                basicEffect.View               = WVP.View(Main.GameViewMatrix.Zoom);
                basicEffect.Projection         = WVP.Projection();
                basicEffect.VertexColorEnabled = true;
                basicEffect.TextureEnabled     = true;
                basicEffect.Texture            = Main.extraTexture[21];


                int totalcount = 3 + (int)div2;

                VertexPositionColorTexture[] vertices = new VertexPositionColorTexture[((totalcount + 1) * 6)];

                Vector3[] prevcoords = { Vector3.One, Vector3.One };

                for (int k = 1; k < totalcount + 1; k += 1)
                {
                    float fraction     = (float)k / (float)totalcount;
                    float fractionPlus = (float)(k + 1d) / (float)totalcount;
                    point = Vector2.Lerp(center2, master.Center, fraction);

                    float scaler = (float)Math.Sin(fraction * Math.PI);
                    float timer1 = (float)Math.Sin(Main.GlobalTime * 17f + (fraction * 24f * div)) * (scaler * 8);
                    float timer2 = (float)Math.Sin(Main.GlobalTime * 6f + (fraction * 78f * div)) * (scaler * 30);

                    //timer2 *= projectile.ai[0] / 300f;

                    goto2 = point + (anglex * (timer1 + timer2)) * Math.Min(length / 300f, 1f) * (k > 0 ? 1f : 0f);

                    if (k >= totalcount)
                    {
                        goto2 = master.Center;
                    }

                    //You want prims, you get prims!

                    Vector2 normal = Vector2.Normalize(goto2 - prev2);
                    Vector3 left   = (normal.RotatedBy(MathHelper.Pi / 2f) * (6)).ToVector3();
                    Vector3 right  = (normal.RotatedBy(-MathHelper.Pi / 2f) * (6)).ToVector3();

                    Vector3 drawtop    = (goto2 + new Vector2(k * 0, 0) - Main.screenPosition).ToVector3();
                    Vector3 drawbottom = (prev2 + new Vector2(k * 0, 0) - Main.screenPosition).ToVector3();

                    if (prevcoords[0] == Vector3.One)
                    {
                        prevcoords = new Vector3[2] {
                            drawbottom + left, drawbottom + right
                        };
                    }

                    float timer = Main.GlobalTime / 99f;

                    Color color  = Color.Lerp(Color.Magenta, Color.MediumAquamarine, fraction);
                    Color color2 = Color.Lerp(Color.Magenta, Color.MediumAquamarine, fractionPlus);

                    vertices[0 + (k * 6)] = new VertexPositionColorTexture(prevcoords[0], color, new Vector2(0, 1));
                    vertices[1 + (k * 6)] = new VertexPositionColorTexture(drawtop + right, color2, new Vector2(1, 0));
                    vertices[2 + (k * 6)] = new VertexPositionColorTexture(drawtop + left, color2, new Vector2(0, 0));

                    vertices[3 + (k * 6)] = new VertexPositionColorTexture(prevcoords[0], color, new Vector2(0, 1));
                    vertices[4 + (k * 6)] = new VertexPositionColorTexture(prevcoords[1], color, new Vector2(1, 1));
                    vertices[5 + (k * 6)] = new VertexPositionColorTexture(drawtop + right, color2, new Vector2(1, 0));

                    prevcoords = new Vector3[2] {
                        drawtop + left, drawtop + right
                    };

                    //Idglib.DrawTether(SGAmod.ExtraTextures[21], prev2, goto2, 1f, 0.25f, 1f, Color.Magenta);

                    prev2 = goto2;
                }

                vertexBuffer = new VertexBuffer(Main.graphics.GraphicsDevice, typeof(VertexPositionColorTexture), vertices.Length, BufferUsage.WriteOnly);
                vertexBuffer.SetData <VertexPositionColorTexture>(vertices);

                Main.graphics.GraphicsDevice.SetVertexBuffer(vertexBuffer);

                RasterizerState rasterizerState = new RasterizerState();
                rasterizerState.CullMode = CullMode.None;
                Main.graphics.GraphicsDevice.RasterizerState = rasterizerState;

                foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
                {
                    pass.Apply();
                    Main.graphics.GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, ((totalcount + 1) * 2));
                }

                for (float i = 0; i < 8; i += 0.5f)
                {
                    float     angle  = master.rotation + projectile.velocity.ToRotation() + ((-MathHelper.Pi / 40f) * (float)i) * master.direction;
                    Vector2   vector = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle));
                    Vector2   center = master.Center + vector * projectile.ai[0];
                    Texture2D tex    = Main.projectileTexture[projectile.type];
                    spriteBatch.Draw(tex, center - Main.screenPosition, null, lightColor * (1f - (i / 8f)), angle, new Vector2(14, master.direction < 0 ? 14 : tex.Height - 14), projectile.scale, master.direction < 0 ? SpriteEffects.FlipVertically : SpriteEffects.None, 0f);
                }
            }
            return(false);
        }
Ejemplo n.º 3
0
        public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
        {
            /*basicEffect.World = WVP.World();
             * basicEffect.View = WVP.View(Main.GameViewMatrix.Zoom);
             * basicEffect.Projection = WVP.Projection();
             * basicEffect.VertexColorEnabled = true;
             * basicEffect.TextureEnabled = true;
             * basicEffect.Texture = SGAmod.ExtraTextures[21];*/

            Main.spriteBatch.End();
            Main.spriteBatch.Begin(SpriteSortMode.Texture, BlendState.AlphaBlend, SamplerState.AnisotropicClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Matrix.Identity);

            spriteBatch.Draw(Main.blackTileTexture, Vector2.Zero, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.Black, 0, Vector2.Zero, 1f, SpriteEffects.None, 0f);

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

            VertexBuffer vertexBuffer;
            Vector2      parallex = new Vector2(Main.screenPosition.X / 9000f, -Main.GlobalTime * 0.1f);
            Color        skycolor = Color.Red * 0.75f;

            effect.Parameters["WorldViewProjection"].SetValue(WVP.View(Main.GameViewMatrix.Zoom) * WVP.Projection());
            effect.Parameters["imageTexture"].SetValue(SGAmod.Instance.GetTexture("Space"));
            effect.Parameters["coordOffset"].SetValue(parallex);
            effect.Parameters["coordMultiplier"].SetValue(4f);
            effect.Parameters["strength"].SetValue(1f);

            VertexPositionColorTexture[] vertices = new VertexPositionColorTexture[12];

            Vector3 screenPos = new Vector3(-16, 0, 0);
            float   skymove   = ((Math.Max(Main.screenPosition.Y - 8000, 0)) / (Main.maxTilesY * 16f));

            Vector3 screenPosParallex = screenPos + new Vector3(0, -Main.screenHeight * (skymove) / 2f, 0);

            vertices[0] = new VertexPositionColorTexture(screenPos + new Vector3(-16, 0, 0), Color.Black, new Vector2(0, 0));
            vertices[1] = new VertexPositionColorTexture(screenPos + new Vector3(-16, Main.screenHeight, 0), Color.Black, new Vector2(0, 0));
            vertices[2] = new VertexPositionColorTexture(screenPos + new Vector3(Main.screenWidth + 16, 0, 0), Color.Black, new Vector2(0, 0));

            vertices[3] = new VertexPositionColorTexture(screenPos + new Vector3(Main.screenWidth + 16, Main.screenHeight, 0), Color.Black, new Vector2(0, 0));
            vertices[4] = new VertexPositionColorTexture(screenPos + new Vector3(-16, Main.screenHeight, 0), Color.Black, new Vector2(0, 0));
            vertices[5] = new VertexPositionColorTexture(screenPos + new Vector3(Main.screenWidth + 16, 0, 0), Color.Black, new Vector2(0, 0));

            vertices[6] = new VertexPositionColorTexture(screenPosParallex + new Vector3(-16, 0, 0), skycolor, new Vector2(0, 0));
            vertices[7] = new VertexPositionColorTexture(screenPosParallex + new Vector3(-16, Main.screenHeight / 2f, 0), Color.Transparent, new Vector2(0, 0.5f));
            vertices[8] = new VertexPositionColorTexture(screenPosParallex + new Vector3(Main.screenWidth + 16, 0, 0), skycolor, new Vector2(1, 0));

            vertices[9]  = new VertexPositionColorTexture(screenPosParallex + new Vector3(Main.screenWidth + 16, Main.screenHeight / 2f, 0), Color.Transparent, new Vector2(1, 0.5f));
            vertices[10] = new VertexPositionColorTexture(screenPosParallex + new Vector3(-16, Main.screenHeight / 2f, 0), Color.Transparent, new Vector2(0, 0.5f));
            vertices[11] = new VertexPositionColorTexture(screenPosParallex + new Vector3(Main.screenWidth + 16, 0, 0), skycolor, new Vector2(1, 0));


            vertexBuffer = new VertexBuffer(Main.graphics.GraphicsDevice, typeof(VertexPositionColorTexture), vertices.Length, BufferUsage.WriteOnly);
            vertexBuffer.SetData <VertexPositionColorTexture>(vertices);

            Main.graphics.GraphicsDevice.SetVertexBuffer(vertexBuffer);

            RasterizerState rasterizerState = new RasterizerState();

            rasterizerState.CullMode = CullMode.None;
            Main.graphics.GraphicsDevice.RasterizerState = rasterizerState;

            effect.CurrentTechnique.Passes["BasicEffectPass"].Apply();
            Main.graphics.GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, 2);

            effect.CurrentTechnique.Passes["FadedBasicEffectPass"].Apply();
            Main.graphics.GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 6, 2);

            if (maxDepth >= 0 && minDepth < 0)
            {
                //spriteBatch.Draw(Main.blackTileTexture, Vector2.Zero, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), (Color.Black * 0.8f), 0, Vector2.Zero, new Vector2(1f, 1f), SpriteEffects.None, 0f);
            }


            if (maxDepth >= 0 && minDepth < 0)
            {
                Main.spriteBatch.End();
                Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.AnisotropicClamp, DepthStencilState.Default, RasterizerState.CullNone, null, Main.GameViewMatrix.TransformationMatrix);
                ArmorShaderData shader2 = GameShaders.Armor.GetShaderFromItemId(ItemID.VoidDye); shader2.Apply(null);
                Texture2D       sun     = SGAmod.ExtraTextures[100];

                Texture2D inner = Main.itemTexture[ModContent.ItemType <AssemblyStar>()];

                Vector2 position = new Vector2((Main.screenWidth / 2), (Main.screenHeight / 8) - ((Main.screenHeight * 16) * skymove * 0.04f));

                Vector2 textureOrigin = new Vector2(inner.Width / 2, inner.Height / 2);

                for (float i = 0; i < 1f; i += 0.10f)
                {
                    spriteBatch.Draw(inner, position, null, (Color.DarkMagenta * (1f - ((i + (Main.GlobalTime / 2f)) % 1f)) * 0.5f) * 0.50f, i * MathHelper.TwoPi, textureOrigin, 16f * (0.5f + 1.25f * (((Main.GlobalTime / 2f) + i) % 1f)), SpriteEffects.None, 0f);
                }

                spriteBatch.Draw(sun, position, null, Color.DarkRed, 0, sun.Size() / 2f, 3f, SpriteEffects.None, 0f);

                //spriteBatch.Draw(sun, new Vector2(Main.screenWidth / 2, Main.screenHeight / 8), null, Color.Red, 0, new Vector2(sun.Width / 2f, sun.Height / 2f), new Vector2(5f, 5f), SpriteEffects.None, 0f);
            }

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

            UnifiedRandom alwaysthesame = new UnifiedRandom(DimDungeonsProxy.DungeonSeeds);

            Texture2D texx = ModContent.GetTexture("SGAmod/Items/WatchersOfNull");

            for (float i = 0.04f; i < 0.35f; i += 0.005f)
            {
                for (int x = -alwaysthesame.Next(900, 3200); x < ((Main.maxTilesX * 16) * i) + Main.screenWidth; x += alwaysthesame.Next(900, 3200))
                {
                    for (int y = -alwaysthesame.Next(900, 3200); y < ((Main.maxTilesY * 16) * i) + Main.screenHeight; y += alwaysthesame.Next(900, 3200))
                    {
                        Vector2 loc = ((-Main.screenPosition * i) + new Vector2(x, y));
                        if (loc.X > -64 && loc.Y > -64 && loc.X < Main.screenWidth + 64 && loc.Y < Main.screenHeight + 64)
                        {
                            spriteBatch.Draw(texx, loc, new Rectangle(0, 0, texx.Width, texx.Height / 13), (Color.White * MathHelper.Clamp(i, 0f, 1f)), 0, Vector2.Zero, new Vector2(1f, 1f), SpriteEffects.None, 0f);
                        }
                    }
                }
            }

            Main.spriteBatch.End();
            Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.GameViewMatrix.TransformationMatrix);
        }
Ejemplo n.º 4
0
        public static void UpdateUI(bool draw = false)
        {
            int   treecount = SkillManager.SkillTreeColors.Length;
            float maxsize   = 600;
            float minsize   = 64;

            float thesize = SKillUI.PercentLerp((float)Main.LocalPlayer.SGAPly().ExpertiseCollectedTotal, minsize, maxsize, SkillManager.skillmax);

            Vector3 loc = new Vector3(Main.screenWidth / 2, Main.screenHeight / 2f, 0);

            if (!draw)
            {
                Main.LocalPlayer.mouseInterface = true;
            }
            if (draw)
            {
                Main.spriteBatch.Draw(Main.blackTileTexture, Vector2.Zero, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), (Color.Purple * 1f), 0, Vector2.Zero, new Vector2(1f, 1f), SpriteEffects.None, 0f);

                Matrix DrawMatrix = Matrix.CreateScale(1f, 1f, 1f);

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


                basicEffect.World              = WVP.World();
                basicEffect.View               = WVP.View(new Vector2(1f, 1f));
                basicEffect.Projection         = WVP.Projection();
                basicEffect.VertexColorEnabled = true;

                int detail = 60;
                int polys  = 1;
                VertexPositionColor[] vertices = new VertexPositionColor[detail * (polys * 3)];

                float  ripplecount   = 20;
                float  ripplesize    = 1f;
                float  overallradius = thesize * (1f - (1f / (1f + SKillUI.SkillUITimer / 10f)));
                Random rand          = new Random(0);

                float[] previous = { 90000f, 90000f };
                float[] starts   = { 0f, 0f };

                for (int tree = 0; tree < treecount; tree += 1)
                {
                    for (int i = 0; i < vertices.Length - 3; i += (polys * 3))
                    {
                        float adder    = UIAngle + MathHelper.ToRadians(((float)tree / (float)treecount) * 360f);
                        float maxdegre = (360f / (float)treecount);
                        float rad1     = (((float)i / (vertices.Length - (polys * 3))) * 360f) * ripplecount;
                        float rad2     = (((float)(i + (polys * 3)) / (vertices.Length - (polys * 3))) * 360f) * ripplecount;
                        if (previous[0] > 89999f)
                        {
                            previous[0] = (float)rand.NextDouble() * 10f; starts[0] = previous[0];
                            previous[1] = (float)rand.NextDouble(); starts[1] = previous[1];
                        }
                        float radius = overallradius + (float)Math.Sin(MathHelper.ToRadians(rad1 + Main.GlobalTime * (90f + previous[0]))) * ((0.50f + previous[1]) * ripplesize);
                        previous[0] = (float)rand.NextDouble() * 10f;
                        previous[1] = (float)rand.NextDouble();
                        if (i + 3 >= vertices.Length)
                        {
                            previous = starts;
                        }

                        float radius2 = overallradius + (float)Math.Sin(MathHelper.ToRadians(rad2 + Main.GlobalTime * (90f + previous[0]))) * ((0.50f + previous[1]) * ripplesize);

                        float   angle    = -(adder + MathHelper.ToRadians(((float)i / (vertices.Length - (polys * 3))) * maxdegre));
                        Vector3 theplace = new Vector3((float)Math.Cos(angle), (float)Math.Sin(angle), 0) * radius;

                        float   angle2    = angle - (MathHelper.ToRadians(((float)(polys * 3) / (vertices.Length - (polys * 3))) * maxdegre));
                        Vector3 theplace2 = new Vector3((float)Math.Cos(angle2), (float)Math.Sin(angle2), 0) * radius2;

                        //Color thecolor = SkillManager.SkillTreeColors[(int)(((float)i / (float)vertices.Length) * (float)treecount)];
                        Color thecolor = SkillManager.SkillTreeColors[tree];

                        vertices[0 + (i)] = new VertexPositionColor(loc, Color.White);
                        vertices[1 + (i)] = new VertexPositionColor(loc + theplace2, thecolor);
                        vertices[2 + (i)] = new VertexPositionColor(loc + theplace, thecolor);
                    }

                    SKillUI.vertexBuffer = new VertexBuffer(Main.graphics.GraphicsDevice, typeof(VertexPositionColor), vertices.Length, BufferUsage.WriteOnly);
                    SKillUI.vertexBuffer.SetData <VertexPositionColor>(vertices);

                    Main.graphics.GraphicsDevice.SetVertexBuffer(vertexBuffer);

                    RasterizerState rasterizerState = new RasterizerState();
                    rasterizerState.CullMode = CullMode.None;
                    Main.graphics.GraphicsDevice.RasterizerState = rasterizerState;

                    foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
                    {
                        pass.Apply();
                        Main.graphics.GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, polys * detail);
                    }
                }
            }

            Vector2 loc2 = new Vector2(loc.X, loc.Y);

            if (draw)
            {
                //Lines and stuff
                for (int i = 0; i < treecount; i += 1)
                {
                    Main.spriteBatch.Draw(Main.blackTileTexture, loc2, new Rectangle(0, 0, 10, 10), Color.Black, -UIAngle + MathHelper.ToRadians(((float)i / (float)treecount) * 360f), new Vector2(0f, 5f), new Vector2(maxsize / 10f, 1f), SpriteEffects.None, 0f);
                }
                for (int i = 0; i < treecount; i += 1)
                {
                    Main.spriteBatch.Draw(Main.blackTileTexture, loc2, new Rectangle(0, 0, 10, 6), Color.Gray, -UIAngle + MathHelper.ToRadians(((float)i / (float)treecount) * 360f), new Vector2(0f, 3f), new Vector2(maxsize / 10f, 1f), SpriteEffects.None, 0f);
                }
                for (int i = 0; i < treecount; i += 1)
                {
                    Main.spriteBatch.Draw(Main.blackTileTexture, loc2, new Rectangle(0, 0, 10, 4), Color.White, -UIAngle + MathHelper.ToRadians(((float)i / (float)treecount) * 360f), new Vector2(0f, 2f), new Vector2(maxsize / 10f, 1f), SpriteEffects.None, 0f);
                }
            }

            foreach (Skill skill in Main.LocalPlayer.SGAPly().skillMananger.Skills)
            {
                //float angle1 = MathHelper.ToRadians((skill.treelocation.Y / (float)treecount) * 360f);
                //angle1 += MathHelper.ToRadians(skill.treelocation.X * (360f/(float)treecount));
                //Vector2 loc3 = new Vector2(SKillUI.PercentLerp(skill.unlockcost, minsize, maxsize, SkillManager.skillmax),0).RotatedBy(-angle1);

                Vector2 loc3 = SKillUI.CircleLocation(skill.treelocation.X, skill.treelocation.Y, skill.unlockcost, minsize, maxsize);

                if (draw)
                {
                    Main.spriteBatch.Draw(Main.blackTileTexture, loc2 + loc3, skill.skillBox, Color.Black * 0.75f, 0, skill.skillBox.Size() / 2f, new Vector2(1f, 1f), SpriteEffects.None, 0f);
                }
            }

            if (draw)
            {
                Main.spriteBatch.End();
                Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.UIScaleMatrix);
            }



            if (!draw)
            {
                UIAngle = UIAngle.AngleLerp(UIAngleTo, 0.1f);
            }
        }