Exemplo n.º 1
0
        public HeroOverlay(Config config)
        {
            Config = config;
            var panel    = Config.Factory.Menu("Hero Overlay");
            var manaBars = panel.Menu("ManaBars");

            ManaBars         = manaBars.Item("Enable", true);
            ManaBarsForAlly  = manaBars.Item("Enable for ally", true);
            ManaBarsForEnemy = manaBars.Item("Enable for enemy", true);
            ManaBarsNumbers  = manaBars.Item("Draw value", true);
            ManaBarsSize     = manaBars.Item("Size", new Slider(12, 5, 20));

            var abilityOverlay = panel.Menu("Ability overlay");

            AbilityOverlay          = abilityOverlay.Item("Enable", true);
            AbilityLevelTextSize    = abilityOverlay.Item("Ability Level text size", new Slider(5, 2, 10));
            AbilityCooldownTextSize = abilityOverlay.Item("Ability Cooldown/ManaCost text size", new Slider(6, 2, 10));
            AbilitySize             = abilityOverlay.Item("Size", new Slider(7, 1, 20));

            var itemOverlay = panel.Menu("Item overlay");

            ItemOverlay     = itemOverlay.Item("Enable", true);
            ItemDrawCharges = itemOverlay.Item("Draw charges", true);
            ItemDangItems   = itemOverlay.Item("Danger items only", false);
            ItemTextSize    = itemOverlay.Item("Cooldown/ManaCost text size", new Slider(10, 2, 10));
            ItemSize        = itemOverlay.Item("Size", new Slider(7, 1, 20));
            ItemBorderClr   = itemOverlay.Item("Border color", new StringList("white", "black"));

            Drawing.OnDraw += DrawingOnOnDraw;
            HealthBarSize   = new Vector2(HudInfo.GetHPBarSizeX(), HudInfo.GetHpBarSizeY());
        }
Exemplo n.º 2
0
    public void AddHud(HudType type, NDictionary args = null)
    {
        HudInfo info = new HudInfo();

        info.type = type;
        info.args = args;
        hudInfoList.Add(info);
    }
Exemplo n.º 3
0
        /// <summary>
        /// 添加一个Hud
        /// </summary>
        public void AddHud(string name, UIBase hud, Vector2 offset)
        {
            if (hudInfoDict.ContainsKey(name))
            {
                Log.Error("重复添加的Hud! name:", name, "hud:", hud);
                return;
            }

            HudInfo hudInfo = new HudInfo();
            hudInfo.Hud = hud;
            hudInfo.Offset = offset;
            hudInfoDict[name] = hudInfo;
        }
Exemplo n.º 4
0
        private Vector2 GetTopPanelPosition(Hero hero)
        {
            Vector2 pos;

            if (!_topPanelPosition.TryGetValue(hero, out pos))
            {
                pos = HudInfo.GetTopPanelPosition(hero);
                _topPanelPosition[hero] = pos;
            }
            else if (pos.IsZero)
            {
                pos = HudInfo.GetTopPanelPosition(hero);
            }
            return(pos + new Vector2(0, _size.Y));
        }
