123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- 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<VRMiniGameScoreBoard>();
- 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<VRMiniGameScoreBoard>().Init();
- gameObject.GetComponent<UICanvasFade>().FadeIn();
- return gameObject.GetComponent<VRMiniGameScoreBoard>();
- }
- 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<UICanvasFade>();
- 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;
- }
|