ZoeAppClass/Assets/Scripts/Class/Game/GameAppearDisappear/GamePage.cs

99 lines
2.9 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GamePage : MonoBehaviour
{
Animator thisAnime;
GeneralScript.GroupColors groupthis;
public Image circle;
public ParticleSystem particles;
public string tagGame;
public string gameName;
private void Start()
{
thisAnime = GetComponent<Animator>();
}
public void generateRandomNumber() {
int rand = Random.Range(0, 10);
thisAnime.SetInteger("SortNbr", rand);
}
public void especialAnime() {
thisAnime.SetBool("DoneEspecial", true);
}
// Start is called before the first frame update
public void fakeStart(GeneralScript.GroupColors colors)
{
Text[] txts = GetComponentsInChildren<Text>(); Debug.Log(tagGame);
GameInfo joojInfo = Resources.Load<GameObject>("Games/" + tagGame + "/Info").GetComponent<GameInfo>();
txts[0].text = joojInfo.gameName;
txts[1].text = joojInfo.gameDesc;
circle.color = colors.clara;
var main = particles.main;
main.startColor = new Color(colors.clara.r, colors.clara.g, colors.clara.b, .15f);
groupthis = colors;
}
public void StartGame() {
GameControl gameControl = GameObject.Find("GameControl").GetComponent<GameControl>();
gameControl.StartGame(tagGame);
}
public void EndGame(bool won)
{
Text[] txts = GetComponentsInChildren<Text>();
GameInfo joojInfo = Resources.Load<GameObject>("Games/" + tagGame + "/Info").GetComponent<GameInfo>();
if (won)
{
int indexStart = gameName.IndexOf("<<");
if (indexStart >= 0)
{
gameName = gameName.Remove(indexStart, (gameName.IndexOf(">>") + 2) - indexStart);
}
txts[0].text = "Congratulations!";
txts[1].text = "You completed the game " + gameName;
ParticleSystem ps_01 = transform.Find("WinParticles").GetComponent<ParticleSystem>();
ParticleSystem ps_02 = transform.Find("WinParticlesLoop").GetComponent<ParticleSystem>();
ps_01.Play();
ps_02.Play();
Text txt_01 = transform.Find("Nome").GetComponent<Text>();
Text txt_02 = transform.Find("Desc").GetComponent<Text>();
Image imgPlay = transform.Find("StartGame").GetComponent<Image>();
txt_01.color = Color.white;
txt_02.color = new Color(.87f, .87f, .87f, 1);
imgPlay.color = Color.white;
imgPlay.transform.localScale = new Vector3(.5f, .5f, .5f);
Image imgFundo = transform.Find("Fundo").GetComponent<Image>();
Color alreadyColor = imgFundo.color;
alreadyColor.a = 1;
imgFundo.color = alreadyColor;
}
else
{
txts[0].text = "Too bad";
txts[1].text = "Better luck next time";
}
}
}