Exemplo n.º 1
0
    public void AddCityToKingdom(CityTileTest city)
    {
        this.kingdom.AddCityToKingdom(city);
//		city.cityAttributes = new CityTest (city.GetComponent<HexTile>(), this);
//		city.cityAttributes.kingdomTile = this;
//		city.GetComponent<HexTile> ().SetTileColor (kingdom.tileColor);
    }
Exemplo n.º 2
0
 public static bool IsTileIncludedInYourKingdom(HexTile hexTile)
 {
     if (!hexTile.isCity)
     {
         return(true);
     }
     else
     {
         if (hexTile.GetComponent <CityTileTest>().cityAttributes.kingdomTile == null)
         {
             return(true);
         }
         else
         {
             CityTileTest otherCity = hexTile.GetComponent <CityTileTest>();
             if (otherCity.cityAttributes.id == targetCity.id)
             {
                 return(true);
             }
             else
             {
                 if (targetCity.kingdomTile.kingdom.cities.Contains(otherCity))
                 {
                     return(false);
                 }
                 else
                 {
                     return(true);
                 }
             }
         }
     }
     return(true);
 }
    public void StartRevolution()
    {
        int numOfCitiesToRevolt = 2;

        if (numOfCitiesToRevolt <= 0)
        {
            return;
        }
        if (currentlySelectedKingdom.cities.Count < 4)
        {
            Debug.LogWarning("The kingdom only has " + currentlySelectedKingdom.cities.Count.ToString() + " cities.");
        }
        else
        {
            if (numOfCitiesToRevolt == currentlySelectedKingdom.cities.Count)
            {
                //Replace Lord
                if (currentlySelectedKingdom.royaltyList.successionRoyalties.Count <= 0)
                {
                    currentlySelectedKingdom.AssignNewLord(null);
                }
                else
                {
                    currentlySelectedKingdom.AssignNewLord(currentlySelectedKingdom.royaltyList.successionRoyalties[0]);
                }

                Debug.Log("Revolution! Lord of: " + currentlySelectedKingdom.kingdomName + " was replaced");
            }
            else
            {
                List <CityTileTest> citiesForNewKingdom = new List <CityTileTest> ();
                CityTileTest        mainCity            = currentlySelectedKingdom.cities [UnityEngine.Random.Range(0, currentlySelectedKingdom.cities.Count)];
                citiesForNewKingdom.Add(mainCity);
                for (int i = 0; i < mainCity.cityAttributes.connectedCities.Count; i++)
                {
                    if (mainCity.cityAttributes.connectedCities [i].cityAttributes.kingdomTile.kingdom.id == currentlySelectedKingdom.id)
                    {
                        citiesForNewKingdom.Add(mainCity.cityAttributes.connectedCities [i]);
                        break;
                    }
                }

                currentlySelectedKingdom.RemoveCitiesFromKingdom(citiesForNewKingdom);
                KingdomTest newKingdom = PoliticsPrototypeManager.Instance.CreateNewKingdom(citiesForNewKingdom, UnityEngine.Random.ColorHSV(0f, 1f, 1f, 1f, 0.5f, 1f));
                newKingdom.CreateInitialRelationshipsToKingdoms();
                PoliticsPrototypeManager.Instance.AddRelationshipToOtherKingdoms(newKingdom);
                Debug.Log("Revolution! New kingdom: " + newKingdom.kingdomName + " was created");
                PoliticsPrototypeManager.Instance.GenerateConnections();
                LoadKingdoms();
            }

            ShowKingdomInfo(currentlySelectedKingdom);
        }
    }
    private List <Citizen> InitialCitizens(CityTileTest cityTile)
    {
//		List<Citizen> citizens = new List<Citizen> ();
//		citizens.Add(new Citizen (CITIZEN_TYPE.FARMER));
//		citizens.Add(new Citizen (CITIZEN_TYPE.MINER));
//		citizens.Add(new Citizen (CITIZEN_TYPE.WOODSMAN));
//		citizens.Add(new Citizen (CITIZEN_TYPE.WARRIOR));
//
//		return citizens;
        return(null);
    }
