Game UI ready
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class ScoreService
|
||||
public class ScoreService : IScoreService
|
||||
{
|
||||
public int score=0;
|
||||
public int highScore=PlayerPrefs.GetInt("HighScore",0);
|
||||
public event Action<int> OnScoreChange;
|
||||
public int score { get; private set; }
|
||||
|
||||
public int highScore { get; private set; } = PlayerPrefs.GetInt("HighScore");
|
||||
|
||||
public void AddScore()
|
||||
{
|
||||
@@ -13,6 +15,7 @@ public class ScoreService
|
||||
{
|
||||
SetNewHighScore();
|
||||
}
|
||||
OnScoreChange?.Invoke(score);
|
||||
}
|
||||
|
||||
private void SetNewHighScore()
|
||||
@@ -23,3 +26,11 @@ public class ScoreService
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public interface IScoreService
|
||||
{
|
||||
int score { get; }
|
||||
int highScore { get; }
|
||||
event Action<int> OnScoreChange;
|
||||
void AddScore();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user