Files
HelixJump/Assets/Scripts/ScoreService/ScoreService.cs
2025-12-14 22:51:43 +05:45

26 lines
444 B
C#

using System;
using UnityEngine;
public class ScoreService
{
public int score=0;
public int highScore=PlayerPrefs.GetInt("HighScore",0);
public void AddScore()
{
score += 5;
if (score>highScore)
{
SetNewHighScore();
}
}
private void SetNewHighScore()
{
highScore = score;
PlayerPrefs.SetInt("HighScore", highScore);
PlayerPrefs.Save();
}
}