-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from DKU-STUDY/main
Change the score outside the class using static.
- Loading branch information
Showing
7 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
|
||
public class BestScore : MonoBehaviour | ||
{ | ||
// Start is called before the first frame update | ||
void Start() | ||
{ | ||
GetComponent<Text>().text = "Best Score: " + Score.bestScore; | ||
} | ||
|
||
// Update is called once per frame | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
|
||
public class CurrentScore : MonoBehaviour | ||
{ | ||
// Start is called before the first frame update | ||
void Start() | ||
{ | ||
GetComponent<Text>().text = "Score: " + Score.score.ToString(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEngine.SceneManagement; | ||
|
||
public class Replay : MonoBehaviour | ||
{ | ||
|
||
public void ReplayGame() | ||
{ | ||
SceneManager.LoadScene("PlayScene"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
|
||
public class Score : MonoBehaviour | ||
{ | ||
public static int score = 0; //static을 붙이면 class 밖에서도 score를 관리할 수 있다! | ||
|
||
public static int bestScore = 0; | ||
|
||
// Start is called before the first frame update | ||
void Start() | ||
{ | ||
score = 0; | ||
} | ||
|
||
// Update is called once per frame | ||
void Update() | ||
{ | ||
GetComponent<Text>().text = score.ToString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
public class ScoreUp : MonoBehaviour | ||
{ | ||
private void OnTriggerEnter2D(Collider2D other) { | ||
Score.score++; | ||
} | ||
} |
Binary file not shown.