XftEvent.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using System;
  2. using UnityEngine;
  3. namespace Xft
  4. {
  5. public class XftEvent
  6. {
  7. public XftEvent(XEventType type, XftEventComponent owner)
  8. {
  9. this.m_type = type;
  10. this.m_owner = owner;
  11. }
  12. public Camera MyCamera
  13. {
  14. get
  15. {
  16. return this.m_owner.Owner.MyCamera;
  17. }
  18. }
  19. protected Camera FindMyCamera()
  20. {
  21. int num = 1 << this.m_owner.gameObject.layer;
  22. Camera[] array = UnityEngine.Object.FindObjectsOfType(typeof(Camera)) as Camera[];
  23. int i = 0;
  24. int num2 = array.Length;
  25. while (i < num2)
  26. {
  27. Camera camera = array[i];
  28. if ((camera.cullingMask & num) != 0)
  29. {
  30. return camera;
  31. }
  32. i++;
  33. }
  34. UnityEngine.Debug.LogError("can't find proper camera for event:" + this.m_type);
  35. return null;
  36. }
  37. public bool CanUpdate
  38. {
  39. get
  40. {
  41. return this.m_canUpdate;
  42. }
  43. set
  44. {
  45. this.m_canUpdate = value;
  46. }
  47. }
  48. public virtual void OnBegin()
  49. {
  50. this.CanUpdate = true;
  51. }
  52. public virtual void Initialize()
  53. {
  54. }
  55. public virtual void Update(float deltaTime)
  56. {
  57. }
  58. public virtual void Reset()
  59. {
  60. this.m_elapsedTime = 0f;
  61. this.CanUpdate = false;
  62. }
  63. protected XEventType m_type;
  64. protected XftEventComponent m_owner;
  65. protected float m_elapsedTime;
  66. protected bool m_canUpdate;
  67. protected Camera m_myCamera;
  68. }
  69. }