You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PlumberUltimateAds/Assets/Scripts/GameManager.cs

166 lines
2.7 KiB
C#

2 months ago
using System;
using UnityEngine;
public class GameManager
{
public static LevelGroup currentLevelGroup;
public static Level currentLevel;
public static bool openLevelSelection;
public static int CurrentLevelNo
{
get
{
return PlayerPrefs.GetInt("currentLevelNo", 1);
}
set
{
PlayerPrefs.SetInt("currentLevelNo", value);
}
1 month ago
2 months ago
}
1 month ago
public static int CurrentLevelNo_Timer
{
get
{
return PlayerPrefs.GetInt("currentLevelNo_Timer", 1);
}
set
{
PlayerPrefs.SetInt("currentLevelNo_Timer", value);
}
}
2 months ago
1 month ago
public static int CurrentLevelGroupIndex
2 months ago
{
get
{
return PlayerPrefs.GetInt("CurrentLevelGroupIndex", 0);
}
set
{
PlayerPrefs.SetInt("CurrentLevelGroupIndex", value);
}
}
public static bool IsSound
{
get
{
return PlayerPrefs.GetInt("IsSound", 1) == 1;
}
set
{
PlayerPrefs.SetInt("IsSound", value ? 1 : 0);
}
}
public static bool IsMusic
{
get
{
return PlayerPrefs.GetInt("IsMusic", 1) == 1;
}
set
{
PlayerPrefs.SetInt("IsMusic", value ? 1 : 0);
}
}
public static int Coin
{
get
{
return PlayerPrefs.GetInt("Coin", 0);
2 months ago
}
set
{
PlayerPrefs.SetInt("Coin", value);
}
}
public static int PipeIndex
{
get
{
return PlayerPrefs.GetInt("PipeIndex", 0);
}
set
{
PlayerPrefs.SetInt("PipeIndex", value);
}
}
2 months ago
public static int StarLevel
2 months ago
{
get
{
return PlayerPrefs.GetInt("CurrentStarLevelget", 1);
}
set
{
PlayerPrefs.SetInt("CurrentStarLevelget", value);
}
}
public static float StarLevelProgress => (float)CurrentStar / (float)TotalStar;
private static int CurrentStar
{
get
{
return PlayerPrefs.GetInt("CurrentStar", 0);
}
set
{
PlayerPrefs.SetInt("CurrentStar", value);
}
}
private static int TotalStar
{
get
{
return PlayerPrefs.GetInt("TotalStar", 3);
}
set
{
PlayerPrefs.SetInt("TotalStar", value);
}
}
public static DateTime LastSpin
{
get
{
return DateTime.FromFileTime(long.Parse(PlayerPrefs.GetString("LastSpinDate", "0")));
}
set
{
PlayerPrefs.SetString("LastSpinDate", value.ToFileTime().ToString());
}
}
public static bool CanSpin => SpinAfter.TotalDays >= 1.0;
public static TimeSpan SpinAfter => DateTime.Now - LastSpin;
public static TimeSpan RemandingForSpin => LastSpin.AddDays(1.0) - DateTime.Now;
public static void AddStar(int s)
{
CurrentStar += s;
if (CurrentStar >= TotalStar)
{
CurrentStar %= TotalStar;
StarLevel++;
TotalStar = 0;
for (int i = 1; i <= StarLevel; i++)
{
TotalStar += i * 3;
}
}
}
}