CameraMgr.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using DG.Tweening;
  2. using UnityEngine;
  3. namespace ET.Client
  4. {
  5. [FriendOfAttribute(typeof(ET.Client.GlobalViewComponent))]
  6. public static class CameraMgr
  7. {
  8. //相机跟随主角
  9. public static void FollowMe(Vector3 pos)
  10. {
  11. /*var camera = Camera.main;
  12. pos.x += 7;
  13. pos.y = 15;
  14. pos.z -= 25;
  15. camera.transform.position = pos;*/
  16. }
  17. private static bool bShaking = false;
  18. public static void ShakeMe(float shakeTime, Vector3 shakeStength)
  19. {
  20. if (bShaking) return;
  21. bShaking = true;
  22. Transform trans = GlobalViewComponent.Instance.BattleCamera.transform;
  23. Tweener tweener = trans.DOShakePosition(shakeTime, shakeStength);
  24. tweener.OnComplete<Tweener>(() =>
  25. {
  26. trans.localPosition = Vector3.zero;
  27. bShaking = false;
  28. });
  29. }
  30. public static Vector3 CarmeraPos()
  31. {
  32. return Camera.main.transform.position;
  33. }
  34. public static void DragCamera(Vector3 start, Vector3 end, float duration, System.Action endcb)
  35. {
  36. Transform trans = GlobalViewComponent.Instance.BattleCamera.transform;
  37. trans.position = start;
  38. var tweener = trans.DOMove(end, duration);
  39. tweener.OnComplete<Tweener>(() =>
  40. {
  41. endcb ?.Invoke();
  42. });
  43. }
  44. }
  45. }