Files
plugin-library/Assets/00.StaryEvo/~Samples/Runtime/CounterApp/Script/AchievementSystem.cs

41 lines
955 B
C#
Raw Normal View History

2025-03-31 11:16:52 +08:00
using UnityEngine;
namespace Stary.Evo.Example.Counter
{
public interface IAchievementSystem : ISystem
{
}
public class AchievementSystem : AbstractSystem, IAchievementSystem
{
public IArchitecture Architecture { get; set; }
public override void Dispose()
{
}
protected override void OnInit()
{
var counterData = this.GetData<ICounterData>();
var previousCount = counterData.Count.Value;
counterData.Count.Register(newCount =>
{
if (newCount >= 10 && previousCount < 10)
{
Debug.Log("解锁 10 次点击成就");
}
else if (newCount >= 20 && previousCount < 20)
{
Debug.Log("解锁 20 次点击成就");
}
previousCount = newCount;
});
}
}
}