private RectangleF WriteTextInElLipseWithBorder(RenderColor background, RenderColor foreground, object text, System.Drawing.Font font, PointF topLeft, bool shiftUp, bool shiftLeft)
        {
            string renderText = (text == null) ? " " : text.ToString();

            SizeF  linesStringSize = _Canvas.MeasureString(renderText, font);
            PointF newTopLeft;

            if (shiftUp)
            {
                newTopLeft = new PointF(topLeft.X, topLeft.Y - linesStringSize.Height);
            }
            else
            {
                newTopLeft = topLeft;
            }

            if (shiftLeft)
            {
                newTopLeft = new PointF(newTopLeft.X - linesStringSize.Width, newTopLeft.Y);
            }

            RectangleF bounds = new RectangleF(newTopLeft.X, newTopLeft.Y, linesStringSize.Width, linesStringSize.Height);

            _Canvas.FillEllipse(MyColors.GetBrush(background), bounds);

            _Canvas.DrawString(renderText, font, MyColors.GetBrush(foreground), newTopLeft);

            _Canvas.DrawEllipse(MyColors.GetPen(foreground), bounds);
            return(bounds);
        }
Esempio n. 2
0
 protected override void OnLoad(EventArgs e)
 {
     renderText = new RenderText("Hello World\nHello World\nOlá", 32);
     renderText.BackgroundColor = OpenTK.Color.Red;
     renderColor = new RenderColor(Color4.DarkOrange);
     renderImage = new RenderImage(Renderer.LoadImage("./csharp.png"));
 }
