Billboard.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using TMPro;
  5. /* 静止靶场景的小黑板 */
  6. public class Billboard : MonoBehaviour
  7. {
  8. public TextMeshProUGUI speedText;
  9. public TextMeshProUGUI speedLabel;
  10. private float arrowSpeed;
  11. private float arrowSpeedScale = 1;
  12. public static Billboard ins;
  13. void Awake() {
  14. ins = this;
  15. if (TextAutoLanguage2.GetLanguage() == LanguageEnum.Chinese) {
  16. speedLabel.transform.localPosition = new Vector3(-0.08f, 2.95f, -0.1f);
  17. speedLabel.transform.localScale = new Vector3(0.0653898f, 0.1120968f, 0.93414f);
  18. speedLabel.text = "速度 千米/小时";
  19. speedText.transform.localPosition = new Vector3(-0.85f, 2.86f, -0.1f);
  20. } else {
  21. speedLabel.transform.localPosition = new Vector3(-0.06f, 2.95f, -0.1f);
  22. speedLabel.transform.localScale = new Vector3(0.0535241f, 0.0917556f, 0.76463f);
  23. speedLabel.text = "Arrow Speed kmph";
  24. speedText.transform.localPosition = new Vector3(0.84f, 2.95f, -0.1f);
  25. }
  26. }
  27. void OnDestroy() {
  28. if (ins == this) ins = null;
  29. }
  30. /**speed m/s */
  31. public void SetArrowSpeed(float value) {
  32. //转km/h
  33. this.arrowSpeed = value * 3600f / 1000f;
  34. }
  35. public void SetArrowSpeedScale(float value) {
  36. this.arrowSpeedScale = value;
  37. }
  38. public void ShowSpeed() {
  39. if (speedText) {
  40. speedText.text = (this.arrowSpeed * this.arrowSpeedScale).ToString($"f{CommonConfig.arrowSpeedPrecision}");
  41. }
  42. }
  43. public void SetShootSpeedText(string text) {
  44. if (speedText) {
  45. speedText.text = text;
  46. }
  47. }
  48. public string GetShootSpeedText() {
  49. return speedText.text;
  50. }
  51. }