BattleCamera.cs 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System;
  5. #region data
  6. public enum CameraMoveMode
  7. {
  8. Camera_SyncFocusPosition = 0, //同步焦点和位置
  9. Camera_MoveFocusPosition = 1, //焦点和位置同时移动
  10. Camera_MoveFocusFirst = 2, //优先移动焦点
  11. Camera_MovePositionFirst = 3, //优先移动位置
  12. Camera_FollowFighterPosition = 5, //同步fighter的位置
  13. Camera_Follow_FixedTarget = 6,
  14. Camera_SyncRotPosition = 7, //同步旋转和位置
  15. Camera_ManualRotate = 8,
  16. }
  17. public enum CameraMode
  18. {
  19. Camera_None = 0,
  20. Camera_BattleAuto = 1,
  21. Camera_FollowLeftFighters = 2,
  22. Camera_LockFighter = 3,
  23. Camera_Fixed_Target = 4,
  24. Camera_Move_BattleFieldCenter = 5,
  25. Camera_TweeningMove = 6,
  26. Camera_TweeningJump = 7,
  27. Camera_ManualRotate = 8,
  28. }
  29. public enum BattleTransitionState
  30. {
  31. BTS_None = 0,
  32. BTS_Out = 1, //离场
  33. BTS_Black = 2, //黑屏
  34. BTS_In = 3, //进场
  35. }
  36. public class CameraFollowFighterHelper
  37. {
  38. public Fighter FollowFighter { get; set; }
  39. public Vector3 TargetOffset { get; set; }
  40. public Vector3 CameraOffset{ get; set; }
  41. public float FollowDist { get; set; }
  42. public float Fov{ get; set; }
  43. public float FollowSpeedRate{ get; set; }
  44. public float ContinueTime{ get; set; }
  45. public CameraMoveMode MoveMode{ get; set; }
  46. public bool IsFollow{ get; set; }
  47. public bool IsUnscaleTime { get; set; }
  48. public bool IsActive { get { return mHasStart && (IsUnscaleTime ? Time.unscaledTime < mStartTime + ContinueTime : Time.time < mStartTime + ContinueTime); } }
  49. float mStartTime;
  50. bool mHasStart;
  51. Vector3 mStartFocus;
  52. Vector3 mStartCameraPosition;
  53. public void Start ()
  54. {
  55. mStartTime = IsUnscaleTime ? Time.unscaledTime : Time.time;
  56. mHasStart = true;
  57. if (!IsFollow)
  58. {
  59. mStartFocus = FollowFighter == null ? Vector3.zero : FollowFighter.Position + TargetOffset;
  60. mStartCameraPosition = mStartFocus + CameraOffset;
  61. }
  62. }
  63. public void Stop ()
  64. {
  65. FollowFighter = null;
  66. mHasStart = false;
  67. }
  68. public Vector3 GetFocus ()
  69. {
  70. return IsFollow ? (FollowFighter == null ? Vector3.zero : FollowFighter.Position + TargetOffset) : mStartFocus;
  71. }
  72. public Vector3 GetCameraPosition ()
  73. {
  74. return IsFollow ?(GetFocus () - FollowFighter.Ctrl.transform.forward * FollowDist + CameraOffset) : mStartCameraPosition;
  75. }
  76. public Vector3 GetCameraPosition(Vector3 forward)
  77. {
  78. return GetFocus() - forward * FollowDist + CameraOffset;
  79. }
  80. public Vector3 Forward
  81. {
  82. get { return IsFollow ? (FollowFighter != null ? FollowFighter.Ctrl.transform.forward : Vector3.zero):Vector3.zero; }
  83. }
  84. }
  85. #endregion
  86. public class BattleCamera : Singleton<BattleCamera>
  87. {
  88. #region static_and_const
  89. public const string FighterLayerName = "Fighter";
  90. public const string SceneEffectLayerName = "FX";
  91. public const string DisableLayerName = "Disable";
  92. public const string BackGroudLayerName = "Background";
  93. public const string WaterLayerName = "Water";
  94. public const string GroundLayerName = "Ground";
  95. public const string ReflectionLayerName = "Reflection";
  96. public const string BackScreenLayerName = "BackScreenEffect";
  97. public const string HideLayerName = "Hide";
  98. public const string T4M5LayerName = "T4M5";
  99. public const float camera_view_border_blank = 0.1f;
  100. public const float camera_view_bottom_blank = 0.2f;
  101. public const float camera_far_clip = 100;
  102. public static int defalutLayer = LayerMask.NameToLayer("Default");
  103. public static int hideLayer = LayerMask.NameToLayer("Hide");
  104. //"Water", "MainCity", "Ground", "Reflection", "InvalidLayer"
  105. //public int FighterLayerMask;
  106. //public int FullLayerMask;
  107. #endregion
  108. #region fields
  109. private bool tracePosition;
  110. private bool mIsDoingSpecialCamera;
  111. private Camera mRealCam;
  112. public Camera RealCamera
  113. {
  114. get
  115. {
  116. return mRealCam;
  117. }
  118. }
  119. public bool BattleCameraEnabled
  120. {
  121. get { return mRealCam != null ? mRealCam.enabled : false; }
  122. }
  123. private Shake mShake = null;
  124. CameraMode currentCameraMode = CameraMode.Camera_BattleAuto;
  125. CameraMoveMode moveMode = CameraMoveMode.Camera_FollowFighterPosition;
  126. bool enableUpdateTo;
  127. bool enableUpdateCurrent;
  128. bool enableAutoFov = true;
  129. const float updateToInterval = 1.0f/60;
  130. float currentUpdateToInterval;
  131. const int maxCallUpdateCnt = 2;
  132. int callUpdateToCnt = 0;
  133. //相机目标属性
  134. Vector3 toFocus = Vector3.zero;
  135. Vector3 toPosition = Vector3.zero;
  136. Vector3 toElerAngle = Vector3.zero;
  137. float toFov;
  138. //相机当前属性
  139. Vector3 currentFocus = Vector3.zero;
  140. Vector3 currentPosition = Vector3.zero;
  141. Vector3 currentElerAngle = Vector3.zero;
  142. float currentFov;
  143. int cullingMask;
  144. public int CullingMask
  145. {
  146. get { return cullingMask; }
  147. }
  148. CameraClearFlags clearFlag;
  149. bool hasSetCamera;
  150. CameraClearFlags realCameraClearFlags;
  151. public bool syncSpeed = true;
  152. float syncFovSpeedRate = 1f;
  153. Transform efxBattleTransition;
  154. public bool enableDynamicSpeed = true;
  155. CameraFollowFighterHelper mFollowFighterHelper;
  156. GameObject camContainer = null;
  157. BattleCamConfig mCameraCfg = null;
  158. Animator camAnimator = null;
  159. RadialBlurEffect mBlurEffect = null;
  160. CameraRotateAround mCamRotateCom = null;
  161. private GameObject mComingCameraGo = null;
  162. #endregion
  163. public GameObject ComingCameraGo { get { return mComingCameraGo; } }
  164. public GameObject CamContainer { get { return camContainer; } }
  165. public BattleCamConfig CamCfg
  166. {
  167. get { return mCameraCfg; }
  168. }
  169. private Vector3 mCameraOffset;
  170. public Vector3 CameraOffset
  171. {
  172. get { return mCameraOffset; }
  173. }
  174. private BossIntroCameraCfg mBossIntroCamCfg;
  175. private bool mCustomFollowCamera;
  176. Vector3 followCameraOffset;
  177. float followCameraFov;
  178. #region properties
  179. Animator AnimatorCom {
  180. get {
  181. return camAnimator;
  182. }
  183. }
  184. public bool IsPlayingAnimation {
  185. get {
  186. if (AnimatorCom != null && AnimatorCom.isActiveAndEnabled)
  187. return true;
  188. return false;
  189. }
  190. }
  191. public Vector3 Forward {
  192. get {
  193. return RealCamera.transform.forward;
  194. }
  195. }
  196. public Vector3 Right {
  197. get {
  198. return RealCamera.transform.right;
  199. }
  200. }
  201. bool IsCurrentCloseToTarget {
  202. get {
  203. return currentPosition.CloseTo (toPosition) && currentFocus.CloseTo (toFocus) && Mathf.Abs (currentFov - toFov) < 0.0001f;
  204. }
  205. }
  206. CameraMode CurrentCameraMode {
  207. get {
  208. return currentCameraMode;
  209. }
  210. set {
  211. currentCameraMode = value;
  212. switch (currentCameraMode)
  213. {
  214. case CameraMode.Camera_None:
  215. enableUpdateTo = false;
  216. enableUpdateCurrent = false;
  217. mIsDoingSpecialCamera = false;
  218. break;
  219. case CameraMode.Camera_FollowLeftFighters:
  220. enableUpdateTo = true;
  221. enableUpdateCurrent = true;
  222. moveMode = CameraMoveMode.Camera_SyncFocusPosition;
  223. enableAutoFov = false;
  224. mIsDoingSpecialCamera = false;
  225. syncSpeed = true;
  226. enableDynamicSpeed = false;
  227. break;
  228. case CameraMode.Camera_LockFighter:
  229. enableUpdateTo = true;
  230. enableUpdateCurrent = true;
  231. enableAutoFov = false;
  232. mIsDoingSpecialCamera = false;
  233. enableDynamicSpeed = true;
  234. break;
  235. case CameraMode.Camera_BattleAuto:
  236. enableUpdateTo = true;
  237. enableUpdateCurrent = true;
  238. moveMode = CameraMoveMode.Camera_SyncFocusPosition;
  239. enableAutoFov = false;
  240. mIsDoingSpecialCamera = false;
  241. enableDynamicSpeed = true;
  242. break;
  243. case CameraMode.Camera_Fixed_Target:
  244. enableUpdateTo = false;
  245. enableUpdateCurrent = false;
  246. moveMode = CameraMoveMode.Camera_Follow_FixedTarget;
  247. enableAutoFov = false;
  248. mIsDoingSpecialCamera = false;
  249. enableDynamicSpeed = false;
  250. break;
  251. case CameraMode.Camera_Move_BattleFieldCenter:
  252. enableUpdateTo = true;
  253. enableUpdateCurrent = true;
  254. moveMode = CameraMoveMode.Camera_MoveFocusPosition;
  255. enableAutoFov = false;
  256. mIsDoingSpecialCamera = false;
  257. syncSpeed = false;
  258. mCustomFollowCamera = false;
  259. enableDynamicSpeed = false;
  260. break;
  261. case CameraMode.Camera_TweeningMove:
  262. enableUpdateTo = false;
  263. enableUpdateCurrent = true;
  264. enableAutoFov = false;
  265. mIsDoingSpecialCamera = true;
  266. enableDynamicSpeed = false;
  267. moveMode = CameraMoveMode.Camera_SyncFocusPosition;
  268. break;
  269. case CameraMode.Camera_ManualRotate:
  270. enableUpdateTo = true;
  271. enableUpdateCurrent = true;
  272. moveMode = CameraMoveMode.Camera_ManualRotate;
  273. enableAutoFov = false;
  274. mIsDoingSpecialCamera = false;
  275. enableDynamicSpeed = false;
  276. break;
  277. }
  278. }
  279. }
  280. public Vector3 CamPosition
  281. {
  282. get {
  283. return camContainer!= null ? camContainer.transform.position : Vector3.zero;
  284. }
  285. set
  286. {
  287. if(camContainer!=null)
  288. camContainer.transform.position = value;
  289. }
  290. }
  291. public Vector3 CamForward
  292. {
  293. get
  294. {
  295. return camContainer!= null ? camContainer.transform.forward : CamEulerAngle.normalized;
  296. }
  297. }
  298. public Vector3 CamEulerAngle
  299. {
  300. get { return mCurCamEulerAngle; }
  301. set
  302. {
  303. if(mCurCamEulerAngle!=value)
  304. {
  305. mCurCamEulerAngle = value;
  306. if(null != camContainer)
  307. camContainer.transform.rotation = Quaternion.Euler(mCurCamEulerAngle);
  308. }
  309. }
  310. }
  311. public float CamFov
  312. {
  313. get { return mRealCam != null?mRealCam.fieldOfView : 60; }
  314. set
  315. {
  316. if(mRealCam!=null)
  317. mRealCam.fieldOfView = Mathf.Max(value, 0.1f);
  318. }
  319. }
  320. bool initialized;
  321. Vector3 mCurCamEulerAngle;
  322. BaseBattle mBattle;
  323. private float mMoveSpeed = 0;
  324. public float MoveSpeed
  325. {
  326. get { return mMoveSpeed; }
  327. set { mMoveSpeed = value; }
  328. }
  329. private float mRotSpeed = 0;
  330. public float RotSpeed
  331. {
  332. get { return mRotSpeed; }
  333. set { mRotSpeed = value; }
  334. }
  335. private float mFovSpeed = 0;
  336. public float FovSpeed
  337. {
  338. get { return mFovSpeed; }
  339. set { mFovSpeed = value; }
  340. }
  341. public float MoveSpeedInBattle
  342. {
  343. get { return CamCfg.CamMoveSpeedInBattle; }
  344. }
  345. #endregion
  346. public override void Init()
  347. {
  348. base.Init();
  349. }
  350. public override void UnInit()
  351. {
  352. base.UnInit();
  353. }
  354. public void Initialize (LogicBattle battle)
  355. {
  356. if (initialized)
  357. return;
  358. mBattle = battle;
  359. //FighterLayerMask = LayerMask.GetMask (new [] { FighterLayerName });
  360. //FullLayerMask = LayerMask.GetMask (new [] {
  361. // FighterLayerName,
  362. // SceneEffectLayerName,
  363. // WaterLayerName,
  364. // ReflectionLayerName,
  365. // GroundLayerName,
  366. // BackGroudLayerName
  367. //});
  368. mComingCameraGo = battle.BattleScene.ComingCamera;
  369. camContainer = battle.BattleScene.CameraContainer;
  370. if (camContainer == null)
  371. return;
  372. mCameraCfg = camContainer.GetComponent<BattleCamConfig>();
  373. if (!camContainer.activeInHierarchy)
  374. camContainer.SetActive(true);
  375. camAnimator = camContainer.GetComponentInChildren<Animator>();
  376. mCamRotateCom = camContainer.GetComponentInChildren<CameraRotateAround>();
  377. if (mCamRotateCom != null)
  378. {
  379. mCamRotateCom.target = battle.TeamCenterPoint;
  380. }
  381. if (battle.BattleScene.BossIntroCamGo != null)
  382. {
  383. mBossIntroCamCfg = battle.BattleScene.BossIntroCamGo.GetComponent<BossIntroCameraCfg>();
  384. }
  385. if (AnimatorCom != null)
  386. AnimatorCom.enabled = false;
  387. mRealCam = battle.BattleScene.CameraTrans.GetComponent<Camera>();
  388. if (Camera.main == null)
  389. mRealCam.tag = "MainCamera";
  390. cullingMask = mRealCam.cullingMask;
  391. clearFlag = mRealCam.clearFlags;
  392. mRealCam.allowHDR = false;
  393. mRealCam.allowMSAA = false;
  394. mRealCam.farClipPlane = camera_far_clip;
  395. InitComponents ();
  396. initialized = true;
  397. toFocus = battle.BattleScene.ActorBornPoint.GetReadyPointPos(0, 1).heroPos;
  398. toPosition = toFocus - battle.BattleScene.ActorBornPoint.transform.forward * mCameraCfg.followDist + mCameraCfg.followCamOffset;
  399. toFov = mCameraCfg.followCameraFov;
  400. mCurCamEulerAngle = camContainer.transform.rotation.eulerAngles;
  401. SetCurrentCamera(false, true,0);
  402. mBlurEffect = mRealCam.GetComponent<RadialBlurEffect>();
  403. mMoveSpeed = CamCfg.CamMoveSpeed;
  404. mRotSpeed = CamCfg.CamRotSpeed;
  405. mFovSpeed = CamCfg.CamFovSpeed;
  406. InitShake();
  407. }
  408. public void Initialize(VersusBattle battle)
  409. {
  410. if (initialized)
  411. return;
  412. mBattle = battle;
  413. //FighterLayerMask = LayerMask.GetMask(new[] { FighterLayerName });
  414. //FullLayerMask = LayerMask.GetMask(new[] {
  415. // FighterLayerName,
  416. // SceneEffectLayerName,
  417. // WaterLayerName,
  418. // ReflectionLayerName,
  419. // GroundLayerName,
  420. // BackGroudLayerName
  421. //});
  422. if (battle == null) return;
  423. mComingCameraGo = battle.BattleScene.ComingCamera;
  424. camContainer = battle.BattleScene.CameraContainer;
  425. if (camContainer == null)
  426. return;
  427. if (!camContainer.activeInHierarchy)
  428. camContainer.SetActive(true);
  429. camAnimator = camContainer.GetComponentInChildren<Animator>();
  430. mCameraCfg = camContainer.GetComponent<BattleCamConfig>();
  431. mRealCam = battle.BattleScene.CameraTrans.GetComponent<Camera>();
  432. if (Camera.main == null)
  433. mRealCam.tag = "MainCamera";
  434. cullingMask = mRealCam.cullingMask;
  435. clearFlag = mRealCam.clearFlags;
  436. mRealCam.allowHDR = false;
  437. mRealCam.allowMSAA = false;
  438. InitComponents();
  439. initialized = true;
  440. SetCamera(battle.BornCamPos,battle.BornCenter,battle.BornCamRot,battle.BornCamFov);
  441. mBlurEffect = mRealCam.GetComponent<RadialBlurEffect>();
  442. InitShake();
  443. }
  444. public void Initialize(BossBattle battle)
  445. {
  446. if (initialized)
  447. return;
  448. mBattle = battle;
  449. //FighterLayerMask = LayerMask.GetMask(new[] { FighterLayerName });
  450. //FullLayerMask = LayerMask.GetMask(new[] {
  451. // FighterLayerName,
  452. // SceneEffectLayerName,
  453. // WaterLayerName,
  454. // ReflectionLayerName,
  455. // GroundLayerName,
  456. // BackGroudLayerName
  457. //});
  458. if (battle == null) return;
  459. mComingCameraGo = battle.BattleScene.ComingCamera;
  460. camContainer = battle.BattleScene.CameraContainer;
  461. if (camContainer == null)
  462. return;
  463. if (!camContainer.activeInHierarchy)
  464. camContainer.SetActive(true);
  465. camAnimator = camContainer.GetComponentInChildren<Animator>();
  466. mCameraCfg = camContainer.GetComponent<BattleCamConfig>();
  467. mRealCam = battle.BattleScene.CameraTrans.GetComponent<Camera>();
  468. if (Camera.main == null)
  469. mRealCam.tag = "MainCamera";
  470. cullingMask = mRealCam.cullingMask;
  471. clearFlag = mRealCam.clearFlags;
  472. mRealCam.allowHDR = false;
  473. mRealCam.allowMSAA = false;
  474. initialized = true;
  475. //SetCameraPosAndRot(battle.SpawnCfg.BossCamPos, battle.SpawnCfg.BossCamRot, 50);
  476. CurrentCameraMode = CameraMode.Camera_None;
  477. mBlurEffect = mRealCam.GetComponent<RadialBlurEffect>();
  478. InitShake();
  479. }
  480. public void Initialize(TimeBattle battle)
  481. {
  482. if (initialized)
  483. return;
  484. mBattle = battle;
  485. if (battle == null) return;
  486. mComingCameraGo = battle.BattleScene.ComingCamera;
  487. camContainer = battle.BattleScene.CameraContainer;
  488. if (camContainer == null)
  489. return;
  490. if (!camContainer.activeInHierarchy)
  491. camContainer.SetActive(true);
  492. camAnimator = camContainer.GetComponentInChildren<Animator>();
  493. mCameraCfg = camContainer.GetComponent<BattleCamConfig>();
  494. mRealCam = battle.BattleScene.CameraTrans.GetComponent<Camera>();
  495. if (Camera.main == null)
  496. mRealCam.tag = "MainCamera";
  497. cullingMask = mRealCam.cullingMask;
  498. clearFlag = mRealCam.clearFlags;
  499. mRealCam.allowHDR = false;
  500. mRealCam.allowMSAA = false;
  501. initialized = true;
  502. CurrentCameraMode = CameraMode.Camera_None;
  503. mBlurEffect = mRealCam.GetComponent<RadialBlurEffect>();
  504. InitShake();
  505. }
  506. private void InitShake()
  507. {
  508. if (mRealCam == null) return;
  509. mShake = mRealCam.GetComponent<Shake>();
  510. if (mShake == null)
  511. {
  512. mShake = mRealCam.gameObject.AddComponent<Shake>();
  513. }
  514. }
  515. public void Update(float deltaTime)
  516. {
  517. if (!initialized)
  518. {
  519. return;
  520. }
  521. if (manualRotating) return;
  522. //if (CurrentCameraMode == CameraMode.Camera_BattleAuto)
  523. //{
  524. // if (callUpdateToCnt < maxCallUpdateCnt)
  525. // {
  526. // if (currentUpdateToInterval <= 0f)
  527. // {
  528. // callUpdateToCnt++;
  529. // UpdateTo();
  530. // currentUpdateToInterval = updateToInterval;
  531. // }
  532. // currentUpdateToInterval -= deltaTime;
  533. // }
  534. //}
  535. //else
  536. //{
  537. //}
  538. UpdateTo();
  539. UpdateCurrent(deltaTime);
  540. }
  541. public void Clear()
  542. {
  543. DisableBattleCam();
  544. //Camera_UI3D.Instance.Clear();
  545. if(mCamRotateCom!=null)
  546. mCamRotateCom.target = null;
  547. mFollowFighterHelper = null;
  548. initialized = false;
  549. camContainer = null;
  550. camAnimator = null;
  551. mBossIntroCamCfg = null;
  552. mRealCam = null;
  553. mCamRotateCom = null;
  554. CurrentCameraMode = CameraMode.Camera_None;
  555. }
  556. void InitComponents ()
  557. {
  558. mFollowFighterHelper = new CameraFollowFighterHelper ();
  559. }
  560. void UpdateFollowFighter ()
  561. {
  562. if (mBattle != null)
  563. {
  564. toFocus = mBattle.TeamCenter + mFollowFighterHelper.TargetOffset;
  565. toFov = mFollowFighterHelper.Fov;
  566. toPosition = toFocus - mFollowFighterHelper.FollowFighter.Ctrl.transform.forward * mFollowFighterHelper.FollowDist + mFollowFighterHelper.CameraOffset;
  567. }
  568. else
  569. {
  570. toFocus = mFollowFighterHelper.GetFocus();
  571. toFov = mFollowFighterHelper.Fov;
  572. toPosition = mFollowFighterHelper.GetCameraPosition();
  573. }
  574. }
  575. void UpdateFollowFighter(Vector3 forward)
  576. {
  577. if(mBattle!=null)
  578. {
  579. toFocus = mBattle.TeamCenter + mFollowFighterHelper.TargetOffset;
  580. toFov = mFollowFighterHelper.Fov;
  581. toPosition = toFocus - forward * mFollowFighterHelper.FollowDist + mFollowFighterHelper.CameraOffset;
  582. }
  583. else
  584. {
  585. toFocus = mFollowFighterHelper.GetFocus();
  586. toFov = mFollowFighterHelper.Fov;
  587. toPosition = mFollowFighterHelper.GetCameraPosition(forward);
  588. }
  589. }
  590. void UpdateTo ()
  591. {
  592. if (!enableUpdateTo)
  593. return;
  594. if (IsPlayingAnimation)
  595. return;
  596. if(CurrentCameraMode == CameraMode.Camera_BattleAuto)
  597. {
  598. if(mFollowFighterHelper != null && mFollowFighterHelper.IsActive)
  599. {
  600. UpdateFollowFighter(mBattleAutoForward);
  601. }
  602. }
  603. else if (mFollowFighterHelper != null && mFollowFighterHelper.IsActive)
  604. {
  605. UpdateFollowFighter();
  606. }
  607. else if (CurrentCameraMode == CameraMode.Camera_FollowLeftFighters)
  608. {
  609. if(mBattle!=null)
  610. {
  611. toFocus = mBattle.FighterMgr.TeamFighterFocus;
  612. Vector3 focusForward = mBattle.FighterMgr.TeamFighterForward;
  613. toPosition = toFocus + FollowCameraOffset;
  614. toFov = FollowCameraFov;
  615. }
  616. }
  617. }
  618. void UpdateCurrent (float deltaTime)
  619. {
  620. if (!enableUpdateCurrent) {
  621. return;
  622. }
  623. switch (MoveMode)
  624. {
  625. case CameraMoveMode.Camera_SyncFocusPosition:
  626. CamSyncFocusPosition(deltaTime);
  627. break;
  628. case CameraMoveMode.Camera_SyncRotPosition:
  629. currentPosition = Vector3.MoveTowards(currentPosition, toPosition, deltaTime * MoveSpeed);
  630. currentElerAngle = Vector3.MoveTowards(currentElerAngle, toElerAngle, deltaTime * RotSpeed);
  631. break;
  632. case CameraMoveMode.Camera_MoveFocusPosition:
  633. currentFocus = Vector3.MoveTowards(currentFocus, toFocus, deltaTime * MoveSpeed);
  634. currentPosition = Vector3.MoveTowards(currentPosition, toPosition, deltaTime * MoveSpeed);
  635. break;
  636. case CameraMoveMode.Camera_MoveFocusFirst:
  637. currentFocus = Vector3.MoveTowards(currentFocus, toFocus, deltaTime * MoveSpeed);
  638. if (currentFocus.CloseTo(toFocus))
  639. currentPosition = Vector3.MoveTowards(currentPosition, toPosition, deltaTime * MoveSpeed);
  640. break;
  641. case CameraMoveMode.Camera_MovePositionFirst:
  642. currentPosition = Vector3.MoveTowards(currentPosition, toPosition, deltaTime * MoveSpeed);
  643. if (currentPosition.CloseTo(toPosition))
  644. currentElerAngle = Vector3.MoveTowards(currentElerAngle, toElerAngle, deltaTime * RotSpeed);
  645. break;
  646. case CameraMoveMode.Camera_FollowFighterPosition:
  647. currentFocus = Vector3.MoveTowards(currentFocus, toFocus, deltaTime * MoveSpeed);
  648. currentPosition = Vector3.MoveTowards(currentPosition, toPosition, deltaTime * MoveSpeed);
  649. break;
  650. case CameraMoveMode.Camera_Follow_FixedTarget:
  651. currentFocus = Vector3.MoveTowards(currentFocus, toFocus, deltaTime * MoveSpeed);
  652. currentPosition = Vector3.MoveTowards(currentPosition, toPosition, deltaTime * MoveSpeed);
  653. break;
  654. case CameraMoveMode.Camera_ManualRotate:
  655. //currentFocus = Vector3.MoveTowards(currentFocus, toFocus, deltaTime * MoveSpeed);
  656. currentFocus = toFocus;
  657. if (currentFocus.CloseTo(toFocus))
  658. currentPosition = Vector3.MoveTowards(currentPosition, toPosition, deltaTime * MoveSpeed);
  659. break;
  660. }
  661. SetCurrentCamera (EnableAutoFov, !hasSetCamera,deltaTime);
  662. }
  663. void CamSyncFocusPosition(float deltaTime)
  664. {
  665. float currentMoveSpeed = MoveSpeed;
  666. float currentRotateSpeed = RotSpeed;
  667. float currentFovSpeed = FovSpeed;
  668. Vector3 vTo = toFocus - toPosition;
  669. currentPosition = CamPosition;
  670. currentFocus = currentPosition + CamForward * vTo.magnitude;
  671. Vector3 vCurrent = currentFocus - currentPosition;
  672. float angleBetween = Vector3.Angle(vTo, vCurrent);
  673. float magnitudeDiff = Mathf.Abs(vTo.magnitude - vCurrent.magnitude);
  674. float positionDistance = Vector3.SqrMagnitude(toPosition - currentPosition);
  675. float focusDistance = Vector3.SqrMagnitude(toFocus - currentFocus);
  676. float magnitudeSpeed = MoveSpeed;
  677. if (syncSpeed)
  678. {
  679. if (focusDistance < positionDistance)
  680. {
  681. if (enableDynamicSpeed)
  682. {
  683. if (focusDistance < 0.5f)
  684. currentMoveSpeed = Mathf.Max(0.1f, 0.05f * MoveSpeed * focusDistance * 2f);
  685. else if (focusDistance < 10f)
  686. currentMoveSpeed = MoveSpeed * focusDistance * 0.1f;
  687. }
  688. float time1 = focusDistance / currentMoveSpeed;
  689. float time2 = angleBetween / currentRotateSpeed;
  690. float time = Mathf.Max(time1, time2);
  691. if (time > 0f)
  692. {
  693. currentMoveSpeed = focusDistance / time;
  694. currentRotateSpeed = angleBetween / time;
  695. magnitudeSpeed = magnitudeDiff / time;
  696. }
  697. }
  698. else
  699. {
  700. if (enableDynamicSpeed)
  701. {
  702. if (positionDistance < 0.5f)
  703. currentMoveSpeed = Mathf.Max(0.1f, 0.05f * MoveSpeed * positionDistance * 2f);
  704. else if (positionDistance < 10f)
  705. currentMoveSpeed = MoveSpeed * positionDistance * 0.1f;
  706. }
  707. float time1 = positionDistance / currentMoveSpeed;
  708. float time2 = angleBetween / currentRotateSpeed;
  709. float time = Mathf.Max(time1, time2);
  710. if (time > 0f)
  711. {
  712. currentMoveSpeed = focusDistance / time;
  713. currentRotateSpeed = angleBetween / time;
  714. magnitudeSpeed = magnitudeDiff / time;
  715. }
  716. }
  717. syncFovSpeedRate = currentFovSpeed / FovSpeed;
  718. }
  719. else
  720. {
  721. if (angleBetween > 0f && currentRotateSpeed > 0f)
  722. magnitudeSpeed = magnitudeDiff / (angleBetween / currentRotateSpeed);
  723. }
  724. //Vector3 v = Vector3.MoveTowards(vCurrent, vTo, deltaTime * currentMoveSpeed);
  725. //currentPosition = Vector3.MoveTowards(currentPosition, toPosition, deltaTime * currentMoveSpeed);
  726. //currentFocus = currentPosition + v;
  727. if (magnitudeSpeed < 0.5f)
  728. {
  729. magnitudeSpeed = 0.5f;
  730. }
  731. Vector3 v = Vector3.RotateTowards(vCurrent, vTo, deltaTime * currentRotateSpeed * Mathf.Deg2Rad, deltaTime * magnitudeSpeed);
  732. if (focusDistance < positionDistance)
  733. {
  734. currentFocus = Vector3.MoveTowards(currentFocus, toFocus, deltaTime * currentMoveSpeed);
  735. currentPosition = currentFocus - v;
  736. }
  737. else
  738. {
  739. currentPosition = Vector3.MoveTowards(currentPosition, toPosition, deltaTime * currentMoveSpeed);
  740. currentFocus = currentPosition + v;
  741. }
  742. }
  743. Quaternion tempQuaternion;
  744. void SetCurrentCamera (bool autoFov, bool immediate,float deltaTime)
  745. {
  746. if(immediate)
  747. {
  748. //DebugHelper.LogError("currentPosition:" + currentPosition + " CamEulerAngle:" + CamEulerAngle);
  749. currentPosition = toPosition;
  750. currentFocus = toFocus;
  751. }
  752. CamPosition = currentPosition;
  753. tempQuaternion.SetLookRotation(currentFocus - currentPosition, Vector3.up);
  754. CamEulerAngle = tempQuaternion.eulerAngles;
  755. if (immediate)
  756. {
  757. currentFov = toFov;
  758. }
  759. else
  760. {
  761. if (syncSpeed && MoveMode == CameraMoveMode.Camera_SyncFocusPosition)
  762. currentFov = Mathf.MoveTowards(currentFov, toFov, syncFovSpeedRate * FovSpeed * deltaTime);
  763. else
  764. currentFov = Mathf.MoveTowards(currentFov, toFov, FovSpeed * deltaTime);
  765. }
  766. CamFov = currentFov;
  767. hasSetCamera |= immediate;
  768. //DebugHelper.LogError("currentPosition:" + currentPosition + " CamEulerAngle:" + CamEulerAngle);
  769. }
  770. void GetCurrentCameraValues()
  771. {
  772. currentPosition = CamPosition;
  773. currentElerAngle = CamEulerAngle;
  774. currentFov = CamFov;
  775. }
  776. public void LockFighter (Fighter fighter, Vector3 CameraOffset, Vector3 forward,float fov,float followDist,bool immediate)
  777. {
  778. if (mRealCam != null)
  779. {
  780. mRealCam.farClipPlane = camera_far_clip;
  781. }
  782. if (mFollowFighterHelper.IsActive)
  783. {
  784. currentUpdateToInterval = 0;
  785. mMoveSpeed = CamCfg.CamMoveSpeed;
  786. mRotSpeed = CamCfg.CamRotSpeed;
  787. if (manualRotating)
  788. {
  789. backupCameraMode = CameraMode.Camera_LockFighter;
  790. }
  791. else
  792. {
  793. SetCameraMode(CameraMode.Camera_LockFighter);
  794. }
  795. return;
  796. }
  797. mFollowFighterHelper.Fov = fov.FEqual (0) ? 30 : fov;
  798. mFollowFighterHelper.FollowFighter = fighter;
  799. mFollowFighterHelper.TargetOffset = Vector3.zero;
  800. mFollowFighterHelper.CameraOffset = CameraOffset;
  801. mFollowFighterHelper.FollowSpeedRate = 1;
  802. mFollowFighterHelper.ContinueTime = 10000f;
  803. mFollowFighterHelper.MoveMode = CameraMoveMode.Camera_SyncFocusPosition;
  804. mFollowFighterHelper.FollowDist = followDist;
  805. mFollowFighterHelper.IsFollow = true;
  806. mFollowFighterHelper.IsUnscaleTime = false;
  807. mFollowFighterHelper.Start ();
  808. if (manualRotating)
  809. {
  810. backupCameraMode = CameraMode.Camera_LockFighter;
  811. }
  812. else
  813. {
  814. SetCameraMode(CameraMode.Camera_LockFighter);
  815. mMoveSpeed = CamCfg.CamMoveSpeed;
  816. mRotSpeed = CamCfg.CamRotSpeed;
  817. if (immediate)
  818. {
  819. UpdateFollowFighter(forward);
  820. Vector3 oldRot = CamEulerAngle;
  821. currentPosition = CamPosition = toPosition;
  822. currentFocus = toFocus;
  823. tempQuaternion.SetLookRotation(currentFocus - currentPosition, Vector3.up);
  824. currentElerAngle = CamEulerAngle = tempQuaternion.eulerAngles;
  825. DebugHelper.Log("TeamCenter:" + mBattle.TeamCenter + " CameraOffset:" + CameraOffset.ToString());
  826. }
  827. }
  828. }
  829. public void StopLockFighter ()
  830. {
  831. if(mFollowFighterHelper!=null)
  832. mFollowFighterHelper.Stop ();
  833. }
  834. public void SetCameraWithFocus (Vector3 targetPosition, Vector3 targetFocus, float targetFov)
  835. {
  836. StopLockFighter();
  837. toFocus = targetFocus;
  838. toPosition = targetPosition;
  839. toFov = targetFov;
  840. SetCameraMode(CameraMode.Camera_Move_BattleFieldCenter);
  841. }
  842. private float mRecordRotSpeed = 0;
  843. private float mRecordMoveSpeed = 0;
  844. public void SetCameraPosAndRot(Vector3 pos,Vector3 rot,float fov = 0,float far = 0)
  845. {
  846. if(manualRotating)
  847. {
  848. RestoreCamRotate();
  849. }
  850. StopLockFighter();
  851. toPosition = pos;
  852. toElerAngle = rot;
  853. currentFov = toFov = fov < 1 ? mCameraCfg.bossCameraFov:fov;
  854. SetCameraMode(CameraMode.Camera_Fixed_Target);
  855. CamFov = currentFov;
  856. currentPosition = CamPosition = toPosition;
  857. currentElerAngle = CamEulerAngle = toElerAngle;
  858. if(far > 0)
  859. {
  860. mRealCam.farClipPlane = far;
  861. }
  862. }
  863. public void SetCamera(Vector3 targetPos,Vector3 targetFocus,Vector3 targetAngles,float targetFov)
  864. {
  865. toPosition = targetPos;
  866. toFocus = targetFocus;
  867. toElerAngle = targetAngles;
  868. currentFov = toFov = targetFov;
  869. CamFov = currentFov;
  870. currentPosition = CamPosition = toPosition;
  871. currentElerAngle = CamEulerAngle = toElerAngle;
  872. currentFocus = toFocus;
  873. SetCameraMode(CameraMode.Camera_None);
  874. }
  875. Vector3 mBattleAutoForward = Vector3.zero;
  876. public void SetBattleAuto(Vector3 forward)
  877. {
  878. mBattleAutoForward = forward;
  879. MoveSpeed = CamCfg.CamMoveSpeedInBattle;
  880. RotSpeed = CamCfg.CamRotSpeedInBattle;
  881. if(!manualRotating)
  882. {
  883. SetCameraMode(CameraMode.Camera_BattleAuto);
  884. }
  885. else
  886. {
  887. backupCameraMode = CurrentCameraMode;
  888. }
  889. }
  890. public void SetCameraMode (CameraMode mode)
  891. {
  892. if (mIsDoingSpecialCamera)
  893. BattleMgr.Instance.StopCoroutine(specialCameraCoroutine);
  894. if(currentCameraMode!=mode)
  895. CurrentCameraMode = mode;
  896. //DebugHelper.LogError("--------------------------SetCameraMode---------------------"+ mode);
  897. }
  898. public void DisableDynamicCamera ()
  899. {
  900. SetCameraMode (CameraMode.Camera_None);
  901. }
  902. public bool IsDoingSpecialCamera {
  903. get {
  904. return mIsDoingSpecialCamera;
  905. }
  906. }
  907. public Vector3 FollowCameraOffset {
  908. get {
  909. return mCustomFollowCamera ? followCameraOffset : mCameraCfg.followCamOffset;
  910. }
  911. }
  912. public float FollowCameraFov {
  913. get {
  914. return mCustomFollowCamera ? followCameraFov : mCameraCfg.followCameraFov;
  915. }
  916. }
  917. public bool EnableAutoFov {
  918. get {
  919. if (mFollowFighterHelper != null && mFollowFighterHelper.IsActive)
  920. return false;
  921. return enableAutoFov;
  922. }
  923. }
  924. public CameraMoveMode MoveMode {
  925. get {
  926. if (mFollowFighterHelper != null && mFollowFighterHelper.IsActive)
  927. return mFollowFighterHelper.MoveMode;
  928. return moveMode;
  929. }
  930. }
  931. static string mEffectLayerNameInBattle = SceneEffectLayerName;
  932. public static string CurrentEffectLayerName {
  933. get { return BattleMgr.Instance != null ? mEffectLayerNameInBattle : SceneEffectLayerName; }
  934. set {
  935. if (BattleMgr.Instance != null)
  936. mEffectLayerNameInBattle = value;
  937. }
  938. }
  939. public bool IsLoadingTransitionEffect { get; private set; }
  940. public void EnableBattleCam()
  941. {
  942. if(RealCamera!=null /*&& !RealCamera.enabled*/)
  943. {
  944. RealCamera.cullingMask = cullingMask;
  945. }
  946. }
  947. public void DisableBattleCam()
  948. {
  949. if (RealCamera != null/* && RealCamera.enabled*/)
  950. {
  951. RealCamera.cullingMask = 0;
  952. }
  953. }
  954. public void EnterBossIntroCam()
  955. {
  956. if (mBossIntroCamCfg != null)
  957. {
  958. mBossIntroCamCfg.Begin();
  959. DisableBattleCam();
  960. //Camera_UI3D.Instance.SetCameraEnabled(false);
  961. }
  962. }
  963. public void ExitBossIntroCam()
  964. {
  965. if (mBossIntroCamCfg != null)
  966. {
  967. mBossIntroCamCfg.Stop();
  968. EnableBattleCam();
  969. //Camera_UI3D.Instance.SetCameraEnabled(true);
  970. }
  971. }
  972. bool manualRotating= false;
  973. CameraMode backupCameraMode = CameraMode.Camera_None;
  974. public void BeginCamRotate()
  975. {
  976. if (mCamRotateCom == null)
  977. return;
  978. manualRotating = true;
  979. mCamRotateCom.StartRotate();
  980. backupCameraMode = CurrentCameraMode;
  981. }
  982. public void RestoreCamRotate()
  983. {
  984. if (mCamRotateCom == null)
  985. return;
  986. manualRotating = false;
  987. SetCameraMode(backupCameraMode);
  988. mCamRotateCom.StopRotate();
  989. }
  990. public void Shake(float leftRight, float upDown, float forwardBackward, float time, int cycle)
  991. {
  992. if (mShake == null) return;
  993. mShake.positionShake = new Vector3(leftRight, upDown, forwardBackward);
  994. mShake.angleShake = Vector3.zero;
  995. if (Mathf.Abs(time) < Mathf.Epsilon)
  996. time = 0.1f;
  997. mShake.cycleTime = time;
  998. mShake.fCycleCount = cycle;
  999. mShake.unscaleTime = false;
  1000. mShake.bothDir = true;
  1001. mShake.autoDisable = true;
  1002. mShake.Restart();
  1003. }
  1004. public void SetBlurEffectEnabled(bool flag)
  1005. {
  1006. if (mBlurEffect == null) return;
  1007. if(flag)
  1008. {
  1009. mBlurEffect.FadeIn();
  1010. }
  1011. else
  1012. {
  1013. mBlurEffect.FadeOut();
  1014. }
  1015. }
  1016. #region 转场镜头
  1017. Coroutine specialCameraCoroutine;
  1018. public void PerformStartCamera(List<MapCameraConfig> camCfgs, bool tweenTo)
  1019. {
  1020. BattleMgr.Instance.StartCoroutine(DoStartCamera(camCfgs, tweenTo));
  1021. }
  1022. IEnumerator DoStartCamera(List<MapCameraConfig> camCfgs, bool tweenTo)
  1023. {
  1024. if (camCfgs == null || camCfgs.Count == 0) yield break;
  1025. mIsDoingSpecialCamera = true;
  1026. syncSpeed = false;
  1027. //DebugHelper.LogError("start camera start");
  1028. MapCameraConfig cfg = camCfgs[0];
  1029. if (tweenTo)
  1030. {
  1031. tempQuaternion.eulerAngles = cfg.rot;
  1032. Vector3 targetForward = (tempQuaternion * Vector3.forward).normalized;
  1033. Vector3 targetFocus = cfg.pos + targetForward * 20;
  1034. ReadyForSpecailCamera();
  1035. MoveSpeed = cfg.moveSpeed;
  1036. RotSpeed = cfg.rotSpeed;
  1037. FovSpeed = cfg.fovSpeed;
  1038. CamEulerAngle = cfg.rot;
  1039. specialCameraCoroutine =BattleMgr.Instance.StartCoroutine(DoTween(cfg.pos, targetFocus, cfg.fov, 0, CameraMoveMode.Camera_SyncFocusPosition));
  1040. while (mIsDoingSpecialCamera)
  1041. yield return 1;
  1042. }
  1043. else
  1044. {
  1045. SetCamera(cfg.pos,cfg.pos, cfg.rot, cfg.fov);
  1046. }
  1047. for (int i = 1; i < camCfgs.Count; i++)
  1048. {
  1049. MapCameraConfig nextCfg = camCfgs[i];
  1050. tempQuaternion.eulerAngles = nextCfg.rot;
  1051. Vector3 targetForward = (tempQuaternion * Vector3.forward).normalized;
  1052. Vector3 targetFocus = nextCfg.pos + targetForward * 20;
  1053. ReadyForSpecailCamera();
  1054. MoveSpeed = cfg.moveSpeed;
  1055. RotSpeed = cfg.rotSpeed;
  1056. FovSpeed = cfg.fovSpeed;
  1057. CamEulerAngle = nextCfg.rot;
  1058. specialCameraCoroutine = BattleMgr.Instance.StartCoroutine(DoTween(nextCfg.pos, targetFocus, nextCfg.fov, 0, CameraMoveMode.Camera_SyncFocusPosition));
  1059. while (mIsDoingSpecialCamera)
  1060. yield return 1;
  1061. }
  1062. //DebugHelper.LogError("start camera end");
  1063. syncSpeed = true;
  1064. mIsDoingSpecialCamera = false;
  1065. }
  1066. IEnumerator DoTween(Vector3 targetPosition, Vector3 targetFocus, float targetFov, float tweenSpeedRate, CameraMoveMode tweenMoveMode)
  1067. {
  1068. if (tweenSpeedRate.FEqual(0))
  1069. tweenSpeedRate = 1f;
  1070. CurrentCameraMode = CameraMode.Camera_TweeningMove;
  1071. moveMode = tweenMoveMode;
  1072. toPosition = targetPosition;
  1073. toFocus = targetFocus;
  1074. toFov = targetFov;
  1075. //DebugHelper.LogError("tween from11 {0}, {1}, {2} to {3}, {4}, {5}, has set : {6}", currentPosition, currentFocus, currentFov, toPosition, toFocus, toFov, hasSetCamera);
  1076. while (!IsCurrentCloseToTarget)
  1077. yield return 1;
  1078. RestoreModeAfterSpecialCamera();
  1079. }
  1080. CameraMode modeBackupBeforeSpecialCamera;
  1081. float moveSpeedBeforeSpecialCamera;
  1082. float rotSpeedBeforeSpecialCamera;
  1083. float fovSpeedBeforeSpecialCamera;
  1084. Vector3 posBackupBeforeSpecialCamera;
  1085. Vector3 rotBackupBeforeSpecialCamera;
  1086. float fovBackupBeforeSpecialCamera;
  1087. void BackupModeBeforeSpecialCamera()
  1088. {
  1089. modeBackupBeforeSpecialCamera = CurrentCameraMode;
  1090. moveSpeedBeforeSpecialCamera = MoveSpeed;
  1091. rotSpeedBeforeSpecialCamera = RotSpeed;
  1092. fovSpeedBeforeSpecialCamera = FovSpeed;
  1093. posBackupBeforeSpecialCamera = CamPosition;
  1094. rotBackupBeforeSpecialCamera = CamEulerAngle;
  1095. fovBackupBeforeSpecialCamera = CamFov;
  1096. }
  1097. void RestoreModeAfterSpecialCamera()
  1098. {
  1099. CurrentCameraMode = modeBackupBeforeSpecialCamera;
  1100. MoveSpeed = moveSpeedBeforeSpecialCamera;
  1101. RotSpeed = rotSpeedBeforeSpecialCamera;
  1102. FovSpeed = fovSpeedBeforeSpecialCamera;
  1103. CamPosition = posBackupBeforeSpecialCamera;
  1104. CamEulerAngle = rotBackupBeforeSpecialCamera;
  1105. CamFov = fovBackupBeforeSpecialCamera;
  1106. }
  1107. void ReadyForSpecailCamera()
  1108. {
  1109. if (specialCameraCoroutine != null && mIsDoingSpecialCamera)
  1110. {
  1111. BattleMgr.Instance.StopCoroutine(specialCameraCoroutine);
  1112. RestoreModeAfterSpecialCamera();
  1113. }
  1114. BackupModeBeforeSpecialCamera();
  1115. }
  1116. #endregion
  1117. }