123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- 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;
- private bool isUpdateCameraToPath;
- private float currValue;
- private float _cameraSelectValue;
- private float targetValue;
- private float _currTime;
- public void Init(CombatController combatController, Camera camera)
- {
- CombatEventManager.Instance.AddEventListener(CombatEventType.SencenBesselPathAlter, SencenBesselPathAlter);
- this.combatController = combatController;
- Camera = camera;
- root = Camera.transform.parent;
- StressReceiver = camera.transform.GetComponentInParent<StressReceiver>();
- TimeLineSingletonEventManager.Instance.AddTimeLineBasic(this);
- EventManager.Instance.AddEventListener(CustomEventType.HeroClick, HeroClick);
- CameraSelect_onValueChanged(0.7f);
- // EventManager.Instance.AddEventListener(CustomEventType.HeroClick, HeroClick);
- }
- private void SencenBesselPathAlter(IEventData eventData)
- {
- isUpdateCameraToPath = true;
- currValue = _cameraSelectValue;
- if (CombatController.currActiveCombat.CombatSenceController.currBesselPath.isCentre)
- {
- targetValue = 0.5f;
- }
- else
- {
- targetValue = 0.7f;
- }
- _currTime = 0;
- }
- protected void HeroClick(IEventData eventData)
- {
- HeroClickEventData heroClickEventData = eventData as HeroClickEventData;
- int heroId = heroClickEventData.heroId;
- if (_followHeroId == heroId)
- {
- _followHeroId = -1;
- }
- else
- {
- _followHeroId = heroId;
- }
- }
- public void CameraSelect_onValueChanged(float value)
- {
- _cameraSelectValue = value;
- Vector3 pos1 = new Vector3(0, -2, -0.7f);
- Vector3 e1 = new Vector3(20, 0, 0);
- Vector3 pos2 = new Vector3(9, 0.7f, -1.4f);
- Vector3 e2 = new Vector3(17.77f, -28.25f, 1.165f);
- Camera.transform.localPosition =
- Vector3.Lerp(pos1, pos2, value);
- Camera.transform.localEulerAngles =
- Vector3.Lerp(e1, e2, value);
- }
- private void ShakeFinish()
- {
- isStartShake = false;
- }
- public void Update(float t)
- {
- // if (isUpdateCameraToPath)
- // {
- // _currTime += t;
- // CameraSelect_onValueChanged(Mathf.Lerp(currValue, targetValue, _currTime));
- // if (_currTime > 1)
- // {
- // isUpdateCameraToPath = false;
- // }
- // }
- if (!isStartShake && !isStop)
- {
- CombatHeroEntity combatHeroEntities = combatController.CombatHeroController.playerHeroEntity;
- if (combatHeroEntities == null)
- {
- return;
- }
- Vector3 p = combatHeroEntities.GameObject.transform.TransformPoint(new Vector3(0, 8, -10));
- root.rotation = Quaternion.Lerp(root.rotation, combatHeroEntities.GameObject.transform.rotation,
- 1);
- root.position = Vector3.Lerp(root.position, p, 1);
- }
- }
- public void SetPos(Transform target)
- {
- Vector3 p = target.TransformPoint(new Vector3(0, 8, -10));
- root.rotation = Quaternion.Lerp(root.rotation, target.rotation,
- 1);
- root.position = Vector3.Lerp(root.position, p, 1);
- }
- 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);
- }
- }
- }
|