CameraMgr.cs 932 B

123456789101112131415161718192021222324252627282930313233
  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.y = 7;
  13. pos.z -= 15;
  14. camera.transform.position = pos;
  15. }
  16. private static bool bShaking = false;
  17. public static void ShakeMe(float shakeTime, Vector3 shakeStength)
  18. {
  19. if (bShaking) return;
  20. bShaking = true;
  21. Transform trans = GlobalViewComponent.Instance.BattleCamera.transform;
  22. Tweener tweener = trans.DOShakePosition(shakeTime, shakeStength);
  23. tweener.OnComplete<Tweener>(() =>
  24. {
  25. trans.localPosition = Vector3.zero;
  26. bShaking = false;
  27. });
  28. }
  29. }
  30. }