123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- 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<GUITexture>();
- 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<GUITexture>();
- 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_;
- }
|