using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using System; using UnityEngine.SceneManagement; public class GameResultView : MonoBehaviour { [SerializeField] Text gameName; [SerializeField] Text hour; [SerializeField] Text min; [SerializeField] Text second; [SerializeField] Text shootCount; [SerializeField] Text calories; [SerializeField] GameObject ArrowInfo; [SerializeField] GameObject GunInfo; // Start is called before the first frame update public Action OnBackClicked; void Start() { SimulateMouseController.ins?.AddOpenLocker(this); } void OnDestroy() { SimulateMouseController.ins?.RemoveOpenLocker(this); } public void setGameResultInfo(string gameNameID, int time, int shootCount) { //this.gameName.text = gameName; var tal2 = this.gameName.GetComponent(); tal2.SetTextKey(gameNameID); int hour = time / 3600; int minute = (time - hour * 3600) / 60; if (minute < 0) minute = 0; int second = time % 60; if (second < 0) second = 0; this.hour.text = string.Format("{0}", hour); this.min.text = string.Format("{0}", minute); this.second.text = string.Format("{0}", second); this.shootCount.text = shootCount.ToString(); // 0.444/2.22=0.2 枪=0.444*0.2 = 0.0888; if (GlobalData.MyDeviceMode == DeviceMode.Gun) { ArrowInfo.SetActive(false); GunInfo.SetActive(true); this.calories.text = (shootCount * 0.0888f).ToString(); } else { ArrowInfo.SetActive(true); GunInfo.SetActive(false); this.calories.text = (shootCount * 0.444f).ToString(); } } public void OnClick_Back() { AudioMgr.ins.PlayBtn(); OnBackClicked?.Invoke(); //ViewManager2.RemoveView(ViewManager2.Path_GameResultView); } //这个脚本存在时候。任何切换操作都直接处理删除 void OnSceneUnloaded(Scene scene) { ViewManager2.HideView(ViewManager2.Path_GameResultView); } void OnEnable() { SceneManager.sceneUnloaded += OnSceneUnloaded; } void OnDisable() { SceneManager.sceneUnloaded -= OnSceneUnloaded; } }