Ejemplo n.º 1
0
        public override IEnumerable <SC2APIProtocol.Action> PerformActions(int frame)
        {
            if (ScoutLocations == null)
            {
                GetScoutLocations();
            }
            if (!LateGame && frame > SharkyOptions.FramesPerSecond * 4 * 60)
            {
                LateGame       = true;
                ScoutLocations = new List <Point2D>();
                foreach (var baseLocation in BaseData.BaseLocations.Where(b => !BaseData.SelfBases.Any(s => s.Location == b.Location) && !BaseData.EnemyBases.Any(s => s.Location == b.Location)))
                {
                    ScoutLocations.Add(baseLocation.MineralLineLocation);
                }
                ScoutLocationIndex = 0;
            }

            var commands = new List <SC2APIProtocol.Action>();

            foreach (var commander in UnitCommanders)
            {
                if (commander.UnitRole != UnitRole.Scout)
                {
                    commander.UnitRole = UnitRole.Scout;
                }
                if (commander.UnitCalculation.NearbyEnemies.Any(e => e.UnitClassifications.Contains(UnitClassification.Worker) || e.Attributes.Contains(Attribute.Structure)) && commander.UnitCalculation.NearbyEnemies.Count() < 5)
                {
                    var enemy  = commander.UnitCalculation.NearbyEnemies.FirstOrDefault();
                    var action = IndividualMicroController.Attack(commander, new Point2D {
                        X = enemy.Unit.Pos.X, Y = enemy.Unit.Pos.Y
                    }, TargetingData.ForwardDefensePoint, null, frame);
                    if (action != null)
                    {
                        commands.AddRange(action);
                    }
                }
                else if (Vector2.DistanceSquared(new Vector2(ScoutLocations[ScoutLocationIndex].X, ScoutLocations[ScoutLocationIndex].Y), commander.UnitCalculation.Position) < 2)
                {
                    ScoutLocationIndex++;
                    if (ScoutLocationIndex >= ScoutLocations.Count())
                    {
                        ScoutLocationIndex = 0;
                    }
                }
                else
                {
                    var action = IndividualMicroController.Scout(commander, ScoutLocations[ScoutLocationIndex], TargetingData.ForwardDefensePoint, frame);
                    if (action != null)
                    {
                        commands.AddRange(action);
                    }
                }
            }

            return(commands);
        }
        public override IEnumerable <SC2APIProtocol.Action> PerformActions(int frame)
        {
            if (ScoutLocations == null)
            {
                GetScoutLocations();
            }

            var commands = new List <SC2APIProtocol.Action>();

            if (!UnitCommanders.Any(c => c.UnitCalculation.Unit.IsHallucination && c.UnitCalculation.Unit.UnitType == (uint)UnitTypes.PROTOSS_PHOENIX))
            {
                foreach (var commander in UnitCommanders)
                {
                    if (commander.UnitCalculation.Unit.UnitType == (uint)UnitTypes.PROTOSS_SENTRY && commander.UnitCalculation.Unit.Energy >= 75)
                    {
                        var action = commander.Order(frame, Abilities.HALLUCINATION_PHOENIX);
                        if (action != null)
                        {
                            commands.AddRange(action);
                        }
                    }
                }
            }
            else
            {
                foreach (var commander in UnitCommanders)
                {
                    if (commander.UnitCalculation.Unit.UnitType == (uint)UnitTypes.PROTOSS_PHOENIX)
                    {
                        if (Vector2.DistanceSquared(new Vector2(ScoutLocations[ScoutLocationIndex].X, ScoutLocations[ScoutLocationIndex].Y), commander.UnitCalculation.Position) < 2)
                        {
                            ScoutLocationIndex++;
                            if (ScoutLocationIndex >= ScoutLocations.Count())
                            {
                                ScoutLocationIndex = 0;
                            }
                        }
                        else
                        {
                            var action = commander.Order(frame, Abilities.MOVE, ScoutLocations[ScoutLocationIndex]);
                            if (action != null)
                            {
                                commands.AddRange(action);
                            }
                        }
                    }
                }
            }

            return(commands);
        }