Exemplo n.º 5
0
        public HeroOverlay(Config config)
        {
            Config = config;
            var panel = Config.Factory.Menu("Hero Overlay");

            EnableForMainHero   = panel.Item("Enable for main hero", true);
            EnableForAllyHeroes = panel.Item("Enable for ally heroes", true);
            ExtraPositionX      = panel.Item("Extra position X", new Slider(0, -50, 50));
            ExtraPositionY      = panel.Item("Extra position Y", new Slider(0, -50, 50));
            ExtraSizeX          = panel.Item("Extra size X", new Slider(0, -50, 50));
            ExtraSizeY          = panel.Item("Extra size Y", new Slider(0, -50, 50));

            var healthBars = panel.Menu("HealthBar");

            HealthBar         = healthBars.Item("Enable", true);
            DrawMaxHealth     = healthBars.Item("Draw max health", true);
            HealthBarTextSize = healthBars.Item("Size", new Slider(12, 5, 20));

            var manaBars = panel.Menu("ManaBars");

            ManaBars         = manaBars.Item("Enable", true);
            ManaBarsForAlly  = manaBars.Item("Enable for ally", true);
            ManaBarsForEnemy = manaBars.Item("Enable for enemy", true);
            ManaBarsNumbers  = manaBars.Item("Draw value", true);
            ManaBarsSize     = manaBars.Item("Size", new Slider(12, 5, 20));

            var abilityOverlay = panel.Menu("Ability overlay");

            AbilityOverlay          = abilityOverlay.Item("Enable", true);
            AbilityLevelTextSize    = abilityOverlay.Item("Ability Level text size", new Slider(5, 2, 10));
            AbilityCooldownTextSize = abilityOverlay.Item("Ability Cooldown/ManaCost text size", new Slider(6, 2, 10));
            AbilitySize             = abilityOverlay.Item("Size", new Slider(7, 1, 20));

            var itemOverlay = panel.Menu("Item overlay");

            ItemOverlay         = itemOverlay.Item("Enable", true);
            ItemDrawCharges     = itemOverlay.Item("Draw charges", true);
            ItemDangItems       = itemOverlay.Item("Danger items only", false);
            ItemInvisBreakItems = itemOverlay.Item("Invis Breaker items only", false);
            ItemInvisBreakItems.Item.SetTooltip("gem, dust, sentry");
            ItemTextSize  = itemOverlay.Item("Cooldown/ManaCost text size", new Slider(10, 2, 10));
            ItemSize      = itemOverlay.Item("Size", new Slider(7, 1, 20));
            ItemBorderClr = itemOverlay.Item("Border color", new StringList("white", "black"));

            Drawing.OnDraw += DrawingOnOnDraw;
            HealthBarSize   = new Vector2(HudInfo.GetHPBarSizeX(), HudInfo.GetHpBarSizeY());
        }
Exemplo n.º 6
0
 public void RemoveHud(HudType type)
 {
     for (int i = hudInfoList.Count - 1; i >= 0; i--)
     {
         HudInfo info = hudInfoList[i];
         if (info.type == type)
         {
             if (info.hudGo != null)
             {
                 IPoolUnit unit = info.hudGo.GetComponent <IPoolUnit>();
                 unit.Restore();
                 info.hudGo = null;
             }
             hudInfoList.RemoveAt(i);
         }
     }
 }
Exemplo n.º 7
0
        private void RendererOnDraw(object sender, EventArgs eventArgs)
        {
            var heroes = Config.Main.Updater.AllyHeroes;
            var size   = HudInfo.GetTopPanelSize();

            foreach (var heroCont in heroes)
            {
                var hero = heroCont.Hero;
                if (heroCont.DontDraw)
                {
                    continue;
                }
                var pos = GetTopPanelPosition(hero);
                if (pos.IsZero)
                {
                    continue;
                }
                if (VisibleBar)
                {
                    var isVisible = hero.IsVisibleToEnemies;
                    if (isVisible)
                    {
                        if (AllyVisibleBarType.Value.SelectedIndex == 1)
                        {
                            //pos = Game.MouseScreenPosition;

                            var rectangle = new RectangleF(pos.X, pos.Y - size.Y, size.X, size.Y);
                            if (IsDx11)
                            {
                                Config.Main.D11Context.RenderTarget.FillRectangle(rectangle, Clr);
                            }
                            else
                            {
                                //Config.Main.D9Context.Device.G.FillRectangle(rectangle, clr);
                                Config.Main.Renderer.DrawRectangle(rectangle,
                                                                   System.Drawing.Color.FromArgb(RectangleA, RectangleR, RectangleG,
                                                                                                 RectangleB), 5);
                            }

                            /*Config.Main.Renderer.DrawRectangle(rectangle,
                             *  System.Drawing.Color.FromArgb(255, 255, 0, 255),10);*/
                        }
                    }
                }
            }
        }
