示例#1
0
        /// <summary>
        ///     Draws the panelspecific data.
        /// </summary>
        /// <param name="g"></param>
        protected override void Draw(BufferedGraphics g)
        {
            try
            {
                if (!GInformation.Gameinfo.IsIngame)
                {
                    return;
                }

                var iValidPlayerCount = GInformation.Gameinfo.ValidPlayerCount;

                if (iValidPlayerCount == 0)
                {
                    return;
                }

                Opacity = PSettings.PreferenceAll.OverlayResources.Opacity;
                var iSingleHeight = Height / iValidPlayerCount;
                var fNewFontSize  = (float)((29.0 / 100) * iSingleHeight);
                var fInternalFont = new Font(PSettings.PreferenceAll.OverlayResources.FontName, fNewFontSize,
                                             FontStyle.Bold);
                var fInternalFontNormal = new Font(fInternalFont.Name, fNewFontSize, FontStyle.Regular);

                if (!BChangingPosition)
                {
                    Height = PSettings.PreferenceAll.OverlayResources.Height * iValidPlayerCount;
                    Width  = PSettings.PreferenceAll.OverlayResources.Width;
                }

                var iCounter = 0;


                for (var i = 0; i < GInformation.Player.Count; i++)
                {
                    var clPlayercolor = GInformation.Player[i].Color;

                    #region Teamcolor

                    RendererHelper.TeamColor(GInformation.Player, i,
                                             GInformation.Gameinfo.IsTeamcolor, ref clPlayercolor);

                    #endregion

                    #region Escape sequences

                    if (PSettings.PreferenceAll.OverlayResources.RemoveAi)
                    {
                        if (GInformation.Player[i].Type.Equals(PlayerType.Ai))
                        {
                            continue;
                        }
                    }

                    if (PSettings.PreferenceAll.OverlayResources.RemoveNeutral)
                    {
                        if (GInformation.Player[i].Type.Equals(PlayerType.Neutral))
                        {
                            continue;
                        }
                    }

                    if (PSettings.PreferenceAll.OverlayResources.RemoveAllie)
                    {
                        if (Player.LocalPlayer.Index == 16)
                        {
                            //Do nothing
                        }

                        else
                        {
                            if (GInformation.Player[i].Team ==
                                Player.LocalPlayer.Team &&
                                GInformation.Player[i].Index != Player.LocalPlayer.Index)
                            {
                                continue;
                            }
                        }
                    }

                    if (PSettings.PreferenceAll.OverlayResources.RemoveLocalplayer)
                    {
                        if (Player.LocalPlayer == GInformation.Player[i])
                        {
                            continue;
                        }
                    }


                    if (GInformation.Player[i].Name.StartsWith("\0") || GInformation.Player[i].NameLength <= 0)
                    {
                        continue;
                    }

                    if (GInformation.Player[i].Type.Equals(PlayerType.Hostile))
                    {
                        continue;
                    }

                    if (GInformation.Player[i].Type.Equals(PlayerType.Observer))
                    {
                        continue;
                    }

                    if (GInformation.Player[i].Type.Equals(PlayerType.Referee))
                    {
                        continue;
                    }

                    if (CheckIfGameheart(GInformation.Player[i]))
                    {
                        continue;
                    }

                    #endregion

                    #region SetValidImages (Race)

                    if (GInformation.Player[i].PlayerRace.Equals(PlayerRace.Terran))
                    {
                        _imgMinerals = Resources.Mineral_Terran;
                        _imgGas      = Resources.Gas_Terran;
                        _imgSupply   = Resources.Supply_Terran;
                        _imgWorker   = Resources.T_SCV;
                    }

                    else if (GInformation.Player[i].PlayerRace.Equals(PlayerRace.Protoss))
                    {
                        _imgMinerals = Resources.Mineral_Protoss;
                        _imgGas      = Resources.Gas_Protoss;
                        _imgSupply   = Resources.Supply_Protoss;
                        _imgWorker   = Resources.P_Probe;
                    }

                    else
                    {
                        _imgMinerals = Resources.Mineral_Zerg;
                        _imgGas      = Resources.Gas_Zerg;
                        _imgSupply   = Resources.Supply_Zerg;
                        _imgWorker   = Resources.Z_Drone;
                    }

                    #endregion

                    #region Draw Bounds and Background

                    if (PSettings.PreferenceAll.OverlayResources.DrawBackground)
                    {
                        /* Background */
                        g.Graphics.FillRectangle(Brushes.Gray, 1, 1 + (iSingleHeight * iCounter), Width - 2,
                                                 iSingleHeight - 2);

                        /* Border */
                        g.Graphics.DrawRectangle(new Pen(new SolidBrush(clPlayercolor), 2), 1,
                                                 1 + (iSingleHeight * iCounter),
                                                 Width - 2, iSingleHeight - 2);
                    }

                    #endregion

                    #region Content Drawing

                    #region Name

                    var strName = (GInformation.Player[i].ClanTag.StartsWith("\0") ||
                                   PSettings.PreferenceAll.OverlayResources.RemoveClanTag)
                        ? GInformation.Player[i].Name
                        : "[" + GInformation.Player[i].ClanTag + "] " + GInformation.Player[i].Name;

                    g.Graphics.DrawString(strName, fInternalFont,
                                          new SolidBrush(clPlayercolor),
                                          Brushes.Black, (float)((1.67 / 100) * Width),
                                          (float)((24.0 / 100) * iSingleHeight) + iSingleHeight * iCounter,
                                          1f, 1f, true);

                    #endregion

                    #region Team

                    g.Graphics.DrawString("#" + GInformation.Player[i].Team, fInternalFontNormal,
                                          Brushes.White,
                                          Brushes.Black, (float)((29.67 / 100) * Width),
                                          (float)((24.0 / 100) * iSingleHeight) + iSingleHeight * iCounter,
                                          1f, 1f, true);

                    #endregion

                    #region Minerals

                    /* Icon */
                    g.Graphics.DrawImage(_imgMinerals, (float)((37.0 / 100) * Width),
                                         (float)((14.0 / 100) * iSingleHeight) + (Height / iValidPlayerCount) * iCounter,
                                         (float)((70.0 / 100) * iSingleHeight), (float)((70.0 / 100) * iSingleHeight), Brushes.Black, 1f, 1f,
                                         false);

                    g.Graphics.DrawString(
                        GInformation.Player[i].Minerals.ToString(CultureInfo.InvariantCulture),
                        fInternalFontNormal,
                        Brushes.White,
                        Brushes.Black, (float)((43.67 / 100) * Width),
                        (float)((24.0 / 100) * iSingleHeight) + iSingleHeight * iCounter,
                        1f, 1f, true);

                    #endregion

                    #region Gas

                    /* Icon */
                    g.Graphics.DrawImage(_imgGas, (float)((57.0 / 100) * Width),
                                         (float)((14.0 / 100) * iSingleHeight) + (Height / iValidPlayerCount) * iCounter,
                                         (float)((70.0 / 100) * iSingleHeight), (float)((70.0 / 100) * iSingleHeight), Brushes.Black, 1f, 1f,
                                         false);

                    g.Graphics.DrawString(
                        GInformation.Player[i].Gas.ToString(CultureInfo.InvariantCulture),
                        fInternalFontNormal,
                        Brushes.White,
                        Brushes.Black, (float)((63.67 / 100) * Width),
                        (float)((24.0 / 100) * iSingleHeight) + iSingleHeight * iCounter,
                        1f, 1f, true);

                    #endregion

                    #region Supply

                    /* Icon */
                    g.Graphics.DrawImage(_imgSupply, (float)((75.0 / 100) * Width),
                                         (float)((14.0 / 100) * iSingleHeight) + (Height / iValidPlayerCount) * iCounter,
                                         (float)((70.0 / 100) * iSingleHeight), (float)((70.0 / 100) * iSingleHeight), Brushes.Black, 1f, 1f,
                                         false);

                    g.Graphics.DrawString(
                        GInformation.Player[i].SupplyMin.ToString(CultureInfo.InvariantCulture) + "/" +
                        GInformation.Player[i].SupplyMax,
                        fInternalFontNormal,
                        Brushes.White,
                        Brushes.Black, (float)((81.67 / 100) * Width),
                        (float)((24.0 / 100) * iSingleHeight) + iSingleHeight * iCounter,
                        1f, 1f, true);

                    #endregion

                    #endregion

                    iCounter++;
                }
            }

            catch (Exception ex)
            {
                Messages.LogFile("Over all", ex);
            }
        }
