TimeLimitGameView.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using UnityEngine.SceneManagement;
  6. /* 限时模式的游戏界面 */
  7. public class TimeLimitGameView : MonoBehaviour
  8. {
  9. public Text nickNameTxt;
  10. public Text highestScoreTxt;
  11. public Text currentScoreTxt;
  12. public Text timeTxt;
  13. TimeLimitGameMode gameMode;
  14. public static TimeLimitGameView ins;
  15. void Start()
  16. {
  17. ins = this;
  18. gameMode = (TimeLimitGameMode) GameMgr.ins.gameMode;
  19. //nickNameTxt.text = LoginMgr.myUserInfo.nickname;
  20. if (GlobalData.pkMatchType == PKMatchType.None && UserSettings.ins.trainMode) {
  21. timeTxt.transform.parent.gameObject.SetActive(false);
  22. }
  23. }
  24. void OnDestroy()
  25. {
  26. if (ins == this) ins = null;
  27. }
  28. void Update()
  29. {
  30. timeTxt.text = gameMode.GetTimeStr();
  31. currentScoreTxt.text = gameMode.score.ToString($"f{CommonConfig.ringsPrecision}");
  32. }
  33. public void RenderHighestScoreByDistance(int distance)
  34. {
  35. float highestScore = 0;
  36. string distanceStr = distance.ToString();
  37. if (LoginMgr.myUserInfo.timeLimitGameScores.ContainsKey(distanceStr)) {
  38. highestScore = LoginMgr.myUserInfo.timeLimitGameScores[distanceStr];
  39. }
  40. highestScoreTxt.text = highestScore.ToString($"f{CommonConfig.ringsPrecision}");
  41. }
  42. }