public void DestroyObject(GameObject obj) { Destroy(obj, 0.01f); opencombo = true; combo++; if (opencombo) { combotimer += combotimervalue; } if (obj.GetComponent <Person>().powernumber == 1 || obj.GetComponent <Person>().powernumber == 13) { Timer.timeleft += 20f; powerupone.Play(); timeparticles.Play(); } if (obj.GetComponent <Person>().powernumber == 2 || obj.GetComponent <Person>().powernumber == 24) { ExpManager.exp += 1; PlayerPrefs.SetFloat("Exp", ExpManager.exp); poweruptwo.Play(); expparticles.Play(); } if (obj.GetComponent <Person>().powernumber == 19) { wavedoneparticles.Play(); StartCoroutine(GenerateWave()); ExpManager.exp += 0.5f; PlayerPrefs.SetFloat("Exp", ExpManager.exp); ExpMeter.StartLerping(); anim.Play("wave4"); } }
public void ABbutton() { if (donorhandler.childCount > 0) { if (donorhandler.GetChild(0).gameObject.CompareTag("A")) { Instantiate(A_Donor, donorhandler); for (int i = 0; i <= donorhandler.childCount - 1; i++) { donorhandler.GetChild(i).SetSiblingIndex(Random.Range(0, donorhandler.childCount)); } } if (donorhandler.GetChild(0).gameObject.CompareTag("B")) { Instantiate(B_Donor, donorhandler); for (int i = 0; i <= donorhandler.childCount - 1; i++) { donorhandler.GetChild(i).SetSiblingIndex(Random.Range(0, donorhandler.childCount)); } } if (donorhandler.GetChild(0).gameObject.CompareTag("O")) { Instantiate(O_Donor, donorhandler); for (int i = 0; i <= donorhandler.childCount - 1; i++) { donorhandler.GetChild(i).SetSiblingIndex(Random.Range(0, donorhandler.childCount)); } } //Destroy(donorhandler.GetChild(0).gameObject); DestroyObject(donorhandler.GetChild(0).gameObject); AB_Supplied++; foreach (Transform child in donorhandler) { child.gameObject.SetActive(false); } if (donorhandler.childCount > 0) { donorhandler.GetChild(0).gameObject.SetActive(true); } if (donorhandler.GetChild(0).CompareTag("AB")) { if (donorhandler.GetChild(0).gameObject.GetComponent <Person>().powernumber == 1 || donorhandler.GetChild(0).gameObject.GetComponent <Person>().powernumber == 13) { Timer.timeleft += 20f; powerupone.Play(); timeparticles.Play(); } if (donorhandler.GetChild(0).gameObject.GetComponent <Person>().powernumber == 2 || donorhandler.GetChild(0).gameObject.GetComponent <Person>().powernumber == 24) { ExpManager.exp += 1; PlayerPrefs.SetFloat("Exp", ExpManager.exp); poweruptwo.Play(); expparticles.Play(); } if (donorhandler.GetChild(0).gameObject.GetComponent <Person>().powernumber == 19) { wavedoneparticles.Play(); StartCoroutine(GenerateWave()); ExpManager.exp += 0.5f; PlayerPrefs.SetFloat("Exp", ExpManager.exp); ExpMeter.StartLerping(); anim.Play("wave4"); } } } }
void Update() { Debug.Log(Time.timeScale); WaveCounter.text = "Wave: " + wave.ToString(); comboTxt.text = "ComboX" + combo.ToString(); ScoreText.text = "Score: " + score.ToString(); if (BigWaveText != null) { BigWaveText.text = "Wave: " + wave.ToString(); } A_Remain = (AGenerate + 1) - A_Supplied; B_Remain = (BGenerate + 1) - B_Supplied; AB_Remain = (ABGenerate + 1) - AB_Supplied; O_Remain = (OGenerate + 1) - O_Supplied; //A_Statstxt.text = A_Remain.ToString(); //B_Statstxt.text = (B_Remain).ToString(); //AB_Statstxt.text = AB_Remain.ToString(); //O_Statstxt.text = O_Remain.ToString(); DisableButton(AButton, A_Remain); DisableButton(BButton, B_Remain); DisableButton(ABButton, AB_Remain); DisableButton(OButton, O_Remain); if (A_Remain == 0 && B_Remain == 0 && AB_Remain == 0 && O_Remain == 0) { StartCoroutine(GenerateWave()); ExpManager.exp += 0.5f; PlayerPrefs.SetFloat("Exp", ExpManager.exp); ExpMeter.StartLerping(); anim.Play("wave4"); } if (donorhandler.childCount > 0) { donorhandler.GetChild(0).gameObject.SetActive(true); } if (AB_Remain == 0) { foreach (Transform child in donorhandler) { if (child.CompareTag("AB")) { Destroy(child.gameObject); } } } if (O_Remain == 0) { foreach (Transform child in donorhandler) { if (child.CompareTag("O")) { Destroy(child.gameObject); } } } if (B_Remain == 0) { foreach (Transform child in donorhandler) { if (child.CompareTag("B")) { Destroy(child.gameObject); } } } if (A_Remain == 0) { foreach (Transform child in donorhandler) { if (child.CompareTag("A")) { Destroy(child.gameObject); } } } if (opencombo) { combotimer -= Time.deltaTime; } if (combotimer <= 0) { opencombo = false; combotimer = combotimervalue; combo = 0; } if (combotimer >= combotimervalue) { combotimer = combotimervalue; } if (combotimer < 0) { combotimer = 0; } if (combo >= 3) { LeanTween.moveX(comboTxtRec, -51, 0.2f); //comboTxtRec.position = new Vector2(0, 0); } else { LeanTween.moveX(comboTxtRec, 437, 0.2f); } if (score > PlayerPrefs.GetInt("HighScore", 0)) { newhighscore.SetActive(true); PlayerPrefs.SetInt("HighScore", score); HighScore.text = "H.S: " + score.ToString(); } if (Input.GetKeyDown(KeyCode.Escape)) { if (!puasemenu.activeSelf) { puasemenu.SetActive(true); Time.timeScale = 0f; } else if (puasemenu.activeSelf) { puasemenu.SetActive(false); Time.timeScale = 1f; } } }