public WinPlatformBuilder(IConsoleWriter consoleWriter,
                           IGameObjectLocator gameObjectLocator, IGeometryMathService geometryMathService)
 {
     _consoleWriter       = consoleWriter;
     _gameObjectLocator   = gameObjectLocator;
     _geometryMathService = geometryMathService;
 }
示例#2
0
        public void Lock_ListOfPlayerId_WhenPlayersAreFound_ShouldReturnLockedPlayers(
            [Frozen] IGameObjectLocator locator,
            IPlayer player1,
            IPlayer player2,
            IPlayer player3,
            DefaultLocker locker)
        {
            IPlayer outPlayer2;

            locator.TryGetObjects(Arg.Is <uint>(id => id >= 1 && id <= 3), out outPlayer2).ReturnsForAnyArgs(call =>
            {
                call[1] = player1;
                return(true);
            }, call =>
            {
                call[1] = player2;
                return(true);
            }, call =>
            {
                call[1] = player3;
                return(true);
            });

            Dictionary <uint, IPlayer> lockedPlayers;
            var multiObjLock = locker.Lock(out lockedPlayers, 1, 2, 3);

            lockedPlayers.Should().Contain(new KeyValuePair <uint, IPlayer>(1, player1));
            lockedPlayers.Should().Contain(new KeyValuePair <uint, IPlayer>(2, player2));
            lockedPlayers.Should().Contain(new KeyValuePair <uint, IPlayer>(3, player3));
            multiObjLock.Received(1)
            .Lock(Arg.Is <ILockable[]>(itemsLocked => itemsLocked.SequenceEqual(new[]
            {
                player1, player2, player3
            })));
        }
示例#3
0
        public void Lock_CityIdTroopId_WhenCityIsFound_ShouldReturnLockedCity(
            [Frozen] IGameObjectLocator locator,
            ICity city,
            ITroopObject troop,
            DefaultLocker locker)
        {
            ICity outCity;

            locator.TryGetObjects(1, out outCity).Returns(call =>
            {
                call[1] = city;
                return(true);
            });

            ITroopObject outTroop;

            city.TryGetTroop(2, out outTroop).Returns(call =>
            {
                call[1] = troop;
                return(true);
            });

            ICity        lockedCity;
            ITroopObject lockedTroop;
            var          multiObjLock = locker.Lock(1, 2, out lockedCity, out lockedTroop);

            ((object)lockedCity).Should().Be(city);
            lockedTroop.Should().Be(troop);
            multiObjLock.Received(1)
            .Lock(Arg.Is <ILockable[]>(itemsLocked => itemsLocked.SequenceEqual(new[] { city })));
        }
示例#4
0
        public void Lock_ListOfCityId_WhenCitiesAreNotFound_ShouldReturnEmptyLockAndEmptyDictionary(
            [Frozen] IGameObjectLocator locator,
            ICity city1,
            ICity city2,
            ICity city3,
            DefaultLocker locker)
        {
            ICity outCity2;

            locator.TryGetObjects(Arg.Is <uint>(id => id >= 1 && id <= 2), out outCity2).ReturnsForAnyArgs(call =>
            {
                call[1] = city1;
                return(true);
            }, call =>
            {
                call[1] = city2;
                return(false);
            });

            Dictionary <uint, ICity> lockedCities;
            var multiObjLock = locker.Lock(out lockedCities, 1, 2);

            lockedCities.Should().BeNull();
            multiObjLock.Received(1)
            .Lock(Arg.Is <ILockable[]>(itemsLocked => !itemsLocked.Any()));
        }
示例#5
0
        public void Lock_ListOfPlayerId_WhenPlayersAreNotFound_ShouldReturnEmptyLockAndEmptyDictionary(
            [Frozen] IGameObjectLocator locator,
            IPlayer player1,
            IPlayer player2,
            IPlayer player3,
            DefaultLocker locker)
        {
            IPlayer outPlayer2;

            locator.TryGetObjects(Arg.Is <uint>(id => id >= 1 && id <= 2), out outPlayer2).ReturnsForAnyArgs(call =>
            {
                call[1] = player1;
                return(true);
            }, call =>
            {
                call[1] = player2;
                return(false);
            });

            Dictionary <uint, IPlayer> lockedPlayers;
            var multiObjLock = locker.Lock(out lockedPlayers, 1, 2);

            lockedPlayers.Should().BeNull();
            multiObjLock.Received(1)
            .Lock(Arg.Is <ILockable[]>(itemsLocked => !itemsLocked.Any()));
        }
示例#6
0
 public LaborMoveActiveAction(Formula formula, Procedure procedure, ILocker locker, IGameObjectLocator gameObjectLocator)
 {
     this.formula           = formula;
     this.procedure         = procedure;
     this.locker            = locker;
     this.gameObjectLocator = gameObjectLocator;
 }
