Exemple #1
0
    void Start()
    {
        FPMapper.Initialise();
        _selectedCountry = null;

        fileName = PlayerPrefs.GetString("ID");

        _coreDataManager = new CoreDataManager();
        _coreDataManager.setNewCoreDataModel(FPRepository.LoadJSONProfile(fileName + ".json", "Profiles/", true));

        _newsDataManager = new NewsDataManager();
        _newsDataManager.setNewsDataModelJSON(FPRepository.LoadFile("News.json", "Config/"));

        NewsGenerator newGen = this.gameObject.AddComponent <NewsGenerator>();

        newGen.newsData  = _newsDataManager;
        newGen.countries = _coreDataManager.GetListCountriesList().ToArray();

        List <NationDataModel> models = _coreDataManager.GetCountries();

        foreach (NationDataModel ndm in models)
        {
            GameObject country = new GameObject(ndm.Name);
            country.transform.parent = this.transform;
            country.tag = "Country";

            FPMapper.MapCountry(country, ndm);
        }
    private void SaveGame()
    {
        if ((int)Time.timeSinceLevelLoad % 100 == 0)
        {
            Debug.Log("Saving: Test_ProfileAlpha.json");

            List <NationDataModel> ndms = new List <NationDataModel>();
            List <GameObject>      gos  = GameObject.FindGameObjectsWithTag("Country").ToList();

            foreach (GameObject go in gos)
            {
                NationDataModel ndm = new NationDataModel();
                ndm.Name            = go.GetComponent <CountryStanding>().Name;
                ndm.Population      = go.GetComponent <CountryStanding>().Population;
                ndm.MapPosition     = go.GetComponent <CountryStanding>().MapPosition;
                ndm.Budget          = go.GetComponent <CountryStanding>().Budget;
                ndm.Allies          = go.GetComponent <CountryStanding>().Allies;
                ndm.Enemies         = go.GetComponent <CountryStanding>().Enemies;
                ndm.TradingPartners = go.GetComponent <CountryStanding>().TradingPartners;
                ndms.Add(ndm);
            }

            _coreDataManager.setNationData(ndms);
            FPRepository.SaveProfile(fileName + ".json", _coreDataManager.getCoreDataModel());
        }
    }
Exemple #3
0
 public void LoadGame()
 {
     FPRepository.LoadFile(PlayerID.text, "Profiles/");
     SceneManager.LoadScene("Scenes/GameScene");
 }