TimeLimitGameView.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. }
  21. void Update()
  22. {
  23. timeTxt.text = gameMode.GetTimeStr();
  24. currentScoreTxt.text = gameMode.score.ToString($"f{CommonConfig.ringsPrecision}");
  25. }
  26. public void RenderHighestScoreByDistance(int distance)
  27. {
  28. float highestScore = 0;
  29. string distanceStr = distance.ToString();
  30. System.Object highestScoreObj = LoginMgr.myUserInfo.timeLimitGameHighestScores[distanceStr];
  31. if (highestScoreObj != null) highestScore = float.Parse(highestScoreObj.ToString());
  32. highestScoreTxt.text = highestScore.ToString($"f{CommonConfig.ringsPrecision}");
  33. }
  34. }