示例#1
0
        private void Drawing_OnEndScene(EventArgs args)
        {
            if (!IsActive())
            {
                return;
            }

            foreach (var info in pingInfo.ToList())
            {
                if (!Common.IsOnScreen(DirectXDrawer.GetScreenPosition(info.Pos.To3D2(), null, false).Position) &&
                    (info.Type == PingCategory.AssistMe || info.Type == PingCategory.Danger || info.Type == PingCategory.OnMyWay ||
                     info.Type == PingCategory.EnemyMissing || info.Type == PingCategory.Fallback))
                {
                    DrawCircle(info.IconBackground.Sprite.Position.X + info.IconBackground.Sprite.Width / 2f,
                               info.IconBackground.Sprite.Position.Y + info.IconBackground.Sprite.Height / 2f,
                               25, 0, true, 32, new ColorBGRA(255, 255, 0, 255));
                }
                //else if (IsActive() &&
                //         !Common.IsOnScreen(
                //             Drawing.WorldToScreen(ObjectManager.GetUnitByNetworkId<Obj_AI_Hero>(info.NetworkId).Position)) &&
                //         info.Type == PingCategory.OnMyWay)
                //{
                //    DrawCircle(info.IconBackground.Sprite.Position.X + info.IconBackground.Sprite.Width / 2f,
                //        info.IconBackground.Sprite.Position.Y + info.IconBackground.Sprite.Height / 2f,
                //        25, 0, true, 32, new ColorBGRA(255, 255, 0, 255));
                //}
            }
        }
示例#2
0
        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);
            }
        }