Initial commit
This commit is contained in:
23
Assets/Scripts/ScoreService/ScoreService.cs
Normal file
23
Assets/Scripts/ScoreService/ScoreService.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class ScoreService
|
||||
{
|
||||
public int score=0;
|
||||
public int highScore=0;
|
||||
|
||||
public void AddScore()
|
||||
{
|
||||
score += 5;
|
||||
if (score>highScore)
|
||||
{
|
||||
SetNewHighScore();
|
||||
}
|
||||
}
|
||||
|
||||
private void SetNewHighScore()
|
||||
{
|
||||
highScore = score;
|
||||
PlayerPrefs.SetInt("HighScore", highScore);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user