ShowGameTime.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class ShowGameTime : MonoBehaviour
  6. {
  7. [SerializeField] Text playTimeText;
  8. [SerializeField] Text cointCountText;
  9. const long PayTimeCountDown = 60 * 1000;
  10. private void Start()
  11. {
  12. //StandaloneAPI.StartGameTimeCountDown();
  13. }
  14. // Update is called once per frame
  15. void Update()
  16. {
  17. //首页投币测试
  18. if (Input.GetKeyDown(KeyCode.Alpha7))
  19. {
  20. //投币接口测试
  21. StandaloneAPI.InsertCoint(1);
  22. }
  23. StandaloneAPI.DoGameTimeCountDown();
  24. playTimeText.text = string.Format("剩余时间{0}", GetTimeStr());
  25. if (UserSettings.ins != null) {
  26. // Debug.Log(StandaloneAPI.CoinCount + " " + UserSettings.ins.PerRoundCoin);
  27. cointCountText.text = string.Format("币:{0}/{1}", StandaloneAPI.CoinCount, UserSettings.ins.PerRoundCoin);
  28. }
  29. }
  30. string GetTimeStr()
  31. {
  32. long second = StandaloneAPI.GetGameTimeCountDown() / 1000;
  33. long minute = second / 60;
  34. second = second % 60;
  35. string str = second + "秒";
  36. if (minute > 0) str = minute + "分" + str;
  37. return str;
  38. }
  39. }