Esempio n. 3
0
        public static void RenderColorThread()
        {
            while (true)
            {
                if (!Globals.RenderEnabled)
                {
                    Thread.Sleep(Globals.IdleWait);
                    continue;
                }
                if (!EngineDLL.InGame)
                {
                    Thread.Sleep(Globals.IdleWait);
                    continue;
                }

                int mp = EngineDLL.MaxPlayer;
                for (int i = 0; i < mp; i++)
                {
                    CBaseEntity baseEntity = entityList[i];
                    if (baseEntity == null)
                    {
                        continue;
                    }
                    CCSPlayer entity = new CCSPlayer(baseEntity);
                    if (entity == null)
                    {
                        continue;
                    }
                    if (entity.Dormant)
                    {
                        continue;
                    }
                    if (entity.Health <= 0)
                    {
                        continue;
                    }

                    if (entity.Team != CBasePlayer.Team)
                    {
                        RenderColor rco = new RenderColor();
                        rco.r = Globals.RenderColor.R;
                        rco.g = Globals.RenderColor.G;
                        rco.b = Globals.RenderColor.B;
                        rco.a = 255;
                        entity.RenderColor = rco;
                    }

                    if (Globals.RenderEnemyOnly)
                    {
                        continue;
                    }

                    RenderColor rc = new RenderColor();
                    rc.r = Globals.RenderColor.R;
                    rc.g = Globals.RenderColor.G;
                    rc.b = Globals.RenderColor.B;
                    rc.a = 255;
                    entity.RenderColor = rc;
                }

                Thread.Sleep(Globals.UsageDelay);
            }
        }
        // Renders the current state of the game to a graphics object
        //
        // The offset is a number between 0 and 1 that specifies how far we are
        // past this game state, in units of time. As this parameter varies from
        // 0 to 1, the fleets all move in the forward direction. This is used to
        // fake smooth animation.
        //
        // On success, return an image. If something goes wrong, returns null.
        public void Render(Game gameData, Image bgImage,         // Background image
                           ColorDictionary colors, Graphics canvas, botDebugBase getPlayerStats)
        {
            _Canvas  = canvas;
            MyColors = colors;
            try
            {
                int    width  = (int)(Width * 0.9);
                int    height = (int)(Height * 0.9);
                PointF offset = new PointF(Width - width - 30, Height - height - 15);

                List <Planet> planets = gameData.Planets;
                List <Fleet>  fleets  = gameData.Fleets;

                if (bgImage != null)
                {
                    _Canvas.DrawImage(bgImage, 0, 0);
                }
                else
                {
                    _Canvas.FillRectangle(Brushes.LightGray, _Canvas.ClipBounds);
                }
                // Determine the dimensions of the viewport in game coordinates.
                double _top          = Double.MAX_VALUE;
                double _left         = Double.MAX_VALUE;
                double _right        = Double.MIN_VALUE;
                double _bottom       = Double.MIN_VALUE;
                int    maxGrowthRate = 0;
                foreach (Planet p in planets)
                {
                    if (p.X < _left)
                    {
                        _left = p.X;
                    }
                    if (p.X > _right)
                    {
                        _right = p.X;
                    }
                    if (p.Y > _bottom)
                    {
                        _bottom = p.Y;
                    }
                    if (p.Y < _top)
                    {
                        _top = p.Y;
                    }
                    if (p.GrowthRate > maxGrowthRate)
                    {
                        maxGrowthRate = p.GrowthRate;
                    }
                }
                _left--; _right++; _top--; _bottom++;

                int _xRange = (int)_right - (int)_left;
                int _yRange = (int)_bottom - (int)_top;

                PointF sizePerUnit = new PointF((float)width / (_xRange),
                                                (float)height / (_yRange));

                double minSizeFactor = 5.0 + (sizePerUnit.X / maxGrowthRate);

                Point[] planetPos = new Point[planets.Count];


                RectangleF bounds = new RectangleF((float)(offset.X), (float)(offset.Y), (float)width, (float)height);

                PointF origin = new PointF((float)(bounds.Left - (_left * sizePerUnit.X)),
                                           (float)(bounds.Top - (_top * sizePerUnit.Y)));

                if (DrawGrid)
                {
                    for (float iGridX = (int)_left; iGridX <= _xRange; iGridX++)
                    {
                        float  newX       = origin.X + (iGridX * sizePerUnit.X);
                        PointF gridTop    = new PointF(newX, bounds.Top);
                        PointF gridBottom = new PointF(newX, bounds.Bottom);

                        _Canvas.DrawLine(MyColors.GetPen(RenderColor.GridLine), gridTop, gridBottom);

                        string linesString = iGridX.ToString();

                        WriteTextInElLipseWithBorder(RenderColor.GridDark, RenderColor.GridLight, linesString, font50, gridTop, true, false);
                        WriteTextInElLipseWithBorder(RenderColor.GridDark, RenderColor.GridLight, linesString, font50, gridBottom, false, false);
                    }



                    for (float iGridY = (int)_top; iGridY <= _yRange; iGridY++)
                    {
                        float  newY      = origin.Y + ((float)_bottom - iGridY) * sizePerUnit.Y;
                        PointF gridLeft  = new PointF(offset.X, newY);
                        PointF gridRight = new PointF(bounds.Right, newY);
                        _Canvas.DrawLine(MyColors.GetPen(RenderColor.GridLine), gridLeft, gridRight);
                        string linesString = iGridY.ToString();
                        WriteTextInElLipseWithBorder(RenderColor.GridDark, RenderColor.GridLight, linesString, font50, gridLeft, true, true);
                        WriteTextInElLipseWithBorder(RenderColor.GridDark, RenderColor.GridLight, linesString, font50, gridRight, false, false);
                    }
                }


                // Draw the planets.
                int   idx = 0;
                int[] growthRatesCounter = new int[4];
                int[] inbaseCounter      = new int[4];
                int[] planetCounter      = new int[4];
                int[] planetOwnerIds     = new int[planets.Count];
                foreach (Planet planet in planets)
                {
                    growthRatesCounter[planet.Owner] += planet.GrowthRate;
                    growthRatesCounter[3]            += planet.GrowthRate;
                    inbaseCounter[planet.Owner]      += planet.NumShips;
                    inbaseCounter[3]            += planet.NumShips;
                    planetCounter[planet.Owner] += 1;
                    planetCounter[3]            += 1;


                    int   newX = (int)(origin.X + (planet.X * sizePerUnit.X));
                    int   newY = (int)(bounds.Bottom - (planet.Y * sizePerUnit.Y));
                    Point pos  = new Point(newX, newY);
                    planetPos[idx]        = pos;
                    planetOwnerIds[idx++] = planet.Owner;

                    int    x    = pos.X;
                    int    y    = pos.Y;
                    double size = minSizeFactor * (planet.GrowthRate + 0.5);
                    double r    = size;

                    double cx = x - r / 2;
                    double cy = y - r / 2;



                    Brush fillColor = MyColors.GetDarkBrush(planet.Owner);
                    Pen   textColor = MyColors.GetLightPen(planet.Owner);
                    if (planet.GrowthRate == 0)
                    {
                        fillColor = Brushes.Black;
                    }
                    else
                    {
                        bool canSurvive = true;
                        if (getPlayerStats != null)
                        {
                            canSurvive = getPlayerStats.QueryPlanetCanSurviveAttack(planet.PlanetID);
                        }
                        if (!canSurvive)
                        {
                            textColor = MyColors.GetDarkPen(planet.Owner);
                            fillColor = MyColors.GetLightBrush(planet.Owner);
                        }
                    }
                    _Canvas.FillEllipse(fillColor, (int)cx, (int)cy, (int)r, (int)r);
                    _Canvas.DrawEllipse(textColor, (int)cx, (int)cy, (int)r, (int)r);
                }

                if (ShortestRoute != null)
                {
                    Planet current = null;
                    foreach (Planet next in ShortestRoute)
                    {
                        if (current != null)
                        {
                            Point from = planetPos[current.PlanetID];
                            Point to   = planetPos[next.PlanetID];
                            _Canvas.DrawLine(Pens.Black, from, to);
                        }
                        current = next;
                    }
                }


                int[] inTransitCounter             = new int[4];
                int[] approachingFleetTotalCount   = new int[planets.Count];
                int[] approachingFleetAttackCount  = new int[planets.Count];
                int[] approachingFleetDefenceCount = new int[planets.Count];
                //Draw in two passes, first the lines, then the labels.
                for (int passCount = 1; passCount < 3; passCount++)
                {
                    foreach (Fleet fleet in fleets)
                    {
                        if (DetermineShouldDrawPlayer(fleet.Owner))
                        {
                            if (passCount == 1)
                            {
                                inTransitCounter[fleet.Owner] += fleet.NumShips;
                                inTransitCounter[3]           += fleet.NumShips;
                                if (fleet.Owner == planets[fleet.DestinationPlanet].Owner)
                                {
                                    approachingFleetTotalCount[fleet.DestinationPlanet]   += fleet.NumShips;
                                    approachingFleetDefenceCount[fleet.DestinationPlanet] += fleet.NumShips;
                                }
                                else
                                {
                                    approachingFleetTotalCount[fleet.DestinationPlanet]  -= fleet.NumShips;
                                    approachingFleetAttackCount[fleet.DestinationPlanet] -= fleet.NumShips;
                                }
                            }

                            Point sPos         = planetPos[fleet.SourcePlanet];
                            Point dPos         = planetPos[fleet.DestinationPlanet];
                            float tripProgress = 1.0f - (float)fleet.TurnsRemaining / (float)fleet.TotalTripLength;


                            if (tripProgress > 0.99 || tripProgress < 0.01)
                            {
                                continue;
                            }
                            int   fleetOwnerOffset = (fleet.Owner - 1) * 2;
                            float dx = dPos.X - sPos.X + fleetOwnerOffset;
                            float dy = dPos.Y - sPos.Y + fleetOwnerOffset;

                            PointF fleetCenter = new PointF(
                                sPos.X + dx * tripProgress + fleetOwnerOffset,
                                sPos.Y + dy * tripProgress + fleetOwnerOffset);
                            if (passCount == 1 && DrawAttacklines)
                            {
                                Pen myPen = MyColors.GetPen(RenderColor.FleetOutgoingAttackLine);
                                if (fleet.Owner == 1)
                                {
                                    if (planetOwnerIds[fleet.DestinationPlanet] == fleet.Owner)
                                    {
                                        myPen = MyColors.GetPen(RenderColor.FleetDefensiveLine);
                                    }
                                }
                                else
                                {
                                    myPen = MyColors.GetPen(RenderColor.FleetIncomingAttackLine);
                                    _Canvas.DrawLine(myPen, dPos.X + 1, dPos.Y, fleetCenter.X + 1, fleetCenter.Y);
                                    _Canvas.DrawLine(myPen, dPos.X, dPos.Y + 1, fleetCenter.X, fleetCenter.Y + 1);
                                }
                                _Canvas.DrawLine(myPen, dPos, fleetCenter);
                            }

                            if (passCount == 2 ||
                                (passCount == 1 && !DrawAttacklines))
                            {
                                SizeF tSize = _Canvas.MeasureString(fleet.NumShips.ToString(), font100);
                                fleetCenter = new PointF((fleetCenter.X - tSize.Width / 2), (fleetCenter.Y - tSize.Height / 2));

                                RenderColor background = MyColors.GetDarkColor(fleet.Owner);
                                RenderColor foreground = MyColors.GetLightColor(fleet.Owner);

                                RectangleF fleetrect = WriteTextInElLipseWithBorder(background, foreground, fleet.NumShips, font100b, fleetCenter, false, false);

                                if (DrawFleetArrival)
                                {
                                    fleetCenter = new PointF(fleetrect.Right + 5, fleetrect.Bottom + 5);
                                    WriteTextInElLipseWithBorder(RenderColor.FleetDistanceDark, RenderColor.FleetDistanceLight, fleet.TurnsRemaining, font25, fleetCenter, true, true);
                                }
                            }
                        }
                    }
                    if (!DrawAttacklines)
                    {
                        break;
                    }
                }

                foreach (Planet planet in planets)
                {
                    Point sPos = planetPos[planet.PlanetID];
                    WriteTextInElLipseWithBorder(RenderColor.PlanetIdDark, RenderColor.PlanetIdLight, planet.PlanetID, font75b, sPos, true, true);
                    RectangleF goRight = WriteTextInElLipseWithBorder(RenderColor.PlanetGrowthDark, RenderColor.PlanetGrowthLight, planet.GrowthRate, font75, sPos, false, true);
                    sPos = new Point((int)goRight.Right, (int)goRight.Bottom);
                    RectangleF goUp = WriteTextInElLipseWithBorder(RenderColor.PlanetNumShipsDark, RenderColor.PlanetNumShipsLight, planet.NumShips, font50b, sPos, true, false);


                    if (DrawPlanetStatistics)
                    {
                        sPos    = new Point((int)goUp.Left + 2, (int)goUp.Top);
                        goRight = WriteTextInElLipseWithBorder(RenderColor.PlanetAttackDark, RenderColor.PlanetAttackLight, approachingFleetAttackCount[planet.PlanetID], font25, sPos, true, false);
                        sPos    = new Point((int)goRight.Right, (int)goUp.Top);
                        WriteTextInElLipseWithBorder(RenderColor.PlanetDefenceDark, RenderColor.PlanetDefenceLight, approachingFleetDefenceCount[planet.PlanetID], font25, sPos, true, false);

                        sPos = new Point((int)goRight.Left, (int)goRight.Top);
                        int nettEffect = approachingFleetTotalCount[planet.PlanetID];
                        if (nettEffect < 0)
                        {
                            WriteTextInElLipseWithBorder(RenderColor.PlanetAttackNettoNegativeDark, RenderColor.PlanetAttackNettoNegativeLight, nettEffect, font25b, sPos, true, false);
                        }
                        else
                        {
                            WriteTextInElLipseWithBorder(RenderColor.PlanetAttackNettoPositiveDark, RenderColor.PlanetAttackNettoPositiveLight, nettEffect, font25b, sPos, true, false);
                        }
                    }
                }

                SizeF textSize = _Canvas.MeasureString("In base : 1234", font50);

                int    lineCounter = 0;
                double avg         = (double)growthRatesCounter[3] / (double)planets.Count;
                #region Draw neutral player stats (UpperLeft)
                Brush color = MyColors.GetLightBrush(0);
                _Canvas.FillRectangle(Brushes.Black, 0, 0, textSize.Width, textSize.Height * 6);
                _Canvas.DrawString("In base : " + inbaseCounter[0], font50, color, 0, textSize.Height * lineCounter++);
                _Canvas.DrawString("Growth  : " + growthRatesCounter[0], font50, color, 0, textSize.Height * lineCounter++);
                _Canvas.DrawString(string.Format("Gr.Avg. : {0:G}", avg), font50, color, 0, textSize.Height * lineCounter++);
                #endregion

                #region Draw Player1 stats (Below neurtral)
                color = MyColors.GetLightBrush(1);
                _Canvas.DrawString("In base : " + inbaseCounter[1], font50, color, 0, textSize.Height * lineCounter++);
                _Canvas.DrawString("Transit : " + inTransitCounter[1], font50, color, 0, textSize.Height * lineCounter++);
                _Canvas.DrawString("Growth  : " + growthRatesCounter[1], font50, color, 0, textSize.Height * lineCounter++);
                #endregion

                int topLeftCornerHeight = (int)(textSize.Height * lineCounter) + 1;
                lineCounter = 0;
                color       = MyColors.GetLightBrush(2);

                #region Draw Player2 stats (Right next to neurtral)
                _Canvas.FillRectangle(Brushes.Black, textSize.Width, 0, textSize.Width, textSize.Height * 3);
                _Canvas.DrawString("In base : " + inbaseCounter[2], font50, color, textSize.Width, textSize.Height * lineCounter++);
                int centralLine = (int)(textSize.Height * lineCounter++);
                _Canvas.DrawString("Transit : " + inTransitCounter[2], font50, color, textSize.Width, centralLine);
                _Canvas.DrawString("Growth  : " + growthRatesCounter[2], font50, color, textSize.Width, textSize.Height * lineCounter++);

                if (getPlayerStats != null)
                {
                    if (getPlayerStats.QueryIsDominating())
                    {
                        _Canvas.DrawString("Dominating", font100b, MyColors.GetDarkBrush(1), Width / 2 - textSize.Width, centralLine);
                    }
                }
                #endregion

                if (DrawUniverseStatistics)
                {
                    PaintVerticalStatisticBars(growthRatesCounter, inbaseCounter, planetCounter, inTransitCounter, color, topLeftCornerHeight);
                }
            }
            finally
            {
                _Canvas  = null;
                MyColors = null;
            }
        }
