Lost
How do I use Lost
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
Line | Code | Ex.. |
---|---|---|
125 | GameLost (); | 1 |
165 | void GameLost(){ | 2 |
50 | case GameState.LostALife: | 3 |
91 | statusText.text = "Lost all lives. Tap to play again"; | 4 |
115 | LostALife, | 5 |
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
165 void GameLost(){
166 if(GameController.instance != null && MusicController.instance != null){
167 if(GameController.instance.isMusicOn){
168 AudioSource.PlayClipAtPoint (MusicController.instance.loseSound, Camera.main.transform.position);
169 }
170 }
171 gameOverPanel.SetActive (true);
172 }
File name: GameManager.cs
Copy
27 void Update()
28 {
29 switch (CurrentGameState)
30 {
31 case GameState.Start:
32 if (InputTaken())
33 {
34 statusText.text = string.Format("Lives: {0} Score: {1}", Lives, Score);
35 CurrentGameState = GameState.Playing;
36 Ball.StartBall();
37 }
38 break;
39 case GameState.Playing:
40 break;
41 case GameState.Won:
42 if (InputTaken())
43 {
44 Restart();
45 Ball.StartBall();
46 statusText.text = string.Format("Lives: {0} Score: {1}", Lives, Score);
47 CurrentGameState = GameState.Playing;
48 }
49 break;
50 case GameState.LostALife:
51 if (InputTaken())
52 {
53 Ball.StartBall();
54 statusText.text = string.Format("Lives: {0} Score: {1}", Lives, Score);
55 CurrentGameState = GameState.Playing;
56 }
57 break;
58 case GameState.LostAllLives:
59 if (InputTaken())
60 {
61 Restart();
62 Ball.StartBall();
63 statusText.text = string.Format("Lives: {0} Score: {1}", Lives, Score);
64 CurrentGameState = GameState.Playing;
65 }
66 break;
67 default:
68 break;
69 }
70 }
File name: GameManager.cs
Copy
84 public void DecreaseLives()
85 {
86 if (Lives > 0)
87 Lives--;
88
89 if(Lives == 0)
90 {
91 statusText.text = "Lost all lives. Tap to play again";
92 CurrentGameState = GameState.LostAllLives;
93 }
94 else
95 {
96 statusText.text = "Lost a life. Tap to continue";
97 CurrentGameState = GameState.LostALife;
98 }
99 Ball.StopBall();
100 }
File name: GameManager.cs
Copy
111 {
112 Start,
113 Playing,
114 Won,
115 LostALife,
116 LostAllLives
117 }
Lost 132 lượt xem
Gõ tìm kiếm nhanh...