123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- using System;
- using Common.Utility.CombatEvent;
- using Fort23.Core;
- using UnityEngine;
- 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 void Init(CombatController combatController, Camera camera)
- {
- this.combatController = combatController;
- Camera = camera;
- root = Camera.transform.parent;
- StressReceiver = camera.transform.GetComponentInParent<StressReceiver>();
- TimeLineSingletonEventManager.Instance.AddTimeLineBasic(this);
- }
- private void ShakeFinish()
- {
- isStartShake = false;
- }
- public void Update(float t)
- {
- if (!isStartShake)
- {
- CombatHeroEntity[] combatHeroEntities = combatController.CombatHeroController.GetHero(false);
- if (combatHeroEntities == null)
- {
- return;
- }
- Vector3 p = Vector3.zero;
- for (int i = 0; i < combatHeroEntities.Length; i++)
- {
- p += combatHeroEntities[i].dotPos;
- }
- p /= combatHeroEntities.Length;
- // Vector3 tp = root.TransformVector(new Vector3(0, 0, -20));
- root.position = Vector3.Lerp(root.position, new Vector3(p.x, root.position.y, p.z+13), 0.1f);
- }
- }
- public void Dispose()
- {
- }
- public void Shaking(CameraShakingSerializtion cameraShakingSerializtion)
- {
- if (StressReceiver != null)
- {
- isStartShake = true;
- StressReceiver.InduceStress(cameraShakingSerializtion.qiangDu, ShakeFinish);
- }
- }
- }
- }
|