Exemplo n.º 8
0
        public TopPanel(Config config)
        {
            Config = config;
            var panel = Config.Factory.Menu("Top Panel");

            HealthAndManaBars = panel.Menu("Health and Mana bars");
            HealthBar         = HealthAndManaBars.Item("Health bar", true);
            ManaBar           = HealthAndManaBars.Item("Mana bar", true);
            ExtraSizeX        = HealthAndManaBars.Item("Extra Size X", new Slider(0, -25, 25));
            SizeY             = HealthAndManaBars.Item("Size Y", new Slider(7, 1, 20));
            ExtraPosX         = HealthAndManaBars.Item("Extra Position X", new Slider(0, -200, 200));
            ExtraPosY         = HealthAndManaBars.Item("Extra Position Y", new Slider(0, -200, 200));

            UltimateBar        = panel.Item("Ultimate bar", true);
            UltimateBarSize    = panel.Item("Ultimate bar size", new Slider(100, 1, 200));
            UltimateIcon       = panel.Item("Ultimate icon", true);
            VisibleBar         = panel.Item("Visible status", true);
            AllyVisibleBarType = panel.Item("Ally Visible status type", new StringList("text", "rectangle"));
            RectangleA         = panel.Item("rectangle's color -> A", new Slider(100, 0, 255));
            RectangleR         = panel.Item("rectangle's color -> R", new Slider(255, 0, 255));
            RectangleG         = panel.Item("rectangle's color -> G", new Slider(0, 0, 255));
            RectangleB         = panel.Item("rectangle's color -> B", new Slider(255, 0, 255));



            _topPanelPosition = new Dictionary <Hero, Vector2>();
            Drawing.OnDraw   += DrawingOnOnDraw;
            var size = HudInfo.GetTopPanelSize(Config.Main.Context.Value.Owner as Hero);

            _size = new Vector2(size[0], size[1]);

            config.Main.Renderer.Draw += RendererOnDraw;
            IsDx11 = Drawing.RenderMode == RenderMode.Dx11;
            if (IsDx11)
            {
                Clr =
                    Config.Main.BrushCache.GetOrCreate(System.Drawing.Color.FromArgb(RectangleA, RectangleR, RectangleG,
                                                                                     RectangleB));
                RectangleA.PropertyChanged += OnChangeClr;
                RectangleR.PropertyChanged += OnChangeClr;
                RectangleG.PropertyChanged += OnChangeClr;
                RectangleB.PropertyChanged += OnChangeClr;
            }
        }
        public void AddHudHead(GameEntity entity)
        {
            UnityView view = entity.view.Value as UnityView;

            if (null != view)
            {
                var hudHeadObject = ResourceSystem.NewObject("HudHead") as GameObject;
                hudHeadObject.transform.SetParent(UIRoot, false);

                HudInfo hudInfo = new HudInfo();
                hudInfo.Obj = hudHeadObject;

                hudInfo.SelfTransform = hudHeadObject.GetComponentInChildren <RectTransform>();
                hudInfo.Owner         = view.gameObject.transform;
                hudInfo.DeleteTime    = -1;

                m_HudHeadInfos.Add(view.gameObject.GetInstanceID(), hudInfo);
            }
        }
Exemplo n.º 10
0
    GameObject CreateHudInstance(HudInfo info, Vector3 pos, Quaternion quat)
    {
        ISubPool pool = null;

        if (info.type == HudType.Collect)
        {
            pool = ObjectPoolSingleton.Instance.GetPool <HudCollect>();
            HudCollect hud = pool.Take(pos, quat, uirootTrans) as HudCollect;
            return(hud.gameObject);
        }
        else if (info.type == HudType.CountDown)
        {
            pool = ObjectPoolSingleton.Instance.GetPool <HudCountDown>();
            HudCountDown hud = pool.Take(pos, quat, uirootTrans) as HudCountDown;
            if (info.args != null)
            {
                hud.SetTimer(info.args.Value <long>("finishtime"));
            }
            return(hud.gameObject);
        }
        else if (info.type == HudType.NameBoard)
        {
            pool = ObjectPoolSingleton.Instance.GetPool <HudNameBoard>();
            HudNameBoard hud = pool.Take(pos, quat, uirootTrans) as HudNameBoard;
            return(hud.gameObject);
        }
        else if (info.type == HudType.ProduceBar)
        {
            pool = ObjectPoolSingleton.Instance.GetPool <HudProduceBar>();
            HudProduceBar hud = pool.Take(pos, quat, uirootTrans) as HudProduceBar;
            return(hud.gameObject);
        }
        else if (info.type == HudType.Exmind)
        {
            pool = ObjectPoolSingleton.Instance.GetPool <HudExmind>();
            HudExmind hud = pool.Take(pos, quat, uirootTrans) as HudExmind;
            return(hud.gameObject);
        }
        return(null);
    }
