private void HandleResultChosen(object sender, System.EventArgs e) { INewGameControl ctl = (INewGameControl)sender; this.playerColor = ctl.PlayerColor; this.civilization = ctl.ChosenCivilization; this.opponents = ctl.ChosenOpponents; this.leaderName = ctl.LeaderName; GameRoot root = ClientApplication.Instance.ServerInstance; root.StartServer(ctl.WorldSize, ctl.Age, ctl.Temperature, ctl.Climate, ctl.Landmass, ctl.WaterCoverage, ctl.BarbarianAggressiveness, ctl.Difficulty, ctl.Rules); OnInvoked(); }
/// <summary> /// Gets the <see cref="CityTile"/> for the specified Era, Civilization, and City size. /// </summary> /// <param name="era"></param> /// <param name="civilization"></param> /// <param name="sizeClass"></param> public CityTile GetTile(Era era, Civilization civilization, CitySizeClass sizeClass) { foreach (CityTile tile in this.Items) { if (tile.Civilization == civilization && tile.Era == era && tile.SizeClass == sizeClass) { return(tile); } } return(null); }
public bool CanBuild(Civilization targetCiv) { if (_buildList == null) { return(true); } if (_buildList.Length > targetCiv.NormalColour) { return(_buildList[targetCiv.NormalColour]); } return(_buildList.Length <= targetCiv.Id || _buildList[targetCiv.Id]); }
public async Task <IHttpActionResult> DeleteCivilization(int id) { Civilization civilization = await db.Civilizations.FindAsync(id); if (civilization == null) { return(NotFound()); } db.Civilizations.Remove(civilization); await db.SaveChangesAsync(); return(Ok(civilization)); }
public void Civ_WithOnlyRace_Parses() { // arrange var data = new List <string> { "The Towers of Quieting, Dwarves" }; // act var civ = new Civilization(data, LoadingWorld.GetTestWorld()); // assert Assert.AreEqual("The Towers of Quieting", civ.Name); Assert.AreEqual("dwarf", civ.Race.Name); Assert.AreEqual("dwarves", civ.Race.PluralName); }
// ~Civilization() // { // world.civDict.Remove(civID); // } public void AddCity(City city) { Civilization oldCiv = world.GetCiv(city.ownerID); //bool gotOldCiv = world.civDict.TryGetValue(city.ownerID, out oldCiv); if (oldCiv != null) { oldCiv.RemoveCity(city); city.IsCapital = false; } city.ownerID = civID; city.Color = color; world.SetOwnership(city.hexRef.Index, civID); // maybe this should be handled in world. cities.Add(city); }
/// <summary> /// Paints the city onto the screen. /// </summary> public override void Paint() { if (this.GridCell.City == null) { return; } City city = this.GridCell.City; CountryBase country = city.ParentCountry; Era era = country.Era; Civilization civilization = country.Civilization; CitySizeClass sizeClass = city.SizeClass; CityTile tile = this.tileset.CityTiles.GetTile(era, civilization, sizeClass); this.Graphics.DrawImage(tile.Image, this.Bounds); }
private CityTile GetCityTile(CityBase city) { CitySizeClass sizeClass = city.SizeClass; Civilization civ = city.ParentCountry.Civilization; Era era = city.ParentCountry.Era; foreach (CityTile tile in this.Items) { if (tile.Civilization == civ && tile.Era == era && tile.SizeClass == sizeClass) { return(tile); } } return(null); }
public static List <PlanetData> GetCivPlanetList(Civilization civ) { GlobalGameData gameDataRef = GameObject.Find("GameManager").GetComponent <GlobalGameData>(); GalaxyData galaxyDataRef = GameObject.Find("GameManager").GetComponent <GalaxyData>(); List <PlanetData> civPlanetList = new List <PlanetData>(); foreach (PlanetData planet in galaxyDataRef.GalaxyPlanetDataList) { if (civ.PlanetIDList.Exists(p => p == planet.ID)) { civPlanetList.Add(planet); } } return(civPlanetList); }
public static List <Province> GetCivProvinceList(Civilization civ) { GlobalGameData gameDataRef = GameObject.Find("GameManager").GetComponent <GlobalGameData>(); GalaxyData galaxyDataRef = GameObject.Find("GameManager").GetComponent <GalaxyData>(); List <Province> civProvinceList = new List <Province>(); foreach (Province prov in galaxyDataRef.ProvinceList) { if (prov.OwningCivID == civ.ID) { civProvinceList.Add(prov); } } return(civProvinceList); }
private void MigratePopsBetweenPlanets(Civilization civ) { foreach (PlanetData pData in civ.PlanetList) { foreach (Region rData in pData.RegionList) { foreach (Pops pop in rData.PopsInTile.ToArray()) { if (pop.IsMigratingOffPlanet) { DetermineMigrationLocation(pop, civ); } } } } }
public static void GeneratePlanetEvents(PlanetData pData, Civilization civ) { GlobalGameData gDataRef = GameObject.Find("GameManager").GetComponent <GlobalGameData>(); // population events if (pData.PopulationChangeLastTurn > 0) { GameEvents.GameEvent.CreateNewStellarEvent(civ.ID, pData.Name, pData.SystemID, pData.ID, GameEvents.GameEvent.eEventType.PlanetGainedPopulation, GameEvents.GameEvent.eEventLevel.Positive, GameEvents.GameEvent.eEventScope.Planet, pData.PopulationChangeLastTurn, null); } if (pData.PopulationChangeLastTurn < 0) { GameEvents.GameEvent.CreateNewStellarEvent(civ.ID, pData.Name, pData.SystemID, pData.ID, GameEvents.GameEvent.eEventType.PlanetLostPopulation, GameEvents.GameEvent.eEventLevel.Moderate, GameEvents.GameEvent.eEventScope.Planet, pData.PopulationChangeLastTurn, null); } // pop distress events if (pData.StarvationOnPlanet) { GameEvents.GameEvent.CreateNewStellarEvent(civ.ID, pData.Name, pData.SystemID, pData.ID, GameEvents.GameEvent.eEventType.StarvationOnPlanet, GameEvents.GameEvent.eEventLevel.Critical, GameEvents.GameEvent.eEventScope.Planet, pData.PopsStarvingOnPlanet, null); } if (pData.BlackoutsOnPlanet) { GameEvents.GameEvent.CreateNewStellarEvent(civ.ID, pData.Name, pData.SystemID, pData.ID, GameEvents.GameEvent.eEventType.BlackoutsOnPlanet, GameEvents.GameEvent.eEventLevel.Serious, GameEvents.GameEvent.eEventScope.Planet, pData.PopsBlackedOutOnPlanet, null); } if (pData.FarmsBuiltLastTurn > 0) { GameEvents.GameEvent.CreateNewStellarEvent(civ.ID, pData.Name, pData.SystemID, pData.ID, GameEvents.GameEvent.eEventType.NewFarmBuilt, GameEvents.GameEvent.eEventLevel.Positive, GameEvents.GameEvent.eEventScope.Planet, pData.FarmsBuiltLastTurn, null); } if (pData.HighTechBuiltLastTurn > 0) { GameEvents.GameEvent.CreateNewStellarEvent(civ.ID, pData.Name, pData.SystemID, pData.ID, GameEvents.GameEvent.eEventType.NewHighTechBuilt, GameEvents.GameEvent.eEventLevel.Positive, GameEvents.GameEvent.eEventScope.Planet, pData.HighTechBuiltLastTurn, null); } if (pData.FactoriesBuiltLastTurn > 0) { GameEvents.GameEvent.CreateNewStellarEvent(civ.ID, pData.Name, pData.SystemID, pData.ID, GameEvents.GameEvent.eEventType.NewFactoryBuilt, GameEvents.GameEvent.eEventLevel.Positive, GameEvents.GameEvent.eEventScope.Planet, pData.FactoriesBuiltLastTurn, null); } if (pData.MinesBuiltLastTurn > 0) { GameEvents.GameEvent.CreateNewStellarEvent(civ.ID, pData.Name, pData.SystemID, pData.ID, GameEvents.GameEvent.eEventType.NewMineBuilt, GameEvents.GameEvent.eEventLevel.Positive, GameEvents.GameEvent.eEventScope.Planet, pData.MinesBuiltLastTurn, null); } }
public static List <StarData> GetCivSystems(Civilization civ) { GalaxyData galaxyDataRef = GameObject.Find("GameManager").GetComponent <GalaxyData>(); PlanetData pData = new PlanetData(); List <PlanetData> pDataList = new List <PlanetData>(); List <StarData> sDataList = new List <StarData>(); foreach (string ID in civ.PlanetIDList) { pData = galaxyDataRef.GalaxyPlanetDataList.Find(p => p.ID == ID); if (!sDataList.Exists(p => p.ID == pData.SystemID)) { sDataList.Add(galaxyDataRef.GalaxyStarDataList.Find(p => p.ID == pData.SystemID)); } } return(sDataList); }
public CombatWindow() { InitializeComponent(); _appContext = ServiceLocator.Current.GetInstance <IAppContext>(); ClientEvents.CombatUpdateReceived.Subscribe(OnCombatUpdateReceived, ThreadOption.UIThread); DataTemplate itemTemplate = TryFindResource("AssetsTreeItemTemplate") as DataTemplate; FriendlyStationItem.HeaderTemplate = itemTemplate; FriendlyCombatantItems.ItemTemplate = itemTemplate; FriendlyNonCombatantItems.ItemTemplate = itemTemplate; FriendlyDestroyedItems.ItemTemplate = itemTemplate; FriendlyAssimilatedItems.ItemTemplate = itemTemplate; FriendlyEscapedItems.ItemTemplate = itemTemplate; HostileStationItem.HeaderTemplate = itemTemplate; HostileCombatantItems.ItemTemplate = itemTemplate; HostileNonCombatantItems.ItemTemplate = itemTemplate; HostileDestroyedItems.ItemTemplate = itemTemplate; HostileAssimilatedItems.ItemTemplate = itemTemplate; HostileEscapedItems.ItemTemplate = itemTemplate; DataTemplate civFriendTemplate = TryFindResource("FriendTreeTemplate") as DataTemplate; // friend civilizations summary FriendCivilizationsItems.ItemTemplate = civFriendTemplate; FriendCivilizationsItems.DataContext = _friendlyCivs; DataTemplate civTemplate = TryFindResource("OthersTreeSummaryTemplate") as DataTemplate; // other civilizations summary for targeting OtherCivilizationsSummaryItem1.ItemTemplate = civTemplate; OtherCivilizationsSummaryItem1.DataContext = _otherCivs; // ListBox data context set to OtherCivs _onlyFireIfFiredAppone = new Civilization(); // The click of "Only Return Fire" radio button by human player _onlyFireIfFiredAppone.ShortName = "Only Return Fire"; _onlyFireIfFiredAppone.CivID = 888; _onlyFireIfFiredAppone.Key = "Only Return Fire"; _theTargeted1Civ = new Civilization(); _theTargeted1Civ = _onlyFireIfFiredAppone; _theTargeted2Civ = new Civilization(); _theTargeted2Civ = _onlyFireIfFiredAppone; }
/// <summary> /// I'm not sure if this formula is correct I've just grabed if from https://forums.civfanatics.com/threads/tips-tricks-for-new-players.96725/ /// </summary> /// <param name="game"></param> /// <param name="civ"></param> /// <returns></returns> public static int CalculateScienceCost(Game game, Civilization civ) { if (civ.ReseachingAdvance < 0) { return(-1); } var techParadigm = game.Rules.Cosmic.TechParadigm; var ourAdvances = TotalAdvances(game, civ.Id); var keyCivAdvances = TotalAdvances(game, civ.PowerRank); var techLead = (ourAdvances - keyCivAdvances) / 3; var baseCost = techParadigm + techLead; if (ourAdvances > 20) { baseCost += _MapSizeAdjustment; } return(baseCost * ourAdvances); }
private void TargetButton1_Click(object sender, RoutedEventArgs e) { RadioButton radioButton1 = (RadioButton)sender; _theTargeted1Civ = (Civilization)radioButton1.DataContext; if (_theTargeted1Civ.ShortName == "Only Return Fire" && _theTargeted2Civ.ShortName == "Only Return Fire") { EngageButton.IsEnabled = false; RushButton.IsEnabled = false; TransportsButton.IsEnabled = false; } else { EngageButton.IsEnabled = true; RushButton.IsEnabled = true; TransportsButton.IsEnabled = true; } GameLog.Core.Test.DebugFormat("Primary Target is set to theTargetCiv = {0}", _theTargeted1Civ.ShortName); //theTargeted1Civ); }
private bool otherCiv(Civilization civ) { if (AllowDuplicates) { return(false); } for (int i = 0; i < PlayerOptions.Count - 1; i++) { for (int j = 0; j < NumCivsPerPerson; j++) { if (PlayerOptions[i].picks[j] == civ) { return(true); } } } return(false); }
private void UpdateEvents(Civilization civ) { foreach (PlanetData pData in civ.PlanetList) { GameEvents.PlanetEventCreator.GeneratePlanetEvents(pData, civ); // generate the events for each planet } foreach (GameEvents.GameEvent gEvent in civ.LastTurnEvents.ToArray()) { if (!gEvent.EventIsNew) // delete the event if it's already been seen { civ.LastTurnEvents.Remove(gEvent); civ.LastTurnEvents.TrimExcess(); } if (gEvent.EventIsNew) { gEvent.EventIsNew = false; } } }
void Awake() { started = false; if (_mainBoard == null) { string[] lines = System.IO.File.ReadAllLines("assets/Vive-Game/buildings.txt"); BuildingTypeFactory.parseBuildingData(lines); started = true; _mainBoard = new Board(64); TerrainGenerator.generateTerrain(_mainBoard); _civ1 = new Civilization(_mainBoard, Color.red, "Peoples' Red-public"); _civ2 = new Civilization(_mainBoard, Color.blue, "Imperial Blue"); _civ3 = new Civilization(_mainBoard, Color.yellow, "Banana Kingdom"); _civ4 = new Civilization(_mainBoard, Color.green, "Green Barony"); _civ5 = new Civilization(_mainBoard, new Color(.65f, .0f, .85f), "Royal Purple"); _civ6 = new Civilization(_mainBoard, Color.black, "Black Hole"); _civ7 = new Civilization(_mainBoard, Color.white, "White Wind"); _civ8 = new Civilization(_mainBoard, Color.cyan, "Cyan Dynasty"); } }
public void Civ_WithLeaderList_Parses() { // arrange var data = new List <string> { "The Towers of Quieting, Dwarves", " king List", " [*] Olon Channelsnarling (b.??? d. 5, Reign Began: 1), *** Original Line, Never Married", " No Children" }; // act var civ = new Civilization(data, LoadingWorld.GetTestWorld()); // assert Assert.AreEqual("The Towers of Quieting", civ.Name); Assert.AreEqual("dwarf", civ.Race.Name); Assert.AreEqual("dwarves", civ.Race.PluralName); Assert.AreEqual("king", civ.Leaders.First().Key); Assert.AreEqual("Olon Channelsnarling", civ.Leaders.First().Value[0].Name); }
public void Civ_WithWorshipList_Parses() { // arrange var data = new List <string> { "The Towers of Quieting, Dwarves", " Worship List", " Atir, deity: wealth" }; // act var civ = new Civilization(data, LoadingWorld.GetTestWorld()); // assert Assert.AreEqual("The Towers of Quieting", civ.Name); Assert.AreEqual("dwarf", civ.Race.Name); Assert.AreEqual("dwarves", civ.Race.PluralName); Assert.AreEqual("Atir", civ.Gods[0].Name); Assert.AreEqual("deity", civ.Gods[0].GodType); Assert.AreEqual("wealth", HistoricalFigure.Spheres[civ.Gods[0].Spheres[0]]); }
public static List <StarData> GetCivSystemList(Civilization civ) { GlobalGameData gameDataRef = GameObject.Find("GameManager").GetComponent <GlobalGameData>(); GalaxyData galaxyDataRef = GameObject.Find("GameManager").GetComponent <GalaxyData>(); List <StarData> civStarList = new List <StarData>(); foreach (PlanetData planet in galaxyDataRef.GalaxyPlanetDataList) { if (civ.PlanetIDList.Exists(p => p == planet.ID)) { StarData star = galaxyDataRef.GalaxyStarDataList.Find(p => p.ID == planet.SystemID); if (!civStarList.Contains(star)) { civStarList.Add(star); } } } return(civStarList); }
private static Tile GetDefaultStart(GameInitializationConfig config, Civilization civilization, Map map) { var index = Array.FindIndex(config.Rules.Leaders, l => l.Adjective == civilization.Adjective); if (index > -1 && index < config.StartPositions.Length) { var pos = config.StartPositions[index]; if (pos[0] != -1 && pos[1] != -1) { var tile = map.TileC2(pos[0], pos[1]); if (tile.Fertility > -1) { map.SetAsStartingLocation(tile, civilization.Id); config.StartTiles.Add(tile); return(tile); } } } return(null); }
public static Path CalculatePathBetween(Game game, Tile startTile, Tile endTile, UnitGAS domain, int moveFactor, Civilization owner, bool alpine, bool ignoreZoc) { if (startTile.Z != endTile.Z || !endTile.Visibility[owner.Id]) { return(null); } switch (domain) { case UnitGAS.Ground when startTile.Island != endTile.Island && startTile.Neighbours().All(t => t.Island != endTile.Island): case UnitGAS.Sea when !OnCompatibleSea(startTile, endTile): return(null); } var rules = game.Rules; Func <Tile, Tile, int> costFunction = domain switch { UnitGAS.Ground => BuildGroundMovementFunction(rules.Cosmic, alpine, moveFactor), UnitGAS.Air => (source, dest) => rules.Cosmic.MovementMultiplier, UnitGAS.Sea => (source, dest) => dest == endTile || dest.Type == TerrainType.Ocean || (dest.CityHere is { } && dest.CityHere.OwnerId == owner.Id)
public void StartGame(Civilization playerCivilization, ArrayList civilizations, string leaderName, WorldSize mapSize) { _cityBitmap = new Bitmap("City.bmp"); _cityBitmap.MakeTransparent(TransparentColor.Value); _gameRoot = GameRoot.GetGameRoot(); _villageBitmap = new Bitmap("village.bmp"); _villageBitmap.MakeTransparent(TransparentColor.Value); _roadNSBitmap = new Bitmap("road_ns.bmp"); _roadNSBitmap.MakeTransparent(TransparentColor.Value); _roadEWBitmap = new Bitmap("road_ew.bmp"); _roadEWBitmap.MakeTransparent(TransparentColor.Value); _activeBitmap = new Bitmap("active.bmp"); _activeBitmap.MakeTransparent(TransparentColor.Value); _irrigationBitmap = new Bitmap("irrigation.bmp"); _irrigationBitmap.MakeTransparent(TransparentColor.Value); _grassBitmap = new Bitmap(@"images\grass.bmp"); _grassBitmap.MakeTransparent(TransparentColor.Value); _gameRoot.StatusChanged += new StatusChangedEventHandler(OnStatusChanged); _gameRoot.MapSize = mapSize; _gameRoot.Start(playerCivilization, civilizations, leaderName); }
Civilization StartNewCiv(City capital) { int index = firstEmptyCivIndex(); if (index == -1) { Debug.LogError("No Civ Slot Availible"); } int civID = index + 1; Civilization newCiv = new Civilization(this, civID, capital); civilizaitons[index] = newCiv; civCount++; Debug.LogFormat("The {0} is born.", newCiv.name); // if (index == 17) // { // Debug.LogError(index.ToString() + " " + newCiv.civID.ToString()); // } return(newCiv); }
private void UpdatePlanets(Civilization civ) // this is where all planet-update functions go to save time { foreach (PlanetData pData in civ.PlanetList) { pData.UpdateBirthAndDeath(); // update popular support and unrest levels pData.MigratePopsBetweenRegions(); // first check to move pops between regions to regions that might better support their talents pData.UpdateEmployment(); // once pops have moved, check employment status pData.UpdateShortfallConditions(); // update shortfall results (food, power, etc) if (gDataRef.GameMonth == 1) // on the first month of every year, do this { pData.SendTaxUpward(); // determine taxes and send up the chute PlanetDevelopmentAI.AdjustViceroyBuildPlan(pData, true); // look at adjusting the build plan for each planet, force every year or when game starts } else { PlanetDevelopmentAI.AdjustViceroyBuildPlan(pData, false); // look at adjusting the build plan for each planet } pData.ExecuteProductionPlan(); // update production of new infrastructure on the planet //GameEvents.PlanetEventCreator.GeneratePlanetEvents(pData, civ); // generate the events for each planet } }
public void StartGame(Civilization playerCivilization, ArrayList enemies, string leaderName, string worldSizeString) { WorldSize worldSize; worldSize = WorldSize.Tiny; _gameWindow.StatusChanged += new StatusChangedEventHandler(OnGameStatusChanged); switch (worldSizeString) { case "Huge": worldSize = WorldSize.Huge; break; case "Large": worldSize = WorldSize.Large; break; case "Small": worldSize = WorldSize.Small; break; case "Standard": worldSize = WorldSize.Standard; break; case "Tiny": worldSize = WorldSize.Tiny; break; } _gameWindow.StartGame(playerCivilization, enemies, leaderName, worldSize); _gameRoot = _gameWindow.GameRoot; _gameRoot.PlayerColony.TechnologyAcquired += new EventHandler(TechnologyAcquired); _gameRoot.PlayerColony.TradeProposed += new TradeProposedEventHandler(TradeProposed); _yearPanel.Text = _gameRoot.Year.ToString(); _governmentPanel.Text = _gameRoot.PlayerColony.Government.Name; _technologyPanel.Text = "Researching " + _gameRoot.PlayerColony.ResearchedTech.Name; }
private void UpdateTradeAgreements() { Civilization civ = gDataRef.CivList[0]; // human civ foreach (PlanetData pData in civ.PlanetList) { // step 1: check for shortfalls of each type if (pData.FoodDifference < 0) { LookForTradePartner(civ, "food", pData.ID); // step 2: see if a trade agreement can be created } if (pData.EnergyDifference < 0) { LookForTradePartner(civ, "energy", pData.ID); // step 2: see if a trade agreement can be created } if (pData.AlphaPreProductionDifference < 0) { LookForTradePartner(civ, "alpha", pData.ID); // step 2: see if a trade agreement can be created } if (pData.HeavyPreProductionDifference < 0) { LookForTradePartner(civ, "heavy", pData.ID); // step 2: see if a trade agreement can be created } if (pData.RarePreProductionDifference < 0) { LookForTradePartner(civ, "rare", pData.ID); // step 2: see if a trade agreement can be created } // step 2 - check to see if this planet will be a supply planet CheckPlanetForSupplyDesignation(pData); UpdatePlanetTradeInfo(pData); } }
/// <summary> /// Creates a <see cref="Country"/> with the specified parameters. /// </summary> /// <param name="civilization"></param> /// <param name="leaderName"></param> /// <param name="isAIPlayer"></param> /// <param name="playerColor"></param> /// <returns></returns> public static Country CreateCountry(Civilization civilization, string leaderName, bool isAIPlayer, Color playerColor) { if (civilization == null) { throw new ArgumentNullException("civilization"); } GameRoot root = GameRoot.Instance; Country newCountry = null; GridCell randomCell = root.Grid.FindRandomDryCell(); Point coordinates = randomCell.Coordinates; if (isAIPlayer) { newCountry = new AICountry(civilization, leaderName, coordinates); } else { newCountry = new Country(civilization, leaderName, coordinates); } newCountry.Color = playerColor; return(newCountry); }
public PlayerData(Civilization civ) { this.civ = civ; }
public CPUData(Civilization civ, DifficultyEnum skill) : base(civ) { this.skill = skill; }
// Changes the UI depending on the chosen civilization public void setCivilization( Civilization civilization ) { // Load the civilization data from UISettings CivilizationData civilizationData = DataManager.Instance.civilizationDatas[civilization]; Sprite flag = civilizationData.FlagSprite; Sprite panel = civilizationData.PanelSprite; Font font = civilizationData.font; // Store the civilization panel sprite for creating future dynamic panels this.panelSprite = panel; // Change the sprite of each panel foreach ( Image image in panels ) { image.sprite = panel; } //Change the font of each text foreach( Text text in texts ) { text.font = font; } // Change the flag sprite flagImage.sprite = flag; }