示例#7
0
        public BarbarianTribeBattlePassiveAction(uint barbarianTribeId,
                                                 ILocker locker,
                                                 IGameObjectLocator gameObjectLocator,
                                                 IDbManager dbManager,
                                                 Formula formula,
                                                 BarbarianTribeBattleProcedure barbarianTribeBattleProcedure,
                                                 IWorld world,
                                                 ISimpleStubGeneratorFactory simpleStubGeneratorFactory)
            : this(locker, gameObjectLocator, dbManager, formula, barbarianTribeBattleProcedure, world, simpleStubGeneratorFactory)
        {
            this.barbarianTribeId              = barbarianTribeId;
            this.locker                        = locker;
            this.gameObjectLocator             = gameObjectLocator;
            this.dbManager                     = dbManager;
            this.formula                       = formula;
            this.barbarianTribeBattleProcedure = barbarianTribeBattleProcedure;
            this.world = world;

            IBarbarianTribe barbarianTribe;

            if (!gameObjectLocator.TryGetObjects(barbarianTribeId, out barbarianTribe))
            {
                throw new Exception("Did not find barb tribe that was supposed to be having a battle");
            }

            simpleStubGenerator = simpleStubGeneratorFactory.CreateSimpleStubGenerator(formula.BarbarianTribeUnitRatios(), formula.BarbarianTribeUnitTypes());
        }
示例#8
0
        public void Lock_CityIdStructureId_WhenCityIsFound_ShouldReturnLockedCity(
            [Frozen] IGameObjectLocator locator,
            ICity city,
            IStructure structure,
            DefaultLocker locker)
        {
            ICity outCity;

            locator.TryGetObjects(1, out outCity).Returns(call =>
            {
                call[1] = city;
                return(true);
            });

            IStructure outStructure;

            city.TryGetStructure(2, out outStructure).Returns(call =>
            {
                call[1] = structure;
                return(true);
            });

            ICity      lockedCity;
            IStructure lockedStructure;
            var        multiObjLock = locker.Lock(1, 2, out lockedCity, out lockedStructure);

            ((object)lockedCity).Should().Be(city);
            lockedStructure.Should().Be(structure);
            multiObjLock.Received(1)
            .Lock(Arg.Is <ILockable[]>(itemsLocked => itemsLocked.SequenceEqual(new[] { city })));
        }
示例#9
0
        public void Lock_ListOfCityId_WhenCitiesAreFound_ShouldReturnLockedCities(
            [Frozen] IGameObjectLocator locator,
            ICity city1,
            ICity city2,
            ICity city3,
            DefaultLocker locker)
        {
            ICity outCity2;

            locator.TryGetObjects(Arg.Is <uint>(id => id >= 1 && id <= 3), out outCity2).ReturnsForAnyArgs(call =>
            {
                call[1] = city1;
                return(true);
            }, call =>
            {
                call[1] = city2;
                return(true);
            }, call =>
            {
                call[1] = city3;
                return(true);
            });

            Dictionary <uint, ICity> lockedCities;
            var multiObjLock = locker.Lock(out lockedCities, 1, 2, 3);

            lockedCities.Should().Contain(new KeyValuePair <uint, ICity>(1, city1));
            lockedCities.Should().Contain(new KeyValuePair <uint, ICity>(2, city2));
            lockedCities.Should().Contain(new KeyValuePair <uint, ICity>(3, city3));
            multiObjLock.Received(1)
            .Lock(Arg.Is <ILockable[]>(itemsLocked => itemsLocked.SequenceEqual(new[]
            {
                city1, city2, city3
            })));
        }
示例#10
0
 public TribeContributeActiveAction(IGameObjectLocator locator,
                                    Formula formula,
                                    ILocker locker)
 {
     this.locator = locator;
     this.formula = formula;
     this.locker  = locker;
 }
示例#11
0
 public CityEngageDefensePassiveAction(BattleProcedure battleProcedure,
                                       CityBattleProcedure cityBattleProcedure,
                                       IGameObjectLocator gameObjectLocator)
 {
     this.battleProcedure     = battleProcedure;
     this.cityBattleProcedure = cityBattleProcedure;
     this.gameObjectLocator   = gameObjectLocator;
 }
示例#12
0
 public DefaultLocker(DefaultMultiObjectLock.Factory multiObjectLockFactory,
                      CallbackLock.Factory callbackLockFactory,
                      IGameObjectLocator locator)
 {
     this.multiObjectLockFactory = multiObjectLockFactory;
     this.callbackLockFactory    = callbackLockFactory;
     this.locator = locator;
 }
示例#13
0
 public TroopMovePassiveAction(Formula formula,
                               ITileLocator tileLocator,
                               IGameObjectLocator world,
                               ILocker locker)
 {
     this.formula     = formula;
     this.tileLocator = tileLocator;
     this.world       = world;
     this.locker      = locker;
 }
示例#14
0
 public CityTileNextAvailableLocationStrategy(MapFactory mapFactory,
                                              Formula formula,
                                              IForestManager forestManager,
                                              IGameObjectLocator gameObjectLocator)
 {
     this.mapFactory        = mapFactory;
     this.formula           = formula;
     this.forestManager     = forestManager;
     this.gameObjectLocator = gameObjectLocator;
 }
        public EnemyInputAggroState(IGameObjectLocator gameObjectLocator,
                                    IGeometryMathService geometryMathService, EnemyData enemyData)
        {
            _gameObjectLocator   = gameObjectLocator;
            _geometryMathService = geometryMathService;

            _enemyData           = enemyData;
            _approachingDistance = enemyData.ApproachingDistance;
            _playerLoseDistance  = enemyData.PlayerLoseDistance;
        }
