GameResultView.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using System;
  6. public class GameResultView : MonoBehaviour
  7. {
  8. [SerializeField] Text gameName;
  9. [SerializeField] Text hour;
  10. [SerializeField] Text min;
  11. [SerializeField] Text second;
  12. [SerializeField] Text shootCount;
  13. [SerializeField] Text calories;
  14. [SerializeField] GameObject ArrowInfo;
  15. [SerializeField] GameObject GunInfo;
  16. // Start is called before the first frame update
  17. public Action OnBackClicked;
  18. void Start()
  19. {
  20. SimulateMouseController.ins?.AddOpenLocker(this);
  21. }
  22. void OnDestroy()
  23. {
  24. SimulateMouseController.ins?.RemoveOpenLocker(this);
  25. }
  26. public void setGameResultInfo(string gameNameID, int time, int shootCount)
  27. {
  28. //this.gameName.text = gameName;
  29. var tal2 = this.gameName.GetComponent<TextAutoLanguage2>();
  30. tal2.SetTextKey(gameNameID);
  31. int hour = time / 3600;
  32. int minute = (time - hour * 3600) / 60;
  33. if (minute < 0) minute = 0;
  34. int second = time % 60;
  35. if (second < 0) second = 0;
  36. this.hour.text = string.Format("{0}", hour);
  37. this.min.text = string.Format("{0}", minute);
  38. this.second.text = string.Format("{0}", second);
  39. this.shootCount.text = shootCount.ToString();
  40. // 0.444/2.22=0.2 ǹ=0.444*0.2 = 0.0888£»
  41. if (GlobalData.MyDeviceMode == DeviceMode.Gun)
  42. {
  43. ArrowInfo.SetActive(false);
  44. GunInfo.SetActive(true);
  45. this.calories.text = (shootCount * 0.0888f).ToString();
  46. }
  47. else {
  48. ArrowInfo.SetActive(true);
  49. GunInfo.SetActive(false);
  50. this.calories.text = (shootCount * 0.444f).ToString();
  51. }
  52. }
  53. public void OnClick_Back()
  54. {
  55. AudioMgr.ins.PlayBtn();
  56. OnBackClicked?.Invoke();
  57. ViewManager2.RemoveView(ViewManager2.Path_GameResultView);
  58. }
  59. }