Exemplo n.º 1
0
        public void OnStart()
        {
            if (GameConstants.ParticipantRace != Race.Zerg)
            {
                return;
            }
            _queenSquadId = _squadRepo.Create("Queens").Id;
            var hatcheries = _squadRepo.Create("Hatcheries");

            hatcheries.AddUnit(_intel.StructuresSelf().First(u => u.UnitType == BlizzardConstants.Unit.Hatchery));
            _hatcheriesId = hatcheries.Id;

            _intel.Handler.RegisterHandler(Case.UnitAddedSelf, u => {
                if (u.UnitType == BlizzardConstants.Unit.Queen)
                {
                    _squadRepo.Get().First(g => g.Name.Equals("Queens")).Units.Add(u);
                }
            });

            _intel.Handler.RegisterHandler(Case.StructureAddedSelf, u => {
                if (u.UnitType == BlizzardConstants.Unit.Hatchery || u.UnitType == BlizzardConstants.Unit.Lair || u.UnitType == BlizzardConstants.Unit.Hive)
                {
                    _squadRepo.Get().First(g => g.Name.Equals("Hatcheries")).Units.Add(u);
                }
            });
        }
Exemplo n.º 2
0
        public void OnStart()
        {
            _mainBuildingTypes = new List <uint>();
            switch (GameConstants.ParticipantRace)
            {
            case NydusNetwork.API.Protocol.Race.NoRace:
                break;

            case NydusNetwork.API.Protocol.Race.Terran:
                _mainBuildingTypes.Add(BlizzardConstants.Unit.CommandCenter);
                _mainBuildingTypes.Add(BlizzardConstants.Unit.OrbitalCommand);
                _mainBuildingTypes.Add(BlizzardConstants.Unit.PlanetaryFortress);
                workerType = BlizzardConstants.Unit.SCV;
                break;

            case NydusNetwork.API.Protocol.Race.Zerg:
                _mainBuildingTypes.Add(BlizzardConstants.Unit.Hatchery);
                _mainBuildingTypes.Add(BlizzardConstants.Unit.Lair);
                _mainBuildingTypes.Add(BlizzardConstants.Unit.Hive);
                workerType = BlizzardConstants.Unit.Drone;
                break;

            case NydusNetwork.API.Protocol.Race.Protoss:
                _mainBuildingTypes.Add(BlizzardConstants.Unit.Nexus);
                workerType = BlizzardConstants.Unit.Probe;
                break;

            case NydusNetwork.API.Protocol.Race.Random:
                break;
            }


            _mainBuildings = _squadRepository.Create("MainBuildings");
            _refineries    = _squadRepository.Create("Refineries");
            _mainBuildings.AddUnit(_intel.StructuresSelf().First(u => _mainBuildingTypes.Contains(u.UnitType)));

            _intel.Handler.RegisterHandler(Case.StructureAddedSelf, u => {
                if (_mainBuildingTypes.Contains(u.UnitType))
                {
                    _mainBuildings.AddUnit(u);
                    _baseAmount++;
                }
                if (GameConstants.RaceRefinery == u.UnitType)
                {
                    _refineries.AddUnit(u);
                }
            });
        }
Exemplo n.º 3
0
 public void OnStart()
 {
     _autoPushArmySize = 10;
     _eStart           = _intel.Colonies.First(c => c.IsStartingLocation).Point;
     _theGang          = _squadRepository.Create("TheGang");
     _intel.Handler.RegisterHandler(Case.UnitAddedSelf, HandleUnitMade);
 }
