Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

using System.

Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

public class Core : MonoBehaviour


{
public GameObject[] labs;

public GameObject[] objOff;


public GameObject[] objOn;

public Text variantText;


public Text waitText;

public CircleDrop[] allCircle;


private StopWatch[] stopWatches;
private string var;

public UnityEvent resetLab_2;

private void Awake()


{
singleton = this;
curLab = 0;
var = null;
}

void Start()
{
stopWatches = FindObjectsOfType<StopWatch>();
}

public static Core singleton;

public void ResetLab()


{
foreach (StopWatch s in stopWatches)
{
s.StopTimer();
s.ResetTimer();
}

foreach (GameObject o in objOff)


o.SetActive(false);

foreach (GameObject o in objOn)


o.SetActive(true);

switch(curLab)
{
case 0:
foreach (CircleDrop c in allCircle)
c.ResetLab();
break;
case 1:
ResetLab2();
break;
}
}

public void ResetLab2()


{
resetLab_2.Invoke();
}

public void AddVariant(string s)


{
if (!string.IsNullOrEmpty(var))
s = "." + s;
var += s;
variantText.text = var;
}

private int curLab;

public void SwitchLab(int i)


{
curLab = i;
}

public void StartLab()


{
StartCoroutine(WaitLab());
}

public GameObject waitImg;

IEnumerator Dots()
{
int i = 0;
while (i != 24)
{
yield return new WaitForSeconds(0.25f);
waitText.text = " " + waitText.text;

if (waitText.text == " .")


waitText.text = ".";

i++;
}

waitImg.SetActive(false);
}

IEnumerator WaitLab()
{
waitImg.SetActive(true);
StartCoroutine(Dots());

yield return new WaitForSeconds(6);

labs[curLab].SetActive(true);

switch (curLab)
{
case 0:
List<int> vars = new List<int>();

foreach (CircleDrop c in allCircle)


{
int v = Random.Range(0, allCircle[0].variant.Length);

if (vars.Count == 0)
{
vars.Add(v);
}
else
{
for (int i = 0; i < vars.Count; i++)
{
if (v == vars[i])
{
i = 0;
v = Random.Range(0, allCircle[0].variant.Length);
}
}
}

c.SetVariant(v);
AddVariant((v+1).ToString());
vars.Add(v);
}
break;
case 1:
break;
}
}

public void StopLab()


{
var = null;
variantText.text = "00.00.00";
ResetLab();
labs[curLab].SetActive(false);
}

public void StopTime()


{
Time.timeScale = 0;
}

public void StartTime()


{
Time.timeScale = 1;
}
}

You might also like