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); }
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); } }