示例#2
0
        /// <summary>
        ///     Draws the panelspecific data.
        /// </summary>
        /// <param name="g"></param>
        protected override void Draw(BufferedGraphics g)
        {
            try
            {
                if (GInformation.Unit == null ||
                    GInformation.Unit.Count <= 0)
                {
                    return;
                }

                if (GInformation.Player == null)
                {
                    return;
                }

                if (!GInformation.Gameinfo.IsIngame)
                {
                    g.Graphics.Clear(Color.White);
                    g.Graphics.Clear(BackColor);
                    return;
                }

                Opacity = PSettings.PreferenceAll.OverlayMaphack.Opacity;

                if (!BChangingPosition)
                {
                    Height = PSettings.PreferenceAll.OverlayMaphack.Height;
                    Width  = PSettings.PreferenceAll.OverlayMaphack.Width;
                }

                var tmpMap = GInformation.Map;

                #region Introduction

                #region Variables

                float fScale;
                float fX;
                float fY;
                float fHypotenuse;

                #endregion

                #region Get minimap Bounds

                var fa = Height / (float)Width;
                var fb = ((float)tmpMap.PlayableHeight / tmpMap.PlayableWidth);

                if (fa >= fb)
                {
                    fScale = (float)Width / tmpMap.PlayableWidth;
                    fX     = 0;
                    fY     = (Height - fScale * tmpMap.PlayableHeight) / 2;
                }
                else
                {
                    fScale = (float)Height / tmpMap.PlayableHeight;
                    fY     = 0;
                    fX     = (Width - fScale * tmpMap.PlayableWidth) / 2;
                }

                #endregion

                #region Calculate Hypotenuse

                fHypotenuse = (float)Math.Sqrt((Math.Pow(ClientSize.Width, 2) + Math.Pow(ClientSize.Height, 2)));

                #endregion

                #region Draw Bounds

                if (!PSettings.PreferenceAll.OverlayMaphack.RemoveVisionArea)
                {
                    /* Draw Rectangle */
                    g.Graphics.DrawRectangle(Constants.PBound, 0, 0, Width - Constants.PBound.Width,
                                             Height - Constants.PBound.Width);

                    /* Draw Playable Area */
                    g.Graphics.DrawRectangle(Constants.PArea, fX, fY, Width - fX * 2 - Constants.PArea.Width,
                                             Height - fY * 2 - Constants.PArea.Width);
                }

                #endregion

                #endregion

                #region Actual Drawing

                #region Draw Unit- destination

                if (!PSettings.PreferenceAll.OverlayMaphack.RemoveDestinationLine)
                {
                    for (var i = 0; i < GInformation.Unit.Count; i++)
                    {
                        var clDestination = PSettings.PreferenceAll.OverlayMaphack.DestinationLine;

                        var tmpUnit = GInformation.Unit[i];

                        #region Escape Sequences

                        /* Ai */
                        if (PSettings.PreferenceAll.OverlayMaphack.RemoveAi)
                        {
                            if (
                                GInformation.Player[tmpUnit.Owner].Type.Equals(
                                    PlayerType.Ai))
                            {
                                continue;
                            }
                        }

                        /* Allie */
                        if (PSettings.PreferenceAll.OverlayMaphack.RemoveAllie)
                        {
                            if (Player.LocalPlayer != null)
                            {
                                if (GInformation.Player[tmpUnit.Owner].Team ==
                                    Player.LocalPlayer.Team &&
                                    GInformation.Player[tmpUnit.Owner] != Player.LocalPlayer)
                                {
                                    continue;
                                }
                            }
                        }

                        /* Localplayer Units */
                        if (PSettings.PreferenceAll.OverlayMaphack.RemoveLocalplayer)
                        {
                            if (tmpUnit.Owner == Player.LocalPlayer.Index)
                            {
                                continue;
                            }
                        }

                        /* Neutral Units */
                        if (PSettings.PreferenceAll.OverlayMaphack.RemoveNeutral)
                        {
                            if (
                                GInformation.Player[tmpUnit.Owner].Type.Equals(
                                    PlayerType.Neutral))
                            {
                                continue;
                            }
                        }

                        /* Dead Units */
                        if ((tmpUnit.TargetFilter & (ulong)TargetFilterFlag.Dead) > 0)
                        {
                            continue;
                        }


                        /* Moving- state */
                        if (tmpUnit.Movestate.Equals(0))
                        {
                            continue;
                        }

                        #endregion

                        #region Scalling (Unitposition + UnitDestination)

                        var iUnitPosX = (tmpUnit.PositionX - tmpMap.Left) * fScale + fX;
                        var iUnitPosY = (tmpMap.Top - tmpUnit.PositionY) * fScale + fY;

                        var iUnitDestPosX = (tmpUnit.DestinationPositionX - tmpMap.Left) * fScale +
                                            fX;
                        var iUnitDestPosY = (tmpMap.Top - tmpUnit.DestinationPositionY) * fScale +
                                            fY;

                        if (float.IsNaN(iUnitPosX) ||
                            float.IsNaN(iUnitPosY) ||
                            float.IsNaN(iUnitDestPosX) ||
                            float.IsNaN(iUnitDestPosY))
                        {
                            continue;
                        }

                        #endregion

                        g.Graphics.CompositingQuality = CompositingQuality.HighQuality;
                        g.Graphics.PixelOffsetMode    = PixelOffsetMode.HighQuality;
                        g.Graphics.SmoothingMode      = SmoothingMode.HighQuality;

                        /* Draws the Line */
                        if (tmpUnit.DestinationPositionX > 10 &&
                            tmpUnit.DestinationPositionY > 10)
                        {
                            g.Graphics.DrawLine(new Pen(new SolidBrush(clDestination)), iUnitPosX, iUnitPosY,
                                                iUnitDestPosX,
                                                iUnitDestPosY);
                        }

                        g.Graphics.CompositingQuality = CompositingQuality.HighSpeed;
                        g.Graphics.PixelOffsetMode    = PixelOffsetMode.HighSpeed;
                        g.Graphics.SmoothingMode      = SmoothingMode.HighSpeed;
                    }
                }

                #endregion

                #region Draw Creeptumors

                for (var i = 0; i < GInformation.Unit.Count; i++)
                {
                    var tmpUnit = GInformation.Unit[i];

                    #region Exceptions

                    /* Ai */
                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveAi)
                    {
                        if (GInformation.Player[tmpUnit.Owner].Type.Equals(PlayerType.Ai))
                        {
                            continue; //clUnitBoundBorder = Color.Transparent;
                        }
                    }

                    /* Allie */
                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveAllie)
                    {
                        if (Player.LocalPlayer != null)
                        {
                            if (GInformation.Player[tmpUnit.Owner].Team ==
                                Player.LocalPlayer.Team &&
                                GInformation.Player[tmpUnit.Owner] != Player.LocalPlayer)
                            {
                                continue; //clUnitBoundBorder = Color.Transparent;
                            }
                        }
                    }

                    /* Localplayer Units */
                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveLocalplayer)
                    {
                        if (tmpUnit.Owner == Player.LocalPlayer.Index)
                        {
                            continue; //clUnitBoundBorder = Color.Transparent;
                        }
                    }

                    /* Neutral Units */
                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveNeutral)
                    {
                        if (GInformation.Player[tmpUnit.Owner].Type.Equals(PlayerType.Neutral))
                        {
                            continue; //clUnitBoundBorder = Color.Transparent;
                        }
                    }

                    /* Dead Units */
                    if ((tmpUnit.TargetFilter & (ulong)TargetFilterFlag.Dead) > 0)
                    {
                        continue;
                    }

                    #endregion

                    #region Actual Drawing

                    if (tmpUnit.Id == UnitId.ZbCreeptumor ||
                        tmpUnit.Id == UnitId.ZbCreepTumorBuilding ||
                        tmpUnit.Id == UnitId.ZbCreepTumorMissle ||
                        tmpUnit.Id == UnitId.ZbCreeptumorBurrowed)
                    {
                        #region Scalling (Unitposition)

                        var iUnitPosX = (tmpUnit.PositionX - tmpMap.Left) * fScale + fX;
                        var iUnitPosY = (tmpMap.Top - tmpUnit.PositionY) * fScale + fY;

                        if (float.IsNaN(iUnitPosX) ||
                            float.IsNaN(iUnitPosY))
                        {
                            continue;
                        }

                        #endregion

                        var fRadius          = 4f;
                        var fLocalHypotenuse = 32.25218f;   //Hypotenuse of size 8

                        var fLocalUnitScale = fHypotenuse / fLocalHypotenuse;
                        var fSize           = (float)Math.Sqrt((Math.Pow(fLocalUnitScale, 2) - Math.Pow((fRadius * 2), 2)));
                        fSize /= 2;

                        g.Graphics.DrawLine(Constants.PBlack2, iUnitPosX - fSize, iUnitPosY - fSize,
                                            iUnitPosX + fSize, iUnitPosY + fSize);
                        g.Graphics.DrawLine(Constants.PBlack2, iUnitPosX + fSize, iUnitPosY - fSize,
                                            iUnitPosX - fSize, iUnitPosY + fSize);
                    }

                    #endregion
                }

                #endregion

                #region Draw Unit (Border/ outer Rectangle)

                for (var i = 0; i < GInformation.Unit.Count; i++)
                {
                    var tmpUnit     = GInformation.Unit[i];
                    var clUnitBound = Color.Black;

                    if (tmpUnit.Owner >= (GInformation.Player.Count))
                    {
                        continue;
                    }

                    #region Escape Sequences

                    /* Ai */
                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveAi)
                    {
                        if (GInformation.Player[tmpUnit.Owner].Type.Equals(PlayerType.Ai))
                        {
                            continue;
                        }
                    }

                    /* Allie */
                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveAllie)
                    {
                        if (Player.LocalPlayer != null)
                        {
                            if (GInformation.Player[tmpUnit.Owner].Team ==
                                Player.LocalPlayer.Team &&
                                GInformation.Player[tmpUnit.Owner] != Player.LocalPlayer)
                            {
                                continue;
                            }
                        }
                    }

                    /* Localplayer Units */
                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveLocalplayer)
                    {
                        if (tmpUnit.Owner == Player.LocalPlayer.Index)
                        {
                            continue;
                        }
                    }

                    /* Neutral Units */
                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveNeutral)
                    {
                        if (GInformation.Player[tmpUnit.Owner].Type.Equals(PlayerType.Neutral))
                        {
                            continue;
                        }
                    }


                    /* Dead Units */
                    if ((tmpUnit.TargetFilter & (ulong)TargetFilterFlag.Dead) > 0)
                    {
                        continue;
                    }

                    /* Creep tumor */
                    if (tmpUnit.Id ==
                        UnitId.ZbCreeptumorBurrowed)
                    {
                        continue;
                    }

                    #endregion

                    #region Scalling (Unitposition)

                    var iUnitPosX = (tmpUnit.PositionX - tmpMap.Left) * fScale + fX;
                    var iUnitPosY = (tmpMap.Top - tmpUnit.PositionY) * fScale + fY;

                    if (float.IsNaN(iUnitPosX) ||
                        float.IsNaN(iUnitPosY))
                    {
                        continue;
                    }

                    #endregion

                    var fUnitSize        = tmpUnit.Size;
                    var size             = 2.0f;
                    var fLocalHypotenuse = 129.0087f;

                    if (fUnitSize >= 0.5)
                    {
                        size             = 3;
                        fLocalHypotenuse = 86.00581f;
                    }

                    if (fUnitSize >= 0.875)
                    {
                        size             = 4;
                        fLocalHypotenuse = 64.50436f;
                    }

                    if (fUnitSize >= 1.5)
                    {
                        size             = 6;
                        fLocalHypotenuse = 43.00291f;
                    }

                    if (fUnitSize >= 2.0)
                    {
                        size             = 8;
                        fLocalHypotenuse = 32.25218f;
                    }

                    if (fUnitSize >= 2.5)
                    {
                        size             = 10;
                        fLocalHypotenuse = 25.8017f;
                    }

                    var fLocalUnitScale = fHypotenuse / fLocalHypotenuse;
                    size = (float)Math.Sqrt((Math.Pow(fLocalUnitScale, 2) - Math.Pow(size, 2)));


                    size += 0.5f;

                    #region Actual drawing

                    g.Graphics.PixelOffsetMode    = PixelOffsetMode.HighSpeed;
                    g.Graphics.SmoothingMode      = SmoothingMode.HighSpeed;
                    g.Graphics.CompositingQuality = CompositingQuality.HighSpeed;

                    if (tmpUnit.IsCloaked &&
                        tmpUnit.Id != UnitId.ZbCreeptumorBurrowed)
                    {
                        g.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.Gray)), iUnitPosX - size / 2,
                                                 iUnitPosY - size / 2, size, size);

                        g.Graphics.DrawRectangle(new Pen(new SolidBrush(clUnitBound)), iUnitPosX - size / 2 - 0.5f,
                                                 iUnitPosY - size / 2 - 0.5f, size + 1, size + 1);
                    }

                    else
                    {
                        g.Graphics.DrawRectangle(new Pen(new SolidBrush(clUnitBound)), iUnitPosX - size / 2,
                                                 iUnitPosY - size / 2, size, size);
                    }

                    g.Graphics.PixelOffsetMode    = PixelOffsetMode.HighSpeed;
                    g.Graphics.SmoothingMode      = SmoothingMode.HighSpeed;
                    g.Graphics.CompositingQuality = CompositingQuality.HighSpeed;

                    #endregion
                }

                #endregion

                #region Draw Unit (Inner Rectangle)

                for (var i = 0; i < GInformation.Unit.Count; i++)
                {
                    var tmpUnit = GInformation.Unit[i];
                    //Color clUnit = LUnit[i].Owner > LPlayer.Count ? Color.Transparent : LPlayer[LUnit[i].Owner].Color;

                    if (tmpUnit.Owner >= GInformation.Player.Count)
                    {
                        continue;
                    }


                    var clUnit = GInformation.Player[tmpUnit.Owner].Color;

                    #region Teamcolor

                    RendererHelper.TeamColor(GInformation.Player, GInformation.Unit, i,
                                             GInformation.Gameinfo.IsTeamcolor, ref clUnit);

                    #endregion

                    #region Scalling (Unitposition)

                    var iUnitPosX = (tmpUnit.PositionX - tmpMap.Left) * fScale + fX;
                    var iUnitPosY = (tmpMap.Top - tmpUnit.PositionY) * fScale + fY;


                    if (float.IsNaN(iUnitPosX) ||
                        float.IsNaN(iUnitPosY))
                    {
                        continue;
                    }

                    #endregion

                    #region Escape Sequences

                    /* Ai */
                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveAi)
                    {
                        if (GInformation.Player[tmpUnit.Owner].Type.Equals(PlayerType.Ai))
                        {
                            continue;
                        }
                    }

                    /* Allie */
                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveAllie)
                    {
                        if (Player.LocalPlayer != null)
                        {
                            if (GInformation.Player[tmpUnit.Owner].Team ==
                                Player.LocalPlayer.Team &&
                                GInformation.Player[tmpUnit.Owner] != Player.LocalPlayer)
                            {
                                continue;
                            }
                        }
                    }

                    /* Localplayer Units */
                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveLocalplayer)
                    {
                        if (tmpUnit.Owner == Player.LocalPlayer.Index)
                        {
                            continue;
                        }
                    }

                    /* Neutral Units */
                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveNeutral)
                    {
                        if (GInformation.Player[tmpUnit.Owner].Type.Equals(PlayerType.Neutral))
                        {
                            continue;
                        }
                    }


                    /* Dead Units */
                    if ((tmpUnit.TargetFilter & (ulong)TargetFilterFlag.Dead) > 0)
                    {
                        continue;
                    }

                    /* Creep tumor */
                    if (tmpUnit.Id ==
                        UnitId.ZbCreeptumorBurrowed)
                    {
                        continue;
                    }

                    #endregion

                    var fUnitSize        = tmpUnit.Size;
                    var size             = 2.0f;
                    var fLocalHypotenuse = 129.0087f;

                    if (fUnitSize >= 0.5)
                    {
                        size             = 3;
                        fLocalHypotenuse = 86.00581f;
                    }

                    if (fUnitSize >= 0.875)
                    {
                        size             = 4;
                        fLocalHypotenuse = 64.50436f;
                    }

                    if (fUnitSize >= 1.5)
                    {
                        size             = 6;
                        fLocalHypotenuse = 43.00291f;
                    }

                    if (fUnitSize >= 2.0)
                    {
                        size             = 8;
                        fLocalHypotenuse = 32.25218f;
                    }

                    if (fUnitSize >= 2.5)
                    {
                        size             = 10;
                        fLocalHypotenuse = 25.8017f;
                    }

                    var fLocalUnitScale = fHypotenuse / fLocalHypotenuse;
                    size = (float)Math.Sqrt((Math.Pow(fLocalUnitScale, 2) - Math.Pow(size, 2)));


                    size -= 0.5f;


                    g.Graphics.PixelOffsetMode    = PixelOffsetMode.HighSpeed;
                    g.Graphics.SmoothingMode      = SmoothingMode.HighSpeed;
                    g.Graphics.CompositingQuality = CompositingQuality.HighSpeed;

                    /* Draw the Unit (Actual Unit) */
                    g.Graphics.FillRectangle(new SolidBrush(clUnit), iUnitPosX - size / 2, iUnitPosY - size / 2, size, size);

                    g.Graphics.PixelOffsetMode    = PixelOffsetMode.HighSpeed;
                    g.Graphics.SmoothingMode      = SmoothingMode.HighSpeed;
                    g.Graphics.CompositingQuality = CompositingQuality.HighSpeed;
                }

                #endregion

                #region Draw Border of special Units

                for (var i = 0; i < GInformation.Unit.Count; i++)
                {
                    var tmpUnit           = GInformation.Unit[i];
                    var clUnitBoundBorder = Color.Black;

                    if (tmpUnit.Owner >= (GInformation.Player.Count))
                    {
                        continue;
                    }

                    #region Scalling (Unitposition)

                    var iUnitPosX = (tmpUnit.PositionX - tmpMap.Left) * fScale + fX;
                    var iUnitPosY = (tmpMap.Top - tmpUnit.PositionY) * fScale + fY;


                    if (float.IsNaN(iUnitPosX) ||
                        float.IsNaN(iUnitPosY))
                    {
                        continue;
                    }

                    var fUnitSize        = tmpUnit.Size;
                    var size             = 2.0f;
                    var fLocalHypotenuse = 129.0087f;

                    if (fUnitSize >= 0.5)
                    {
                        size             = 3;
                        fLocalHypotenuse = 86.00581f;
                    }

                    if (fUnitSize >= 0.875)
                    {
                        size             = 4;
                        fLocalHypotenuse = 64.50436f;
                    }

                    if (fUnitSize >= 1.5)
                    {
                        size             = 6;
                        fLocalHypotenuse = 43.00291f;
                    }

                    if (fUnitSize >= 2.0)
                    {
                        size             = 8;
                        fLocalHypotenuse = 32.25218f;
                    }

                    if (fUnitSize >= 2.5)
                    {
                        size             = 10;
                        fLocalHypotenuse = 25.8017f;
                    }

                    var fLocalUnitScale = fHypotenuse / fLocalHypotenuse;
                    size = (float)Math.Sqrt((Math.Pow(fLocalUnitScale, 2) - Math.Pow(size, 2)));


                    size += 0.5f;


                    #endregion

                    #region Escape Sequences

                    /* Ai */
                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveAi)
                    {
                        if (GInformation.Player[tmpUnit.Owner].Type.Equals(PlayerType.Ai))
                        {
                            continue; //clUnitBoundBorder = Color.Transparent;
                        }
                    }

                    /* Allie */
                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveAllie)
                    {
                        if (Player.LocalPlayer != null)
                        {
                            if (GInformation.Player[tmpUnit.Owner].Team ==
                                Player.LocalPlayer.Team &&
                                GInformation.Player[tmpUnit.Owner] != Player.LocalPlayer)
                            {
                                continue; //clUnitBoundBorder = Color.Transparent;
                            }
                        }
                    }

                    /* Localplayer Units */
                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveLocalplayer)
                    {
                        if (tmpUnit.Owner == Player.LocalPlayer.Index)
                        {
                            continue;
                        }
                    }

                    /* Neutral Units */
                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveNeutral)
                    {
                        if (GInformation.Player[tmpUnit.Owner].Type.Equals(PlayerType.Neutral))
                        {
                            continue; //clUnitBoundBorder = Color.Transparent;
                        }
                    }


                    /* Dead Units */
                    if ((tmpUnit.TargetFilter & (ulong)TargetFilterFlag.Dead) > 0)
                    {
                        continue;
                    }

                    #endregion

                    #region Border special Units

                    #region Self created Units

                    if (PSettings.PreferenceAll.OverlayMaphack.UnitIds != null ||
                        PSettings.PreferenceAll.OverlayMaphack.UnitColors != null)
                    {
                        for (var j = 0; j < PSettings.PreferenceAll.OverlayMaphack.UnitIds.Count; j++)
                        {
                            var tmpSettingsId = PSettings.PreferenceAll.OverlayMaphack.UnitIds[j];
                            var bExpression   = false;

                            if (tmpSettingsId == UnitId.ZuChangeling)
                            {
                                if (tmpUnit.Id == UnitId.ZuChangeling ||
                                    tmpUnit.Id == UnitId.ZuChangelingMarine ||
                                    tmpUnit.Id == UnitId.ZuChangelingMarineShield ||
                                    tmpUnit.Id == UnitId.ZuChangelingSpeedling ||
                                    tmpUnit.Id == UnitId.ZuChangelingZealot ||
                                    tmpUnit.Id == UnitId.ZuChangelingZergling)
                                {
                                    bExpression = true;
                                }
                            }

                            else
                            {
                                bExpression = tmpUnit.Id == PSettings.PreferenceAll.OverlayMaphack.UnitIds[j]
                                    ? true
                                    : false;
                            }

                            if (bExpression)
                            {
                                if (PSettings.PreferenceAll.OverlayMaphack.UnitColors[j] != Color.Transparent)
                                {
                                    var clUnit = PSettings.PreferenceAll.OverlayMaphack.UnitColors[j];
                                    if (!tmpUnit.IsAlive)
                                    {
                                        continue;
                                    }

                                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveLocalplayer)
                                    {
                                        if (tmpUnit.Owner ==
                                            Player.LocalPlayer.Index)
                                        {
                                            continue;
                                        }
                                    }

                                    g.Graphics.DrawRectangle(
                                        new Pen(new SolidBrush(clUnit), 1.5f),
                                        (iUnitPosX - size / 2), (iUnitPosY - size / 2), size, size);

                                    g.Graphics.DrawRectangle(new Pen(new SolidBrush(clUnitBoundBorder)),
                                                             iUnitPosX - ((size / 2) + 0.75f),
                                                             iUnitPosY - ((size / 2) + 0.75f), size + 1.75f, size + 1.75f);
                                }
                            }
                        }
                    }

                    #endregion

                    #region CreepTumors

                    //if (_hMainHandler.GInformation.Unit[i].CustomStruct.Id == (int) PredefinedTypes.UnitId.ZbCreeptumor)
                    //{
                    //    g.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.Gray), 1.5f),
                    //                             (iUnitPosX - size/2), (iUnitPosY - size/2), size, size);

                    //    g.Graphics.DrawRectangle(new Pen(new SolidBrush(clUnitBoundBorder)),
                    //                             iUnitPosX - ((size/2) + 0.75f),
                    //                             iUnitPosY - ((size/2) + 0.75f), size + 1.75f, size + 1.75f);
                    //}


                    //if (_hMainHandler.GInformation.Unit[i].CustomStruct.Id == (int)PredefinedTypes.UnitId.ZbCreeptumor ||
                    //    _hMainHandler.GInformation.Unit[i].CustomStruct.Id == (int)PredefinedTypes.UnitId.ZbCreepTumorBuilding ||
                    //    _hMainHandler.GInformation.Unit[i].CustomStruct.Id == (int)PredefinedTypes.UnitId.ZbCreepTumorMissle ||
                    //    _hMainHandler.GInformation.Unit[i].CustomStruct.Id == (int)PredefinedTypes.UnitId.ZbCreeptumorBurrowed)
                    //{
                    //    const Int32 iRadius = 4;

                    //    g.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
                    //    g.Graphics.SmoothingMode = SmoothingMode.HighQuality;

                    //    g.Graphics.DrawLine(Constants.PBlack1, iUnitPosX - iRadius, iUnitPosY - iRadius, iUnitPosX + iRadius, iUnitPosY + iRadius);
                    //    g.Graphics.DrawLine(Constants.PBlack1, iUnitPosX + iRadius, iUnitPosY - iRadius, iUnitPosX - iRadius, iUnitPosY + iRadius);

                    //    g.Graphics.SmoothingMode = SmoothingMode.HighSpeed;
                    //    g.Graphics.PixelOffsetMode = PixelOffsetMode.HighSpeed;

                    //}

                    #endregion

                    #region Unitgroup I - Defensive Buildings

                    if (PSettings.PreferenceAll.OverlayMaphack.ColorDefensiveStructures)
                    {
                        if (tmpUnit.Id == UnitId.TbTurret ||
                            tmpUnit.Id == UnitId.TbBunker ||
                            tmpUnit.Id == UnitId.TbPlanetary ||
                            tmpUnit.Id == UnitId.ZbSpineCrawler ||
                            tmpUnit.Id == UnitId.ZbSpineCrawlerUnrooted ||
                            tmpUnit.Id == UnitId.ZbSporeCrawler ||
                            tmpUnit.Id == UnitId.ZbSporeCrawlerUnrooted ||
                            tmpUnit.Id == UnitId.PbCannon)
                        {
                            var clUnitBound = Color.Yellow;


                            if ((tmpUnit.TargetFilter & (ulong)TargetFilterFlag.Dead) > 0)
                            {
                                continue;
                            }


                            if (PSettings.PreferenceAll.OverlayMaphack.RemoveLocalplayer)
                            {
                                if (tmpUnit.Owner == Player.LocalPlayer.Index)
                                {
                                    continue;
                                }
                            }

                            g.Graphics.DrawRectangle(new Pen(new SolidBrush(clUnitBound), 1.5f),
                                                     (iUnitPosX - size / 2), (iUnitPosY - size / 2), size, size);

                            g.Graphics.DrawRectangle(new Pen(new SolidBrush(clUnitBoundBorder)),
                                                     iUnitPosX - ((size / 2) + 0.75f),
                                                     iUnitPosY - ((size / 2) + 0.75f), size + 1.75f, size + 1.75f);
                        }
                    }

                    #endregion

                    #region Hallucinations - make a triangle

                    #endregion

                    var ptPoints = new PointF[3];
                    var fRadius  = size * 2;

                    if (tmpUnit.IsHallucination)
                    {
                        ptPoints[0] = new PointF(iUnitPosX + (size / 2), iUnitPosY - fRadius - 1);
                        ptPoints[1] = new PointF(iUnitPosX - fRadius, iUnitPosY + fRadius);
                        ptPoints[2] = new PointF(iUnitPosX + fRadius + 1, iUnitPosY + fRadius);
                    }

                    g.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
                    g.Graphics.SmoothingMode   = SmoothingMode.HighQuality;

                    g.Graphics.DrawPolygon(new Pen(Brushes.Orange, 1), ptPoints);

                    g.Graphics.SmoothingMode   = SmoothingMode.HighSpeed;
                    g.Graphics.PixelOffsetMode = PixelOffsetMode.HighSpeed;

                    #endregion
                }

                #endregion

                #region Draw Player camera

                if (!PSettings.PreferenceAll.OverlayMaphack.RemoveCamera)
                {
                    for (var i = 0; i < GInformation.Player.Count; i++)
                    {
                        var clPlayercolor = GInformation.Player[i].Color;

                        #region Teamcolor

                        if (GInformation.Gameinfo.IsTeamcolor)
                        {
                            if (Player.LocalPlayer != null)
                            {
                                if (GInformation.Player[i] == Player.LocalPlayer)
                                {
                                    clPlayercolor = Color.Green;
                                }

                                else if (GInformation.Player[i].Team ==
                                         Player.LocalPlayer.Team &&
                                         GInformation.Player[i] != Player.LocalPlayer)
                                {
                                    clPlayercolor = Color.Yellow;
                                }

                                else
                                {
                                    clPlayercolor = Color.Red;
                                }
                            }
                        }

                        #endregion

                        #region Escape Sequences

                        /* Ai - Works */
                        if (PSettings.PreferenceAll.OverlayMaphack.RemoveAi)
                        {
                            if (GInformation.Player[i].Type.Equals(PlayerType.Ai))
                            {
                                continue;
                            }
                        }

                        /* Localplayer - Works */
                        if (PSettings.PreferenceAll.OverlayMaphack.RemoveLocalplayer)
                        {
                            if (GInformation.Player[i] == Player.LocalPlayer)
                            {
                                continue;
                            }
                        }

                        /* Allie */
                        if (PSettings.PreferenceAll.OverlayMaphack.RemoveAllie)
                        {
                            if (Player.LocalPlayer != null)
                            {
                                if (GInformation.Player[i].Team ==
                                    Player.LocalPlayer.Team &&
                                    GInformation.Player[i] != Player.LocalPlayer)
                                {
                                    continue;
                                }
                            }
                        }

                        /* Neutral */
                        if (PSettings.PreferenceAll.OverlayMaphack.RemoveNeutral)
                        {
                            if (GInformation.Player[i].Type.Equals(PlayerType.Neutral))
                            {
                                continue;
                            }
                        }

                        if (GInformation.Player[i].Type.Equals(PlayerType.Hostile))
                        {
                            continue;
                        }

                        if (GInformation.Player[i].Type.Equals(PlayerType.Observer))
                        {
                            continue;
                        }

                        if (GInformation.Player[i].Type.Equals(PlayerType.Referee))
                        {
                            continue;
                        }

                        if (float.IsInfinity(fScale))
                        {
                            continue;
                        }

                        if (CheckIfGameheart(GInformation.Player[i]))
                        {
                            continue;
                        }

                        #endregion

                        #region Drawing

                        //The actrual position of the Cameras
                        var fPlayerX = (GInformation.Player[i].CameraPositionX - tmpMap.Left) * fScale + fX;
                        var fPlayerY = (tmpMap.Top - GInformation.Player[i].CameraPositionY) * fScale + fY;


                        if (fPlayerX <= 0 || fPlayerX >= Width ||
                            fPlayerY <= 0 || fPlayerY >= Height)
                        {
                            continue;
                        }

                        var size             = 48f;
                        var upper            = 35f;
                        var lower            = 10f;
                        var fLocalHypotenuse = 5.3755f;
                        var fUpperHypotenuse = 7.3718f;
                        var fLowerHypotenuse = 25.8016f;
                        var fLocalSizeScale  = fHypotenuse / fLocalHypotenuse;
                        var fLocalUpperScale = fHypotenuse / fUpperHypotenuse;
                        var fLocalLowerScale = fHypotenuse / fLowerHypotenuse;
                        size = (float)Math.Sqrt((Math.Pow(fLocalSizeScale, 2) - Math.Pow(size, 2)));
                        var upperRadius = (float)Math.Sqrt((Math.Pow(fLocalUpperScale, 2) - Math.Pow(upper, 2)));
                        var lowerRadius = (float)Math.Sqrt((Math.Pow(fLocalLowerScale, 2) - Math.Pow(lower, 2)));
                        var radius      = size / 2;



                        var ptPoints = new PointF[4];
                        ptPoints[0] = new PointF(fPlayerX - upperRadius, fPlayerY - radius);
                        ptPoints[1] = new PointF(fPlayerX + upperRadius, fPlayerY - radius);
                        ptPoints[2] = new PointF(fPlayerX + radius, fPlayerY + lowerRadius);
                        ptPoints[3] = new PointF(fPlayerX - radius, fPlayerY + lowerRadius);


                        g.Graphics.DrawPolygon(new Pen(new SolidBrush(clPlayercolor), 2), ptPoints);

                        #endregion
                    }
                }

                #endregion

                #endregion
            }

            catch (Exception ex)
            {
                Messages.LogFile("Over all", ex);
            }
        }
