Exemplo n.º 1
0
    public void ApplyScenarioDataToMap()
    {
        string nationsPath = Application.dataPath +
                             "/StreamingAssets/Scenarios/" + scenario + "/Nations";
        string provincesPath = Application.dataPath +
                               "/StreamingAssets/Scenarios/" + scenario + "/Provinces";

        string[] provFiles = Directory.GetFiles(provincesPath, "*.json");
        foreach (string file in provFiles)
        {
            string dataAsJson  = File.ReadAllText(file);
            var    newProvince = Newtonsoft.Json.JsonConvert.DeserializeObject <assemblyCsharp.Province>
                                     (dataAsJson);
            //  Debug.Log("Prov quality size" + newProvince.quality[0]);
            provinces.Add(newProvince.getIndex(), newProvince);
            map.GetProvince(newProvince.getIndex()).name        = newProvince.getProvName();
            map.GetProvince(newProvince.getIndex()).customLabel = newProvince.getProvName();
        }

        string[] nationFiles = Directory.GetFiles(nationsPath, "*.json");
        foreach (string file in nationFiles)
        {
            string dataAsJson = File.ReadAllText(file);
            var    newNation  = Newtonsoft.Json.JsonConvert.DeserializeObject <assemblyCsharp.Nation>(dataAsJson);

            nations.Add(newNation.getIndex(), newNation);
            Debug.Log("Nation Name: " + newNation.getNationName());
            Debug.Log("Nation's Capital " + newNation.capital);

            // Debug.Log("Nation Name: " + newNation.getNationName());
            //   Debug.Log("Number of Provinces " + newNation.getAllProvinceIndexes().Count);
            map.GetCountry(newNation.getIndex()).name        = newNation.getNationName();
            map.GetCountry(newNation.getIndex()).customLabel = newNation.getNationName();
            map.CountryRename("Country" + newNation.getIndex(), newNation.getNationName());
            for (int i = 0; i < newNation.getProvinces().Count; i++)
            {
                int provIndex = newNation.getProvinces()[i];
                WorldMapStrategyKit.Province prov = map.GetProvince(provIndex);
                prov.countryIndex = newNation.getIndex();
            }
        }
    }