Beispiel #1
0
        void Game_OnGameUpdate(EventArgs args)
        {
            if (!IsActive())
            {
                return;
            }

            float percentScale = (float)MinimapAwarenessTracker.GetMenuItem("SAssembliesTrackersUimScale").GetValue <Slider>().Value / 100;

            foreach (var enemy in _enemies)
            {
                //if (enemy.Key.IsVisible)
                //{
                //    enemy.Value.LastPosition = enemy.Key.ServerPosition;
                //}
                enemy.Value.LastPosition = enemy.Key.ServerPosition;
                if (enemy.Value.SpriteInfo == null || enemy.Value.SpriteInfo.Sprite == null)
                {
                    SpriteHelper.LoadTexture(enemy.Value.Name, ref enemy.Value.SpriteInfo, "UIM");
                }
                if (enemy.Value.SpriteInfo != null && enemy.Value.SpriteInfo.DownloadFinished && !enemy.Value.SpriteInfo.LoadingFinished)
                {
                    enemy.Value.SpriteInfo.Sprite.GrayScale();
                    enemy.Value.SpriteInfo.Sprite.UpdateTextureBitmap(SpriteHelper.CropImage(enemy.Value.SpriteInfo.Sprite.Bitmap, enemy.Value.SpriteInfo.Sprite.Width));
                    enemy.Value.SpriteInfo.Sprite.Scale          = new Vector2(((float)24 / enemy.Value.SpriteInfo.Sprite.Width) * percentScale, ((float)24 / enemy.Value.SpriteInfo.Sprite.Height) * percentScale);
                    enemy.Value.SpriteInfo.Sprite.PositionUpdate = delegate
                    {
                        Vector2 serverPos = Drawing.WorldToMinimap(enemy.Value.LastPosition);
                        var     mPos      = new Vector2((int)(serverPos[0] - 32 * 0.3f), (int)(serverPos[1] - 32 * 0.3f));
                        return(new Vector2(mPos.X, mPos.Y));
                    };
                    enemy.Value.SpriteInfo.Sprite.VisibleCondition = delegate
                    {
                        return(IsActive() && !enemy.Key.IsVisible && enemy.Value.LastPosition != Vector3.Zero);
                    };
                    enemy.Value.SpriteInfo.Sprite.Add(0);
                    enemy.Value.SpriteInfo.LoadingFinished = true;
                }
            }
        }
        private void CreateSprites(PingInfo info)
        {
            String    iconName           = null;
            String    iconBackgroundName = null;
            String    directionName      = null;
            String    typeName           = "";
            ColorBGRA directionColor     = SharpDX.Color.White;

            switch (info.Type)
            {
            case PingCategory.AssistMe:
                iconName           = "pingcomehere";
                iconBackgroundName = "pingmarker";
                directionName      = "directionindicator";
                typeName           = "Assist";
                directionColor     = SharpDX.Color.DeepSkyBlue;
                break;

            case PingCategory.Danger:
                iconName           = "pinggetback";
                iconBackgroundName = "pingmarker_red";
                directionName      = "directionindicator";
                typeName           = "Danger";
                directionColor     = SharpDX.Color.Red;
                break;

            case PingCategory.OnMyWay:
                iconName           = "pingomw";
                iconBackgroundName = "pingmarker_green";
                directionName      = "directionindicator";
                typeName           = "OnMyWay";
                directionColor     = SharpDX.Color.MediumSeaGreen;
                break;

            case PingCategory.Fallback:
                iconName           = "pingmia";
                iconBackgroundName = "pingmarker_yellow";
                directionName      = "directionindicator";
                typeName           = "Fallback";
                directionColor     = SharpDX.Color.Yellow;
                break;

            case PingCategory.EnemyMissing:
                iconName           = "pingmia";
                iconBackgroundName = "pingmarker_yellow";
                directionName      = "directionindicator";
                typeName           = "Miss";
                directionColor     = SharpDX.Color.Yellow;
                break;
            }

            //info.Text = new Render.Text(typeName, 0, 0, 20, Color.Aqua);
            //info.Text.PositionUpdate = delegate
            //    {
            //        return GetScreenPosition(info.Pos, new Size(50, 50));
            //    };
            //info.Text.Add(1);

            if (iconName == null)
            {
                return;
            }

            SpriteHelper.LoadTexture(iconName, ref info.Icon, SpriteHelper.TextureType.Default);
            info.Icon.Sprite.Scale = new Vector2(0.3f);
            SpriteHelper.LoadTexture(iconBackgroundName, ref info.IconBackground, SpriteHelper.TextureType.Default);
            info.IconBackground.Sprite.Scale = new Vector2(1.5f);
            SpriteHelper.LoadTexture(directionName, ref info.Direction, SpriteHelper.TextureType.Default);
            info.Direction.Sprite.Scale = new Vector2(0.6f);
            info.Direction.Sprite.Color = directionColor;

            info.Direction.Sprite.PositionUpdate = delegate
            {
                var     posInfo   = DirectXDrawer.GetScreenPosition(info.Pos.To3D2(), new Size(info.Direction.Sprite.Width, info.Direction.Sprite.Height));
                Vector2 screenPos = posInfo.Position;
                int     apparentX = (int)Math.Max(1 + info.Direction.Sprite.Width, Math.Min(screenPos.X, Drawing.Width - info.Direction.Sprite.Width));
                int     apparentY = (int)Math.Max(1 + info.Direction.Sprite.Height, Math.Min(screenPos.Y, Drawing.Height - info.Direction.Sprite.Height));
                float   angle     = posInfo.Angle;
                info.Direction.Sprite.Rotation = angle;
                return(new Vector2(apparentX, apparentY));
            };
            info.Direction.Sprite.VisibleCondition = delegate
            {
                return(IsActive() && !Common.IsOnScreen(Drawing.WorldToScreen(info.Pos.To3D2())));
            };
            info.Direction.Sprite.Add(2);

            info.Icon.Sprite.PositionUpdate = delegate
            {
                var     posInfo  = DirectXDrawer.GetScreenPosition(info.Pos.To3D2(), new Size(info.Icon.Sprite.Width + info.Direction.Sprite.Width, info.Icon.Sprite.Height + info.Direction.Sprite.Height));
                Vector2 position = posInfo.Position;
                for (int i = 0; i < 200; i = i + 10)
                {
                    var     aabbBox     = DirectXDrawer.GetAABBBox(info.Direction.Sprite);
                    Vector2 positionNew = position.Extend(position + posInfo.Direction, -i);
                    if (!((Math.Abs(positionNew.X - aabbBox.X) * 2 <
                           (info.Icon.Sprite.Width + aabbBox.Width)) &&
                          (Math.Abs(positionNew.Y - aabbBox.Y) * 2 <
                           (info.Icon.Sprite.Height + aabbBox.Height))) &&
                        positionNew.X > 50 && positionNew.X < Drawing.Width - 100 &&
                        positionNew.Y > 50 && positionNew.Y < Drawing.Height - 100)
                    {
                        if (Common.IsOnScreen(positionNew))
                        {
                            return(positionNew);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                for (int i = 0; i < 200; i = i + 10)
                {
                    var     aabbBox     = DirectXDrawer.GetAABBBox(info.Direction.Sprite);
                    Vector2 positionNew = position.Extend(position + posInfo.Direction, i);
                    if (!((Math.Abs(positionNew.X - aabbBox.X) * 2 <
                           (info.Icon.Sprite.Width + aabbBox.Width)) &&
                          (Math.Abs(positionNew.Y - aabbBox.Y) * 2 <
                           (info.Icon.Sprite.Height + aabbBox.Height))) &&
                        positionNew.X > 50 && positionNew.X < Drawing.Width - 100 &&
                        positionNew.Y > 50 && positionNew.Y < Drawing.Height - 100)
                    {
                        if (Common.IsOnScreen(positionNew))
                        {
                            return(positionNew);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                return(new Vector2(1, 1));
            };
            info.Icon.Sprite.VisibleCondition = delegate
            {
                return(IsActive() && !Common.IsOnScreen(Drawing.WorldToScreen(info.Pos.To3D2())));
            };
            info.Icon.Sprite.Add(1);

            info.IconBackground.Sprite.PositionUpdate = delegate
            {
                var backgroundPos = info.Icon.Sprite.Position;
                return(new Vector2(backgroundPos.X - 7, backgroundPos.Y - 7));
            };
            info.IconBackground.Sprite.VisibleCondition = delegate
            {
                return(IsActive() && !Common.IsOnScreen(Drawing.WorldToScreen(info.Pos.To3D2())));
            };
            info.IconBackground.Sprite.Add(0);

            if (info.Type == PingCategory.OnMyWay)
            {
                SpriteHelper.LoadTexture(ObjectManager.GetUnitByNetworkId <Obj_AI_Hero>(info.NetworkId).ChampionName + ".png", ref info.Champion, "SPI");
                if (info.Champion == null)
                {
                    return;
                }

                SpriteHelper.LoadTexture(directionName, ref info.ChampionDirection, SpriteHelper.TextureType.Default);
                info.ChampionDirection.Sprite.Scale = new Vector2(0.6f);
                info.ChampionDirection.Sprite.Color = directionColor;

                info.ChampionDirection.Sprite.PositionUpdate = delegate
                {
                    var posInfo = DirectXDrawer.GetScreenPosition(ObjectManager.GetUnitByNetworkId <Obj_AI_Hero>(info.NetworkId).Position,
                                                                  new Size(info.ChampionDirection.Sprite.Width, info.ChampionDirection.Sprite.Height));
                    Vector2 screenPos = posInfo.Position;
                    int     apparentX = (int)Math.Max(1 + info.ChampionDirection.Sprite.Width, Math.Min(screenPos.X, Drawing.Width - info.ChampionDirection.Sprite.Width));
                    int     apparentY = (int)Math.Max(1 + info.ChampionDirection.Sprite.Height, Math.Min(screenPos.Y, Drawing.Height - info.ChampionDirection.Sprite.Height));
                    float   angle     = posInfo.Angle;
                    info.ChampionDirection.Sprite.Rotation = angle;
                    return(new Vector2(apparentX, apparentY));
                };
                info.ChampionDirection.Sprite.VisibleCondition = delegate
                {
                    return(IsActive() && !Common.IsOnScreen(Drawing.WorldToScreen(ObjectManager.GetUnitByNetworkId <Obj_AI_Hero>(info.NetworkId).Position)));
                };
                info.ChampionDirection.Sprite.Add(2);

                info.Champion.Sprite.UpdateTextureBitmap(SpriteHelper.CropImage(info.Champion.Sprite.Bitmap, info.Champion.Sprite.Width));
                info.Champion.Sprite.Scale = new Vector2(0.5f);

                info.Champion.Sprite.PositionUpdate = delegate
                {
                    var posInfo = DirectXDrawer.GetScreenPosition(ObjectManager.GetUnitByNetworkId <Obj_AI_Hero>(info.NetworkId).Position,
                                                                  new Size(info.Champion.Sprite.Width + info.ChampionDirection.Sprite.Width, info.Champion.Sprite.Height + info.ChampionDirection.Sprite.Height));
                    Vector2 position = posInfo.Position;
                    for (int i = 0; i < 200; i = i + 10)
                    {
                        var     aabbBox     = DirectXDrawer.GetAABBBox(info.ChampionDirection.Sprite);
                        Vector2 positionNew = position.Extend(position + posInfo.Direction, -i);
                        if (!((Math.Abs(positionNew.X - aabbBox.X) * 2 <
                               (info.Champion.Sprite.Width + aabbBox.Width)) &&
                              (Math.Abs(positionNew.Y - aabbBox.Y) * 2 <
                               (info.Champion.Sprite.Height + aabbBox.Height))) &&
                            positionNew.X > 50 && positionNew.X < Drawing.Width - 100 &&
                            positionNew.Y > 50 && positionNew.Y < Drawing.Height - 100)
                        {
                            if (Common.IsOnScreen(positionNew))
                            {
                                return(positionNew);
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                    for (int i = 0; i < 200; i = i + 10)
                    {
                        var     aabbBox     = DirectXDrawer.GetAABBBox(info.ChampionDirection.Sprite);
                        Vector2 positionNew = position.Extend(position + posInfo.Direction, i);
                        if (!((Math.Abs(positionNew.X - aabbBox.X) * 2 <
                               (info.Champion.Sprite.Width + aabbBox.Width)) &&
                              (Math.Abs(positionNew.Y - aabbBox.Y) * 2 <
                               (info.Champion.Sprite.Height + aabbBox.Height))) &&
                            positionNew.X > 50 && positionNew.X < Drawing.Width - 100 &&
                            positionNew.Y > 50 && positionNew.Y < Drawing.Height - 100)
                        {
                            if (Common.IsOnScreen(positionNew))
                            {
                                return(positionNew);
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                    return(new Vector2(1, 1));
                };
                info.Champion.Sprite.VisibleCondition = delegate
                {
                    return(IsActive() && !Common.IsOnScreen(Drawing.WorldToScreen(ObjectManager.GetUnitByNetworkId <Obj_AI_Hero>(info.NetworkId).Position)));
                };
                info.Champion.Sprite.Add(1);
            }
        }