| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 | using System;using Common.Utility.CombatEvent;using Fort23.Core;using UnityEngine;using Utility;using Utility.CustomizeTimeLogic.FxLogic.TimeLineEvent;using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface;namespace GameLogic.Combat.CombatTool{    public class CombatCameraControllder : IDisposable, ICameraShaking    {        public Transform root;        public Camera Camera;        public CombatController combatController;        public StressReceiver StressReceiver;        private bool isStartShake;        public int FollowHeroId        {            get { return _followHeroId; }        }        private int _followHeroId = -1;              public bool isStop;        public void Init(CombatController combatController, Camera camera)        {            this.combatController = combatController;            Camera = camera;            root = Camera.transform.parent;            StressReceiver = camera.transform.GetComponentInParent<StressReceiver>();            TimeLineSingletonEventManager.Instance.AddTimeLineBasic(this);            EventManager.Instance.AddEventListener(CustomEventType.HeroClick, HeroClick);            // EventManager.Instance.AddEventListener(CustomEventType.HeroClick, HeroClick);        }        protected void HeroClick(IEventData eventData)        {            HeroClickEventData heroClickEventData = eventData as HeroClickEventData;            int heroId = heroClickEventData.heroId;            if (_followHeroId == heroId)            {                _followHeroId = -1;            }            else            {                _followHeroId = heroId;            }        }        private void ShakeFinish()        {            isStartShake = false;        }        public void Update(float t)        {            if (!isStartShake && !isStop)            {                CombatHeroEntity combatHeroEntities = combatController.CombatHeroController.followTarget;                if (combatHeroEntities == null)                {                    return;                }                if (combatHeroEntities.isDie)                {                    CombatHeroEntity[] allHero= combatController.CombatHeroController.GetHero(false);                    if (allHero != null&& allHero.Length > 0)                    {                        combatHeroEntities=  allHero[0];                    }                }                Vector3 p = combatHeroEntities.dotPos;                // bool isHero = false;                // if (_followHeroId != -1)                // {                //     for (int i = 0; i < combatHeroEntities.Length; i++)                //     {                //         if (combatHeroEntities[i].CurrCombatHeroInfo.modelID == _followHeroId)                //         {                //             p = combatHeroEntities[i].dotPos;                //             isHero = true;                //             break;                //         }                //     }                // }                //                // if (!isHero)                // {                //     int c = 0;                //     for (int i = 0; i < combatHeroEntities.Length; i++)                //     {                //         if (!combatHeroEntities[i].isDie)                //         {                //             c++;                //             p += combatHeroEntities[i].dotPos;                //         }                //     }                //                //     if (c <= 0)                //     {                //         return;                //     }                //                //     p /= c;                // }                            // Vector3 tp = root.TransformVector(new Vector3(0, 0, -20));                root.position = Vector3.Lerp(root.position, p, 0.05f);            }        }        public void Dispose()        {            EventManager.Instance.RemoveEventListener(CustomEventType.HeroClick, HeroClick);        }        public void Shaking(float qiangDu)        {            if (StressReceiver != null)            {                isStartShake = true;                StressReceiver.InduceStress(qiangDu, ShakeFinish);            }        }        public void Shaking(CameraShakingSerializtion cameraShakingSerializtion)        {            Shaking(cameraShakingSerializtion.qiangDu);        }    }}
 |