public KingdomTest(float populationGrowth, RACE race, List <CityTileTest> cities, Color tileColor, KingdomTileTest kingdomTile) { this.id = GetID() + 1; this.kingdomName = "KINGDOM" + this.id; this.kingdomTile = kingdomTile; this.lord = null; // this.lord = new Lord(this); // this.assignedLord = new Royalty (this, true); this.cities = cities; this.kingdomRace = race; this.isDead = false; this.tileColor = tileColor; this.relationshipKingdoms = new List <RelationshipKingdoms>(); this.expansionChance = defaultExpansionChance; this.armyBaseUnits = GetArmyBaseUnits(); this.armyIncreaseUnits = GetArmyIncreaseUnits(); this.armyBaseStats = GetArmyBaseStats(); this.armyIncreaseStats = GetArmyIncreaseStats(); this.armyIncreaseUnitResource = GetArmyIncreaseUnitResource(); this.royaltyList = new RoyaltyList(); this.marriedCouples = new List <MarriedCouple>(); SetLastID(this.id); DetermineCityUpgradeResourceType(); CreateInitialRoyalties(); }
public void DevelopNewCity(KingdomTileTest conqueror, List <General> visitingGenerals) { this.cityAttributes = new CityTest(this.hexTile, conqueror); this.cityAttributes.OccupyCity(); this.GetComponent <SpriteRenderer> ().color = this.cityAttributes.kingdomTile.kingdom.tileColor; this.cityAttributes.visitingGenerals.AddRange(visitingGenerals); GameManager.Instance.UpdateAllMilitaryData(); }
void AssignCitiesToKingdoms() { for (int i = 0; i < cities.Count; i++) { KingdomTileTest randomKingdom = kingdoms [UnityEngine.Random.Range(0, kingdoms.Count)]; randomKingdom.AddCityToKingdom(cities [i].GetComponent <CityTileTest> ()); } }
internal void CheckForRevolution() { for (int i = 0; i < cities.Count; i++) { // cities [i].cityAttributes.unrest = 0; List <Relationship> previousLordsWars = this.lord.currentWars; int chanceToRevolt = (int)Mathf.Abs((float)cities[i].cityAttributes.unrest / 4f); int choice = Random.Range(0, 1000); if (choice < chanceToRevolt) { //A city has revolted! if (this.cities.Count == 1) { //Replace Lord GameManager.Instance.RemoveRelationshipToOtherLords(this.lord); this.lord = new Lord(this); this.lord.CreateInitialRelationshipsToLords(); GameManager.Instance.AddRelationshipToOtherLords(this.lord); GameManager.Instance.UpdateLordAdjacency(); PassOnWarsToOtherLord(previousLordsWars, this.lord); return; } else if (this.cities.Count >= 2) { int numOfCitiesToJoinRevolt = 0; int averageUnrest = (TotalUnrestInKingdom() / 8) / this.cities.Count; int x = this.cities.Count - 1; while (x > 0) { int chance = averageUnrest * x; choice = Random.Range(0, 100); if (choice < chance) { numOfCitiesToJoinRevolt++; } x--; } List <CityTileTest> citiesForNewKingdom = new List <CityTileTest>(); citiesForNewKingdom.Add(cities[i]); // Debug.Log("Number of cities to join revolt: " + numOfCitiesToJoinRevolt.ToString () + "/" + this.cities.Count.ToString()); if (numOfCitiesToJoinRevolt == (this.cities.Count - 1)) { GameManager.Instance.RemoveRelationshipToOtherLords(this.lord); this.lord = new Lord(this); this.lord.CreateInitialRelationshipsToLords(); GameManager.Instance.AddRelationshipToOtherLords(this.lord); GameManager.Instance.UpdateLordAdjacency(); PassOnWarsToOtherLord(previousLordsWars, this.lord); return; } else if (numOfCitiesToJoinRevolt > 0) { for (int j = 0; j < citiesOrderedByUnrest.Count; j++) { if (citiesOrderedByUnrest [j] == cities [i]) { continue; } citiesForNewKingdom.Add(citiesOrderedByUnrest[j]); if ((citiesForNewKingdom.Count - 1) == numOfCitiesToJoinRevolt) { break; } } } this.RemoveCitiesFromKingdom(citiesForNewKingdom); KingdomTileTest newKingdom = GameManager.Instance.CreateNewKingdom(this.kingdomRace, citiesForNewKingdom); //Set this kingdom's lord to dislike the new lord of the new kingdom for (int j = 0; j < this.lord.relationshipLords.Count; j++) { if (this.lord.relationshipLords[j].lord.id == newKingdom.kingdom.lord.id) { this.lord.relationshipLords[j].like = -50; this.lord.relationshipLords[j].lordRelationship = this.lord.GetLordRelationship(this.lord.relationshipLords[j].like); //Set both new lord and this kingdom's lord to war this.lord.GoToWarWith(newKingdom.kingdom.lord); newKingdom.kingdom.lord.GoToWarWith(this.lord); Debug.Log("Lord that rebelled: " + newKingdom.kingdom.lord.id.ToString() + " - " + newKingdom.kingdom.lord.name + "is now at war with: " + this.lord.id.ToString() + " - " + this.lord.name); break; } } break; } } } }