using UnityEngine;

namespace GameLogic.Combat.CombatTool
{
    public class CombatCameraControllder
    {
        public Transform root;
        public Camera Camera;
        public CombatController combatController;

        public void Init(CombatController combatController, Camera camera)
        {
            this.combatController = combatController;
            Camera = camera;
            root = Camera.transform.parent;
        }

        public void Update(float t)
        {
            CombatHeroEntity[] combatHeroEntities = combatController.CombatHeroController.GetHero(false);
            Vector3 p = Vector3.zero;
            for (int i = 0; i < combatHeroEntities.Length; i++)
            {
                p += combatHeroEntities[i].dotPos;
            }

            p /= combatHeroEntities.Length;
            root.position = new Vector3(p.x, root.position.y, p.z - 5);
        }
    }
}