Exemplo n.º 5
0
    void GenerateCityConnections()
    {
        for (int i = 0; i < this.cities.Count; i++)
        {
            CityTileTest currentCityTile   = this.cities[i].GetComponent <CityTileTest>();
            int          nextCityIndex     = i + 1;
            int          previousCityIndex = i - 1;
            if (nextCityIndex >= this.cities.Count)
            {
                nextCityIndex = 0;
            }
            if (previousCityIndex < 0)
            {
                previousCityIndex = 5;
            }

            currentCityTile.cityAttributes.AddCityAsConnected(this.cities [nextCityIndex].GetComponent <CityTileTest>());
            currentCityTile.cityAttributes.AddCityAsConnected(this.cities [previousCityIndex].GetComponent <CityTileTest>());

            Tile thisCity = currentCityTile.GetComponent <HexTile>().tile;
            for (int j = 0; j < currentCityTile.cityAttributes.connectedCities.Count; j++)
            {
                Tile tileToConnectTo = currentCityTile.cityAttributes.connectedCities[j].hexTile.tile;
                thisCity.canPass        = true;
                tileToConnectTo.canPass = true;
                List <Tile> roads = GetPath(thisCity, tileToConnectTo, PATHFINDING_MODE.ROAD_CREATION).ToList();
                for (int k = 0; k < roads.Count; k++)
                {
                    roads [k].hexTile.isRoad = true;
                    if (!roads [k].hexTile.isCity && !roads [k].hexTile.isOccupied)
                    {
                        roads [k].hexTile.SetTileColor(Color.gray);
                    }
                }
                thisCity.canPass        = false;
                tileToConnectTo.canPass = false;
            }
        }
    }
