CameraMgr.cs 973 B

1234567891011121314151617181920212223242526272829303132333435
  1. using DG.Tweening;
  2. using FairyGUI;
  3. using UnityEngine;
  4. namespace ET.Client
  5. {
  6. [FriendOfAttribute(typeof(ET.Client.GlobalViewComponent))]
  7. public static class CameraMgr
  8. {
  9. //相机跟随主角
  10. public static void FollowMe(Vector3 pos)
  11. {
  12. var camera = Camera.main;
  13. pos.x += 7;
  14. pos.y = 15;
  15. pos.z -= 25;
  16. camera.transform.position = pos;
  17. }
  18. private static bool bShaking = false;
  19. public static void ShakeMe(float shakeTime, Vector3 shakeStength)
  20. {
  21. if (bShaking) return;
  22. bShaking = true;
  23. Transform trans = GlobalViewComponent.Instance.BattleCamera.transform;
  24. Tweener tweener = trans.DOShakePosition(shakeTime, shakeStength);
  25. tweener.OnComplete<Tweener>(() =>
  26. {
  27. trans.localPosition = Vector3.zero;
  28. bShaking = false;
  29. });
  30. }
  31. }
  32. }