using System; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; public class VRMiniGameScoreBoard : MonoBehaviour { public int score { get { return this.m_Score; } set { if (this.m_Score != value) { this.m_Score = value; } } } public int life { get { return this.m_Life; } set { if (this.m_Life != value) { this.m_Life = value; this.m_TextLife.text = "残弾数:" + this.m_Life.ToString(); } } } public static VRMiniGameScoreBoard Create(Vector3 WorldPos, Quaternion Qt) { VRMiniGameScoreBoard vrminiGameScoreBoard = UnityEngine.Object.FindObjectOfType(); GameObject gameObject; if (!vrminiGameScoreBoard) { string path = "SceneVRCommunication/Tablet/MiniGameScoreBoard"; UnityEngine.Object original = Resources.Load(path); gameObject = (UnityEngine.Object.Instantiate(original, WorldPos, Qt) as GameObject); } else { gameObject = vrminiGameScoreBoard.gameObject; } gameObject.GetComponent().Init(); gameObject.GetComponent().FadeIn(); return gameObject.GetComponent(); } private void Init() { this.m_ParentPlayingUI.gameObject.SetActive(true); this.m_ParentResultUI.gameObject.SetActive(false); this.score = 0; this.life = 10; } private void Update() { int num = this.m_Score - this.m_CalculatingScore; if (num > 10) { this.m_CalculatingScore++; } else { if (num <= 0) { return; } this.m_CalculatingScore++; } this.m_TextScore.text = this.m_CalculatingScore.ToString("00"); } private void OnEnable() { this.m_TextScore.text = this.m_Score.ToString("00"); this.m_TextLife.text = "残弾数:" + this.m_Life.ToString(); } public void Result(string message, UnityAction callback) { this.m_ParentResultUI.gameObject.SetActive(true); this.m_ParentPlayingUI.gameObject.SetActive(false); this.m_TextResultMessage.text = message; UICanvasFade fade = base.GetComponent(); this.m_ButtonExit.onClick.RemoveAllListeners(); this.m_ButtonExit.onClick.AddListener(delegate() { fade.FadeOut(fade.fadeTime, fade.isTimeScaling, delegate() { callback(); }); }); } [SerializeField] private RectTransform m_ParentPlayingUI; [SerializeField] private Text m_TextScore; [SerializeField] private Text m_TextLife; [SerializeField] private RectTransform m_ParentResultUI; [SerializeField] private Text m_TextResultMessage; [SerializeField] private Button m_ButtonExit; [SerializeField] private int m_Score; private int m_CalculatingScore; [SerializeField] private int m_Life = 10; }