Exemplo n.º 4
0
        public void OnStart()
        {
            if (_startCalled)
            {
                return;
            }
            _productionManager.ClearBuildOrder();

            // Colonies marked with Starting location are possible starting locations of the enemy NOT yourself
            _eStarts = _intelManager.Colonies.Where(c => c.IsStartingLocation);

            // Queue a hardcoded all-in
            QueueOneBaseRavager();

            // Using the AutoHarvestGather module DesiredVespeneWorkers decides how many workers will be assigned to gather vespene
            // Without AutoHarvestGather in the setup.json file (or and alternative) this has no effect
            _intelManager.PrimaryColony.DesiredVespeneWorkers = 4;

            // Creating a squad allows for treating a group of units as one.
            _theGang = _squadRep.Create("TheGang"); // The name allows other modules to look it up by name! (as IDs are generated at runtime)

            // The _intelManager.Handler allows for actions to be carried out when specific events happens.
            // Registering a handler to a Case means the handler will be called every time the event happens.
            _intelManager.Handler.RegisterHandler(Case.UnitAddedSelf, UnitMadeHandler);
            _intelManager.Handler.RegisterHandler(Case.StructureAddedSelf, s => {
                if (s.UnitType == BlizzardConstants.Unit.RoachWarren)
                {
                    _intelManager.PrimaryColony.DesiredVespeneWorkers = 6; // Increase vespene workers after the roach warren is added!
                }
            });

            // A variable needed since ZergDemo is a replaceable module relying on its on OnStart, but dont want it to be called twice
            _startCalled = true;
            _done        = false;
        }
Exemplo n.º 5
0
        public void OnStart()
        {
            factories = new List <ProductionFacility>();
            intelManager.StructuresSelf(BlizzardConstants.Unit.Factory, BlizzardConstants.Unit.FactoryReactor)
            .ToList().ForEach(b => factories.Add(new ProductionFacility(b)));

            squads       = new Dictionary <string, Squad>();
            unitToSquad  = new Dictionary <ulong, string>();
            currentSquad = squadRepo.Create(NextSquadName());

            // Register handlers
            intelManager.Handler.RegisterHandler(Case.UnitAddedSelf, OnUnitBuilt);
            intelManager.Handler.RegisterHandler(Case.UnitDestroyed, OnUnitDestroyed);
            intelManager.Handler.RegisterHandler(Case.StructureAddedSelf, OnStructureBuilt);
            intelManager.Handler.RegisterHandler(Case.StructureDestroyed, OnStructureDestroyed);
        }
Exemplo n.º 6
0
        // OnStart() will always be called before a game as this module does inherit from IReplableableModule
        // it can therefore not be added/removed mid-game.
        public void OnStart()
        {
            // Lazy Lou likes BattleCruisers, but does not want to queue everything needed to create it.
            _productionManager.QueueUnit(BlizzardConstants.Unit.Battlecruiser);
            // The production manager is not gonna crash or deadlock on this request,
            // but will try to make due with what Lazy Lou is giving it. Thus it will create
            // all the requirements for a battlecruise and then the battlecruiser itself.

            // Supply on the other hand will NOT be automaticly added by the production manager,
            // ... unless you add the "AutoSupply" module in the setup file and let the framework handle supply too.
            // Same goes for energy fields (Pylons) and creep.
            for (int i = 0; i < 5; i++)
            {
                _productionManager.QueueUnit(BlizzardConstants.Unit.SupplyDepot, spacing: 0);
                _productionManager.QueueUnit(BlizzardConstants.Unit.Marine);
            }

            // Tech will automatically detect requirements just as units.
            // If there is no barracks with room for a techlab/reactor when you try to build it
            // the nearest free barrack will lift-off and relocate to a place where it can be build (and log a warning)
            _productionManager.QueueTech(BlizzardConstants.Research.Stimpack);
            // The production manager detects that TechLab requires a Barrack,
            // but it is already queued and will thus not queue another.


            // You can give squads names so other modules can look them up (as their ID are generated at runtime)
            _lousBoys = _squadRepo.Create("insert_name");
            _intel.Handler.RegisterHandler(Case.UnitAddedSelf, JowanHandlesIt);
            _first  = true;
            _second = true;
        }
Exemplo n.º 7
0
 public void OnStart()
 {
     if (_startCalled)
     {
         return;
     }
     _eStarts = _intelManager.Colonies.Where(c => c.IsStartingLocation);
     Queue1ImmortalRush();
     _intelManager.Handler.RegisterHandler(Case.UnitAddedSelf, HandleUnitMade);
     theGang      = _squadRep.Create("TheGang");
     _startCalled = true;
 }
