Billboard.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. private float arrowSpeed;
  10. private float arrowSpeedScale = 1;
  11. public static Billboard ins;
  12. void Awake() {
  13. ins = this;
  14. }
  15. void OnDestroy() {
  16. if (ins == this) ins = null;
  17. }
  18. /**speed m/s */
  19. public void SetArrowSpeed(float value) {
  20. //转km/h
  21. this.arrowSpeed = value * 3600f / 1000f;
  22. }
  23. public void SetArrowSpeedScale(float value) {
  24. this.arrowSpeedScale = value;
  25. }
  26. public void ShowSpeed() {
  27. if (speedText) {
  28. speedText.text = (this.arrowSpeed * this.arrowSpeedScale).ToString($"f{CommonConfig.arrowSpeedPrecision}");
  29. }
  30. }
  31. public void SetShootSpeedText(string text) {
  32. if (speedText) {
  33. speedText.text = text;
  34. }
  35. }
  36. public string GetShootSpeedText() {
  37. return speedText.text;
  38. }
  39. }