示例#16
0
        public EnemyInputComponent(IGameObjectLocator gameObjectLocator,
                                   IGeometryMathService geometryMathService, EnemyData enemyData)
        {
            _enemyState = new EnemyInputIdleState(gameObjectLocator,
                                                  geometryMathService, enemyData);

            _gameObjectLocator   = gameObjectLocator;
            _geometryMathService = geometryMathService;
            _enemyData           = enemyData;
        }
示例#17
0
 public EnemyBuilder(IConsoleWriter consoleWriter,
                     IGameObjectLocator gameObjectLocator,
                     IGeometryMathService geometryMathService, IGameCommand fireCommand,
                     EnemyData enemyData)
 {
     _consoleWriter       = consoleWriter;
     _gameObjectLocator   = gameObjectLocator;
     _geometryMathService = geometryMathService;
     _fireCommand         = fireCommand;
     _enemyData           = enemyData;
 }
示例#18
0
 public StrongholdEngageGateAttackPassiveAction(IBattleFormulas battleFormula,
                                                IGameObjectLocator gameObjectLocator,
                                                StrongholdBattleProcedure strongholdBattleProcedure,
                                                IDbManager dbManager,
                                                IStaminaMonitorFactory staminaMonitorFactory)
 {
     this.battleFormula             = battleFormula;
     this.gameObjectLocator         = gameObjectLocator;
     this.strongholdBattleProcedure = strongholdBattleProcedure;
     this.dbManager             = dbManager;
     this.staminaMonitorFactory = staminaMonitorFactory;
 }
示例#19
0
 public ObjectRemovePassiveAction(IGameObjectLocator gameObjectLocator,
                                  ILocker locker,
                                  Procedure procedure,
                                  CallbackProcedure callbackProcedure,
                                  IDbManager dbmanager)
 {
     this.gameObjectLocator = gameObjectLocator;
     this.locker            = locker;
     this.procedure         = procedure;
     this.callbackProcedure = callbackProcedure;
     this.dbmanager         = dbmanager;
 }
        public EnemyLogicComponent(IGameObjectLocator gameObjectLocator,
                                   IGameCommand fireCommand, IGeometryMathService geometryMathService,
                                   EnemyData enemyData)
        {
            _enemyState = new EnemyLogicNormalState(gameObjectLocator,
                                                    fireCommand, geometryMathService, enemyData);

            _gameObjectLocator   = gameObjectLocator;
            _fireCommand         = fireCommand;
            _geometryMathService = geometryMathService;
            _enemyData           = enemyData;
        }
示例#21
0
 public AssignmentCommandsModule(BattleProcedure battleProcedure,
                                 IGameObjectLocator gameObjectLocator,
                                 ILocker locker,
                                 IStrongholdManager strongholdManager,
                                 ICityManager cityManager)
 {
     this.battleProcedure   = battleProcedure;
     this.gameObjectLocator = gameObjectLocator;
     this.locker            = locker;
     this.strongholdManager = strongholdManager;
     this.cityManager       = cityManager;
 }
        public EnemyLogicNormalState(IGameObjectLocator gameObjectLocator,
                                     IGameCommand fireCommand, IGeometryMathService geometryMathService,
                                     EnemyData enemyData)
        {
            _gameObjectLocator   = gameObjectLocator;
            _fireCommand         = fireCommand;
            _geometryMathService = geometryMathService;
            _enemyData           = enemyData;

            _updatesForReload        = enemyData.UpdatesForReload;
            _currentUpdatesForReload = 0;
        }
示例#23
0
 public BarbarianTribeAttackChainAction(IActionFactory actionFactory,
                                        Procedure procedure,
                                        ILocker locker,
                                        IGameObjectLocator gameObjectLocator,
                                        BattleProcedure battleProcedure)
 {
     this.actionFactory     = actionFactory;
     this.procedure         = procedure;
     this.locker            = locker;
     this.gameObjectLocator = gameObjectLocator;
     this.battleProcedure   = battleProcedure;
 }
示例#24
0
 public CityEngageDefensePassiveAction(uint cityId,
                                       uint troopObjectId,
                                       FormationType formationType,
                                       BattleProcedure battleProcedure,
                                       CityBattleProcedure cityBattleProcedure,
                                       IGameObjectLocator gameObjectLocator)
     : this(battleProcedure, cityBattleProcedure, gameObjectLocator)
 {
     this.cityId        = cityId;
     this.troopObjectId = troopObjectId;
     this.formationType = formationType;
 }
示例#25
0
 public TribeContributeActiveAction(uint cityId,
                                    uint structureId,
                                    Resource resource,
                                    IGameObjectLocator locator,
                                    Formula formula,
                                    ILocker locker)
     : this(locator, formula, locker)
 {
     this.cityId      = cityId;
     this.structureId = structureId;
     this.resource    = new Resource(resource);
 }