GameplayController
How do I use Gameplay Controller
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: Background.cs
Copy
22 void Update () {
23 if (GameplayController.instance.startMoving) {
24 ScrollMovement ();
25 }
26 }
File name: Cloud.cs
Copy
22 void Update () {
23 if (transform.position != target) {
24 transform.position = Vector3.MoveTowards (transform.position, target, speed * Time.deltaTime);
25 } else {
26 Destroy (gameObject);
27 GameplayController.instance.InitializeSpawners ();
28 }
29 }
File name: EnemySpawner.cs
Copy
28 void Update () {
29 if(GameplayController.instance.gameInProgress){
30 LimitBounds ();
31 SpawnEnemies ();
32 CheckedEnemies ();
33 }
34 }
File name: EnemySpawner.cs
Copy
82 void CheckedEnemies(){
83 if(!active){
84 if (GameObject.FindGameObjectWithTag("Enemy") == null) {
85 if(!isBossReady){
86 isBossReady = true;
87 GameplayController.instance.ShowWarning();
88 }
89 }
90 }
91 }
File name: CoinMotion.cs
Copy
17 void OnTriggerEnter2D(Collider2D collider){
18 if(collider.CompareTag("Player")){
19 Destroy (gameObject);
20 if(GameController.instance != null && MusicController.instance != null){
21 if(GameController.instance.isMusicOn){
22 MusicController.instance.audioSource.PlayOneShot (MusicController.instance.coin);
23 }
24 }
25
26 GameplayController.instance.UpdateCoins ();
27 }
28 }
File name: PlayerController.cs
Copy
31 void Update () {
32 if (GameplayController.instance.gameInProgress) {
33 LimitPosition ();
34 if (Application.platform == RuntimePlatform.WindowsEditor) {
35 PlayerMovement ();
36 }else if(Application.platform == RuntimePlatform.Android){
37 TouchMovement ();
38 }
39
40 }
41 }
File name: PlayerController.cs
Copy
91 public void PlayerDied(){
92 if(GameController.instance != null && MusicController.instance != null){
93 if(GameController.instance.isMusicOn){
94 MusicController.instance.PlayerDeath ();
95 }
96 }
97 Instantiate (explosion, transform.position, Quaternion.identity);
98 Destroy (gameObject);
99 GameplayController.instance.GameOver ();
100 }
File name: PlayerShoot.cs
Copy
24 void Update () {
25 if (GameplayController.instance.gameInProgress) {
26 ShootBullet ();
27 }
28 }
File name: CameraFollow.cs
Copy
30 void Update () {
31 if (GameplayController.instance.gameInProgress) {
32 if (isFollowing) {
33 if (GameObject.FindGameObjectWithTag ("Player Bullet") != null) {
34 MoveCameraFollow ();
35 }
36 } else {
37 if (!GameplayController.instance.player.GetChild (0).transform.GetComponent
38 MoveCameraBackToStart ();
39 AfterShotMoveAgain ();
40 allowToMove = false;
41 } else {
42 timeSinceShot = 0;
43 allowToMove = true;
44 }
45
46 }
47
48 if (Application.platform == RuntimePlatform.Android) {
49 TouchMoveCamera ();
50 } else if (Application.platform == RuntimePlatform.WindowsEditor) {
51 MoveCamera ();
52 }
53 }
54
55 }
File name: CameraFollow.cs
Copy
67 void AfterShotMoveAgain(){
68 timeSinceShot += Time.deltaTime;
69 if (timeSinceShot > 2f) {
70 if(startPosition == transform.position){
71 GameplayController.instance.player.GetChild (0).transform.GetComponent
72 }
73 }
74 }
Download file with original file name:GameplayController
GameplayController 110 lượt xem
Gõ tìm kiếm nhanh...