/* * void Awake() * { * * } */ // Use this for initialization void Start() { // If the default is not valid, that means the blocks have reached the top // Which means game over if (!isValidGridPos()) { //Debug.Log("Game Over"); Data.cod = "OVERFLOW!"; if (Data.mode == 1) { SceneManager.LoadScene("Over"); } else { Game2P.winner = 2; SceneManager.LoadScene("Over2P"); } } foreach (Transform child in transform) { Vector2 pos = Game.RoundPosition(child.position); if (Data.mode == 1) { if (pos.y < 14) { Data.cod = "OVERFLOW!"; SceneManager.LoadScene("Over"); } } else { if (pos.y < 16) { Data.cod = "OVERFLOW!"; SceneManager.LoadScene("Over2P"); } } } if (Data.mode == 1) { spawner = GameObject.Find("Spawner").GetComponent <Spawner>(); } else { spawner2P = GameObject.Find("SpawnerP1").GetComponent <Spawner2P>(); } }
void Awake() { scoreObj1 = GameObject.FindGameObjectWithTag("ScoreP1"); scoreObj2 = GameObject.FindGameObjectWithTag("ScoreP2"); opObj1 = GameObject.FindGameObjectWithTag("OperationP1"); opObj2 = GameObject.FindGameObjectWithTag("OperationP2"); unlockedP1 = new List <GameObject>(); unlockedP2 = new List <GameObject>(); addSound = GameObject.FindGameObjectWithTag("AddSound"); subSound = GameObject.FindGameObjectWithTag("SubSound"); divSound = GameObject.FindGameObjectWithTag("DivSound"); mulSound = GameObject.FindGameObjectWithTag("MulSound"); subUpSound = GameObject.Find("SubUpSound"); subDownSound = GameObject.Find("SubDownSound"); replaySound = GameObject.Find("Replay Sound"); clickSound = GameObject.Find("Click Sound"); mainSound = GameObject.Find("Tetris"); /* * unlockedObj1 = GameObject.Find("UnlockedTextP1"); * unlockedText1 = unlockedObj1.GetComponent<Text>(); * unlockedObj1.SetActive(false); * * unlockedObj2 = GameObject.Find("UnlockedTextP2"); * unlockedText2 = unlockedObj2.GetComponent<Text>(); * unlockedObj2.SetActive(false); */ if (addSound) { addSoundClip = addSound.GetComponent <AudioSource>(); } if (subSound) { subSoundClip = subSound.GetComponent <AudioSource>(); } if (divSound) { divSoundClip = divSound.GetComponent <AudioSource>(); } if (mulSound) { mulSoundClip = mulSound.GetComponent <AudioSource>(); } if (replaySound) { replaySoundClip = replaySound.GetComponent <AudioSource>(); } if (clickSound) { clickSoundClip = clickSound.GetComponent <AudioSource>(); } if (subUpSound) { subUpSoundClip = subUpSound.GetComponent <AudioSource>(); } if (subDownSound) { subDownSoundClip = subDownSound.GetComponent <AudioSource>(); } if (mainSound) { mainSoundClip = mainSound.GetComponent <AudioSource>(); String scene = SceneManager.GetActiveScene().name; if (mainSoundClip) { if (!mainSoundClip.isPlaying && scene != "Over" && scene != "Over2P") { mainSoundClip.Play(); } } } if (scoreObj1 && scoreObj2) { Data.fallSpeed = 0.4f; scoreText1 = scoreObj1.GetComponent <Text>(); scoreText1.text = "SCORE:\n0.00"; scoreText2 = scoreObj2.GetComponent <Text>(); scoreText2.text = "SCORE:\n0.00"; opText1 = opObj1.GetComponent <Text>(); opText2 = opObj2.GetComponent <Text>(); } spawnerObj1 = GameObject.Find("SpawnerP1"); spawnerObj2 = GameObject.Find("SpawnerP2"); if (spawnerObj1) { spawner1 = spawnerObj1.GetComponent <Spawner2P>(); } if (spawnerObj2) { spawner2 = spawnerObj2.GetComponent <Spawner2P>(); } opDict = new Dictionary <string, GameObject>(); foreach (GameObject go in spawner1.operators) { opDict.Add(go.name, go); } unlockedP1.Add(opDict["add"]); unlockedP1.Add(opDict["subtract"]); unlockedP2.Add(opDict["add"]); unlockedP2.Add(opDict["subtract"]); mult1 = GameObject.Find("Mult"); if (mult1) { mult1.active = false; } div1 = GameObject.Find("Div"); if (div1) { div1.active = false; } mult2 = GameObject.Find("MultP2"); if (mult2) { mult2.active = false; } div2 = GameObject.Find("DivP2"); if (div2) { div2.active = false; } addCountObjP1 = GameObject.Find("AddCountP1"); mulCountObjP1 = GameObject.Find("MulCountP1"); subCountObjP1 = GameObject.Find("SubCountP1"); divCountObjP1 = GameObject.Find("DivCountP1"); if (mulCountObjP1) { mulCountObjP1.active = false; } if (divCountObjP1) { divCountObjP1.active = false; } addCountObjP1.GetComponent <Text>().text = "x0"; subCountObjP1.GetComponent <Text>().text = "x0"; addCountObjP2 = GameObject.Find("AddCountP2"); mulCountObjP2 = GameObject.Find("MulCountP2"); subCountObjP2 = GameObject.Find("SubCountP2"); divCountObjP2 = GameObject.Find("DivCountP2"); if (mulCountObjP2) { mulCountObjP2.active = false; } if (divCountObjP2) { divCountObjP2.active = false; } addCountObjP2.GetComponent <Text>().text = "x0"; subCountObjP2.GetComponent <Text>().text = "x0"; Reset(); }