void OnMouseOver() { lifeTime -= Time.deltaTime; if (lifeTime < 0) { shake.camshake(); spawner.CreateNew(gameObject); Destroy(gameObject); if (soundNum == 1) { death1.GetComponent <AudioSource>().PlayOneShot(death1.GetComponent <AudioSource>().clip, .5f); } else if (soundNum == 2) { death2.GetComponent <AudioSource>().PlayOneShot(death2.GetComponent <AudioSource>().clip, .5f); } else { death3.GetComponent <AudioSource>().PlayOneShot(death3.GetComponent <AudioSource>().clip, .5f); } } }
void Update() { Debug.Log(playerScore); playerScore = scoreKeeper.ScoreforPower; if (playerScore >= 150) { PowerBar.SetActive(true); } if (playerScore >= 150 && Input.GetKeyDown(KeyCode.Space)) { PowerBar.SetActive(false); flashOfLight.SetActive(true); runTimer = true; for (int i = 0; i < spawner.enemies.Count; i++) { Destroy(spawner.enemies[i]); spawner.CreateNew(spawner.enemies[i]); } playerScore = 0; scoreKeeper.ResetScore(); } if (runTimer) { if (timer >= 0) { timer -= Time.deltaTime; } else { runTimer = false; timer = timerConstant; flashOfLight.SetActive(false); } } }
public void OnTriggerEnter2D(Collider2D collision) { Debug.Log(health); spawner.CreateNew(collision.gameObject); Destroy(collision.gameObject); health--; if (health <= 0) { sceneManager.LoadNextLevel(SceneIndex); } }