public static Vector2 CircleLocation(float x, float y, int rad, float minsize, float maxsize) { int treecount = SkillManager.SkillTreeColors.Length; float angle1 = MathHelper.ToRadians((y / (float)treecount) * 360f); angle1 += MathHelper.ToRadians(x * (360f / (float)treecount)); return(new Vector2(SKillUI.PercentLerp(rad, minsize, maxsize, SkillManager.skillmax), 0).RotatedBy(-angle1)); }
public static bool DrawSkillUI() { SKillUI.UpdateUI(true); return(true); }
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); } }