TimeLimitGameView.cs 1.3 KB

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