using System; using UnityEngine; public class LoadIcon : MonoBehaviour { public void Awake() { if (!GameMain.Instance.VRMode || GameMain.Instance.VRDummyMode) { this.screen_overlay_ = GameMain.Instance.MainCamera.m_FadeTargetCamera; this.gui_tex_ = base.GetComponent(); this.Update(); } } public void NextLoadIcontImmediatelyDisplay() { this.next_immediately_display_ = true; } public void Update() { if (GameMain.Instance.VRMode && !GameMain.Instance.VRDummyMode) { return; } bool flag = GameMain.Instance.CharacterMgr.IsBusy() || this.force_draw_new; if (!this.draw_enabled_ && (this.force_draw_ || this.screen_overlay_.intensity == 0f) && flag) { this.draw_enabled_ = true; this.wait_frame_count_ = 0; if (this.next_immediately_display_) { this.wait_frame_count_ = this.WaitFrame; } this.next_immediately_display_ = false; } else if (this.draw_enabled_ && ((this.force_draw_ && !flag) || (!this.force_draw_ && (!flag || this.screen_overlay_.intensity == 1f)))) { this.draw_enabled_ = false; this.wait_frame_count_ = 0; this.next_immediately_display_ = false; } if (!this.draw_enabled_) { return; } this.wait_frame_count_++; if (this.wait_frame_count_ < this.WaitFrame) { return; } bool flag2 = this.UpdateRenderRect(); this.frame_count_++; int num = (int)(Time.time * this.FramePerSecond); num %= this.FrameTextures.Length; if (this.tex_index_ != num || flag2) { this.tex_index_ = num; if (this.tex_index_ == this.FrameTextures.Length - 1) { this.frame_count_ = 0; } num %= this.FrameTextures.Length; GUITexture component = base.GetComponent(); component.texture = this.FrameTextures[this.tex_index_]; Vector2 vector = new Vector2((float)component.texture.width, (float)component.texture.height); if (!this.is_center_draw) { this.render_rect = new Rect((float)Screen.width - vector.x - 20f, (float)Screen.height - vector.y - 10f, vector.x, vector.y); } else { 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); } } } public void SetForceDraw(bool value) { this.force_draw_ = value; } public bool force_draw_new { get; set; } public bool is_center_draw { get; set; } public void OnGUI() { if (GameMain.Instance.VRMode && !GameMain.Instance.VRDummyMode) { return; } if (!this.draw_enabled_ || this.wait_frame_count_ < this.WaitFrame) { return; } GUI.DrawTexture(this.render_rect, this.gui_tex_.texture); } public bool UpdateRenderRect() { if (GameMain.Instance.VRMode && !GameMain.Instance.VRDummyMode) { return false; } if (this.window_size_.x != (float)Screen.width || this.window_size_.y != (float)Screen.height) { this.window_size_.x = (float)Screen.width; this.window_size_.y = (float)Screen.height; return true; } return false; } public Texture2D[] FrameTextures; public float FramePerSecond = 10f; public int WaitFrame = 3; private int wait_frame_count_; private FadeInAndFadeOutOnGUI screen_overlay_; private GUITexture gui_tex_; private Rect render_rect = default(Rect); private Vector2 window_size_ = Vector2.zero; private int frame_count_; private int tex_index_ = -1; private bool draw_enabled_; private bool next_immediately_display_; private bool force_draw_; }