private City GenerateCity(Player owner) { var city = new City(); city.Name = NamesGenerator.Generate(); do { //city.X = GlobalUtils.Rand(config.WorldWidth - 50) + 20; // X=Rnd(590)+20 //city.Y = GlobalUtils.Rand(config.WorldHeight - 52) + 20; // Y=Rnd(460)+20 city.X = GlobalUtils.Rand(_legionConfig.WorldWidth); city.Y = GlobalUtils.Rand(_legionConfig.WorldHeight); } while (!IsCityPositionAvailable(city.X, city.Y)); city.Population = GlobalUtils.Rand(900) + 10; city.Owner = owner; city.BobId = 8 + (city.Owner != null ? city.Owner.Id : 0) * 2; if (city.Population > 700) { city.BobId++; city.WallType = GlobalUtils.Rand(2) + 1; } else { city.WallType = GlobalUtils.Rand(1); } city.Tax = GlobalUtils.Rand(25); city.Morale = GlobalUtils.Rand(100); //TEREN[X+4,Y+4] //city.TerrainType = terrainManager.GetTerrain(city.X + 4, city.Y + 4); //if (city.TerrainType == 7) city.TerrainType = 1; city.X += 8; city.Y += 8; city.Craziness = GlobalUtils.Rand(10) + 5; city.DaysToGetInfo = 30; _citiesHelper.UpdatePriceModificators(city); var buildings = GenerateBuildings(); city.Buildings = buildings; return(city); }
private void AfterAttackOnCity(Army army, City city, Army cityArmy) { city.Population -= city.Population / 4; if (city.Population < 20) { city.Population = 20; } if (cityArmy == null || cityArmy.IsKilled) { if (army.Owner.IsChaosControlled) { city.Owner = null; city.Population -= city.Population / 2; if (city.Population < 20) { city.Population = 20; } for (var i = 2; i <= 10; i++) { if (GlobalUtils.Rand(3) == 1) { city.Population = 0; } } var burnedCityMessage = new Message(); burnedCityMessage.Type = MessageType.ChaosWarriorsBurnedCity; burnedCityMessage.MapObjects = new List <MapObject> { city }; _messagesService.ShowMessage(burnedCityMessage); } else { var cityOwner = city.Owner; city.Owner = army.Owner; if (cityOwner == _playersRepository.UserPlayer || army.Owner == _playersRepository.UserPlayer) { var capturedCityMessage = new Message(); capturedCityMessage.MapObjects = new List <MapObject> { city }; if (army.Owner == _playersRepository.UserPlayer) { _citiesHelper.UpdatePriceModificators(city); capturedCityMessage.Type = MessageType.UserCapturedCity; } else { capturedCityMessage.Type = MessageType.EnemyCapturedUserCity; } _messagesService.ShowMessage(capturedCityMessage); } } } else { if (army.IsTracked || army.Owner == _playersRepository.UserPlayer) { //TODO: CENTER[X1, Y1, 1] var failedMessage = new Message(); failedMessage.Type = MessageType.UserArmyFailedToCaptureCity; failedMessage.MapObjects = new List <MapObject> { army }; _messagesService.ShowMessage(failedMessage); } } }