protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(new Color(40, 40, 40)); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend); { //successgens / totalgens spriteBatch.DrawFill(new Rectangle(0, 0, 225, 800), Color.Gray); if (totalgens > 0) { spriteBatch.DrawString(font, $"Total - {totalgens} \nSuccess ({successgens}) - {(1f * successgens / totalgens):0.000}", new Vector2(245, 10), Color.White); int i = 0, j = 0; ResultEntry hov = new ResultEntry(); foreach (var r in results) { if (i > 36) { j += 1; i = 0; } var rc = new Rectangle(1 + 6 * i, 1 + 6 * j, 5, 5); if (rc.Contains(Control.MousePos)) { hov = r; } spriteBatch.DrawFill(rc, new Color(r.data[0] / 100, r.data[1] / 100, r.data[2] / 100)); i++; } float x = successpopup.Progress; float y = (float)(-(x - 1) * (x + 1) / 0.5 / 2); if (!last.Equals(default(ResultEntry))) { spriteBatch.DrawString(font, $"+S[{last.data[0]:0.00} | {last.data[1]:0.00} | {last.data[2]:0.00}]", new Vector2(15, 10 + 30 * y), last.col * (1 - y)); } if (!hov.Equals(default(ResultEntry))) { Rectangle dr; if (PrimaryViewport.Height - Control.MousePos.Y < 100) { dr = new Rectangle(Control.MousePos.ToPoint() - new Point(100, 100), new Point(100, 100)); } else { dr = new Rectangle(Control.MousePos.ToPoint(), new Point(100, 100)); } spriteBatch.DrawFill(dr, new Color(hov.data[0] / 100, hov.data[1] / 100, hov.data[2] / 100)); spriteBatch.DrawString(font, $"E : {(hov.data[0]):0.000}\nR:{(hov.data[1]):0.000}\nS:{(hov.data[2]):0.000}", Control.MousePos + new Vector2(20), Color.White); } } } spriteBatch.End(); generation.Draw(spriteBatch); base.Draw(gameTime); }
void Generate() { if (generation != null && generation.genes.Count > MaxGenes) { results.Add(new ResultEntry(generation)); if (!successpopup.IsRunning) { successpopup.Reset(false); successpopup.Start(); last = results[results.Count - 1]; } successgens++; } List <Gene> genes = new List <Gene>(); for (int i = 0; i < 20; i++) { // [Energy : ResAmount : Speed] => Result genes.Add(new Gene(Rand * 20, Rand * 100, Rand * 100, 0)); } generation = new Generation(genes); totalgens++; }