ZoeRobotIngles/Assets/Scripts/ControllerMenu/ZoeSleep.cs

109 lines
2.7 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ZoeSleep : MonoBehaviour
{
Image thisImg; public bool clickAwake = false;
// Start is called before the first frame update
void Start()
{
thisImg = GetComponent<Image>();
StartCoroutine(RollImage());
}
public void StopNAwake() {
StopAllCoroutines();
Animator childAnime = GetComponentInChildren<Animator>();
childAnime.SetBool("wakeup", true);
StartCoroutine(RollAwake());
}
IEnumerator RollAwake() {
yield return runAnimeGlassNegative("Zoe Sleeping - _00", "Sleeping", 0, 108);
GameObject obj = GameObject.Find("EffectSleep");
Destroy(obj);
OpenAp ap = GameObject.Find("Controller").GetComponent<OpenAp>();
ap.WakeUpZoe();
yield break;
}
IEnumerator RollImage() {
while (!clickAwake)
{
yield return runAnimeGlass("Zoe Sleeping - _00", "Sleeping", 174, 116);
yield return new WaitForEndOfFrame();
}
yield break;
}
IEnumerator runAnimeGlass(string nameBase, string pasteName, int nbrframes, int startframe)
{
int index = startframe;
//audio.Play();
//Mitsuko Glass _ 293
while (index <= nbrframes)
{
string url;
if (index < 10)
{
url = nameBase + "00" + index.ToString();
}
else if (index < 100)
{
url = nameBase + "0" + index.ToString();
}
else
{
url = nameBase + index.ToString();
}
thisImg.sprite = Resources.Load<Sprite>("Mitsuku/" + pasteName + "/" + url);
index += 1;
yield return new WaitForSecondsRealtime(0.04f);
}
yield break;
}
IEnumerator runAnimeGlassNegative(string nameBase, string pasteName, int nbrframes, int startframe)
{
int index = startframe;
//audio.Play();
//Mitsuko Glass _ 293
while (index >= nbrframes)
{
string url;
if (index < 10)
{
url = nameBase + "00" + index.ToString();
}
else if (index < 100)
{
url = nameBase + "0" + index.ToString();
}
else
{
url = nameBase + index.ToString();
}
thisImg.sprite = Resources.Load<Sprite>("Mitsuku/" + pasteName + "/" + url);
index -= 1;
yield return new WaitForSecondsRealtime(0.04f);
}
yield break;
}
}