LoadIcon.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. using System;
  2. using UnityEngine;
  3. public class LoadIcon : MonoBehaviour
  4. {
  5. public void Awake()
  6. {
  7. if (!GameMain.Instance.VRMode || GameMain.Instance.VRDummyMode)
  8. {
  9. this.screen_overlay_ = GameMain.Instance.MainCamera.m_FadeTargetCamera;
  10. this.gui_tex_ = base.GetComponent<GUITexture>();
  11. this.Update();
  12. }
  13. }
  14. public void NextLoadIcontImmediatelyDisplay()
  15. {
  16. this.next_immediately_display_ = true;
  17. }
  18. public void Update()
  19. {
  20. if (GameMain.Instance.VRMode && !GameMain.Instance.VRDummyMode)
  21. {
  22. return;
  23. }
  24. bool flag = GameMain.Instance.CharacterMgr.IsBusy() || this.force_draw_new;
  25. if (!this.draw_enabled_ && (this.force_draw_ || this.screen_overlay_.intensity == 0f) && flag)
  26. {
  27. this.draw_enabled_ = true;
  28. this.wait_frame_count_ = 0;
  29. if (this.next_immediately_display_)
  30. {
  31. this.wait_frame_count_ = this.WaitFrame;
  32. }
  33. this.next_immediately_display_ = false;
  34. }
  35. else if (this.draw_enabled_ && ((this.force_draw_ && !flag) || (!this.force_draw_ && (!flag || this.screen_overlay_.intensity == 1f))))
  36. {
  37. this.draw_enabled_ = false;
  38. this.wait_frame_count_ = 0;
  39. this.next_immediately_display_ = false;
  40. }
  41. if (!this.draw_enabled_)
  42. {
  43. return;
  44. }
  45. this.wait_frame_count_++;
  46. if (this.wait_frame_count_ < this.WaitFrame)
  47. {
  48. return;
  49. }
  50. bool flag2 = this.UpdateRenderRect();
  51. this.frame_count_++;
  52. int num = (int)(Time.time * this.FramePerSecond);
  53. num %= this.FrameTextures.Length;
  54. if (this.tex_index_ != num || flag2)
  55. {
  56. this.tex_index_ = num;
  57. if (this.tex_index_ == this.FrameTextures.Length - 1)
  58. {
  59. this.frame_count_ = 0;
  60. }
  61. num %= this.FrameTextures.Length;
  62. GUITexture component = base.GetComponent<GUITexture>();
  63. component.texture = this.FrameTextures[this.tex_index_];
  64. Vector2 vector = new Vector2((float)component.texture.width, (float)component.texture.height);
  65. if (!this.is_center_draw)
  66. {
  67. this.render_rect = new Rect((float)Screen.width - vector.x - 20f, (float)Screen.height - vector.y - 10f, vector.x, vector.y);
  68. }
  69. else
  70. {
  71. this.render_rect = new Rect((float)Screen.width * 0.5f - vector.x - 20f, (float)Screen.height * 0.5f - vector.y - 10f, vector.x, vector.y);
  72. }
  73. }
  74. }
  75. public void SetForceDraw(bool value)
  76. {
  77. this.force_draw_ = value;
  78. }
  79. public bool force_draw_new { get; set; }
  80. public bool is_center_draw { get; set; }
  81. public void OnGUI()
  82. {
  83. if (GameMain.Instance.VRMode && !GameMain.Instance.VRDummyMode)
  84. {
  85. return;
  86. }
  87. if (!this.draw_enabled_ || this.wait_frame_count_ < this.WaitFrame)
  88. {
  89. return;
  90. }
  91. GUI.DrawTexture(this.render_rect, this.gui_tex_.texture);
  92. }
  93. public bool UpdateRenderRect()
  94. {
  95. if (GameMain.Instance.VRMode && !GameMain.Instance.VRDummyMode)
  96. {
  97. return false;
  98. }
  99. if (this.window_size_.x != (float)Screen.width || this.window_size_.y != (float)Screen.height)
  100. {
  101. this.window_size_.x = (float)Screen.width;
  102. this.window_size_.y = (float)Screen.height;
  103. return true;
  104. }
  105. return false;
  106. }
  107. public Texture2D[] FrameTextures;
  108. public float FramePerSecond = 10f;
  109. public int WaitFrame = 3;
  110. private int wait_frame_count_;
  111. private FadeInAndFadeOutOnGUI screen_overlay_;
  112. private GUITexture gui_tex_;
  113. private Rect render_rect = default(Rect);
  114. private Vector2 window_size_ = Vector2.zero;
  115. private int frame_count_;
  116. private int tex_index_ = -1;
  117. private bool draw_enabled_;
  118. private bool next_immediately_display_;
  119. private bool force_draw_;
  120. }