Exemple #1
0
        public Stronghold(uint id,
                          string name,
                          byte level,
                          uint x,
                          uint y,
                          decimal gate,
                          int gateMax,
                          string theme,
                          IDbManager dbManager,
                          NotificationManager notificationManager,
                          ITroopManager troopManager,
                          IActionWorker actionWorker,
                          Formula formula)
            : base(id, x, y)
        {
            Notifications  = notificationManager;
            this.dbManager = dbManager;
            this.formula   = formula;

            Name    = name;
            Lvl     = level;
            Worker  = actionWorker;
            Troops  = troopManager;
            Gate    = gate;
            GateMax = gateMax;
            Theme   = theme;

            Notifications.NotificationAdded   += NotificationsUpdate;
            Notifications.NotificationRemoved += NotificationsUpdate;
            Notifications.NotificationUpdated += NotificationsUpdate;
        }
Exemple #2
0
        public ReferenceManager(uint cityId, IActionWorker actionWorker, ILockable lockingObj, IDbManager dbManager, ILocker locker)
        {
            this.cityId       = cityId;
            this.actionWorker = actionWorker;
            this.lockingObj   = lockingObj;
            this.dbManager    = dbManager;
            this.locker       = locker;

            actionWorker.ActionsRemovedFromWorker += WorkerOnActionsRemovedFromWorker;
            actionWorker.ActionRemoved            += WorkerOnActionRemoved;
        }
Exemple #3
0
        public BarbarianTribe(uint id,
                              byte level,
                              uint x,
                              uint y,
                              int count,
                              IDbManager dbManager,
                              IActionWorker actionWorker)
            : base(id, x, y)
        {
            this.dbManager = dbManager;

            Lvl          = level;
            Worker       = actionWorker;
            CampRemains  = (byte)count;
            Created      = DateTime.UtcNow;
            LastAttacked = DateTime.MinValue;

            actionWorker.LockDelegate = () => this;
            actionWorker.Location     = this;

            Resource              = new Resource();
            Resource.StatsUpdate += ResourceOnStatsUpdate;
        }
Exemple #4
0
        public City(uint id,
                    IPlayer owner,
                    string name,
                    Position position,
                    ILazyResource resource,
                    byte radius,
                    decimal ap,
                    string defaultTheme,
                    string roadTheme,
                    string troopTheme,
                    string wallTheme,
                    IActionWorker worker,
                    CityNotificationManager notifications,
                    IReferenceManager references,
                    ITechnologyManager technologies,
                    ITroopManager troops,
                    IUnitTemplate template,
                    ITroopStubFactory troopStubFactory,
                    IDbManager dbManager,
                    IGameObjectFactory gameObjectFactory,
                    IActionFactory actionFactory,
                    BattleProcedure battleProcedure)
        {
            Id                     = id;
            Owner                  = owner;
            this.name              = name;
            this.radius            = radius;
            this.troopStubFactory  = troopStubFactory;
            this.dbManager         = dbManager;
            this.gameObjectFactory = gameObjectFactory;
            this.actionFactory     = actionFactory;
            this.battleProcedure   = battleProcedure;

            PrimaryPosition = position;
            AlignmentPoint  = ap;
            DefaultTheme    = defaultTheme;
            RoadTheme       = roadTheme;
            WallTheme       = wallTheme;
            TroopTheme      = troopTheme;
            Resource        = resource;

            Worker        = worker;
            Notifications = notifications;
            References    = references;
            Technologies  = technologies;
            Troops        = troops;
            Template      = template;

            #region Event Proxies

            Template.UnitUpdated += evtTemplate =>
            {
                if (Global.Current.FireEvents && DbPersisted)
                {
                    dbManager.Save(evtTemplate);
                }

                UnitTemplateUpdated(this, new EventArgs());
            };

            Troops.TroopAdded += stub => TroopAdded(this, new TroopStubEventArgs {
                Stub = stub
            });
            Troops.TroopRemoved += stub => TroopRemoved(this, new TroopStubEventArgs {
                Stub = stub
            });
            Troops.TroopUpdated += stub => TroopUpdated(this, new TroopStubEventArgs {
                Stub = stub
            });
            Troops.TroopUnitUpdated += stub => TroopUnitUpdated(this, new TroopStubEventArgs {
                Stub = stub
            });

            Worker.ActionRemoved += (stub, state) => ActionRemoved(this, new ActionWorkerEventArgs {
                State = state, Stub = stub
            });
            Worker.ActionStarted += (stub, state) => ActionStarted(this, new ActionWorkerEventArgs {
                State = state, Stub = stub
            });
            Worker.ActionRescheduled += (stub, state) => ActionRescheduled(this, new ActionWorkerEventArgs {
                State = state, Stub = stub
            });

            Resource.ResourcesUpdate += () =>
            {
                CheckUpdateMode();
                ResourcesUpdated(this, new EventArgs());
            };

            Technologies.TechnologyCleared  += OnTechnologyCleared;
            Technologies.TechnologyAdded    += OnTechnologyAdded;
            Technologies.TechnologyRemoved  += OnTechnologyRemoved;
            Technologies.TechnologyUpgraded += OnTechnologyUpgraded;

            References.ReferenceAdded   += (sender, args) => ReferenceAdded(this, args);
            References.ReferenceRemoved += (sender, args) => ReferenceRemoved(this, args);

            #endregion
        }
Exemple #5
0
 public NotificationManager(IActionWorker worker, IDbManager dbManager)
 {
     this.dbManager            = dbManager;
     worker.ActionRescheduled += WorkerActionRescheduled;
     worker.ActionRemoved     += WorkerOnActionRemoved;
 }
Exemple #6
0
 public void AddWorker(IActionWorker worker)
 {
     commands.Enqueue(worker);
 }
Exemple #7
0
 public CityNotificationManager(IActionWorker worker, uint cityId, string channelName, IDbManager dbManager)
     : base(worker, dbManager)
 {
     this.cityId      = cityId;
     this.channelName = channelName;
 }
Exemple #8
0
 public IReferenceManager CreateReferenceManager(uint cityId, IActionWorker actionWorker, ILockable lockingObj)
 {
     return(new ReferenceManager(cityId, actionWorker, lockingObj, kernel.Get <IDbManager>(), kernel.Get <ILocker>()));
 }
        void Check(IActionWorker worker, bool serverMode, bool clientMode)
        {
            CustomActionData customActionData = new CustomActionData();
              Microsoft.Deployment.WindowsInstaller.Fakes.ShimSession.AllInstances.CustomActionDataGet = delegate { return customActionData; };

              // Проверка режима сервера.
              SetValue(worker, false);
              customActionData.AddObject<UIType>(SessionUITypeGetterExtension.keyUIType, UIType.Server);
              worker.Execute();
              Assert.AreEqual(serverMode, GetValue(worker), worker.GetType().ToString() + " Server");

              // Проверка режима клиента.
              SetValue(worker, false);
              customActionData.Clear();
              customActionData.AddObject<UIType>(SessionUITypeGetterExtension.keyUIType, UIType.Client);
              worker.Execute();
              Assert.AreEqual(clientMode, GetValue(worker), worker.GetType().ToString() + " Client");
        }
Exemple #10
0
 public NotificationManager CreateNotificationManager(IActionWorker worker)
 {
     return(new NotificationManager(worker, kernel.Get <IDbManager>()));
 }
Exemple #11
0
 public CityNotificationManager CreateCityNotificationManager(IActionWorker worker, uint cityId, string channelName)
 {
     return(new CityNotificationManager(worker, cityId, channelName, kernel.Get <IDbManager>()));
 }