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 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
        }