GameResultView.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. // Start is called before the first frame update
  15. public Action OnBackClicked;
  16. void Start()
  17. {
  18. SimulateMouseController.ins?.AddOpenLocker(this);
  19. }
  20. void OnDestroy()
  21. {
  22. SimulateMouseController.ins?.RemoveOpenLocker(this);
  23. }
  24. public void setGameResultInfo(string gameNameID, int time, int shootCount)
  25. {
  26. //this.gameName.text = gameName;
  27. var tal2 = this.gameName.GetComponent<TextAutoLanguage2>();
  28. tal2.SetTextKey(gameNameID);
  29. int hour = time / 3600;
  30. int minute = (time - hour * 3600) / 60;
  31. if (minute < 0) minute = 0;
  32. int second = time % 60;
  33. if (second < 0) second = 0;
  34. this.hour.text = string.Format("{0}", hour);
  35. this.min.text = string.Format("{0}", minute);
  36. this.second.text = string.Format("{0}", second);
  37. this.shootCount.text = shootCount.ToString();
  38. // 0.444/2.22=0.2 ǹ=0.444*0.2 = 0.0888£»
  39. if (GlobalData.MyDeviceMode == DeviceMode.Gun)
  40. {
  41. this.calories.text = (shootCount * 0.0888f).ToString();
  42. }
  43. else {
  44. this.calories.text = (shootCount * 0.444f).ToString();
  45. }
  46. }
  47. public void OnClick_Back()
  48. {
  49. AudioMgr.ins.PlayBtn();
  50. OnBackClicked?.Invoke();
  51. ViewManager2.RemoveView(ViewManager2.Path_GameResultView);
  52. }
  53. }