Exemplo n.º 8
0
        public void OnStart()
        {
            if (_startCalled)
            {
                return;
            }
            // Colonies marked with starting location are possible starting locations of the enemy, never yourself
            _eStarts = _intelManager.Colonies.Where(c => c.IsStartingLocation);

            QueueRaxRush();

            gang         = _squadRep.Create("TheGang");
            _startCalled = true;
        }
Exemplo n.º 9
0
 /// <summary>
 /// Called on the first frame of the game.
 /// Queue our gameplan!
 /// </summary>
 public void OnStart()
 {
     if (_startCalled)
     {
         return;
     }
     // Find start locations (never includes our own base)
     _eStarts = _intelManager.Colonies.Where(c => c.IsStartingLocation);
     // Queue build order
     QueueImmortalRush();
     // Register a callback function for new units (not workers) added.
     _intelManager.Handler.RegisterHandler(Case.UnitAddedSelf, UnitCreationHandler);
     // Create a 'squad', a collection of units.
     _theGang     = _squadRep.Create("TheGang");
     _startCalled = true;
 }
Exemplo n.º 10
0
        public void OnStart()
        {
            starports = new List <ProductionFacility>();
            loneUnits = new HashSet <IUnit>();
            fleet     = squadRepo.Create(SQUAD_NAME);

            // Register handlers
            intelManager.Handler.RegisterHandler(Case.StructureAddedSelf, OnStructureBuilt);
            intelManager.Handler.RegisterHandler(Case.StructureDestroyed, OnStructureDestroyed);
            intelManager.Handler.RegisterHandler(Case.UnitAddedSelf, OnUnitBuilt);
            intelManager.Handler.RegisterHandler(Case.UnitDestroyed, OnUnitDestroyed);

            if (!intelManager.StructuresSelf(BlizzardConstants.Unit.Starport).Any())
            {
                productionManager.QueueUnit(BlizzardConstants.Unit.Starport, lowPriority: true,
                                            desiredPosition: snapshot.LeastExpandedColony.Point, spacing: 2);
            }
        }
Exemplo n.º 11
0
        public void OnStart()
        {
            if (_startCalled)
            {
                return;
            }
            _productionManager.ClearBuildOrder();

            // Colonies marked with starting location are possible starting locations of the enemy, never yourself
            _eStarts = _intelManager.Colonies.Where(c => c.IsStartingLocation);
            _intelManager.Handler.RegisterHandler(Case.UnitAddedSelf, addCrook);

            QueueRaxRush();

            gang         = _squadRep.Create("TheGang");
            _done        = false;
            _startCalled = true;
        }
Exemplo n.º 12
0
        public void OnStart()
        {
            // Get all colonies that is marked as a possible enemy starting locations
            _eStarts = _intelManager.Colonies.Where(c => c.IsStartingLocation);

            // Register a handler to be called when a new unit friendly is added
            _intelManager.Handler.RegisterHandler(Case.UnitAddedSelf, HandleUnitMade);

            // Produce some units with abilities
            for (int i = 0; i < 5; i++)
            {
                // Create pylons with spacing to ensure we have enough space to build.
                _productionManager.QueueUnit(BlizzardConstants.Unit.Pylon, spacing: 3);
            }
            for (int i = 0; i < 10; i++)
            {
                _productionManager.QueueUnit(BlizzardConstants.Unit.Probe, lowPriority: true);
            }

            // Use BlizzardConstants to get friendly names for unit type ids
            _productionManager.QueueUnit(BlizzardConstants.Unit.Assimilator);
            _productionManager.QueueUnit(BlizzardConstants.Unit.Assimilator);
            _productionManager.QueueUnit(BlizzardConstants.Unit.Gateway);
            _productionManager.QueueUnit(BlizzardConstants.Unit.Gateway);
            _productionManager.QueueUnit(BlizzardConstants.Unit.Gateway);

            for (int i = 0; i < 10; i++)
            {
                _productionManager.QueueUnit(BlizzardConstants.Unit.Adept);
            }

            _productionManager.QueueUnit(BlizzardConstants.Unit.Sentry);
            _productionManager.QueueUnit(BlizzardConstants.Unit.Sentry);

            _productionManager.QueueUnit(BlizzardConstants.Unit.Phoenix);
            _productionManager.QueueUnit(BlizzardConstants.Unit.Phoenix);

            // Create a squad to control your units as one unit
            theGang = _squadRep.Create("TheGang");
        }
