Exemplo n.º 1
0
        bool Merge(UnitCommander commander, int frame, out List <SC2APIProtocol.Action> action)
        {
            action = null;
            if (commander.UnitCalculation.Unit.Energy > 40 || commander.UnitCalculation.NearbyEnemies.Count() == 0)
            {
                return(false);
            }

            if (commander.UnitCalculation.Unit.Orders.Any(o => o.AbilityId == (uint)Abilities.MORPH_ARCHON))
            {
                return(true);
            }

            var otherHighTemplar = commander.UnitCalculation.NearbyAllies.Where(a => a.Unit.UnitType == (uint)UnitTypes.PROTOSS_HIGHTEMPLAR && a.Unit.Energy <= 40);

            if (otherHighTemplar.Count() > 0)
            {
                var target = otherHighTemplar.OrderBy(o => Vector2.DistanceSquared(o.Position, commander.UnitCalculation.Position)).FirstOrDefault();
                if (target != null)
                {
                    var merge = commander.Merge(target.Unit.Tag);
                    if (merge != null)
                    {
                        action = new List <Action> {
                            merge
                        };
                    }
                    return(true);
                }
            }

            return(false);
        }