GameResultView.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using System;
  6. using UnityEngine.SceneManagement;
  7. public class GameResultView : MonoBehaviour
  8. {
  9. [SerializeField] Text gameName;
  10. [SerializeField] Text hour;
  11. [SerializeField] Text min;
  12. [SerializeField] Text second;
  13. [SerializeField] Text shootCount;
  14. [SerializeField] Text calories;
  15. [SerializeField] GameObject ArrowInfo;
  16. [SerializeField] GameObject GunInfo;
  17. // Start is called before the first frame update
  18. public Action OnBackClicked;
  19. void Start()
  20. {
  21. SimulateMouseController.ins?.AddOpenLocker(this);
  22. }
  23. void OnDestroy()
  24. {
  25. SimulateMouseController.ins?.RemoveOpenLocker(this);
  26. }
  27. public void setGameResultInfo(string gameNameID, int time, int shootCount)
  28. {
  29. //this.gameName.text = gameName;
  30. var tal2 = this.gameName.GetComponent<TextAutoLanguage2>();
  31. tal2.SetTextKey(gameNameID);
  32. int hour = time / 3600;
  33. int minute = (time - hour * 3600) / 60;
  34. if (minute < 0) minute = 0;
  35. int second = time % 60;
  36. if (second < 0) second = 0;
  37. this.hour.text = string.Format("{0}", hour);
  38. this.min.text = string.Format("{0}", minute);
  39. this.second.text = string.Format("{0}", second);
  40. this.shootCount.text = shootCount.ToString();
  41. // 0.444/2.22=0.2 枪=0.444*0.2 = 0.0888;
  42. if (GlobalData.MyDeviceMode == DeviceMode.Gun)
  43. {
  44. ArrowInfo.SetActive(false);
  45. GunInfo.SetActive(true);
  46. this.calories.text = (shootCount * 0.0888f).ToString();
  47. }
  48. else {
  49. ArrowInfo.SetActive(true);
  50. GunInfo.SetActive(false);
  51. this.calories.text = (shootCount * 0.444f).ToString();
  52. }
  53. }
  54. public void OnClick_Back()
  55. {
  56. AudioMgr.ins.PlayBtn();
  57. OnBackClicked?.Invoke();
  58. //ViewManager2.RemoveView(ViewManager2.Path_GameResultView);
  59. }
  60. //这个脚本存在时候。任何切换操作都直接处理删除
  61. void OnSceneUnloaded(Scene scene)
  62. {
  63. ViewManager2.HideView(ViewManager2.Path_GameResultView);
  64. }
  65. void OnEnable()
  66. {
  67. SceneManager.sceneUnloaded += OnSceneUnloaded;
  68. }
  69. void OnDisable()
  70. {
  71. SceneManager.sceneUnloaded -= OnSceneUnloaded;
  72. }
  73. }