ZoeAppClass/Assets/Jogos/281/Scripts/ControllerShadows.cs

108 lines
2.5 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ControllerShadows : MonoBehaviour
{
public Image image1, image2, image3, image4, image5;
public GameObject go1, go2, go3, go4, go5;
public static bool finishedGame = false;
public static bool ended = false;
public static int stage;
private void Awake()
{
int index = 0;
ended = false;
finishedGame = false;
stage = 1;
StartCoroutine(WaitToDIE());
GameControl.instance.StartedGame();
}
private void Update()
{
// Debug.Log(stage);
}
public void buttonAction()
{
if(stage == 1)
{
image1.color = new Color(255, 255, 255);
StartCoroutine(HideImages(2));
StartCoroutine(NextStage(2));
}
else if (stage == 2)
{
image2.color = new Color(255, 255, 255);
StartCoroutine(HideImages(2));
StartCoroutine(NextStage(2));
}
else if (stage == 3)
{
image3.color = new Color(255, 255, 255);
StartCoroutine(HideImages(2));
StartCoroutine(NextStage(2));
}
else if (stage == 4)
{
image4.color = new Color(255, 255, 255);
StartCoroutine(HideImages(2));
StartCoroutine(NextStage(2));
}
else if (stage == 5)
{
image5.color = new Color(255, 255, 255);
StartCoroutine(NextStage(2));
}
}
IEnumerator NextStage(float time)
{
yield return new WaitForSeconds(time);
stage++;
if(stage == 6)
{
win();
}
}
IEnumerator HideImages(float time)
{
yield return new WaitForSeconds(time);
if(stage == 1)
{
go1.SetActive(false);
go2.SetActive(true);
}
if (stage == 2)
{
go2.SetActive(false);
go3.SetActive(true);
}
if (stage == 3)
{
go3.SetActive(false);
go4.SetActive(true);
}
if (stage == 4)
{
go4.SetActive(false);
go5.SetActive(true);
}
}
void win()
{
GameControl.instance.FinishGame();
}
IEnumerator WaitToDIE()
{
yield return new WaitForSecondsRealtime(.5f);
go2.SetActive(false);go3.SetActive(false);go4.SetActive(false);go5.SetActive(false);
}
}