Пример #1
0
    public static SessionSaveData Instance()
    {
        if (gameSessionData == null)
        {
            gameSessionData = new SessionSaveData();
        }

        return(gameSessionData);
    }
Пример #2
0
    //Creating some default data
    public void CreatData()
    {
//        Debug.Log("Create");
        for (int countryCount = 0; countryCount < dynamicCountryCount; countryCount++)        //country
        {
            //creating a country data class where all state and cities data will be there
            CountryData countryDataClass = new CountryData();

            //Directly putting the country name as per indexing
            if (countryCount == 0)
            {
                countryDataClass._Cntname = "INDIA";
            }
            if (countryCount == 1)
            {
                countryDataClass._Cntname = "GERMANY";
            }
            if (countryCount == 2)
            {
                countryDataClass._Cntname = "JAPAN";
            }

            //creating a list of states in country object
            countryDataClass.sTATEs = new List <StateData>();

            for (int stateCount = 0; stateCount <= dynamicStateCount; stateCount++)            //state
            {
                //Creating a state object in this country object
                StateData sTATE = new StateData();

                //Name on the basis of state index
                sTATE._stateName = "STATE_" + stateCount.ToString();

                //creating the object of the list of city
                sTATE.cityList = new List <string>();

                countryDataClass.sTATEs.Add(sTATE);


                //Creating a list of cities for this state
                for (int cityCount = 0; cityCount <= dynamicCityCount; cityCount++)                //City
                {
                    string cityName = "CITY_" + cityCount.ToString();
                    sTATE.cityList.Add(cityName);
                }
            }

            //adding the country data to a dictionary as countryName is key
            SessionSaveData.Instance().allDataDict.Add(countryDataClass._Cntname, countryDataClass);
        }
    }
Пример #3
0
    private void Start()
    {
//		Debug.Log ("START in UI");
        //loading the data from session data
        SessionSaveData.Instance().Load();

        //Assigning the button in all country button
        for (int i = 0; i < countryPanel.childCount; i++) //country button panel
        {
            int index = i;
            Debug.Log(index + "  i= " + i + "  list  " + SessionSaveData.Instance().allDataClassObject.structList.Count);
            Button button = countryPanel.GetChild(index).GetComponent <Button>();
            button.onClick.RemoveAllListeners();
            button.onClick.AddListener(() =>
            {
                //Updatng the states data according to country selected
                UpdateStateData(SessionSaveData.Instance().allDataClassObject.structList[index], index);
            });
        }
    }
Пример #4
0
    void Awake()
    {
        //deciding length of country state and cities Which can be changed anytime
        dynamicCountryCount = 3;
        dynamicStateCount   = 9;
        dynamicCityCount    = 9;

        //Creating some default data if there is not JSON data for country state and cities
//		if (SessionSaveData.Instance ().allDataDict.Count == 0)
//		{
//			CreatData ();
//			SessionSaveData.Instance ().Save ();
//		}

        //Loading the JSON file to game from storage
//		SessionSaveData.Instance ().Load ();
        if (SessionSaveData.Instance().allDataDict.Count == 0)
        {
            CreatData();
        }

        SessionSaveData.Instance().Save();
    }