GameWin









How do I use Game Win
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets

Line Code Ex..
115 GameWin (); 1
140 void GameWin(){ 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
140  void GameWin(){
141   if(GameController.instance != null && MusicController.instance != null){
142    if(GameController.instance.isMusicOn){
143     AudioSource.PlayClipAtPoint (MusicController.instance.winSound, Camera.main.transform.position);
144    }
145
146    if(GameController.instance.score > GameController.instance.highscore[ GameController.instance.currentLevel - 1]){
147     GameController.instance.highscore [ GameController.instance.currentLevel - 1] = GameController.instance.score;
148    }
149
150    highscore.text = GameController.instance.highscore [GameController.instance.currentLevel].ToString ("N0");
151
152    int level = GameController.instance.currentLevel;
153    level++;
154    if(!(level-1 >= GameController.instance.levels.Length)){
155     GameController.instance.levels [level - 1] = true;
156    }
157
158    GameController.instance.Save ();
159    GameController.instance.currentLevel = level;
160   }
161   gameWinPanel.SetActive (true);
162
163  }

Download file with original file name:GameWin

GameWin 114 lượt xem

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