using System; using I2.Loc; using UnityEngine; using wf; public class MouseExposition : MonoBehaviour { public static MouseExposition GetObject() { if (GameObject.Find("UI Root/MouseExposition") != null) { return GameObject.Find("UI Root/MouseExposition").GetComponent(); } GameObject gameObject = Utility.CreatePrefab(GameObject.Find("UI Root"), "System/Prefab/MouseExposition", true); gameObject.name = gameObject.name.Replace("(Clone)", string.Empty); MouseExposition component = gameObject.GetComponent(); component.text = string.Empty; component.visible = true; GameObject gameObject2 = new GameObject(); gameObject2.transform.SetParent(gameObject.transform); component.dummy_object_ = gameObject2; return gameObject.GetComponent(); } private void Awake() { if (this.sprite_ != null) { return; } this.camera_ = GameObject.Find("UI Root/Camera").GetComponent(); this.sprite_ = base.GetComponentInChildren(); this.label_ = base.GetComponentInChildren(); this.visible_ = true; this.UpdateAlpha(0f); } public void Update() { if (!GameMain.Instance.VRMode) { Vector3 vector = this.camera_.ScreenToWorldPoint(Input.mousePosition); vector = base.transform.parent.InverseTransformPoint(vector); vector.z = 0f; vector.y -= (float)(this.sprite_.height + 15); vector.x += 10f; base.transform.localPosition = vector; } else { base.transform.localPosition = Vector3.zero; } if (!string.IsNullOrEmpty(this.label_.text) && this.sprite_.alpha < 1f) { if (base.GetComponent() == null) { iTween.ValueTo(base.gameObject, iTween.Hash(new object[] { "easetype", iTween.EaseType.easeOutCubic, "from", this.sprite_.alpha, "to", 1, "time", MouseExposition.kFadeTime, "onupdate", "UpdateAlpha" })); } } else if (string.IsNullOrEmpty(this.label_.text) && 0f < this.sprite_.alpha && base.GetComponent() == null) { iTween.ValueTo(base.gameObject, iTween.Hash(new object[] { "easetype", iTween.EaseType.easeOutCubic, "from", this.sprite_.alpha, "to", 0, "time", MouseExposition.kFadeTime, "onupdate", "UpdateAlpha" })); } } public void SetText(string draw_text, float time) { this.text = draw_text; if (!string.IsNullOrEmpty(this.label_.text) && this.sprite_.alpha < 1f) { if (base.GetComponent() == null) { iTween.ValueTo(base.gameObject, iTween.Hash(new object[] { "easetype", iTween.EaseType.easeOutCubic, "from", this.sprite_.alpha, "to", 1, "time", MouseExposition.kFadeTime, "onupdate", "UpdateAlpha" })); } } else if (string.IsNullOrEmpty(this.label_.text) && 0f < this.sprite_.alpha && base.GetComponent() == null) { iTween.ValueTo(base.gameObject, iTween.Hash(new object[] { "easetype", iTween.EaseType.easeOutCubic, "from", this.sprite_.alpha, "to", 0, "time", MouseExposition.kFadeTime, "onupdate", "UpdateAlpha" })); } iTween.ValueTo(base.gameObject, iTween.Hash(new object[] { "easetype", iTween.EaseType.linear, "from", 0, "to", 1, "time", time, "onUpdate", "OnUpdateDummy", "onComplete", "OnComplete" })); } public void OnUpdateDummy() { } public void OnComplete() { this.text = string.Empty; } public string textFromLanguageTerm { set { string translation = LocalizationManager.GetTranslation(value, true, 0, true, false, null, null); if (!string.IsNullOrEmpty(translation)) { this.text = translation; } else { this.text = Utility.GetTermLastWord(value); } } } public string text { get { return this.label_.text; } set { this.label_.text = value; this.label_.width = 0; this.label_.MakePixelPerfect(); this.sprite_.width = this.label_.width + 15; if (!this.visible_) { return; } iTween.Stop(base.gameObject); iTween[] components = base.GetComponents(); for (int i = 0; i < components.Length; i++) { UnityEngine.Object.DestroyImmediate(components[i]); } } } public bool visible { get { return base.gameObject.activeSelf; } set { this.visible_ = value; if (!this.visible_) { iTween.Stop(base.gameObject); iTween[] componentsInChildren = base.GetComponentsInChildren(); for (int i = 0; i < componentsInChildren.Length; i++) { UnityEngine.Object.DestroyImmediate(componentsInChildren[i]); } this.UpdateAlpha(0f); } } } private void UpdateAlpha(float value) { this.sprite_.alpha = value; this.label_.alpha = value; float num = wf.Math.RoundMinMax(0.5f + value, 0f, 1f); this.sprite_.transform.localScale = new Vector2(num, num); } private static float kFadeTime = 0.3f; private Camera camera_; private UISprite sprite_; private UILabel label_; private bool visible_; private GameObject dummy_object_; }