AllStopMoving









How do I use All Stop Moving
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


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
187  private bool AllStopMoving(){
188   foreach (var item in objects.Union(enemies)) {
189    if(item != null && item.GetComponent().velocity.sqrMagnitude > 0){
190     return false;
191    }
192
193   }
194
195   return true;
196  }

AllStopMoving 104 lượt xem

Gõ tìm kiếm nhanh...