// Start is called before the first frame update void Start() { TimeMaster.instance.SaveDate(); HGAnimator = GetComponent <Animator>(); saving = GetComponent <Hatchigotchi>(); if (!GetTheCode.newUser) { data = SaveSystem.LoadHatchigotchi(); hungerMeter = data.hungerMeter; happinessMeter = data.happinessMeter; playfulMeter = data.playfulMeter; sleepinessMeter = data.sleepinessMeter; } else { hungerMeter = moderateValue; happinessMeter = moderateValue; playfulMeter = moderateValue; sleepinessMeter = moderateValue; } inSleepTimer -= TimeMaster.instance.CheckDate(); GetTheCode.newUser = false; }
public void LoadHatchigotchi() { try { HatchigotchiData data = SaveSystem.LoadHatchigotchi(); if (!SceneHandler.eggScene) { name = data.name; print("name: " + name); bondingMeter = data.bondingMeter; hungerMeter = data.hungerMeter; happinessMeter = data.happinessMeter; playfulMeter = data.playfulMeter; //sleepinessMeter = data.sleepinessMeter; } // Load the scene currentScene = data.currentScene; SceneManager.LoadScene(currentScene); } catch (System.Exception ex) { Debug.Log(ex); throw ex; } }
public static void SaveHatchigotchi(Hatchigotchi hatchigotchi) { BinaryFormatter formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "/hatchigotchi.fun"; FileStream stream = new FileStream(path, FileMode.Create); HatchigotchiData data = new HatchigotchiData(hatchigotchi); formatter.Serialize(stream, data); stream.Close(); }
// Start is called before the first frame update void Start() { hatchigotchiName = GetComponent <Text>(); inputName = GetComponent <Text>(); data = SaveSystem.LoadHatchigotchi(); inputName = NamingStageScript.theName; LoadName(); try{ hatchigotchiName.text = inputName.text; data.name = hatchigotchiName.text; } catch (System.Exception ex) { Debug.Log(ex); } }
//private Hatchigotchi saving; // Start is called before the first frame update void Start() { SceneHandler.currentScene = 4; renderer2D = GetComponent <SpriteRenderer>(); body2d = GetComponent <Rigidbody2D>(); cardPos = new Vector3(0, 0, 0); try { data = SaveSystem.LoadHatchigotchi(); bondingMeter = data.bondingMeter; } catch (System.Exception) { bondingMeter = 0; throw; } }
public static HatchigotchiData LoadHatchigotchi() { string path = Application.persistentDataPath + "/hatchigotchi.fun"; if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); HatchigotchiData data = formatter.Deserialize(stream) as HatchigotchiData; stream.Close(); return(data); } else { Debug.LogError("Save file not found in" + path); return(null); } }