
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;
            });
        }
    }
}