Exemplo n.º 11
0
        private void DrawAction(List <CourContainer> cours)
        {
            foreach (var cour in cours)
            {
                var hero = cour.Cour;
                if (!hero.IsAlive)
                {
                    continue;
                }
                if (!hero.IsVisible)
                {
                    continue;
                }
                var pos = HudInfo.GetHPbarPosition(hero);
                if (pos.IsZero)
                {
                    continue;
                }
                var size         = new Vector2(HudInfo.GetHPBarSizeX(hero), HudInfo.GetHpBarSizeY(hero));
                var tempSize     = size.X * ItemSize / 30f;
                var abilitySize  = new Vector2(tempSize);
                var abilities    = cour.Items;
                var abilityCount = abilities.Count;
                pos += new Vector2(0, size.Y - 2);
                pos += new Vector2((size.X - tempSize * abilityCount) / 2f, -abilitySize.Y);

                foreach (var ability in abilities)
                {
                    if (ability == null || !ability.IsValid)
                    {
                        continue;
                    }
                    pos = DrawItemState(pos, ability, abilitySize, Color.White);
                }
            }
        }
Exemplo n.º 12
0
        private void DrawingOnOnDraw(EventArgs args)
        {
            var heroes          = Config.Main.Updater.Heroes;
            var itemBorderWhite = ItemBorderClr.Value.SelectedIndex == 0;

            foreach (var heroCont in heroes)
            {
                if (!EnableForMainHero && heroCont.IsOwner)
                {
                    continue;
                }
                var hero = heroCont.Hero;
                if (!hero.IsAlive)
                {
                    continue;
                }
                if (!hero.IsVisible)
                {
                    continue;
                }
                var hpBarPos = HudInfo.GetHPbarPosition(hero);
                var pos      = hpBarPos + new Vector2(ExtraPositionX, ExtraPositionY);
                if (pos.IsZero)
                {
                    continue;
                }
                var copy = pos;
                var size = new Vector2(HudInfo.GetHPBarSizeX(hero) + ExtraSizeX,
                                       HudInfo.GetHpBarSizeY(hero) + ExtraSizeY);
                if (HealthBar)
                {
                    if (!heroCont.IsAlly)
                    {
                        var health = DrawMaxHealth ? $"{hero.Health}/{heroCont.MaxHealth}" : $"{hero.Health}";
                        DrawingHelper.DrawHealthBar(pos, size, health, HealthBarTextSize);
                    }
                }
                if (heroCont.IsOwner)
                {
                    pos  += new Vector2(-1, size.Y);
                    size -= new Vector2(1, 0);
                }
                else
                {
                    pos += new Vector2(0, size.Y - 2);
                }

                if (ManaBars)
                {
                    if (heroCont.IsAlly && ManaBarsForAlly || !heroCont.IsAlly && ManaBarsForEnemy)
                    {
                        var mana = heroCont.Mana;
                        pos = DrawingHelper.DrawManaBar(pos, mana * size.X / heroCont.MaxMana, size,
                                                        new Color(0, 155, 255, 255),
                                                        new Color(0, 0, 0, 255), ((int)mana).ToString(), ManaBarsNumbers,
                                                        ManaBarsSize.Value.Value);
                    }
                }

                if (AbilityOverlay)
                {
                    var tempSize    = size.X * AbilitySize / 30f;
                    var abilitySize = new Vector2(tempSize);

                    //IEnumerable<Ability> abilities = heroCont.Abilities;
                    //var enumerable = abilities as Ability[] ?? abilities.ToArray();
                    //var abilityCount = abilities.Count();
                    var abilities    = heroCont.Abilities2.Where(x => x.IsValid && !x.IsHidden).ToList();
                    var abilityCount = abilities.Count;
                    //var extraAbilitites = abilityCount - 4;
                    pos += new Vector2((size.X - tempSize * abilityCount) / 2f, 0);

                    /*if (extraAbilitites > 0)
                     * {
                     *  pos -= new Vector2(abilitySize.X * extraAbilitites / 2f, 0);
                     * }*/

                    /*foreach (var ability in abilities)
                     * {
                     *  if (ability == null || !ability.IsValid || ability.IsHidden)
                     *  {
                     *      heroCont.RefreshAbilities();
                     *      continue;
                     *  }
                     *  pos = DrawAbilityState(pos, ability, abilitySize);
                     * }*/

                    try
                    {
                        foreach (var ability in abilities.OrderBy(x => x.AbilitySlot))
                        {
                            pos = DrawAbilityState(pos, ability, abilitySize);
                        }
                    }
                    catch (Exception)
                    {
                        // ignored
                    }
                }

                if (ItemOverlay)
                {
                    var tempSize     = size.X * ItemSize / 30f;
                    var abilitySize  = new Vector2(tempSize);
                    var abilities    = ItemDangItems ? heroCont.DangItems : heroCont.Items;
                    var abilityCount = abilities.Count;
                    //var extraAbilitites = abilityCount - 4;
                    pos  = copy;
                    pos += new Vector2((size.X - tempSize * abilityCount) / 2f, -abilitySize.Y);

                    /*if (extraAbilitites > 0)
                     * {
                     *  //pos -= new Vector2(abilitySize.X * extraAbilitites / 2f, 0);
                     *
                     * }*/

                    foreach (var ability in abilities)
                    {
                        if (ability == null || !ability.IsValid)
                        {
                            continue;
                        }
                        pos = DrawItemState(pos, ability, abilitySize, itemBorderWhite ? Color.White : Color.Black);
                    }
                }
            }
        }
