public void Show(Draw D) { AutoSave_Timer++; if (AutoSave_Timer > AutoSave_Interval) { SaveButton.ButtonTimer = 20; Save(Path.Combine(FilePath, "Autosave")); AutoSave_Timer = 0; } if (LoadState || SaveState) { CancelButton.Show(D); } if (!LoadState) { SaveButton.Show(D); } if (!(SaveState || LoadState)) { LoadButton.Show(D); } if (SaveState) { TextBox.Show(D); } foreach (GuiElement E in FileButtons) { E.Show(D); } }
void DrawGUI() { if (UpdateFamily) { UpdateFamilyList(); } CreatureText.Text = "Creatures:" + UpdateWorld.Creatures.Count.ToString(); TreeText.Text = "Trees:" + UpdateWorld.Trees.Count.ToString(); if (Selected is Creature SelectedCreature) { Rectangle BrainRect = new Rectangle(20, 70, 190, 350); //DrawGuiBox(Brushes.LightGray, BrainRect); FamilyButton.Rect.Y = BrainRect.Y + BrainRect.Height + 15; if (SelectedCreature.Family != null) { if (SelectedFamily) { Graphics.FillRectangle(new SolidBrush(Color.FromArgb(150, Color.Black)), 0, 0, Size.Width, Size.Height); SelectedCreature.Family.Show(this, new Rectangle(BrainRect.Width + BrainRect.X - 50, 0, Form1.PB.Width - (200 + BrainRect.Width + BrainRect.X), Form1.PB.Height)); } FamilyButton.Show(this); } else { SelectedFamily = false; } /*for (int i = 0; i < SelectedElements.Count; i++) * { * GuiElement E = SelectedElements[i]; * E.Rect.Y= BrainRect.Y + BrainRect.Height + 65+i*50; * E.Show(this); * }*/ SelectedCreature.Brain.Show(Graphics, BrainRect); } if (Selected is Tree T) { T.Selected = true; T.ShowSelected(this, Draw3D); double S = 15; for (int i = -5; i < 5; i++) { for (int j = -5; j < 5; j++) { Draw3D.addLine(Color.Black, 1, Draw3D.CenterPos + new Vector3(i * S, j * S, 0), Draw3D.CenterPos + new Vector3(i * S + S, j * S, 0)); Draw3D.addLine(Color.Black, 1, Draw3D.CenterPos + new Vector3(i * S, j * S, 0), Draw3D.CenterPos + new Vector3(i * S, j * S + S, 0)); } } Draw3D.display(); Pen P = new Pen(Color.Black, 4) { LineJoin = System.Drawing.Drawing2D.LineJoin.Round }; Graphics.DrawImage(Bm, Rect3D.Location); Graphics.DrawRectangle(P, new Rectangle(Rect3D.Location, Draw3D.Size)); TreeEnergyText.Rect.Y = Rect3D.Y + Rect3D.Height + 20; TreeEnergyText.Text = "Energy:" + T.Energy.ToString("0"); TreeEnergyText.Show(this); TreeGenerationText.Rect.Y = TreeEnergyText.Rect.Y + 50; TreeGenerationText.Text = "Gen:" + T.Generation.ToString("0"); TreeGenerationText.Show(this); TreeMutationText.Rect.Y = TreeGenerationText.Rect.Y + 50; TreeMutationText.Text = "MutationRate:" + (T.MutationRate * 100).ToString("0") + "%"; TreeMutationText.Show(this); T.NeuralNetwork.Show(Graphics, new Rectangle(20, TreeMutationText.Rect.Y + 50, 200, 350)); } foreach (var E in Elements) { E.Show(this); } if (!(FileHandler.LoadState || FileHandler.SaveState)) { int i = -1; foreach (var E in FamilyButtons) { E.Show(this); if (i >= 0) { E.Text = Families[i].Root.Name + ":" + Families[i].FamilyMembersAlive.ToString(); } i++; } } if (!SelectedFamily) { CreatureGraph.Show(this); TreeGraph.Show(this); CreatureText.Show(this); TreeText.Show(this); } }