Example #1
0
    static Action TestAOEHeal(Entity hero, IEnumerable <Entity> my)
    {
        if (hero.HeroType == HeroType.DOCTOR_STRANGE)
        {
            if (hero.Mana > 50 && hero.CountDown[0] == 0)
            {
                var oh = my.Where(u => u.Type == UnitType.HERO &&
                                  u.Id != hero.Id).FirstOrDefault();
                var distOh = oh != null?Math.Sqrt(Dist2(hero, oh)) : 100000;

                if (oh != null && oh.Health < 300 && distOh < 350)
                {
                    if (distOh < 250)
                    {
                        return(Action.AOEHeal(hero, oh.X, oh.Y));
                    }
                    else
                    {
                        var pct = 250.0 / distOh;
                        var px  = hero.X + pct * (oh.X - hero.X);
                        var py  = hero.Y + pct * (oh.Y - hero.Y);
                        return(Action.AOEHeal(hero, px, py));
                    }
                }
                else if (oh == null && hero.Health < 300)
                {
                    return(Action.AOEHeal(hero, hero.X, hero.Y)); // heal myself
                }
            }
        }
        return(Action.Wait(hero));
    }