LearnWithTouch/Assets/scripts/Intro.cs

58 lines
1.5 KiB
C#
Raw Normal View History

2019-07-01 14:33:21 +02:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Intro : MonoBehaviour
{
public Image image;
private int count = 0;
public Sprite[] intro;
public new List<AudioSource> audio = new List<AudioSource>();
public Animator animator;
public void Start() {
audio[0].Play();
}
// Update is called once per frame
void Update()
{
if (animator.GetCurrentAnimatorStateInfo(0).normalizedTime > 1.0f || Input.touchCount >0)
{
if (count == 3)
{
DontDestroyOnLoad(Gamestate.Instance);
Gamestate.Instance.startGame();
/*if (Gamestate.Instance.getTutorial())
Gamestate.Instance.startTutorial();
else
{
Gamestate.Instance.startGame();
}*/
}
else
{
//background.texture.LoadImage();
image.sprite = intro[count];// newSprite;
audio[count].Stop();
audio[count+1].Play();
}
if (count < 2)
animator.Play("Intro_Fader", -1, 0f);
else
{
animator.Play("Intro_Fader2", -1, 0f);
}
count += 1;
Debug.Log("count: " + count.ToString());
}
}
}