City GetCityByTypeAndFaction(CityType cityType, Faction faction)
 {
     foreach (City city in ObjectsManager.Instance.transform.Find("Map/Cities").GetComponentsInChildren <City>())
     {
         if (city.CityType == cityType && city.CityCurrentFaction == faction)
         {
             return(city);
         }
     }
     Debug.LogError("Failed to find city with " + cityType.ToString() + " type and " + faction.ToString() + " faction.");
     return(null);
 }
Exemple #2
0
    public ForeignCity()
    {
        Id = current_id;
        current_id++;
        Name = NameManager.Instance.Get_Name(NameManager.NameType.City, false);
        if (RNG.Instance.Next(0, 100) < 33)
        {
            //Hostile
            Opinion = -1.0f + RNG.Instance.Next_F();
        }
        else if (RNG.Instance.Next(0, 100) < 10)
        {
            //Positive
            Opinion = 0.25f + (RNG.Instance.Next_F() * (OPINION_MAX_RESTING_POINT - 0.25f));
        }
        else
        {
            //Neutral
            Opinion = RNG.Instance.Next_F() * 0.25f;
        }
        Opinion_Resting_Point = -1.0f;
        Update_Opinion_Resting_Point();
        City_Type = RNG.Instance.Item(Enum.GetValues(typeof(CityType)).Cast <CityType>().Where(x => x != CityType.Colony).ToList());
        Dictionary <TradeRouteType, int> trade_route_chances = new Dictionary <TradeRouteType, int>()
        {
            { TradeRouteType.Land, 40 }, { TradeRouteType.Water, 40 }, { TradeRouteType.Both, 20 }
        };

        Preferred_Imports  = new List <Resource>();
        Disliked_Imports   = new List <Resource>();
        Unaccepted_Imports = new List <Resource>();
        Exports            = new List <Resource>();
        Cheap_Exports      = new List <Resource>();
        Expensive_Exports  = new List <Resource>();
        possible_exports   = new List <Resource.ResourceTag>();
        impossible_exports = new List <Resource.ResourceTag>();

        switch (City_Type)
        {
        case CityType.Farming_Town:
            Initialize_Exports_And_Imports(
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Agricultural, Resource.ResourceTag.Livestock, Resource.ResourceTag.Crop
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Clothing
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Opulent, Resource.ResourceTag.Exotic
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Hunting, Resource.ResourceTag.Coastal
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Archaic, Resource.ResourceTag.Opulent, Resource.ResourceTag.Foraging, Resource.ResourceTag.Food
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Opulent
            });
            trade_route_chances[TradeRouteType.Land]  = 70;
            trade_route_chances[TradeRouteType.Water] = 15;
            trade_route_chances[TradeRouteType.Both]  = 15;
            break;

        case CityType.Rural_Town:
            Initialize_Exports_And_Imports(
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Agricultural, Resource.ResourceTag.Forestry, Resource.ResourceTag.Crop
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Foraging, Resource.ResourceTag.Clothing
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Opulent, Resource.ResourceTag.Fine, Resource.ResourceTag.Exotic
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Construction, Resource.ResourceTag.Coastal
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Agricultural, Resource.ResourceTag.Livestock, Resource.ResourceTag.Archaic, Resource.ResourceTag.Opulent, Resource.ResourceTag.Foraging
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Opulent
            });
            trade_route_chances[TradeRouteType.Land]  = 80;
            trade_route_chances[TradeRouteType.Water] = 10;
            trade_route_chances[TradeRouteType.Both]  = 10;
            break;

        case CityType.Remote_Village:
            Initialize_Exports_And_Imports(
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Archaic
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Foraging, Resource.ResourceTag.Hunting, Resource.ResourceTag.Crop
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Opulent, Resource.ResourceTag.Fine, Resource.ResourceTag.Exotic
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Construction, Resource.ResourceTag.Clothing, Resource.ResourceTag.Food
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Archaic, Resource.ResourceTag.Foraging, Resource.ResourceTag.Hunting, Resource.ResourceTag.Exotic
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Opulent
            });
            trade_route_chances[TradeRouteType.Land]  = 90;
            trade_route_chances[TradeRouteType.Water] = 5;
            trade_route_chances[TradeRouteType.Both]  = 5;
            break;

        case CityType.Maritime_Town:
            Initialize_Exports_And_Imports(
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Coastal
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Industrial, Resource.ResourceTag.Exotic, Resource.ResourceTag.Jewelry
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Mining
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Forestry, Resource.ResourceTag.Foraging
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Coastal
            },
                new List <Resource.ResourceTag>()
            {
            });
            trade_route_chances[TradeRouteType.Land]  = 0;
            trade_route_chances[TradeRouteType.Water] = 90;
            trade_route_chances[TradeRouteType.Both]  = 10;
            break;

        case CityType.Forest_Village:
            Initialize_Exports_And_Imports(
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Forestry
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Foraging, Resource.ResourceTag.Hunting
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Opulent, Resource.ResourceTag.Exotic
            },
                new List <Resource.ResourceTag>()
            {
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Forestry, Resource.ResourceTag.Foraging, Resource.ResourceTag.Hunting, Resource.ResourceTag.Opulent
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Opulent
            });
            trade_route_chances[TradeRouteType.Land]  = 90;
            trade_route_chances[TradeRouteType.Water] = 5;
            trade_route_chances[TradeRouteType.Both]  = 5;
            break;

        case CityType.Industrial_City:
            Initialize_Exports_And_Imports(
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Industrial
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Construction
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Exotic
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Mining, Resource.ResourceTag.Industrial, Resource.ResourceTag.Food
            },
                new List <Resource.ResourceTag>()
            {
            },
                new List <Resource.ResourceTag>()
            {
            });
            trade_route_chances[TradeRouteType.Land]  = 45;
            trade_route_chances[TradeRouteType.Water] = 30;
            trade_route_chances[TradeRouteType.Both]  = 25;
            break;

        case CityType.Mining_Town:
            Initialize_Exports_And_Imports(
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Mining
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Industrial, Resource.ResourceTag.Construction
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Fine, Resource.ResourceTag.Exotic, Resource.ResourceTag.Opulent
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Food, Resource.ResourceTag.Forestry, Resource.ResourceTag.Construction
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Mining, Resource.ResourceTag.Opulent
            },
                new List <Resource.ResourceTag>()
            {
            });
            trade_route_chances[TradeRouteType.Land]  = 90;
            trade_route_chances[TradeRouteType.Water] = 5;
            trade_route_chances[TradeRouteType.Both]  = 5;
            break;

        case CityType.Large_City:
            Initialize_Exports_And_Imports(
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Opulent, Resource.ResourceTag.Industrial, Resource.ResourceTag.Agricultural, Resource.ResourceTag.Clothing
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Coastal, Resource.ResourceTag.Fine
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Archaic, Resource.ResourceTag.Exotic, Resource.ResourceTag.Crop, Resource.ResourceTag.Livestock
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Food, Resource.ResourceTag.Industrial, Resource.ResourceTag.Opulent, Resource.ResourceTag.Exotic
            },
                new List <Resource.ResourceTag>()
            {
                Resource.ResourceTag.Archaic, Resource.ResourceTag.Foraging
            },
                new List <Resource.ResourceTag>()
            {
            });
            trade_route_chances[TradeRouteType.Land]  = 45;
            trade_route_chances[TradeRouteType.Water] = 45;
            trade_route_chances[TradeRouteType.Both]  = 10;
            break;

        default:
            CustomLogger.Instance.Error(string.Format("Unimplemented city type: {0}", City_Type.ToString()));
            break;
        }
        int check_total = 0;
        int random      = RNG.Instance.Next(0, 100);

        foreach (TradeRouteType type in Enum.GetValues(typeof(TradeRouteType)))
        {
            check_total += trade_route_chances[type];
        }
        if (random <= trade_route_chances[TradeRouteType.Land])
        {
            Trade_Route_Type = TradeRouteType.Land;
        }
        else if (random > trade_route_chances[TradeRouteType.Land] && random <= trade_route_chances[TradeRouteType.Land] + trade_route_chances[TradeRouteType.Water])
        {
            Trade_Route_Type = TradeRouteType.Water;
        }
        else
        {
            Trade_Route_Type = TradeRouteType.Both;
        }

        if (check_total != 100)
        {
            CustomLogger.Instance.Error(string.Format("Chance total is not 100 for type: {0}", City_Type.ToString()));
        }
    }