Exemplo n.º 1
0
        public static double DangerFor(this Formation source, Formation dest)
        {
            var destAeralPercent    = dest.AeralPercent;
            var oneUnitAeralAttack  = Math.Max(0, destAeralPercent * (source.AvgAerialDamage - dest.AvgAerialDefence));
            var oneUnitGroundAttack =
                Math.Max(0, (1 - destAeralPercent) * (source.AvgGroundDamage - dest.AvgGroundDefence));
            var oneUnitAttack = oneUnitGroundAttack + oneUnitAeralAttack;
            var totalAttack   = Math.Min(source.Count * oneUnitAttack, dest.Durability);

            //            var danger = totalAttack / (dest.Durability + 1);
            // var danger = Math.Max(0, oneUnitAttack / (dest.Durability + 1));
            return(totalAttack);
        }
Exemplo n.º 2
0
 public void AbortOldActionsFor(Formation formation)
 {
     foreach (var seq in _internalQueue)
     {
         foreach (var act in seq)
         {
             if (act.Formation == formation &&
                 act.Interruptable &&
                 (act.Status == ActionStatus.Pending || act.Status == ActionStatus.Executing) &&
                 (act.ActionType == ActionType.Move || act.ActionType == ActionType.Scale ||
                  act.ActionType == ActionType.Rotate)
                 )
             {
                 act.Abort();
             }
         }
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Тактичекий приказ: Двигать все свои юниты на заданный тип юнитов, выбирая ближайший
        /// </summary>
        /// <param name="type"></param>
        /// <param name="targetTypes"></param>
        /// <param name="me"></param>
        /// <param name="self"></param>
        /// <param name="maxSpeed"></param>
        public static void CommonAttack(Formation formation, List <VehicleType> targetTypes, bool self = false, double maxSpeed = 0)
        {
            var move = new Action();

            if (formation.Units.Count == 0)
            {
                return;
            }

            foreach (var targetType in targetTypes)
            {
                var targets = Global.Units.Values.Where(i => i.Type == targetType && (self ? i.PlayerId == Global.Me.Id : i.PlayerId != Global.Me.Id)).ToList();

                if (targets.Any())
                {
                    var target = targets.OrderBy(i => formation.MassCenter.Distance(i)).First();

                    formation.MoveTo(target.X, target.Y, Formation.TACTICAL_ORDER, maxSpeed);
                    return;
                }
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Масштабирование относительно центра масс юнитов игрока
 /// </summary>
 /// <param name="scale"></param>
 public static void ScaleRelative(double scale, Formation formation = null, int waitDuringTicks = 0)
 {
     Global.ActionQueue.Add(new Action {
         Action = ActionType.Scale, Factor = scale, Formation = formation, WaitDuringTicks = waitDuringTicks, Relative = true
     });
 }
Exemplo n.º 5
0
 /// <summary>
 /// Масштабирование относительно точки
 /// </summary>
 /// <param name="scale"></param>
 /// <param name="position"></param>
 public static void Scale(double scale, Point position, Formation formation = null, int waitDuringTicks = 0)
 {
     Scale(scale, position.X, position.Y, formation, waitDuringTicks);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Масштабирование относительно точки
 /// </summary>
 /// <param name="scale"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 public static void Scale(double scale, double x, double y, Formation formation = null, int waitDuringTicks = 0)
 {
     Global.ActionQueue.Add(new Action {
         Action = ActionType.Scale, Factor = scale, X = x, Y = y, Formation = formation, WaitDuringTicks = waitDuringTicks
     });
 }
Exemplo n.º 7
0
 /// <summary>
 /// Двигаться к точке с заданной скоростью
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="maxSpeed"></param>
 public static void MoveRelative(double x, double y, Formation formation = null, int waitDuringTicks = 0, double maxSpeed = 0)
 {
     Global.ActionQueue.Add(new Action {
         Action = ActionType.Move, X = x, Y = y, MaxSpeed = maxSpeed, Formation = formation, WaitDuringTicks = waitDuringTicks, Relative = true
     });
 }