// Update is called once per frame void Update() { if (fmb.intensity != 0) { fmb.intensity = Mathf.MoveTowards(fmb.intensity, 0, 0.1f); } ScoreTxt.text = score.ToString(); if (gameover) { GameOver(); BG.Stop(); SFX.PlayOneShot(SFXCLIPS[9]); } StartCoroutine(ClearCube()); //Controls if (Input.GetMouseButtonDown(0)) { //shoot sound SFX.PlayOneShot(SFXCLIPS[0]); //TAG_1 if (Input.mousePosition.x < Screen.width / 4) { GameObject block = Instantiate(shooter, new Vector3(-2f, -4.5f, 0), Quaternion.identity, ShooterParent.transform); block.tag = "TAG_1"; } //TAG_2 if (Input.mousePosition.x >= Screen.width / 4 && Input.mousePosition.x < Screen.width / 4 * 2) { GameObject block = Instantiate(shooter, new Vector3(-0.7f, -4.5f, 0), Quaternion.identity, ShooterParent.transform); block.tag = "TAG_1"; } //TAG_3 if (Input.mousePosition.x >= Screen.width / 4 * 2 && Input.mousePosition.x < Screen.width / 4 * 3) { GameObject block = Instantiate(shooter, new Vector3(0.7f, -4.5f, 0), Quaternion.identity, ShooterParent.transform); block.tag = "TAG_1"; } //TAG_4 if (Input.mousePosition.x >= Screen.width / 4 * 3) { GameObject block = Instantiate(shooter, new Vector3(2f, -4.5f, 0), Quaternion.identity, ShooterParent.transform); block.tag = "TAG_1"; } } shooter.transform.Translate(Vector2.up * CubeSpeed * Time.deltaTime); if (Time.time > SpaceTime) { SpaceTime = Time.time + Rate; CubeBarrier(); if (SpaceTime < 40) { AddedSpeed += 0.01f; } } }
void Update() { LevelText.text = Levels.ToString(); ScoreText.text = score.ToString(); for (int i = 0; i < int.Parse(KnifesToHit.ToString()); i++) { ToHit.transform.GetChild(i).gameObject.SetActive(true); } for (int j = int.Parse(KnifesToHit.ToString()); j < ToHit.transform.childCount - 1; j++) { ToHit.transform.GetChild(j).gameObject.SetActive(false); } if (Levels == 0) { if (int.Parse(lives.ToString()) < 4) { Lives.GetChild(int.Parse(lives.ToString())).GetComponent <Image>().color = Color.red; } if (int.Parse(lives.ToString()) == 4) { foreach (Transform t in Lives.transform) { t.GetComponent <Image>().color = Color.white; } } ; } else if (Levels > 0 && Levels < 4) { Lives.GetChild(Lives.childCount - 1).gameObject.SetActive(false); if (int.Parse(lives.ToString()) < 3) { Lives.GetChild(int.Parse(lives.ToString())).GetComponent <Image>().color = Color.red; } if (int.Parse(lives.ToString()) == 3) { foreach (Transform t in Lives.transform) { t.GetComponent <Image>().color = Color.white; } } } else if (Levels == 4) { Lives.GetChild(Lives.childCount - 1).gameObject.SetActive(false); Lives.GetChild(Lives.childCount - 2).gameObject.SetActive(false); if (int.Parse(lives.ToString()) < 2) { Lives.GetChild(int.Parse(lives.ToString())).GetComponent <Image>().color = Color.red; } if (int.Parse(lives.ToString()) == 2) { foreach (Transform t in Lives.transform) { t.GetComponent <Image>().color = Color.white; } } ; } if (int.Parse(lives.ToString()) == 0) { GAMEOVER(); } if (hit > 0) { timer -= Time.deltaTime; if (SpeedMeter.fillAmount == 1) { PowerMode = true; poweron = true; } else { if (!PowerMode) { SpeedMeter.fillAmount = hit * 0.2f; } } } else { timer = 1f; if (!PowerMode && !IsLevelChanging) { SpeedMeter.fillAmount -= Time.deltaTime * 0.7f; } } if (timer < 0) { hit = 0; timer = 1f; } if (PowerMode) { BonusText.gameObject.SetActive(true); BonusText.text = (power + 2).ToString() + "X"; StartCoroutine(PowerUp()); } else { BonusText.gameObject.SetActive(false); StopCoroutine(PowerUp()); } if (SpeedMeter.fillAmount == 0) { PowerMode = false; if (poweron) { power++; poweron = false; } } }
private void ShowScore() { ScoreText.text = score.ToString(); }