1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- 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;
- root.position = Vector3.Lerp(root.position, new Vector3(p.x, root.position.y, p.z - 7), 0.3f);
- }
- }
- public void Dispose()
- {
- }
- public void Shaking(CameraShakingSerializtion cameraShakingSerializtion)
- {
- if (StressReceiver != null)
- {
- isStartShake = true;
- StressReceiver.InduceStress(cameraShakingSerializtion.qiangDu, ShakeFinish);
- }
- }
- }
- }
|