72 lines
1.7 KiB
C#
72 lines
1.7 KiB
C#
using UnityEngine;
|
|
|
|
public enum GlobalAchievementMetricType
|
|
{
|
|
TotalCoinsEarned = 0,
|
|
OwnedHeroCount = 1,
|
|
OwnedSongCount = 2,
|
|
BestSingleSongTotalScore = 3,
|
|
TotalSongBestScoreSum = 4,
|
|
LoginDays = 5,
|
|
}
|
|
|
|
[CreateAssetMenu(fileName = "GA_", menuName = "SO_Data/GlobalAchievement")]
|
|
public class GlobalAchievementSO : ScriptableObject
|
|
{
|
|
[Header("identity")]
|
|
public int achievementId;
|
|
public string displayName;
|
|
public string achievementSeriesKey;
|
|
[Range(0, 6)] public int achievementLevel;
|
|
|
|
[TextArea(2, 5)]
|
|
public string description;
|
|
|
|
[Header("display")]
|
|
public Sprite icon;
|
|
public int sortOrder;
|
|
public bool hiddenUntilUnlocked;
|
|
|
|
[Header("runtime mirror")]
|
|
[SerializeField] private bool isUnlocked;
|
|
[SerializeField] private string unlockedDateTime;
|
|
|
|
[Header("trigger")]
|
|
public GlobalAchievementMetricType metricType = GlobalAchievementMetricType.LoginDays;
|
|
public float targetValue = 1f;
|
|
|
|
[Header("steam")]
|
|
public bool syncWithSteam;
|
|
public string steamAchievementApiName;
|
|
|
|
public bool IsUnlocked
|
|
{
|
|
get { return isUnlocked; }
|
|
}
|
|
|
|
public string UnlockedDateTime
|
|
{
|
|
get { return unlockedDateTime; }
|
|
}
|
|
|
|
public void SetUnlockedState(bool value, long unlockedUtcTicks = 0L)
|
|
{
|
|
isUnlocked = value;
|
|
if (value && unlockedUtcTicks > 0L)
|
|
{
|
|
unlockedDateTime = new System.DateTime(unlockedUtcTicks, System.DateTimeKind.Utc).ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss");
|
|
}
|
|
else if (!value)
|
|
{
|
|
unlockedDateTime = string.Empty;
|
|
}
|
|
|
|
#if UNITY_EDITOR
|
|
if (!Application.isPlaying)
|
|
{
|
|
UnityEditor.EditorUtility.SetDirty(this);
|
|
}
|
|
#endif
|
|
}
|
|
}
|