示例#3
0
        /// <summary>
        ///     Draws the panelspecific data.
        /// </summary>
        /// <param name="g"></param>
        protected override void Draw(BufferedGraphics g)
        {
            try
            {
                if (!GInformation.Gameinfo.IsIngame)
                {
                    return;
                }

                var iValidPlayerCount = GInformation.Gameinfo.ValidPlayerCount;

                if (iValidPlayerCount == 0)
                {
                    return;
                }

                Opacity = PSettings.PreferenceAll.OverlayApm.Opacity;
                var iSingleHeight       = Height / iValidPlayerCount;
                var fNewFontSize        = (float)((29.0 / 100) * iSingleHeight);
                var fInternalFont       = new Font(PSettings.PreferenceAll.OverlayApm.FontName, fNewFontSize, FontStyle.Bold);
                var fInternalFontNormal = new Font(fInternalFont.Name, fNewFontSize, FontStyle.Regular);

                if (!BChangingPosition)
                {
                    Height = PSettings.PreferenceAll.OverlayApm.Height * iValidPlayerCount;
                    Width  = PSettings.PreferenceAll.OverlayApm.Width;
                }

                var iCounter = 0;
                for (var i = 0; i < GInformation.Player.Count; i++)
                {
                    var clPlayercolor = GInformation.Player[i].Color;

                    #region Teamcolor

                    RendererHelper.TeamColor(GInformation.Player, i,
                                             GInformation.Gameinfo.IsTeamcolor, ref clPlayercolor);

                    #endregion

                    #region Escape sequences

                    if (GInformation.Player[i].Name.StartsWith("\0") || GInformation.Player[i].NameLength <= 0)
                    {
                        continue;
                    }

                    if (GInformation.Player[i].Type.Equals(PlayerType.Hostile))
                    {
                        continue;
                    }

                    if (GInformation.Player[i].Type.Equals(PlayerType.Observer))
                    {
                        continue;
                    }

                    if (GInformation.Player[i].Type.Equals(PlayerType.Referee))
                    {
                        continue;
                    }

                    if (CheckIfGameheart(GInformation.Player[i]))
                    {
                        continue;
                    }


                    if (PSettings.PreferenceAll.OverlayApm.RemoveAi)
                    {
                        if (GInformation.Player[i].Type.Equals(PlayerType.Ai))
                        {
                            continue;
                        }
                    }

                    if (PSettings.PreferenceAll.OverlayApm.RemoveNeutral)
                    {
                        if (GInformation.Player[i].Type.Equals(PlayerType.Neutral))
                        {
                            continue;
                        }
                    }

                    if (PSettings.PreferenceAll.OverlayApm.RemoveAllie)
                    {
                        if (Player.LocalPlayer.Index == 16)
                        {
                            //Do nothing
                        }

                        else
                        {
                            if (GInformation.Player[i].Team ==
                                Player.LocalPlayer.Team &&
                                GInformation.Player[i].Index != Player.LocalPlayer.Index)
                            {
                                continue;
                            }
                        }
                    }

                    if (PSettings.PreferenceAll.OverlayApm.RemoveLocalplayer)
                    {
                        if (Player.LocalPlayer == GInformation.Player[i])
                        {
                            continue;
                        }
                    }

                    #endregion

                    #region Draw Bounds and Background

                    if (PSettings.PreferenceAll.OverlayApm.DrawBackground)
                    {
                        /* Background */
                        g.Graphics.FillRectangle(Brushes.Gray, 1, 1 + (iSingleHeight * iCounter), Width - 2,
                                                 iSingleHeight - 2);

                        /* Border */
                        g.Graphics.DrawRectangle(new Pen(new SolidBrush(clPlayercolor), 2), 1,
                                                 1 + (iSingleHeight * iCounter),
                                                 Width - 2, iSingleHeight - 2);
                    }

                    #endregion

                    #region Content Drawing

                    #region Name

                    var strName = (GInformation.Player[i].ClanTag.StartsWith("\0") ||
                                   PSettings.PreferenceAll.OverlayApm.RemoveClanTag)
                        ? GInformation.Player[i].Name
                        : "[" + GInformation.Player[i].ClanTag + "] " + GInformation.Player[i].Name;

                    g.Graphics.DrawString(
                        strName,
                        fInternalFont,
                        new SolidBrush(clPlayercolor),
                        Brushes.Black, (float)((1.67 / 100) * Width),
                        (float)((24.0 / 100) * iSingleHeight) + iSingleHeight * iCounter,
                        1f, 1f, true);

                    #endregion

                    #region Team

                    g.Graphics.DrawString(
                        "#" + GInformation.Player[i].Team, fInternalFontNormal,
                        Brushes.White,
                        Brushes.Black, (float)((29.67 / 100) * Width),
                        (float)((24.0 / 100) * iSingleHeight) + iSingleHeight * iCounter,
                        1f, 1f, true);

                    #endregion

                    #region Apm

                    g.Graphics.DrawString(
                        "APM: " + GInformation.Player[i].ApmAverage +
                        " [" + GInformation.Player[i].Apm + "]", fInternalFontNormal,
                        Brushes.White,
                        Brushes.Black, (float)((37.0 / 100) * Width),
                        (float)((24.0 / 100) * iSingleHeight) + iSingleHeight * iCounter,
                        1f, 1f, true);

                    #endregion

                    #region Epm

                    g.Graphics.DrawString(
                        "EPM: " + GInformation.Player[i].EpmAverage +
                        " [" + GInformation.Player[i].Epm + "]", fInternalFontNormal,
                        Brushes.White,
                        Brushes.Black, (float)((63.67 / 100) * Width),
                        (float)((24.0 / 100) * iSingleHeight) + iSingleHeight * iCounter,
                        1f, 1f, true);

                    #endregion

                    #endregion

                    iCounter++;
                }
            }

            catch (Exception ex)
            {
                Logger.Emit(ex);
            }
        }