Esempio n. 5
0
        public static RenderColor toRender(this Color c)
        {
            var render = new RenderColor(c.R, c.G, c.B, c.A);

            return(render);
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            #region Engine Setup
            Console.SetWindowSize(60, 30);
            ColorRenderer renderer = new ColorRenderer();
            renderer.DefaultColor = new RenderColor(ConsoleColor.Red, ConsoleColor.Black);

            OiskiEngine.ChangeRenderer(renderer);
            OiskiEngine.Run();
            #endregion

            RenderColor textColor   = new RenderColor(ConsoleColor.Cyan, ConsoleColor.Black);
            RenderColor borderColor = new RenderColor(ConsoleColor.DarkBlue, ConsoleColor.Black);

            FitnessCalc fitness = new FitnessCalc();

            Menu mainMenu   = new Menu();
            Menu dataMenu   = new Menu();
            Menu resultMenu = new Menu();

            #region Main Menu

            #region Header
            ColorableLabel mainHeader = new ColorableLabel("Oiski's Fitness Calculator", textColor, borderColor, _attachToEngine: false);
            mainHeader.Position = new Vector2(Vector2.CenterX(mainHeader.Size.x), 5);

            mainMenu.Controls.AddControl(mainHeader);
            #endregion

            #region Data Menu Button
            ColorableOption toDataMenu = new ColorableOption("Data Collection", textColor, borderColor, _attachToEngine: false)
            {
                SelectedIndex = Vector2.Zero
            };
            toDataMenu.Position = new Vector2(Vector2.CenterX(toDataMenu.Size.x), mainHeader.Position.y + 6);
            toDataMenu.BorderStyle(BorderArea.Horizontal, '~');

            toDataMenu.OnSelect += (s) =>
            {
                #region Hide Main Menu
                OiskiEngine.Input.ResetInput();
                OiskiEngine.Input.ResetSlection();
                s.BorderStyle(BorderArea.Horizontal, '-');

                mainMenu.Show(false);
                #endregion

                dataMenu.Controls.GetSelectableControls[0].BorderStyle(BorderArea.Horizontal, '~');
                dataMenu.Show();
            };

            mainMenu.Controls.AddControl(toDataMenu);
            #endregion

            #region Result Menu Button
            ColorableOption toResultMenu = new ColorableOption("Results", textColor, borderColor, _attachToEngine: false)
            {
                SelectedIndex = new Vector2(0, 1)
            };
            toResultMenu.Position = new Vector2(Vector2.CenterX(toResultMenu.Size.x), toDataMenu.Position.y + 3);

            toResultMenu.OnSelect += (s) =>
            {
                #region Hide Main Menu
                OiskiEngine.Input.ResetInput();
                OiskiEngine.Input.ResetSlection();
                s.BorderStyle(BorderArea.Horizontal, '-');

                mainMenu.Show(false);
                #endregion

                resultMenu.Controls.GetSelectableControls[0].BorderStyle(BorderArea.Horizontal, '~');
                resultMenu.Show();
            };

            mainMenu.Controls.AddControl(toResultMenu);
            #endregion

            #region Exit Button
            ColorableOption exitButton = new ColorableOption("Exit ", textColor, borderColor, _attachToEngine: false)
            {
                SelectedIndex = new Vector2(0, 2)
            };
            exitButton.Position = new Vector2(Vector2.CenterX(exitButton.Size.x), toResultMenu.Position.y + 3);

            exitButton.OnSelect += (s) =>
            {
                Environment.Exit(0);
            };

            mainMenu.Controls.AddControl(exitButton);
            #endregion

            mainMenu.Show();
            #endregion

            #region Data Menu

            #region Header
            ColorableLabel dataHeader = new ColorableLabel("Oiski's Data", textColor, borderColor, _attachToEngine: false);
            dataHeader.Position = new Vector2(Vector2.CenterX(dataHeader.Size.x), 5);

            dataMenu.Controls.AddControl(dataHeader);
            #endregion

            #region Weight
            decimal weight = 0;

            ColorableLabel weightLabel = new ColorableLabel("Weight", textColor, borderColor, _attachToEngine: false);
            weightLabel.Position = new Vector2(15, dataHeader.Position.y + 6);

            dataMenu.Controls.AddControl(weightLabel);

            ColorableTextField weightText = new ColorableTextField("Type Weight...", new RenderColor(ConsoleColor.Green, ConsoleColor.Black), borderColor, _attachToEngine: false)
            {
                SelectedIndex        = Vector2.Zero,
                ResetAfterFirstWrite = false,
                EraseTextOnSelect    = true
            };
            weightText.Position = new Vector2(weightLabel.Position.x + weightLabel.Size.x - 1, weightLabel.Position.y);
            weightText.BorderStyle(BorderArea.Horizontal, '~');

            weightText.OnSelect += (s) =>
            {
                if (!OiskiEngine.Input.CanWrite)
                {
                    if (!decimal.TryParse(weightText.Text, out weight))
                    {
                        weightText.TextColor = new RenderColor(ConsoleColor.Red, ConsoleColor.Black);
                        weightText.Text      = "Invalid Input";
                    }
                }
                else
                {
                    weightText.TextColor = new RenderColor(ConsoleColor.Green, ConsoleColor.Black);
                }
            };

            dataMenu.Controls.AddControl(weightText);
            #endregion

            #region Resting Heart Rate
            int restingHeartRate = 0;

            ColorableLabel restingHeartRateLabel = new ColorableLabel("R-Heart Rate (BPM)", textColor, borderColor, _attachToEngine: false);
            restingHeartRateLabel.Position = new Vector2(15, weightLabel.Position.y + 3);

            dataMenu.Controls.AddControl(restingHeartRateLabel);

            ColorableTextField restingHeartRateText = new ColorableTextField("Type Rate...", new RenderColor(ConsoleColor.Green, ConsoleColor.Black), borderColor, _attachToEngine: false)
            {
                SelectedIndex        = new Vector2(0, 1),
                ResetAfterFirstWrite = false,
                EraseTextOnSelect    = true
            };
            restingHeartRateText.Position = new Vector2(restingHeartRateLabel.Position.x + restingHeartRateLabel.Size.x - 1, restingHeartRateLabel.Position.y);

            restingHeartRateText.OnSelect += (s) =>
            {
                if (!OiskiEngine.Input.CanWrite)
                {
                    if (!int.TryParse(restingHeartRateText.Text, out restingHeartRate))
                    {
                        restingHeartRateText.TextColor = new RenderColor(ConsoleColor.Red, ConsoleColor.Black);
                        restingHeartRateText.Text      = "Invalid Input";
                    }
                }
                else
                {
                    restingHeartRateText.TextColor = new RenderColor(ConsoleColor.Green, ConsoleColor.Black);
                }
            };

            dataMenu.Controls.AddControl(restingHeartRateText);
            #endregion

            #region Max Heart Rate
            int maxHeartRate = 0;

            ColorableLabel maxHeartRateLabel = new ColorableLabel("M-Heart Rate (BPM)", textColor, borderColor, _attachToEngine: false);
            maxHeartRateLabel.Position = new Vector2(15, restingHeartRateLabel.Position.y + 3);

            dataMenu.Controls.AddControl(maxHeartRateLabel);

            ColorableTextField maxHeartRateText = new ColorableTextField("Type Rate...", new RenderColor(ConsoleColor.Green, ConsoleColor.Black), borderColor, _attachToEngine: false)
            {
                SelectedIndex        = new Vector2(0, 2),
                ResetAfterFirstWrite = false,
                EraseTextOnSelect    = true
            };
            maxHeartRateText.Position = new Vector2(maxHeartRateLabel.Position.x + maxHeartRateLabel.Size.x - 1, maxHeartRateLabel.Position.y);

            maxHeartRateText.OnSelect += (s) =>
            {
                if (!OiskiEngine.Input.CanWrite)
                {
                    if (!int.TryParse(maxHeartRateText.Text, out maxHeartRate))
                    {
                        maxHeartRateText.TextColor = new RenderColor(ConsoleColor.Red, ConsoleColor.Black);
                        maxHeartRateText.Text      = "Invalid Input";
                    }
                }
                else
                {
                    maxHeartRateText.TextColor = new RenderColor(ConsoleColor.Green, ConsoleColor.Black);
                }
            };

            dataMenu.Controls.AddControl(maxHeartRateText);
            #endregion

            #region Back Button
            ColorableOption dataMenuBackButton = new ColorableOption("Back ", textColor, borderColor, _attachToEngine: false)
            {
                SelectedIndex = new Vector2(0, 3)
            };
            dataMenuBackButton.Position = new Vector2(Vector2.CenterX(dataMenuBackButton.Size.x), maxHeartRateLabel.Position.y + 3);

            dataMenuBackButton.OnSelect += (s) =>
            {
                #region Hide Data Menu
                OiskiEngine.Input.ResetInput();
                OiskiEngine.Input.ResetSlection();
                s.BorderStyle(BorderArea.Horizontal, '-');

                dataMenu.Show(false);
                #endregion

                fitness.Weight           = weight;
                fitness.RestingHeartRate = restingHeartRate;
                fitness.MaxHeartRate     = maxHeartRate;

                mainMenu.Controls.GetSelectableControls[0].BorderStyle(BorderArea.Horizontal, '~');
                mainMenu.Show();
            };

            dataMenu.Controls.AddControl(dataMenuBackButton);
            #endregion

            #endregion

            #region Result Menu

            #region Header
            ColorableLabel resultHeader = new ColorableLabel("Oiski's Results", textColor, borderColor, _attachToEngine: false);
            resultHeader.Position = new Vector2(Vector2.CenterX(resultHeader.Size.x), 5);

            resultMenu.Controls.AddControl(resultHeader);
            #endregion

            #region Weight
            ColorableLabel weightResultLabel = new ColorableLabel("Weight (kg)", textColor, borderColor, _attachToEngine: false);
            weightResultLabel.Position = new Vector2(10, resultHeader.Position.y + 5);

            resultMenu.Controls.AddControl(weightResultLabel);

            ColorableLabel weightResultText = new ColorableLabel(fitness.Weight.ToString(), new RenderColor(ConsoleColor.Green, ConsoleColor.Black), borderColor, _attachToEngine: false);
            weightResultText.Position = new Vector2(weightResultLabel.Position.x + weightResultLabel.Size.x - 1, weightResultLabel.Position.y);

            weightResultText.OnUpdate += (c) =>
            {
                weightResultText.Text = fitness.Weight.ToString();
            };

            resultMenu.Controls.AddControl(weightResultText);
            #endregion

            #region Resting Heart Rate
            ColorableLabel restingHeartRateResultLabel = new ColorableLabel("R-Heart Rate (BPM)", textColor, borderColor, _attachToEngine: false);
            int            positionX = weightResultLabel.Position.x + weightResultLabel.Size.x + weightResultText.Size.x + 2;
            restingHeartRateResultLabel.Position = new Vector2(positionX, weightResultLabel.Position.y);

            resultMenu.Controls.AddControl(restingHeartRateResultLabel);

            ColorableLabel restingHeartRateResultText = new ColorableLabel(fitness.RestingHeartRate.ToString(), new RenderColor(ConsoleColor.Green, ConsoleColor.Black), borderColor, _attachToEngine: false);
            restingHeartRateResultText.Position = new Vector2(restingHeartRateResultLabel.Position.x + restingHeartRateResultLabel.Size.x - 1, restingHeartRateResultLabel.Position.y);

            restingHeartRateResultText.OnUpdate += (c) =>
            {
                restingHeartRateResultText.Text = fitness.RestingHeartRate.ToString();
            };

            resultMenu.Controls.AddControl(restingHeartRateResultText);
            #endregion

            #region Max Heart Rate
            ColorableLabel maxHeartRateResultLabel = new ColorableLabel("M-Heart Rate (BPM)", textColor, borderColor, _attachToEngine: false);
            maxHeartRateResultLabel.Position = new Vector2(weightResultLabel.Position.x, weightResultLabel.Position.y + 3);

            resultMenu.Controls.AddControl(maxHeartRateResultLabel);

            ColorableLabel maxHeartRateResultText = new ColorableLabel(fitness.MaxHeartRate.ToString(), new RenderColor(ConsoleColor.Green, ConsoleColor.Black), borderColor, _attachToEngine: false);
            maxHeartRateResultText.Position = new Vector2(maxHeartRateResultLabel.Position.x + maxHeartRateResultLabel.Size.x - 1, maxHeartRateResultLabel.Position.y);

            maxHeartRateResultText.OnUpdate += (c) =>
            {
                maxHeartRateResultText.Text = fitness.MaxHeartRate.ToString();
            };

            resultMenu.Controls.AddControl(maxHeartRateResultText);
            #endregion

            #region Fitness Level
            ColorableLabel fitnessLabel = new ColorableLabel("Fitness Level", textColor, borderColor, _attachToEngine: false);
            fitnessLabel.Position = new Vector2(weightResultLabel.Position.x, restingHeartRateLabel.Position.y + 2);

            resultMenu.Controls.AddControl(fitnessLabel);

            ColorableLabel fitnessLevelText = new ColorableLabel("Error", new RenderColor(ConsoleColor.Red, ConsoleColor.Black), borderColor, _attachToEngine: false);
            fitnessLevelText.Position = new Vector2(fitnessLabel.Position.x + fitnessLabel.Size.x - 1, fitnessLabel.Position.y);

            fitnessLevelText.OnUpdate += (c) =>
            {
                try
                {
                    fitnessLevelText.TextColor = new RenderColor(ConsoleColor.Green, ConsoleColor.Black);
                    fitnessLevelText.Text      = fitness.GetFitnessLevel().ToString();
                }
                catch (DivideByZeroException)
                {
                    fitnessLevelText.TextColor = new RenderColor(ConsoleColor.Red, ConsoleColor.Black);
                    fitnessLevelText.Text      = "Error";
                }
            };

            resultMenu.Controls.AddControl(fitnessLevelText);
            #endregion

            #region VO2 Max
            ColorableLabel vO2Label = new ColorableLabel("VO2 Max Score", textColor, borderColor, _attachToEngine: false);
            vO2Label.Position = new Vector2(weightResultLabel.Position.x, fitnessLabel.Position.y + 2);

            resultMenu.Controls.AddControl(vO2Label);

            ColorableLabel vO2Text = new ColorableLabel("Error", new RenderColor(ConsoleColor.Red, ConsoleColor.Black), borderColor, _attachToEngine: false);
            vO2Text.Position = new Vector2(vO2Label.Position.x + vO2Label.Size.x - 1, vO2Label.Position.y);

            vO2Text.OnUpdate += (c) =>
            {
                try
                {
                    vO2Text.TextColor = new RenderColor(ConsoleColor.Green, ConsoleColor.Black);
                    vO2Text.Text      = $"{fitness.GetVO2Max():0.0}";
                }
                catch (DivideByZeroException)
                {
                    vO2Text.TextColor = new RenderColor(ConsoleColor.Red, ConsoleColor.Black);
                    vO2Text.Text      = "Error";
                }
            };

            resultMenu.Controls.AddControl(vO2Text);
            #endregion

            #region Back Button
            ColorableOption resultMenuBackButton = new ColorableOption("Back ", textColor, borderColor, _attachToEngine: false)
            {
                SelectedIndex = Vector2.Zero
            };
            resultMenuBackButton.Position = new Vector2(Vector2.CenterX(resultMenuBackButton.Size.x), vO2Label.Position.y + 4);

            resultMenuBackButton.OnSelect += (s) =>
            {
                #region Hide Data Menu
                OiskiEngine.Input.ResetInput();
                OiskiEngine.Input.ResetSlection();
                s.BorderStyle(BorderArea.Horizontal, '-');

                resultMenu.Show(false);
                #endregion

                mainMenu.Controls.GetSelectableControls[0].BorderStyle(BorderArea.Horizontal, '~');
                mainMenu.Show();
            };

            resultMenu.Controls.AddControl(resultMenuBackButton);
            #endregion

            #endregion
        }
        private RectangleF WriteTextInElLipseWithBorder(RenderColor background, RenderColor foreground, object text, System.Drawing.Font font, PointF topLeft, bool shiftUp, bool shiftLeft)
        {
            string renderText = (text == null) ? " " : text.ToString();

            SizeF linesStringSize = _Canvas.MeasureString(renderText, font);
            PointF newTopLeft;
            if (shiftUp)
                newTopLeft = new PointF(topLeft.X, topLeft.Y - linesStringSize.Height);
            else
                newTopLeft = topLeft;

            if (shiftLeft)
            {
                newTopLeft = new PointF(newTopLeft.X - linesStringSize.Width, newTopLeft.Y);
            }

            RectangleF bounds = new RectangleF(newTopLeft.X, newTopLeft.Y, linesStringSize.Width, linesStringSize.Height);
            _Canvas.FillEllipse(MyColors.GetBrush(background), bounds);

            _Canvas.DrawString(renderText, font, MyColors.GetBrush(foreground), newTopLeft);

            _Canvas.DrawEllipse(MyColors.GetPen(foreground), bounds);
            return bounds;
        }
