public SaveLoadData() { if (instance == null) { instance = this; } }
public ModelNPC.ObjectData UpdateData(string callFunc) { _dataObject = SaveLoadData.GetObjectDataByGobj(this.gameObject); if (_dataObject == null) { Debug.Log("#################### Error data game object is Empty !!!! :" + callFunc); return(null); } _dataObject.Init(); if (_dataObject.NameObject != this.name) { Debug.Log("#################### Error data game object : " + _dataObject.NameObject + " GO: " + this.name + " :" + callFunc); return(null); } //if (_dataObject.TargetPosition == new Vector3(0, 0, 0)) //{ // Debug.Log("#################### Error UFO dataUfo.TargetPosition is zero !!!! :" + callFunc); // return null; //} return(_dataObject); }
private void Init() { //PlayerPrefs.DeleteAll(); //JoaoResetData CSVReader.LoadLanguageCSV(); //JoaoResetData if (!PlayerPrefs.GetString("PlayerSavedData").Equals("")) { //dbg += "from save"; Debug.Log(PlayerPrefs.GetString("PlayerSavedData")); SaveLoadData.LoadPlayerData(); if (GlobalData.SAVEDQUIZQUESTIONS.Count > 0) { // dbg+="has loaded quiz questions from save"; SaveLoadData.SavePlayerData(); } else { // dbg+="not loaded quiz questions from save"; LoadQuiz(-1); } } else { //dbg += "loading_quiz\n"; Debug.Log("loadquiz"); LoadQuiz(-1); } SoundControl.PlayMusic(GlobalData.Music_Paths[0], true); this.transform.Find("OptionsMenu").GetComponent <OptionsMenu>().updateMusicSFXImages(); }
void Awake() { //add alles wat met game controll heeft te maken. if (destroyIfExists) { if (GameObject.FindGameObjectsWithTag("GameController").Length > 1) { Destroy(gameObject); } else { destroyIfExists = false; } } else { DontDestroyOnLoad(gameObject); } saveLoad = gameObject.AddComponent <SaveLoadData> (); playerProgression = gameObject.AddComponent <PlayerProgression>(); dataScoreTransfer = gameObject.AddComponent <DataScoreTransfer> (); //save data when scene loaded. }
/// <summary> /// Sets the users prefs into the global variables in AppManeger and save it. /// Please, enter with a dictonary with the keys: /// {Smoke, MinAge, MaxAge, Habit, WantToMeetMan, WantToMeetWoman}. /// </summary> /// <param name="dic">Dictionary</param> static public void SetUsersPrefsVariables(Dictionary <string, string> dic) { AppManeger.instance.wantToMeet = new List <Gender> (); // reset list // ====================== Add the results into the global vars ========================================= if (Convert.ToBoolean(dic ["WantToMeetMan"])) { AppManeger.instance.wantToMeet.Add(Gender.Male); } if (Convert.ToBoolean(dic ["WantToMeetWoman"])) { AppManeger.instance.wantToMeet.Add(Gender.Female); } AppManeger.instance.wantAge [0] = Convert.ToInt32(dic["MinAge"]); AppManeger.instance.wantAge [1] = Convert.ToInt32(dic["MaxAge"]); AppManeger.instance.isSmoke = Convert.ToBoolean(dic["Smoke"]); AppManeger.instance.yourHabit = (Habit)Enum.Parse((typeof(Habit)), dic["Habit"]); // =================================================================================================== //-------------- Save user prefs data on the phone ---------------------------------- string fileName = string.Format("Prefs_{0}", AppManeger.instance.userID); SaveLoadData.Save(fileName, SaveLoadData.DataType.UserPrefs); //----------------------------------------------------------------------------- }
void Start() { ge = new Thread(GetEnegy); gameSave = SaveLoadData.LoadData(); if (!gameSave.everSave) { for (int i = 0; i < catHolder.Length; i++) { gameSave.stateSave[i] = catHolder[i].GetComponent <CatControll>().state; } for (int i = 0; i < catNum.Length; i++) { gameSave.catNum[i] = catNum[i]; } for (int i = 0; i < catBuyYet.Length; i++) { gameSave.catBuyYet[i] = catBuyYet[i]; } SaveAllData(); } nowTime = DateTime.Now; timeSpan_f = nowTime.Subtract(gameSave.recordTime); Debug.Log(timeSpan_f.TotalSeconds + "秒"); int deltaenegy = (int)timeSpan_f.TotalSeconds / 300; LoadAllData(); enegy = (enegy + deltaenegy > 50) ? 50 : enegy + deltaenegy; if (enegy < 0) { enegy = 0; } timeSpan_d = timeSpan_f.Add(new TimeSpan(0, 0, -deltaenegy * 300)); }
private static SaveLoadData LoadData() { if (File.Exists(Path.Combine(Application.persistentDataPath, fileName))) { BinaryFormatter binaryFormatter = new BinaryFormatter(); SaveLoadData data = null; try { FileStream file = File.Open(Path.Combine(Application.persistentDataPath, fileName), FileMode.Open); data = (SaveLoadData)binaryFormatter.Deserialize(file); file.Close(); } catch (Exception ex) { Debug.Log(ex.Message); debugEvent.Invoke(ex.Message); } return(data); } else { Debug.Log("noFileToLoad"); SaveData(loadedData); return(LoadData()); } }
/* * Loads a new chunk from file with tiles and objects at desired position */ public void LoadChunkAt(int x, int y) { if (!chunks.ContainsKey(new Vector2(x, y))) { SaveLoadData saveLoadData = new SaveLoadData(); var savedChunk = saveLoadData.LoadChunk(x, y, worldName); if (savedChunk != null) { //Creates an empty gameobject chunk to store the tiles var chunkGO = Instantiate(chunkEmptyObject, new Vector3(x, y, 0), Quaternion.identity, transform); var newChunk = chunkGO.GetComponent <Chunk>(); chunkGO.name = "Chunk(" + x + "," + y + ")"; //Fills the chunk class component on the chunk GO newChunk.size = savedChunk.size; newChunk.posX = savedChunk.posX; newChunk.posY = savedChunk.posY; newChunk.tiles = savedChunk.tiles; newChunk.objects = savedChunk.objects; //Creates the tiles on the chunk CreateLayers(newChunk); //Adds chunk to the total list of chunks chunks.Add(new Vector2(x, y), newChunk); } } }
public void Load() { playerName_Ps = SaveLoadData.LoadPlayerName(); won_Ps = SaveLoadData.LoadPlayerBool(); roundsSurvived_Ps = SaveLoadData.LoadPlayerRound(); secondsInLastRound_Ps = SaveLoadData.LoadPlayerTime(); }
public void FaceBookLogin() { GetMethods.GetUserId(email, (id) => { if (id != "0") // The user exits in the data base // Verify if an Update is necessary. { UpdateMethods.UpdateUsersDatabase(id, userName, age, AppManeger.instance.userGender.ToString(), (result) => { Debug.Log(string.Format("Update {0}", result)); }); string fileName = string.Format("Prefs_{0}", AppManeger.instance.userID); //GetMethods.GetUserPrefs(id, (prefsResult) => {PrefsResult(prefsResult);}); // Check if the user are in the Prefs Database if (SaveLoadData.FileExits(fileName)) // If exit { SaveLoadData.Load(fileName, SaveLoadData.DataType.UserPrefs); // load from device GoToCheersPanel(); // Means the user has everyting setted; } else { GetMethods.GetUserPrefs(id, (prefsResult) => { PrefsResult(prefsResult); }); // Check if the user are in the Prefs Database } } else // User don't exit in the data base { PostMethods.InsertUserIntoUsersDatabase(userName, age, email, gender, (result) => { InsertUserResult(result); }); } }); }
public void load() { float[] loadedData = SaveLoadData.loadPosition(); transform.position = new Vector3(loadedData[0], loadedData[1], loadedData[2]); }
private ModelNPC.GameDataUfo FindObjectData(string callFunc) { var dataUfo = SaveLoadData.GetObjectDataByGobj(this.gameObject) as ModelNPC.GameDataUfo; if (dataUfo == null) { Debug.Log("#################### Error UFO MoveObjectToPosition dataUfo is Empty !!!! :" + callFunc); return(null); } if (dataUfo.NameObject != this.name) { Debug.Log("#################### Error UFO MoveObjectToPosition dataUfo: " + dataUfo.NameObject + " GO: " + this.name + " :" + callFunc); return(null); } if (dataUfo.TargetPosition == new Vector3(0, 0, 0)) { Debug.Log("#################### Error UFO dataUfo.TargetPosition is zero !!!! :" + callFunc); return(null); } return(dataUfo); }
public void SelectLanguage(Dropdown sel_lang) { cur_language = sel_lang.value; Debug.Log(cur_language); cur_text.text = list_text[cur_language]; SaveLoadData.SaveData("selected_language", cur_language); }
public void StartLevel(int level_n) { SoundControl.PlaySFX(GlobalData.SFX_Paths[1], false, true, true); Debug.Log(level_n); if (level_n <= 10) { GlobalData.current_level = level_n; } else { GlobalData.current_difficulty++; GlobalData.current_level = 1; } if (GlobalData.current_difficulty == 3) { GlobalData.current_difficulty = 2; GlobalData.current_level = 10; } Debug.Log(PlayerData.lastunlockeddificulty + " difficulty compare " + GlobalData.current_difficulty); Debug.Log(PlayerData.lastunlockedlevel + " level compare " + GlobalData.current_level); if (PlayerData.lastunlockeddificulty < GlobalData.current_difficulty) { PlayerData.lastunlockeddificulty = GlobalData.current_difficulty; PlayerData.lastunlockedlevel = GlobalData.current_level; } else if (PlayerData.lastunlockeddificulty == GlobalData.current_difficulty) { if (PlayerData.lastunlockedlevel < GlobalData.current_level) { PlayerData.lastunlockedlevel = GlobalData.current_level; } } if (GlobalData.current_level == 1 && GlobalData.current_difficulty == 0) { GlobalData.current_tutorial = -1; } else { GlobalData.current_tutorial = -2; } SaveLoadData.SavePlayerData(); Debug.Log("PlayerData Unlocked level " + PlayerData.lastunlockedlevel); Debug.Log("level " + (GlobalData.current_level - 1) + " difficulty " + (GlobalData.current_difficulty)); if (GlobalData.LevelsUnlocked[GlobalData.current_difficulty][GlobalData.current_level - 1]) { GameObject quiz = (GameObject)Instantiate(Resources.Load("Prefabs/Quiz")); quiz.transform.parent = this.transform.parent; quiz.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Screen.width); quiz.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Screen.height); quiz.transform.position = new Vector3(Screen.width / 2, Screen.height / 2, 0); quiz.GetComponent <QuizControl>().LoadQuiz(3); } }
public void EndGame() { Debug.Log("EndGame"); StopAllCoroutines(); ready_now = false; total_errors.text = error_count.ToString(); total_time_text.text = timer_text.text; timer_text.enabled = false; timer_min = 0; HitEvent.Invoke(); if (!pause) { record_int[4]++; SaveLoadData.SaveData("round_counter", record_int[4].ToString()); switch (width_row_number) { case 3: if (timer_sec < record_int[0]) { record_int[0] = timer_sec; SaveLoadData.SaveData("3x3", record_int[0].ToString()); } break; case 4: if (timer_sec < record_int[1]) { record_int[1] = timer_sec; SaveLoadData.SaveData("4x4", record_int[1].ToString()); } break; case 5: if (timer_sec < record_int[2]) { record_int[2] = timer_sec; SaveLoadData.SaveData("5x5", record_int[2].ToString()); } break; case 6: if (timer_sec < record_int[3]) { record_int[3] = timer_sec; SaveLoadData.SaveData("6x6", record_int[3].ToString()); } break; } } else { pause = false; } for (int i = numbers_panel.childCount; i > 0; i--) { DestroyImmediate(numbers_panel.GetChild(0).gameObject); } }
void Start() { string dataCountry = SaveLoadData.LoadData(nameVarCodeCountry, true); if (dataCountry == "" || dataCountry == "Null") SaveLoadData.SaveData(nameVarCodeCountry, ToCountryCode(Application.systemLanguage), true); if (Input.location.isEnabledByUser) StartCoroutine(getGeographicalCoordinatesCoroutine()); }
public void ShowRecord() { record_text[0].text = SaveLoadData.LoadData("3x3"); record_text[1].text = SaveLoadData.LoadData("4x4"); record_text[2].text = SaveLoadData.LoadData("5x5"); record_text[3].text = SaveLoadData.LoadData("6x6"); record_text[4].text = SaveLoadData.LoadData("round_counter"); }
// Use this for initialization void Start() { _sctiptData = GetComponent <SaveLoadData>(); if (_sctiptData == null) { Debug.Log("GenerateGridFields.Start : sctiptData not load !!!"); } }
public void PrivacyAgree(int agree) { SaveLoadData.SaveData("agree_privacy_polit", agree); if (agree == 0) { Application.Quit(); } }
// Use this for initialization void Awake() { playerProgression = gameObject.AddComponent <PlayerProgression> (); saveLoadData = gameObject.AddComponent <SaveLoadData> (); saveLoadData.Load(); SendMessage("AllDataComponentsAdded", SendMessageOptions.DontRequireReceiver); //laat weten dat alle data dingen zijn geadd. }
public string[] list_text;//english, russian, deutsch, francias, chines, indian, japan void Start() { game_mngr = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameManager>(); if (PlayerPrefs.HasKey("selected_language")) { cur_language = SaveLoadData.LoadDataInt("selected_language"); cur_text.text = list_text[cur_language]; } }
public Test(Creature creature, float testTime, int test, int generation) { sLD = new SaveLoadData(); this.generation = generation; this.test = test; this.testTime = testTime; this.creature = creature; initialCenterOfMass = CalculateMeanCenterOfMass(); }
void Start() { onDungeonCompleted += DungeonFinished; Scene scene = SceneManager.GetActiveScene(); _levelName = scene.name; _player = GameObject.FindGameObjectWithTag(Tags.PLAYER).GetComponent <Player>(); _saveData = GameObject.FindGameObjectWithTag(Tags.SAVELOADOBJECT).GetComponent <SaveLoadData>(); }
public static SaveLoadData Load() { string[] saveFileLines; var retVal = new SaveLoadData(); try { saveFileLines = File.ReadAllLines(SAVE_LOAD_FILE); } catch(Exception ex) { retVal.Error = "Could not load " + SAVE_LOAD_FILE + " Did you copy it to the scripts folder?"; SaveLoad.Log(ex.ToString()); return retVal; } StringBuilder currentsb = null; for (var i = 0; i < saveFileLines.Length; i++) { var nextLine = saveFileLines[i]; if (nextLine == "") continue; switch (nextLine) { case "[PropData]": { currentsb = null; break; } case "[OnTickCode]": { currentsb = retVal.OnTickCode; break; } case "[ImmediateCode]": { currentsb = retVal.ImmediateCode; break; } //case "[CompileTemplate]": //{ // currentsb = retVal.CompileTemplate; // break; //} default: { if (currentsb != null) currentsb.AppendLine(nextLine); else retVal.PropData.Add(nextLine); break; } } } return retVal; }
public void LoadData() { Debug.Log("讀檔"); GameSave gameSave = new GameSave(); gameSave = SaveLoadData.LoadData(); state = gameSave.stateSave[state.uid - 1000]; }
public PoolGameObject AddPoolNewTypeObject(string prefabTag, bool isLog = false) { GameObject newGO = null; if (!m_collectionPoolPrefabsStr.ContainsKey(prefabTag)) { prefabTag = TypePoolPrefabs.PoolFloor.ToString(); Debug.Log("############ AddPoolNewTypeObject Not prefab in collection for prefabTag=" + prefabTag); } GameObject prefabPoolInst = m_collectionPoolPrefabsStr[prefabTag]; if (prefabPoolInst == null) { Debug.Log("####### AddPoolNewTypeObject prefabPoolInst == null " + prefabTag); } newGO = SaveLoadData.CopyGameObject(prefabPoolInst); PoolGameObject poolObj = new PoolGameObject(); poolObj.Name = "GameObjectPool " + indexPool++; poolObj.Tag = prefabTag; poolObj.Init(newGO); poolObj.Deactivate(); //Fix Tile field bool isField = false; isField = TypePoolPrefabs.PoolFloor.ToString() == prefabTag; if (isField) { //see: GetPrefabField ModelNPC.TerraData terrD = new ModelNPC.TerraData() { ModelView = "Weed" }; //Update texture Object pool Field default terrD.UpdateGameObject(newGO); } var stackPool = new Stack <PoolGameObject>(); if (!PoolGamesObjectsStack.ContainsKey(prefabTag)) { PoolGamesObjectsStack.Add(prefabTag, stackPool); } else { stackPool = PoolGamesObjectsStack[prefabTag]; } //int countInPool = PoolGamesObjectsStack[prefabTag].Count; stackPool.Push(poolObj); return(poolObj); }
public void NoSetTeam() { SoundControll.Instance.PlayEffecSound(SoundControll.Instance.buttonClip); GlobalValue.instance.gameSave = SaveLoadData.LoadData(); for (int j = 0; j < 3; j++) { GlobalValue.instance.catNum[j] = GlobalValue.instance.gameSave.catNum[j]; AddCatList(j); } noSetPanel.SetActive(false); }
public void OnBack() { GlobalValue.instance.gameSave = SaveLoadData.LoadData(); for (int i = 0; i < 3; i++) { GlobalValue.instance.catNum[i] = GlobalValue.instance.gameSave.catNum[i]; } GlobalValue.instance.SaveAllData(); loading.SetActive(true); loading.GetComponent <Loading>().GotoScene("MainScene"); }
private void OnEnable() { if (GetType().Equals(typeof(NewOperator))) { return; } storeDataAction = delegate { StoreData(); }; saveDataAction = delegate { SaveLoadData.AddOperatorData(data); }; SaveLoadData.OnBeforeSave += storeDataAction; SaveLoadData.OnBeforeSave += saveDataAction; }
private void OnGUI() { if (GUI.Button(new Rect(50, 50, 100, 40), "存档")) { SaveLoadData.SaveGame(); } if (GUI.Button(new Rect(50, 150, 100, 40), "读档")) { SaveLoadData.LoadGame(); } }
private void OnApplicationQuit() { //save the time last opened time.StopCoroutine(time.PassYearsRealtime()); //stop gaining money money.StopCoroutine(money.GainMoney()); //save game data SaveLoadData.SaveGameData(); }