Exemplo n.º 6
0
    public void SetCityInfoToShow(CityTileTest cityTile)
    {
        lblUpgradeCitizenCost.text = "";
        lblUpgradeCityCost.text    = "";
        lblCreateCitizenCost.text  = "";
        currentDisplayingCityTile  = cityTile;
        lblCityName.text           = "Name: " + cityTile.cityAttributes.cityName;
        lblCityLevel.text          = "Lvl: " + cityTile.cityAttributes.cityLevel.ToString();

//		lblUpgradeCitizenTarget.text = "Needed Role: " + cityTile.cityAttributes.neededRole.ToString ();
//		List<Resource> neededRoleCost = cityTile.cityAttributes.GetCitizenCreationCostPerType (cityTile.cityAttributes.neededRole);
//		if (neededRoleCost != null) {
//			for (int i = 0; i < neededRoleCost.Count; i++) {
//				lblUpgradeCitizenCost.text += neededRoleCost [i].resourceType.ToString () + ": " + neededRoleCost [i].resourceQuantity.ToString () + "\n";
//			}
//		}
//
//
//		if (cityTile.cityAttributes.newCitizenTarget != JOB_TYPE.NONE) {
//			lblCreateCitizenTarget.text = "Create: " + cityTile.cityAttributes.newCitizenTarget.ToString();
//		}
////		else {
////			lblCreateCitizenTarget.text = "Create: NONE";
////		}
//
//		List<Resource> createCitizenResources = cityTile.cityAttributes.GetCitizenCreationCostPerType (cityTile.cityAttributes.newCitizenTarget);
//		if(createCitizenResources != null){
//			for (int i = 0; i < createCitizenResources.Count; i++) {
//				lblCreateCitizenCost.text += createCitizenResources[i].resourceQuantity + " " + createCitizenResources[i].resourceType.ToString() + "\n";
//			}
//		}

        if (cityTile.cityAttributes.nextCityCitizenAction == CITY_CITIZEN_ACTION.CREATE_CITIZEN)
        {
            lblCityCitizenAction.text = "CREATE new " + cityTile.cityAttributes.citizenActionJobType.ToString() + " on tile "
                                        + cityTile.cityAttributes.citizenActionHexTile.name;
        }
        else if (cityTile.cityAttributes.nextCityCitizenAction == CITY_CITIZEN_ACTION.CHANGE_CITIZEN)
        {
            lblCityCitizenAction.text = "CHANGE " + cityTile.cityAttributes.citizenToChange.name + "/" + cityTile.cityAttributes.citizenToChange.job.jobType.ToString() +
                                        " to " + cityTile.cityAttributes.citizenActionJobType.ToString();
        }
        else
        {
            lblCityCitizenAction.text = "No Citizen Action";
        }

        lblNeededResources.text = "[";
        int[] neededResources = cityTile.cityAttributes.GetNeededResources();
        for (int i = 0; i < neededResources.Length; i++)
        {
            lblNeededResources.text += neededResources[i].ToString() + ",";
        }
        lblNeededResources.text += "]";


        for (int i = 0; i < cityTile.cityAttributes.cityUpgradeRequirements.resource.Count; i++)
        {
            Resource currentResource = cityTile.cityAttributes.cityUpgradeRequirements.resource [i];
            lblUpgradeCityCost.text += currentResource.resourceType.ToString() + ": " + currentResource.resourceQuantity.ToString() + "\n";
        }

        lblGoldCount.text          = "Gold: " + cityTile.cityAttributes.goldCount.ToString() + "\n" + cityTile.cityAttributes.GetResourceStatusByType(RESOURCE.GOLD).status.ToString();
        lblFoodCount.text          = "Food: " + cityTile.cityAttributes.foodCount.ToString() + "\n" + cityTile.cityAttributes.GetResourceStatusByType(RESOURCE.FOOD).status.ToString();
        lblFoodStockPileCount.text = "Stock: " + cityTile.cityAttributes.foodStockpileCount.ToString();
        lblLumberCount.text        = "Lumber: " + cityTile.cityAttributes.lumberCount.ToString() + "\n" + cityTile.cityAttributes.GetResourceStatusByType(RESOURCE.LUMBER).status.ToString();
        lblStoneCount.text         = "Stone: " + cityTile.cityAttributes.stoneCount.ToString() + "\n" + cityTile.cityAttributes.GetResourceStatusByType(RESOURCE.STONE).status.ToString();
        lblManaStoneCount.text     = "Mana: " + cityTile.cityAttributes.manaStoneCount.ToString() + "\n" + cityTile.cityAttributes.GetResourceStatusByType(RESOURCE.MANA).status.ToString();
        lblMetalCount.text         = "Metal: " + cityTile.cityAttributes.metalCount.ToString() + "\n" + cityTile.cityAttributes.GetResourceStatusByType(RESOURCE.METAL).status.ToString();
        if (cityTile.cityAttributes.kingdomTile)
        {
            lblKingdomName.text = "Kingdom: " + cityTile.cityAttributes.kingdomTile.kingdom.kingdomRace;
        }
        else
        {
            lblKingdomName.text = "Kingdom: None";
        }

        lblCitizenCap.text     = cityTile.cityAttributes.citizens.Count.ToString() + "/" + cityTile.cityAttributes.citizenLimit.ToString();
        lblFarmerCount.text    = cityTile.cityAttributes.GetNumberOfCitizensPerType(JOB_TYPE.FARMER).ToString();
        lblHunterCount.text    = cityTile.cityAttributes.GetNumberOfCitizensPerType(JOB_TYPE.HUNTER).ToString();
        lblWoodsmanCount.text  = cityTile.cityAttributes.GetNumberOfCitizensPerType(JOB_TYPE.WOODSMAN).ToString();
        lblMinerCount.text     = cityTile.cityAttributes.GetNumberOfCitizensPerType(JOB_TYPE.MINER).ToString();
        lblAlchemistCount.text = cityTile.cityAttributes.GetNumberOfCitizensPerType(JOB_TYPE.ALCHEMIST).ToString();
//		lblWarriorCount.text = cityTile.cityAttributes.GetNumberOfCitizensPerType(JOB_TYPE.DEFENSE_GENERAL).ToString();
//		lblArcherCount.text = cityTile.cityAttributes.GetNumberOfCitizensPerType(JOB_TYPE.OFFENSE_GENERAL).ToString();
//		lblMageCount.text = cityTile.cityAttributes.GetNumberOfCitizensPerType(JOB_TYPE.MAGE).ToString();
        lblQuarrymanCount.text = cityTile.cityAttributes.GetNumberOfCitizensPerType(JOB_TYPE.QUARRYMAN).ToString();
        lblMerchantCount.text  = cityTile.cityAttributes.GetNumberOfCitizensPerType(JOB_TYPE.MERCHANT).ToString();
//		lblBrawlerCount.text = cityTile.cityAttributes.GetNumberOfCitizensPerType(JOB_TYPE.BRAWLER).ToString();

        lblUnrest.text      = "Unrest: " + cityTile.cityAttributes.unrest.ToString();
        lblCitySummary.text = cityTile.cityAttributes.cityLogs;
    }
Exemplo n.º 7
0
//-----------------------------------------------------------------------------------------------
    internal void AddCityToKingdom(CityTileTest city)
    {
        this.cities.Add(city);
        city.cityAttributes.kingdomTile = this.kingdomTile;
        city.GetComponent <HexTile> ().SetTileColor(this.tileColor);
    }