Exemplo n.º 13
0
        private void DrawGlobalPanel(EventArgs args)
        {
            var startPos = HudInfo.GetFakeTopPanelPosition(5, Team.Radiant) +
                           new Vector2(Config.TopPanel.ExtraPosX,
                                       (float)HudInfo.GetTopPanelSizeY() + Config.TopPanel.ExtraPosY);
            var endPos = HudInfo.GetFakeTopPanelPosition(5, Team.Dire) +
                         new Vector2(Config.TopPanel.ExtraPosX, Config.TopPanel.ExtraPosY);
            var  size           = new Vector2(endPos.X - startPos.X, GlobalSizeY);
            uint direNetwoth    = 0;
            uint radiantNetworh = 0;

            foreach (var heroC in Config.Main.Updater.Heroes)
            {
                var hero = heroC.Hero;
                if (hero.Team == Team.Radiant)
                {
                    radiantNetworh += heroC.Networth;
                }
                else
                {
                    direNetwoth += heroC.Networth;
                }
            }
            Color rightClr;
            Color leftClr;

            var percent     = 100 * radiantNetworh / Math.Max(1, radiantNetworh + direNetwoth);
            var currentSize = size.X / 100 * percent;
            var lineSize    = new Vector2(currentSize, size.Y);
            var endOfGreen  = startPos + new Vector2(lineSize.X, 0);

            if (Config.Main.Context.Value.Owner.Team != Team.Radiant)
            {
                leftClr  = new Color(155, 0, 0, 155);
                rightClr = new Color(0, 155, 0, 155);
                percent  = 100 - percent;
            }
            else
            {
                rightClr = new Color(155, 0, 0, 155);
                leftClr  = new Color(0, 155, 0, 155);
            }

            Drawing.DrawRect(startPos, lineSize, leftClr);
            Drawing.DrawRect(endOfGreen, new Vector2(size.X - lineSize.X, lineSize.Y), rightClr);
            Drawing.DrawRect(startPos, size, new Color(0, 0, 0, 255), true);


            var text     = $"{percent}%";
            var textSize = Drawing.MeasureText(text, "Arial",
                                               new Vector2((float)(size.Y * .95), size.Y / 2), FontFlags.AntiAlias);
            var textPos = endOfGreen - new Vector2(textSize.X / 2, /*lineSize.Y / 2 - textSize.Y / 2*/ 0);
            var coef    = GetCoef / 10f;

            if (DrawPercent)
            {
                Drawing.DrawText(
                    text,
                    textPos,
                    new Vector2(textSize.Y, 0),
                    Color.White,
                    FontFlags.AntiAlias | FontFlags.StrikeOut);
            }
            if (DrawTeamValues)
            {
                text = $"{radiantNetworh}";
                Drawing.DrawText(
                    text,
                    startPos + new Vector2(0, size.Y),
                    new Vector2(textSize.Y * coef, 0),
                    Color.White,
                    FontFlags.AntiAlias | FontFlags.StrikeOut);
                text = $"{direNetwoth}";
                Drawing.DrawText(
                    text,
                    startPos + new Vector2(size.X - textSize.X * coef, size.Y),
                    new Vector2(textSize.Y * coef, 0),
                    Color.White,
                    FontFlags.AntiAlias | FontFlags.StrikeOut);
            }
        }
