Billboard.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 (TextAutoLanguage.GetLanguage() == LanguageEnum.Chinese) {
  16. speedLabel.text = "速度 千米/时";
  17. Vector3 lpos = speedText.transform.localPosition;
  18. lpos.x = -0.61f;
  19. lpos.y = 2.86f;
  20. speedText.transform.localPosition = lpos;
  21. } else {
  22. speedLabel.text = "Speed KM/H";
  23. }
  24. }
  25. void OnDestroy() {
  26. if (ins == this) ins = null;
  27. }
  28. /**speed m/s */
  29. public void SetArrowSpeed(float value) {
  30. //转km/h
  31. this.arrowSpeed = value * 3600f / 1000f;
  32. }
  33. public void SetArrowSpeedScale(float value) {
  34. this.arrowSpeedScale = value;
  35. }
  36. public void ShowSpeed() {
  37. if (speedText) {
  38. speedText.text = (this.arrowSpeed * this.arrowSpeedScale).ToString($"f{CommonConfig.arrowSpeedPrecision}");
  39. }
  40. }
  41. public void SetShootSpeedText(string text) {
  42. if (speedText) {
  43. speedText.text = text;
  44. }
  45. }
  46. public string GetShootSpeedText() {
  47. return speedText.text;
  48. }
  49. }