Billboard.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using TMPro;
  5. public class Billboard : MonoBehaviour
  6. {
  7. public TextMeshProUGUI speedText;
  8. private float arrowSpeed;
  9. private float arrowSpeedScale = 1;
  10. public static Billboard ins;
  11. void Awake() {
  12. ins = this;
  13. }
  14. void OnDestroy() {
  15. if (ins == this) ins = null;
  16. }
  17. /**speed m/s */
  18. public void SetArrowSpeed(float value) {
  19. //转km/h
  20. this.arrowSpeed = value * 3600f / 1000f;
  21. }
  22. public void SetArrowSpeedScale(float value) {
  23. this.arrowSpeedScale = value;
  24. }
  25. public void ShowSpeed() {
  26. if (speedText) {
  27. speedText.text = (this.arrowSpeed * this.arrowSpeedScale).ToString($"f{CommonConfig.arrowSpeedPrecision}");
  28. }
  29. }
  30. public void SetShootSpeedText(string text) {
  31. if (speedText) {
  32. speedText.text = text;
  33. }
  34. }
  35. public string GetShootSpeedText() {
  36. return speedText.text;
  37. }
  38. }