Example #1
0
        public static void Draw()
        {
            GameHelper.SpriteBatch.Draw(GameHelper.TextureManager["PIXEL"], ViewerPosition, null, new Color(80, 80, 80, 200), 0f, Vector2.Zero, ViewerSize, SpriteEffects.None, 0f);

            GameHelper.SpriteBatch.Draw(GameHelper.TextureManager["PIXEL"], ViewerPosition, null, Color.Black, 0f, Vector2.Zero, new Vector2(2, ViewerSize.Y), SpriteEffects.None, 0.001f);
            GameHelper.SpriteBatch.Draw(GameHelper.TextureManager["PIXEL"], ViewerPosition, null, Color.Black, 0f, Vector2.Zero, new Vector2(ViewerSize.X, 2), SpriteEffects.None, 0.001f);
            GameHelper.SpriteBatch.Draw(GameHelper.TextureManager["PIXEL"], ViewerPosition + new Vector2(ViewerSize.X, 0), null, Color.Black, 0f, Vector2.Zero, new Vector2(2, ViewerSize.Y), SpriteEffects.None, 0.001f);
            GameHelper.SpriteBatch.Draw(GameHelper.TextureManager["PIXEL"], ViewerPosition + new Vector2(0, ViewerSize.Y), null, Color.Black, 0f, Vector2.Zero, new Vector2(ViewerSize.X + 2, 2), SpriteEffects.None, 0.001f);

            btn_close.Draw();

            if (Viewing != null)
            {
                int amount = Viewing.Evolvis.Count();

                int squarRoot = (int)Math.Sqrt(Viewing.Evolvis.Count()) + 1;

                int x = (int)Math.Ceiling((double)amount / squarRoot);

                float xScale = ((ViewerSize.X) / x);
                float yScale = ((ViewerSize.Y - 80) / squarRoot);

                for (int yy = 0; yy < squarRoot; yy++)
                {
                    for (int xx = 0; xx < x; xx++)
                    {
                        int thisEvolvi = (yy * squarRoot) + xx;

                        if (thisEvolvi < amount)
                        {
                            if (Viewing.Evolvis[thisEvolvi] == Viewing.Fittest)
                            {
                                Viewing.Evolvis[thisEvolvi].CustomDraw(ViewerPosition + new Vector2(50, 80) + new Vector2(xScale * xx, yScale * yy), 0f, 2f, Color.Gold);
                            }
                            else
                            {
                                Viewing.Evolvis[thisEvolvi].CustomDraw(ViewerPosition + new Vector2(50, 80) + new Vector2(xScale * xx, yScale * yy), 0f, 2f);
                            }

                            Viewing.Evolvis[thisEvolvi].Movement = new Vector2(2.5f, 0);
                            GameHelper.SpriteBatch.DrawString(GameHelper.Font, (thisEvolvi + 1).ToString(), ViewerPosition + new Vector2(50, 80) + new Vector2(xScale * xx, yScale * yy) + new Vector2(0, yScale / 2f), Color.White);
                        }
                    }
                }

                int mouseGeneration = -1;

                Rectangle viewRec = new Rectangle(ViewerPosition.ToPoint() + new Point(0, 60), new Point((int)(squarRoot * yScale) + 100, (int)(x * xScale) + 160));

                if (InputManager.MouseBoxScreen.Intersects(viewRec))
                {
                    int mX = (int)Math.Round((InputManager.MousePositionScreen - ViewerPosition - new Vector2(50, 80)).X / xScale);
                    int mY = (int)Math.Round((InputManager.MousePositionScreen - ViewerPosition - new Vector2(50, 80)).Y / yScale);


                    mouseGeneration = ((mY * squarRoot) + mX);

                    if (mouseGeneration < amount)
                    {
                        if (InputManager.PressedMouseLeft())
                        {
                            SelectedEvolvi = new Vector3(mX, mY, mouseGeneration);
                        }
                    }

                    if (SelectedEvolvi.Z != -1)
                    {
                        GameHelper.DrawLine(ViewerPosition + new Vector2(50, 80) + new Vector2(xScale * SelectedEvolvi.X, yScale * SelectedEvolvi.Y), InputManager.MousePositionScreen + new Vector2(15, 0), Color.Black, 5, 0f);
                        //DrawToolTip(InputManager.MousePositionScreen + new Vector2(30, 0), mX.ToString() + "\n" + mY.ToString() + "\n" + mouseGeneration.ToString());
                        DrawToolTipIndividual(InputManager.MousePositionScreen + new Vector2(15, 0), Viewing.Evolvis[(int)SelectedEvolvi.Z]);
                    }
                }
            }
        }