Exemplo n.º 13
0
        /// <summary>
        /// Called on the first frame of the game.
        /// Queue our gameplan!
        /// </summary>
        public void OnStart()
        {
            if (_startCalled)
            {
                return;
            }
            _productionManager.ClearBuildOrder();

            // Colonies marked with starting location are possible starting locations of the enemy, never yourself
            _eStarts = _intelManager.Colonies.Where(c => c.IsStartingLocation);
            // Register callback function with Abathur -- this will call addCrook everytime we build a unit.
            _intelManager.Handler.RegisterHandler(Case.UnitAddedSelf, UnitCreationHandler);

            // Queue our build orders.
            QueueRaxRush();

            // Create a 'squad' (collection of units)
            gang = _squadRep.Create("TheGang");

            // Set primitive state trackers...
            _attackMode  = false;
            _startCalled = true;
        }
Exemplo n.º 14
0
        public void Execute(CombatRequest request)
        {
            switch (request.CommandCase)
            {
            case CombatRequest.CommandOneofCase.MoveUnit:
                _manager.Move(request.MoveUnit.UnitTag, request.MoveUnit.Point, request.MoveUnit.Queue);
                break;

            case CombatRequest.CommandOneofCase.MoveSquad:
                _manager.Move(_repository.Get().First(s => s.Id.Equals(request.MoveSquad.Squad)),
                              request.MoveSquad.Point, request.MoveSquad.Queue);
                break;

            case CombatRequest.CommandOneofCase.AttackMoveUnit:
                _manager.AttackMove(request.AttackMoveUnit.UnitTag, request.AttackMoveUnit.Point,
                                    request.AttackMoveUnit.Queue);
                break;

            case CombatRequest.CommandOneofCase.AttackMoveSquad:
                _manager.AttackMove(_repository.Get().First(s => s.Id.Equals(request.AttackMoveSquad.Squad)),
                                    request.AttackMoveSquad.Point, request.AttackMoveSquad.Queue);
                break;

            case CombatRequest.CommandOneofCase.AttackUnit:
                _manager.Attack(request.AttackUnit.SourceUnit, request.AttackUnit.TargetUnit,
                                request.AttackUnit.Queue);
                break;

            case CombatRequest.CommandOneofCase.AttackSquad:
                _manager.Attack(_repository.Get().First(s => s.Id.Equals(request.AttackSquad.Squad)),
                                request.AttackSquad.TargetUnit, request.AttackSquad.Queue);
                break;

            case CombatRequest.CommandOneofCase.UseTargetedAbilityUnit:
                _manager.UseTargetedAbility(request.UseTargetedAbilityUnit.AbilityId,
                                            request.UseTargetedAbilityUnit.SourceUnit, request.UseTargetedAbilityUnit.TargetUnit,
                                            request.UseTargetedAbilityUnit.Queue);
                break;

            case CombatRequest.CommandOneofCase.UseTargetedAbilitySquad:
                _manager.UseTargetedAbility(request.UseTargetedAbilitySquad.AbilityId,
                                            _repository.Get().First(s => s.Id.Equals(request.UseTargetedAbilitySquad.Squad)),
                                            request.UseTargetedAbilitySquad.TargetUnit, request.UseTargetedAbilitySquad.Queue);
                break;

            case CombatRequest.CommandOneofCase.UsePointCenteredAbilityUnit:
                _manager.UsePointCenteredAbility(request.UsePointCenteredAbilityUnit.AbilityId,
                                                 request.UsePointCenteredAbilityUnit.SourceUnit, request.UsePointCenteredAbilityUnit.Point);
                break;

            case CombatRequest.CommandOneofCase.UsePointCenteredAbilitySquad:
                _manager.UsePointCenteredAbility(request.UsePointCenteredAbilitySquad.AbilityId,
                                                 _repository.Get().First(s => s.Id.Equals(request.UsePointCenteredAbilitySquad.Squad)),
                                                 request.UsePointCenteredAbilitySquad.Point, request.UsePointCenteredAbilitySquad.Queue);
                break;

            case CombatRequest.CommandOneofCase.UseTargetlessAbilityUnit:
                _manager.UseTargetlessAbility(request.UseTargetlessAbilityUnit.AbilityId,
                                              request.UseTargetlessAbilityUnit.SourceUnit, request.UseTargetlessAbilityUnit.Queue);
                break;

            case CombatRequest.CommandOneofCase.UseTargetlessAbilitySquad:
                _manager.UseTargetlessAbility(request.UseTargetedAbilitySquad.AbilityId,
                                              _repository.Get().First(s => s.Id.Equals(request.UseTargetedAbilitySquad.Squad)),
                                              request.UseTargetedAbilitySquad.Queue);
                break;

            case CombatRequest.CommandOneofCase.SmartMoveUnit:
                if (_intel.TryGet(request.SmartMoveUnit.UnitTag, out IUnit unit))
                {
                    _manager.SmartMove(unit, request.SmartMoveUnit.Point, request.SmartMoveUnit.Queue);
                }
                break;

            case CombatRequest.CommandOneofCase.SmartMoveSquad:
                _manager.SmartMove(_repository.Get().First(s => s.Id.Equals(request.SmartMoveSquad.Squad)),
                                   request.SmartMoveSquad.Point, request.SmartMoveSquad.Queue);
                break;

            case CombatRequest.CommandOneofCase.SmartAttackMoveUnit:
                if (_intel.TryGet(request.SmartMoveUnit.UnitTag, out IUnit u))
                {
                    _manager.SmartAttackMove(u, request.SmartAttackMoveUnit.Point, request.SmartAttackMoveUnit.Queue);
                }
                break;

            case CombatRequest.CommandOneofCase.SmartAttackMoveSquad:
                _manager.SmartAttackMove(
                    _repository.Get().First(s => s.Id.Equals(request.SmartAttackMoveSquad.Squad)),
                    request.SmartAttackMoveSquad.Point, request.SmartAttackMoveSquad.Queue);
                break;

            case CombatRequest.CommandOneofCase.SmartAttackUnit:
                if (_intel.TryGet(request.SmartAttackUnit.SourceUnit, out IUnit un))
                {
                    _manager.SmartAttack(un, request.SmartAttackUnit.TargetUnit, request.SmartAttackUnit.Queue);
                }
                break;

            case CombatRequest.CommandOneofCase.SmartAttackSquad:
                _manager.SmartAttack(_repository.Get().First(s => s.Id.Equals(request.SmartAttackSquad.Squad)),
                                     request.SmartAttackSquad.TargetUnit, request.SmartAttackSquad.Queue);
                break;

            case CombatRequest.CommandOneofCase.SquadRequest:
                var addUnits    = request.SquadRequest.AddUnits;
                var removeUnits = request.SquadRequest.RemoveUnits;
                var createSquad = request.SquadRequest.CreateSquad;
                var removeSquad = request.SquadRequest.RemoveSquad;
                if (request.SquadRequest.AddUnits != null)
                {
                    foreach (var tag in addUnits.Tags)
                    {
                        if (_intel.TryGet(tag, out var addedUnit))
                        {
                            _repository.Get().First(s => s.Id.Equals(request.SquadRequest.AddUnits.SquadId))
                            .AddUnit(addedUnit);
                        }
                    }
                }
                if (removeUnits != null)
                {
                    foreach (var tag in removeUnits.Tags)
                    {
                        if (_intel.TryGet(tag, out var removedUnit))
                        {
                            _repository.Get().First(s => s.Id.Equals(request.SquadRequest.RemoveUnits.SquadId))
                            .RemoveUnit(removedUnit);
                        }
                    }
                }
                if (createSquad != null)
                {
                    _repository.Create(createSquad.Squad.Name, createSquad.Squad.SquadId);
                }
                if (removeSquad != null)
                {
                    _repository.Remove(removeSquad.SquadId);
                }
                break;

            default:
                throw new System.NotImplementedException();
            }
        }
Exemplo n.º 15
0
 void IModule.OnStart()
 {
     depots = rep.Create("MASTER DEPOTS <3");
     intelManager.Handler.RegisterHandler(Case.StructureAddedSelf, u => Handle(u));
 }