Пример #1
0
        public IActionResult Index()
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api.covid19india.org/data.json");

            request.Method = "GET";
            String test = String.Empty;

            using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
            {
                Stream       dataStream = response.GetResponseStream();
                StreamReader reader     = new StreamReader(dataStream);
                test = reader.ReadToEnd();
                reader.Close();
                dataStream.Close();
            }

            NationDataModel nationDataModel = JsonConvert.DeserializeObject <NationDataModel>(test);

            ChartsModel chartsModel = ChartsModelMapper.Map(nationDataModel);
            var         stringModel = JsonConvert.SerializeObject(chartsModel);



            return(View(chartsModel));
        }
Пример #2
0
    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());
        }
    }
Пример #3
0
    // Use this for initialization
    void Start()
    {
        // Saving the players enetered data in a string

        PlayerID = PlayerPrefs.GetString("ID");
        Debug.Log(PlayerID);
        PlayerCountry = PlayerPrefs.GetString("Country");
        Debug.Log(PlayerCountry);
        Score  = Standings.GetScore();
        Player = GameObject.Find(PlayerCountry);


        CoreDataManager        PlayerDataManger = new CoreDataManager();
        List <NationDataModel> nationList       = new List <NationDataModel>();

        nationList = PlayerDataManger.GetCountries();
        //List<GameObject> gos = GameObject.FindGameObjectsWithTag("Country");

        //still cant get it to pass the countrys data into the script
        foreach (GameObject go in GameObject.FindGameObjectsWithTag("Country"))
        {
            Debug.Log("Entering player Data");
            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;
            nationList.Add(ndm);
        }

        foreach (NationDataModel nation in nationList)
        {
            if (nation.Name == Player.name)
            {
                PlayerBudget          = nation.Budget;
                PlayerPopulation      = nation.Population;
                PlayerAllies          = nation.Allies;
                PlayerTradingPartners = nation.TradingPartners;
                PlayerEnemies         = nation.Enemies;
                Debug.Log(PlayerBudget);
                Debug.Log(PlayerPopulation);
            }
        }
    }