GameScreen
How do I use Game Screen
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: UIgame.cs
Copy
100 public void Pause_btn()
101 {
102 if (SystemScr.paused)
103 {
104 Resume_btn();
105 }
106 else
107 {
108 sounds.PlaySoundsUI(false);
109
110 SystemScr.Pause(true);
111 GameScreen.SetActive(false);
112 PauseScreen.SetActive(true);
113 }
114 }
File name: UIgame.cs
Copy
116 public void Resume_btn()
117 {
118 sounds.PlaySoundsUI(false);
119
120 SystemScr.Pause(false);
121 GameScreen.SetActive(true);
122 PauseScreen.SetActive(false);
123 OptionsScreen.SetActive(false);
124 }
File name: GuideLayer.cs
Copy
11 public void hideGuide()
12 {
13 gameScreen.showCounter();
14 Data.saveData(Data.KEY_GUIDE, 1);
15 Destroy(gameObject);
16 }
File name: PauseLayerClickListener.cs
Copy
29 public override void OnTouchUp()
30 {
31 if (InputController.Name != InputNames.DIALOG) return;
32 base.OnTouchUp();
33 switch (buttonIndex)
34 {
35 case 0://music
36 SoundManager.isMusic = !SoundManager.isMusic;
37 pauseLayer.changeSprite(0, SoundManager.isMusic);
38 break;
39 case 1://sound
40 SoundManager.isSound = !SoundManager.isSound;
41 pauseLayer.changeSprite(1, SoundManager.isSound);
42 break;
43 case 2://help
44
45 pauseLayer.gameObject.SetActive(false);
46 gameScreen.guideGame();
47
48 break;
49 case 3://resume
50 gameScreen.resumeGame();
51 break;
52 case 4://restart
53 Application.LoadLevel("GameScreen");
54 break;
55 case 5://menu
56 Application.LoadLevel("MapScreen");
57 SoundManager.LoadBgMusic("Sounds/menu", true);
58 break;
59 }
60 }
File name: ButtonStartClickListener.cs
Copy
31 public override void OnTouchUp()
32 {
33 if (InputController.Name != InputNames.DIALOG) return;
34 base.OnTouchUp();
35 if (Data.getData(Data.KEY_GUIDE) == 0)
36 {
37 gameScreen.guideGame();
38 Destroy(transform.parent.gameObject);
39 }
40 else
41 {
42 InputController.Name = "";
43 //InputController.Name = InputNames.GAMESCREEN;
44 //gameScreen.resumeGame();
45 gameScreen.showCounter();
46 Destroy(transform.parent.gameObject);
47 }
48 }
File name: CounterLayer.cs
Copy
22 public void Update()
23 {
24 stateTime += Time.deltaTime;
25 if (isFinish)
26 {
27 if (stateTime >= 0.1f)
28 {
29 //play game
30 gameScreen.resumeGame();
31 InputController.Name = InputNames.GAMESCREEN;
32 Destroy(gameObject);
33 SoundManager.LoadBgMusic("Sounds/bg1", true);
34 }
35 }else if (stateTime >= 1)
36 {
37 stateTime = 0;
38 numberObject.GetComponent
39 number++;
40 if (number >= 3)
41 isFinish = true;
42 }
43 }
File name: ResultClickListener.cs
Copy
21 public override void OnTouchUp()
22 {
23 if (InputController.Name != InputNames.DIALOG) return;
24 base.OnTouchUp();
25 switch(gameObject.name)
26 {
27 case "Bt_Menu":
28 Application.LoadLevel("MapScreen");
29 SoundManager.LoadBgMusic("Sounds/menu", true);
30 break;
31 case "Bt_Replay":
32 Application.LoadLevel("GameScreen");
33 break;
34 case "Bt_Next":
35 if (Attr.currentLevel == 14)
36 {
37 Application.LoadLevel("MapScreen");
38 }
39 else
40 {
41 Attr.currentLevel++;
42 Application.LoadLevel("ShopScreen");
43 SoundManager.LoadBgMusic("Sounds/menu", true);
44 }
45 break;
46 }
47 }
File name: Animal.cs
Copy
82 private void createShadow()
83 {
84 if (animalIndex != 0) return;
85 shadowCreateTime += Time.deltaTime;
86 if (shadowCreateTime >= 0.05f)
87 {
88 shadowCreateTime = 0;
89 GameObject shadowObject = new GameObject("Shadow");
90 shadowObject.transform.parent = gameScreen.shadowLayer.transform;
91 shadowObject.layer = LayerMask.NameToLayer("AnimalStand");
92 shadowObject.transform.localPosition = transform.localPosition + new Vector3(0, 0.3f, 0);
93 shadowObject.AddComponent
94 shadowObject.GetComponent
95 shadowObject.GetComponent
96 shadowObject.AddComponent
97 new ActionColorTo(0, 0, 0, 0, 0.5f),
98 new ActionRunnable(delegate ()
99 {
100 Destroy(shadowObject);
101 })
102 ));
103 }
104 }
File name: Animal.cs
Copy
300 public void OnCollisionEnter2D(Collision2D otherCollision)
301 {
302 if (otherCollision.gameObject.name == MapObjectNames.GroundObject)
303 {
304 state = RUN;
305 stepJump = 2;
306 isSprings = false;
307 }
308 else if (otherCollision.gameObject.name == "Bullet")
309 {
310 if (gameObject.GetComponent
311 if (animalIndex != otherCollision.gameObject.GetComponent
312 {
313 if (otherCollision.gameObject.GetComponent
314 {
315 if (otherCollision.gameObject.GetComponent
316 {
317 gameScreen.addScore(10, gameObject.transform.localPosition);
318 gameScreen.setCombo(1, otherCollision.gameObject.GetComponent
319 }
320 gameScreen.AnimalcollisionWithBullet(gameObject, otherCollision.gameObject);
321 }
322 }
323 }
324 }
Download file with original file name:GameScreen
GameScreen 103 lượt xem
Gõ tìm kiếm nhanh...