using System;
using UnityEngine;
using XGame.Framework.Map;
using XGame.Framework.ObjectCollection;

namespace FL.Map.UI
{
    public class HpAddEntityView : EntityView<HpAddEntityVM>
    {
        protected override void OnEnable(object intent)
        {
        }
        protected override void OnDisable()
        {
        }
        protected override void OnDispose()
        {
        }

        public void ShowValue(int value, Vector3 position, Action callback)
        {
            VM.HpText.text = value.ToString();
            VM.Tr.localPosition = position;
            var animation = VM.AniRoot;
            var timer = Context.Time.AddDelayTimer(500, callback);
        }
    }
    public class HpAddEntityVM : EntityViewModel
    {
        public UnityEngine.UI.Text HpText { get; private set; }
        public Transform Root { get; private set; }
        public Animation AniRoot { get; private set; }
        protected override void OnInit(IObjectCollector collector)
        {
            HpText = collector.GetComponent<UnityEngine.UI.Text>("HpText");
            Root = collector.GetGameObject("Root").transform;
            AniRoot = collector.GetComponent<Animation>("AniRoot");
        }
    }
}
