// Update is called once per frame void Update() { if (Input.GetButtonDown("Fire1") && ms.gameTime > 0) { Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); Vector2 mousePos2D = new Vector2(mousePos.x, mousePos.y); RaycastHit2D hit = Physics2D.Raycast(mousePos2D, Vector2.zero); if (hit.collider != null) { // Score change if bonus, malus or basic mole if (hit.transform.gameObject.name.Equals("bonusMole(Clone)")) { score += 3; } else if (hit.transform.gameObject.name.Equals("malusMole(Clone)")) { score -= 2; } else { score += 1; } scoreText.text = score.ToString(); Destroy(hit.transform.gameObject); ms.Spawn(); } } }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0) && ms.gameTime > 0) { Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); Vector2 mousePos2D = new Vector2(mousePos.x, mousePos.y); RaycastHit2D hit = Physics2D.Raycast(mousePos2D, Vector2.zero); if (hit.collider != null) { Destroy(hit.transform.gameObject); score++; scoreText.text = score.ToString(); if (ms.gameTime >= 10) { ms.moleTime = 2; } else if (ms.gameTime < 10) { ms.moleTime = 1; } ms.Spawn(); } } if (ms.gameTime < 1) { finalScore.text = score.ToString(); finalScore.enabled = true; finalBackground.enabled = true; finalText1.enabled = true; finalText2.enabled = true; } }
// Update is called once per frame void Update() { if (Input.GetButtonDown("Fire1") && ms.gameTime > 0) { Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); Vector2 mousePos2D = new Vector2(mousePos.x, mousePos.y); RaycastHit2D hit = Physics2D.Raycast(mousePos2D, Vector2.zero); if (hit.collider != null) { Destroy(hit.transform.gameObject); score += 1; scoreText.text = score.ToString(); ms.Spawn(); } } }