/// <summary> /// Create or overwrite the savefile /// </summary> /// <returns></returns> public IEnumerator Create() { startingData.Level = 1; startingData.masterVolume = _options.MasterVolume; startingData.SFXvolume = _options.SFXVolume; BinaryFormatter formatter = new BinaryFormatter(); using (FileStream fs = File.Create(SAVEFILE_PATH)) { formatter.Serialize(fs, startingData); yield return(null); } _levelLoader.ClickToLoadAsync(startingData.Level); }
private void Update() { if (fadeIn) { fadeDurationCpt++; if (fadeDurationCpt >= fadeInOutDuration) { showCpt++; if (showCpt >= nextSentence) { fadeIn = false; FadeOut(); showCpt = 0; fadeDurationCpt = 0; } } else { FadeIn(); } } else { fadeDurationCpt++; if (fadeDurationCpt >= fadeInOutDuration) { fadeIn = true; sentencesCounter++; if (sentencesCounter < sentences.Length) { nextSentence = (sentences[sentencesCounter].Length); text.text = sentences[sentencesCounter]; } else { levelLoader.ClickToLoadAsync(nextLevel); } fadeDurationCpt = 0; } else { FadeOut(); } } /*if(Time.time>=nextSentence && fadeOut) * { * Debug.Log("NextSentence"); * sentencesCounter++; * if (sentencesCounter < sentences.Length) * { * textRyhtm = sentences[sentencesCounter].Length / 20; * nextSentence = Time.time + textRyhtm; * text.text = sentences[sentencesCounter]; * text.CrossFadeAlpha(1, fadeInOutDuration, false); * fadeOut = false; * fadeIn = true; * * } * else * { * levelLoader.ClickToLoadAsync(nextLevel); * } * } * else if(Time.time>=nextSentence && fadeIn) * { * nextSentence = Time.time + fadeInOutDuration; * text.CrossFadeAlpha(0, fadeInOutDuration, false); * fadeOut = true; * fadeIn = false; * }*/ }
private void HandleVictory() { _data.Level = SceneManager.GetActiveScene().buildIndex + 1; _saveGame.Save(); _levelLoader.ClickToLoadAsync(_data.Level); }
private void LoadGame() { _levelLoader.ClickToLoadAsync(data.Level); }