Esempio n. 8
0
        internal static void OnRenderer(int fps, EventArgs args)
        {
            if (!ProcessExists)
            {
                return;
            }
            if ((!isGameOnTop) && (!isOverlayOnTop))
            {
                return;
            }
            if (!InGame)
            {
                return;
            }

            //Misc
            if (cMisc.aintiflash.Enabled)
            {
                FlashAlpha = 0.0f;
            }


            if (isPlayerMoving())
            {
                if ((cMisc.BunnyKey.Enabled) && Flags == 257)
                {
                    ForceJump(true);
                    ForceForward(true);
                    Input.SleepWS(10);
                    ForceJump(false);
                    ForceForward(false);
                }
            }


            int mPlayers = MaxPlayer;

            for (int i = 0; i < mPlayers; i++)
            {
                BaseEntity baseEntity = entityList[i];
                if (baseEntity == null)
                {
                    continue;
                }
                Player entity = new Player(baseEntity);
                if (entity == null)
                {
                    continue;
                }
                if (entity.Dormant)
                {
                    continue;
                }
                if (entity.Health <= 0)
                {
                    continue;
                }

                if (entity.Team != Team)
                {
                    RenderColor rco = new RenderColor();
                    rco.r = Color.Red.R;
                    rco.g = Color.Red.G;
                    rco.b = Color.Red.B;
                    rco.a = 255;
                    entity.RenderColor = rco;
                }

                ModelAmbientIntensity = 1;

                //Radar
                if (entity.Team != Team)
                {
                    if (!entity.Spotted)
                    {
                        entity.Spotted = true;
                    }
                }

                //TringgerBot
                if (cTrigger.TriggerEnable.Enabled)
                {
                    if (cTrigger.TriggerKey.Enabled)
                    {
                        if (CrosshairID > 0 && CrosshairID < MaxPlayer + 2)
                        {
                            baseEntity = entityList[CrosshairID - 1];
                            if (baseEntity == null)
                            {
                                return;
                            }
                            Player crossEntity = new Player(baseEntity);
                            if (crossEntity == null)
                            {
                                return;
                            }
                            if (crossEntity != null && crossEntity.Team != Team)
                            {
                                Input.SleepWS(1);
                                ForceAttack(true);
                                Input.SleepWS(5);
                                ForceAttack(false);
                            }
                        }
                    }
                }

                //Aimbot and ESP
                if ((entity.Health > 0) && (entity.Dormant == false))
                {
                    //Factures Aimbot
                    double fClosestPos = 999999;
                    AimTarg2D = new Vector2(0, 0);
                    AimTarg3D = new Vector3(0, 0, 0);

                    var f_modelHeight = WeScriptWrapper.Memory.ReadFloat(csHandle, (IntPtr)(entity.Base + 0x33C));
                    var headPos_fake  = new Vector3(entity.VectorOrigin.X, entity.VectorOrigin.Y, entity.VectorOrigin.Z + f_modelHeight);
                    var matrix        = WeScriptWrapper.Memory.ReadMatrix(csHandle, (IntPtr)(dwViewMatrix_Offs.ToInt64() + 0xB0));

                    var m_bIsDefusing = WeScriptWrapper.Memory.ReadBool(csHandle, (IntPtr)entity.Base + 0x3930);
                    var myPunchAngles = WeScriptWrapper.Memory.ReadVector3(csHandle, (IntPtr)(LocalPlayerPtr + 0x302C));
                    var myEyePos      = WeScriptWrapper.Memory.ReadVector3(csHandle, (IntPtr)(LocalPlayerPtr + 0x108));
                    var myAngles      = WeScriptWrapper.Memory.ReadVector3(csHandle, (IntPtr)(LocalPlayerPtr + 0x31D8));
                    var myPos         = WeScriptWrapper.Memory.ReadVector3(csHandle, (IntPtr)(LocalPlayerPtr + 0x138));

                    Vector2 vScreen_head = new Vector2(0, 0);
                    Vector2 vScreen_foot = new Vector2(0, 0);

                    //ESP
                    if (Renderer.WorldToScreen(headPos_fake, out vScreen_head, matrix, wndMargins, wndSize, W2SType.TypeD3D9))
                    {
                        Renderer.WorldToScreen(entity.VectorOrigin, out vScreen_foot, matrix, wndMargins, wndSize, W2SType.TypeD3D9);
                        {
                            if (cVisual.DrawTheVisuals.Enabled)
                            {
                                if (entity != null && entity.Team != Team)
                                {
                                    if (!m_bIsDefusing)
                                    {
                                        Renderer.DrawFPSBox(vScreen_head, vScreen_foot, (Team == 3) ? cVisual.ESPColor.Color : cVisual.ESPColor.Color, (f_modelHeight == 54.0f) ? BoxStance.crouching : BoxStance.standing, cVisual.DrawBoxThic.Value, cVisual.DrawBoxBorder.Enabled, cVisual.DrawBox.Enabled, entity.Health, cVisual.DrawBoxHP.Enabled ? 100 : 0, 0, 0);
                                    }
                                    else
                                    {
                                        Renderer.DrawFPSBox(vScreen_head, vScreen_foot, (Team == 3) ? Color.White : Color.White, BoxStance.crouching);
                                    }
                                }
                            }
                        }
                    }

                    //Aimbot
                    if (entity != null && entity.Team != Team)
                    {
                        Vector2 vScreen_aim = new Vector2(0, 0);
                        Vector3 targetVec   = new Vector3(0, 0, 0);
                        var     entityAddr  = WeScriptWrapper.Memory.ReadPointer(csHandle, (IntPtr)(dwEntityList_Offs.ToInt64() + i * 0x10), isWow64Process);
                        switch (cAimbot.PriorityBone.Value)
                        {
                        case 0:     //head
                        {
                            targetVec = ReadBonePos(entityAddr, 8);
                        }
                        break;

                        case 1:     //body
                        {
                            targetVec = ReadBonePos(entityAddr, 0);
                        }
                        break;

                        default:
                            break;
                        }

                        var AimDist2D = GetDistance2D(vScreen_aim, GameCenterPos);
                        if (cAimbot.AimFov.Value < AimDist2D)
                        {
                            continue;
                        }
                        if (AimDist2D < fClosestPos)
                        {
                            fClosestPos = AimDist2D;
                            AimTarg2D   = vScreen_aim;
                            AimTarg3D   = targetVec;
                        }
                        if (Renderer.WorldToScreen(headPos_fake, out vScreen_head, matrix, wndMargins, wndSize, W2SType.TypeD3D9))
                        {
                            if (cAimbot.AimKey.Enabled)
                            {
                                var dx = (GameCenterPos.X * 2) / 90;
                                var dy = (GameCenterPos.Y * 2) / 90;

                                var    rx    = GameCenterPos.X - (dx * ((myPunchAngles.Y)));
                                var    ry    = GameCenterPos.Y + (dy * ((myPunchAngles.X)));
                                double DistX = 0;
                                double DistY = 0;

                                DistX = (AimTarg2D.X) - rx;
                                DistY = (AimTarg2D.Y) - ry;

                                double slowDistX = DistX / (1.0f + (Math.Abs(DistX) / (1.0f + 12)));
                                double slowDistY = DistY / (1.0f + (Math.Abs(DistY) / (1.0f + 12)));
                                Input.mouse_eventWS(MouseEventFlags.MOVE, (int)slowDistX, (int)slowDistY, MouseEventDataXButtons.NONE, IntPtr.Zero);
                            }
                        }
                    }
                }
            }
        }