using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class ScoreScene : MonoBehaviour { public Image image; //private int count = 0; //public Sprite[] intro; public new List audio = new List(); public Animator animator; //private bool audio_play = false; //private float timer1 = 0.1f; //fuellt den Pot //private int val = 0; public Text scoreText; public Text motiveText; private bool genug = false; private bool touched = false; private float timer2 = 1.0f; //wartet auf fade_out private float timer0 = 1.0f; //wartet auf fade_in private bool switched=false; private void Start() { float t = Gamestate.Instance.getNumberTrials()*10f; Debug.Log("ScoreScene: " + Gamestate.Instance.getNumberTrials()); Debug.Log("ScoreScene points: " + Gamestate.Instance.getGamePoints().ToString()); if (0 <= Gamestate.Instance.getGamePoints() & Gamestate.Instance.getGamePoints() < t*0.25f) { scoreText.text = "Du hast "+Gamestate.Instance.getGamePoints().ToString() +" Punkte gesammelt!"; motiveText.text = "Okay"; genug = false; } else if (t*0.25f <= Gamestate.Instance.getGamePoints() & Gamestate.Instance.getGamePoints() < t*0.5f) { scoreText.text = "Du hast "+Gamestate.Instance.getGamePoints().ToString() +" Punkte gesammelt!"; motiveText.text = "Gut!"; genug = false; } else if (t*0.5f <= Gamestate.Instance.getGamePoints() & Gamestate.Instance.getGamePoints() < t*0.75f) { scoreText.text = "Du hast "+Gamestate.Instance.getGamePoints().ToString() +" Punkte gesammelt!"; motiveText.text = "Sehr gut!!"; genug = true; } else if (t*0.75f <= Gamestate.Instance.getGamePoints()) { scoreText.text = "Du hast "+Gamestate.Instance.getGamePoints().ToString() +" Punkte gesammelt!"; motiveText.text = "Super!!!"; genug = true; } } // Update is called once per frame void Update() { timer0 -= Time.deltaTime; if (timer0 <= 0) { //pot.GetComponent().color = new Color32(255, 255, 255, 255); //progressBar.GetComponent().color = new Color32(255, 255, 255, 255); /*if (genug & !audio_play) { audio[0].Play(); //Gamestate.Instance.startEndScene(); audio_play = true; }*/ if (Input.touchCount > 0 && !touched) { touched = true; timer2 = 1.0f; animator.SetBool("fadeout", true); } timer2 -= Time.deltaTime; if (timer2 <= 0 && touched) { //animator.SetBool("fadeout", false); //Debug.Log("----------------- timer2 <= 0...."); if (genug) { switch(Gamestate.Instance.getLevel()) { case "1": if(!switched) { Gamestate.Instance.setLevel("2"); Gamestate.Instance.setTutorial(false); switched = true; DontDestroyOnLoad(Gamestate.Instance); Gamestate.Instance.startGame(); } break; case "2": if(!switched) { Gamestate.Instance.setLevel("3"); Gamestate.Instance.setTutorial(false); switched = true; DontDestroyOnLoad(Gamestate.Instance); Gamestate.Instance.startGame(); } break; case "3": if(!switched) { Gamestate.Instance.setLevel("3"); switched = true; DontDestroyOnLoad(Gamestate.Instance); Gamestate.Instance.startEndScene(); } break; } } else { DontDestroyOnLoad(Gamestate.Instance); Gamestate.Instance.startGame(); } } } } }