AllEnemiesDestroyed
How do I use All Enemies Destroyed
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
Line | Code | Ex.. |
---|---|---|
112 | if (AllEnemiesDestroyed ()) { | 1 |
182 | private bool AllEnemiesDestroyed(){ | 2 |
File name: GameplayController.cs
Copy
88 void GameIsOnPlay(){
89 /*if (PlayerBullet () == 0) {
90 timeAfterLastShot += Time.deltaTime;
91 camera.isFollowing = false;
92 if (timeAfterLastShot > 2f) {
93 if (AllStopMoving () && AllEnemiesDestroyed ()) {
94 if (!gameFinished) {
95 gameFinished = true;
96 Debug.Log ("Hello World");
97 }
98 } else if (AllStopMoving () && !AllEnemiesDestroyed ()) {
99 if (!gameFinished) {
100 gameFinished = true;
101 Debug.Log ("Hi World");
102 }
103 }
104 }
105
106 }*/
107
108 if(checkGameStatus){
109 timeAfterLastShot += Time.deltaTime;
110 if (timeAfterLastShot > 2f) {
111 if (AllStopMoving () || Time.time - timeSinceStartedShot > 8f) {
112 if (AllEnemiesDestroyed ()) {
113 if (!gameFinished) {
114 gameFinished = true;
115 GameWin ();
116 timeAfterLastShot = 0;
117 checkGameStatus = false;
118 }
119 } else {
120 if (PlayerBullet () == 0) {
121 if (!gameFinished) {
122 gameFinished = true;
123 timeAfterLastShot = 0;
124 checkGameStatus = false;
125 GameLost ();
126 }
127 } else {
128 checkGameStatus = false;
129 camera.isFollowing = false;
130 timeAfterLastShot = 0;
131 }
132 }
133 }
134 }
135
136 }
137
138 }
File name: GameplayController.cs
Copy
182 private bool AllEnemiesDestroyed(){
183 return enemies.All(x => x == null);
184 }
AllEnemiesDestroyed 100 lượt xem
Gõ tìm kiếm nhanh...