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

namespace FL.Map
{
    public class TestMainMapVM : IEntityViewModel
    {
        public MeshRenderer BgMR { get; private set; }
        public Transform PlayerRoot { get; private set; }
        public Transform EnemyRoot { get; private set; }
        public Transform HpRoot { get; private set; }
        public ParallelCamera Camera { get; private set; }

        
        public TestMainMapVM(IObjectCollector collector)
        {
            BgMR = collector.GetComponent<MeshRenderer>("Quad");
            PlayerRoot = collector.GetGameObject("PlayerRoot").transform;
            EnemyRoot = collector.GetGameObject("EnemyRoot").transform;
            HpRoot = collector.GetGameObject("HpRoot").transform;
            Camera = collector.GetComponent<ParallelCamera>("MainCamera");
            _bgMaterial = BgMR.material;
            BgMR.material = _bgMaterial;
        }

        #region 地图滚动
        private Material _bgMaterial;
        private bool _isMapMove;
        private int _moveTime = 0;
        public void UpdateMapMoveTime(int millisecond)
        {
            if (_isMapMove)
            {
                _moveTime += millisecond;
                _bgMaterial.SetFloat("_MoveTime", _moveTime * 0.001f);
            }
        }
        #endregion
    }
}