Exemplo n.º 1
0
        internal void EndTurn()
        {
            _populationGrowth += GrowthRate;
            if (_populationGrowth >= 1000 && Citizens.TotalPopulation < Constants.MAXIMUM_POPULATION_SIZE)
            {
                Citizens.IncreaseByOne(_buildingsBuilt);
                _populationGrowth = 0;
                var world = CallContext <World> .GetData("GameWorld");

                world.NotificationList.Add($"- {Name} has grown to a population of {Citizens.TotalPopulation}");
            }

            if (_currentlyBuilding.BuildingId >= 0)
            {
                var building = _gameConfigCache.GetBuildingConfigById(_currentlyBuilding.BuildingId);

                _currentlyBuilding = new CurrentlyBuilding(_currentlyBuilding.BuildingId, -1, -1, _currentlyBuilding.ProductionAccrued + SettlementProduction);
                if (_currentlyBuilding.ProductionAccrued >= building.ConstructionCost)
                {
                    _buildingsBuilt.Add(_currentlyBuilding.BuildingId);
                    var world = CallContext <World> .GetData("GameWorld");

                    world.NotificationList.Add($"- {Name} has produced a {building.Name}");
                    _currentlyBuilding = new CurrentlyBuilding(-1, -1, -1, 0);

                    OnSettlementOpened(EventArgs.Empty);
                }
            }
            if (_currentlyBuilding.UnitId >= 0)
            {
                _currentlyBuilding = new CurrentlyBuilding(-1, _currentlyBuilding.UnitId, -1, _currentlyBuilding.ProductionAccrued + SettlementProduction);

                var unit = _gameConfigCache.GetUnitConfigById(_currentlyBuilding.UnitId);
                if (_currentlyBuilding.ProductionAccrued >= unit.ConstructionCost)
                {
                    var world = CallContext <World> .GetData("GameWorld");

                    //world.AddUnit(Location, unitType);
                    world.NotificationList.Add($"- {Name} has produced a {unit.Name}");
                    _currentlyBuilding = new CurrentlyBuilding(-1, _currentlyBuilding.UnitId, -1, 0);
                }
            }
            if (_currentlyBuilding.OtherId >= 0)
            {
                // TODO: others
            }
        }
Exemplo n.º 2
0
        public Settlement(string name, int raceId, PointI location, byte settlementSize, CellGrid cellGrid, int[] buildingIds)
        {
            _gameConfigCache = CallContext <GameConfigCache> .GetData("GameConfigCache");

            _id = location.Y * Constants.WORLD_MAP_COLUMNS + location.X;

            Name               = name;
            Race               = _gameConfigCache.GetRaceConfigById(raceId);
            Location           = location;
            _populationGrowth  = 0;
            _currentlyBuilding = new CurrentlyBuilding(-1, -1, -1, 0);
            _buildingsBuilt    = new List <int>();
            foreach (var buildingId in buildingIds)
            {
                _buildingsBuilt.Add(buildingId);
            }
            Citizens = new SettlementCitizens(this, settlementSize, _buildingsBuilt);

            // control
            _catchmentCells = cellGrid.GetCatchment(location.X, location.Y, 2);
            foreach (var item in _catchmentCells)
            {
                var cell = cellGrid.GetCell(item.Column, item.Row);
                cellGrid.SetCell(cell, cell.SeenState, 1);
            }
            _catchmentCells = cellGrid.GetCatchment(location.X, location.Y, 2);
            cellGrid.CellFactionChange(_catchmentCells);

            // sight
            _seenCells = cellGrid.GetCatchment(location.X, location.Y, 3);
            foreach (var item in _seenCells)
            {
                var cell = cellGrid.GetCell(item.Column, item.Row);
                cellGrid.SetCell(cell, SeenState.CurrentlySeen);
            }
        }
Exemplo n.º 3
0
 public void AddToProductionQueue(UnitConfig unit)
 {
     _currentlyBuilding = new CurrentlyBuilding(-1, unit.Id, -1, _currentlyBuilding.ProductionAccrued);
 }
Exemplo n.º 4
0
 public void AddToProductionQueue(BuildingConfig building)
 {
     _currentlyBuilding = new CurrentlyBuilding(building.Id, -1, -1, _currentlyBuilding.ProductionAccrued);
 }