CameraChase.cs 1014 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using System;
  2. using UnityEngine;
  3. public class CameraChase : MonoBehaviour
  4. {
  5. public void StartChase(bool f_bOnece, float f_fTime, Vector3 f_vWorldOffset)
  6. {
  7. this.m_bOnece = f_bOnece;
  8. this.m_fTime = f_fTime;
  9. this.m_fNowTime = 0f;
  10. this.m_camMain = GameMain.Instance.MainCamera;
  11. this.m_trMy = base.gameObject.transform;
  12. this.m_vWorldOffset = f_vWorldOffset;
  13. if (this.m_camMain != null)
  14. {
  15. this.m_camMain.SetTargetPos(this.m_trMy.position + this.m_vWorldOffset, true);
  16. }
  17. }
  18. public void OnDisable()
  19. {
  20. UnityEngine.Object.Destroy(this);
  21. }
  22. private void Update()
  23. {
  24. if (this.m_camMain != null)
  25. {
  26. this.m_camMain.SetTargetPos(this.m_trMy.position + this.m_vWorldOffset, true);
  27. }
  28. if (this.m_bOnece && this.m_fTime <= (this.m_fNowTime += Time.deltaTime))
  29. {
  30. UnityEngine.Object.Destroy(this);
  31. }
  32. }
  33. private bool m_bOnece = true;
  34. private float m_fTime;
  35. private float m_fNowTime;
  36. private CameraMain m_camMain;
  37. private Transform m_trMy;
  38. private Vector3 m_vWorldOffset;
  39. }