Exemplo n.º 14
0
        public void Tick(ICameraService cameraService)
        {
            float time  = Time.time;
            int   count = m_Damages.Count;

            for (int i = count - 1; i >= 0; i--)
            {
                DamageInfo textInfo = m_Damages[i];

                if (null == textInfo.Obj)
                {
                    m_Damages.Remove(textInfo);
                    continue;
                }

                if (textInfo.DeleteTime > 0 && time > textInfo.DeleteTime)
                {
                    ResourceSystem.RecycleObject(textInfo.Obj);
                    m_Damages.Remove(textInfo);
                }

                bool canMove = Time.time > textInfo.Delay;

                int mov = ScreenPosition(textInfo.Position, cameraService);
                if (canMove)
                {
                    textInfo.YQuickness += Time.deltaTime;
                    float floatSpeed = textInfo.FloatSpeed;
                    switch (textInfo.Movement)
                    {
                    case Guidance.Up:
                        textInfo.YCounterVail += (((Time.deltaTime * floatSpeed) * mov) * m_FactorMultiplier) * textInfo.YQuickness;
                        break;

                    case Guidance.Down:
                        textInfo.YCounterVail -= (((Time.deltaTime * floatSpeed) * mov) * m_FactorMultiplier) * textInfo.YQuickness;
                        break;

                    case Guidance.Left:
                        textInfo.XCounterVail -= ((Time.deltaTime * floatSpeed) * mov) * m_FactorMultiplier;
                        break;

                    case Guidance.Right:
                        textInfo.XCounterVail += ((Time.deltaTime * floatSpeed) * mov) * m_FactorMultiplier;
                        break;

                    case Guidance.RightUp:
                        textInfo.YCounterVail += (((Time.deltaTime * floatSpeed) * mov) * m_FactorMultiplier) * textInfo.YQuickness;
                        textInfo.XCounterVail += ((Time.deltaTime * floatSpeed) * mov) * m_FactorMultiplier;
                        break;

                    case Guidance.RightDown:
                        textInfo.YCounterVail -= (((Time.deltaTime * floatSpeed) * mov) * m_FactorMultiplier) * textInfo.YQuickness;
                        textInfo.XCounterVail += ((Time.deltaTime * floatSpeed) * mov) * m_FactorMultiplier;
                        break;

                    case Guidance.LeftUp:
                        textInfo.YCounterVail += (((Time.deltaTime * floatSpeed) * mov) * m_FactorMultiplier) * textInfo.YQuickness;
                        textInfo.XCounterVail -= ((Time.deltaTime * floatSpeed) * mov) * m_FactorMultiplier;
                        break;

                    case Guidance.LeftDown:
                        textInfo.YCounterVail -= (((Time.deltaTime * floatSpeed) * mov) * m_FactorMultiplier) * textInfo.YQuickness;
                        textInfo.XCounterVail -= ((Time.deltaTime * floatSpeed) * mov) * m_FactorMultiplier;
                        break;
                    }
                }

                Vector2 viewPosition  = cameraService.WorldToViewportPoint(textInfo.Position);
                Vector2 finalPosition = new Vector2(viewPosition.x * 0.5f + textInfo.XCounterVail, -viewPosition.y - textInfo.YCounterVail);

                textInfo.SelfTransform.anchorMax        = viewPosition;
                textInfo.SelfTransform.anchorMin        = viewPosition;
                textInfo.SelfTransform.anchoredPosition = finalPosition;
            }
            foreach (var pair in m_HudHeadInfos)
            {
                int     id      = pair.Key;
                HudInfo hudInfo = pair.Value;

                Vector2 screenPosition = cameraService.WorldToViewportPoint(hudInfo.Owner.position + Vector3.up * 2);

                hudInfo.SelfTransform.anchorMax        = screenPosition;
                hudInfo.SelfTransform.anchorMin        = screenPosition;
                hudInfo.SelfTransform.anchoredPosition = new Vector2(screenPosition.x * 0.5f, -screenPosition.y);
            }
        }