BossDestroyed
How do I use Boss Destroyed
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
Line | Code | Ex.. |
---|---|---|
39 | BossDestroyed (); | 1 |
44 | void BossDestroyed(){ | 2 |
File name: BossHealth.cs
Copy
28 public void Health(int damage){
29 if (!invulnerable) {
30 if (!health.gameObject.activeInHierarchy) {
31 health.gameObject.SetActive (true);
32 }
33
34 if (health.value > 0) {
35 health.value -= damage;
36 }
37
38 if (health.value == 0) {
39 BossDestroyed ();
40 }
41 }
42 }
File name: BossHealth.cs
Copy
44 void BossDestroyed(){
45 Destroy (gameObject);
46 GameObject.FindGameObjectWithTag ("Spawner").transform.GetComponent
47 GameObject.FindGameObjectWithTag ("Spawner").transform.GetComponent
48 if(GameController.instance != null && MusicController.instance != null){
49 if(GameController.instance.isMusicOn){
50 MusicController.instance.audioSource.PlayOneShot (MusicController.instance.bossExplode);
51 }
52 }
53 Instantiate (explode, transform.position, Quaternion.identity);
54 for (int i = 0; i < 5; i++) {
55 Instantiate (coin, transform.position, Quaternion.identity);
56 }
57 }
BossDestroyed 100 lượt xem
Gõ tìm kiếm nhanh...