Billboard.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 TextMeshProUGUI speedText2;
  13. public TextMeshProUGUI speedLabel2;
  14. private float arrowSpeed2;
  15. private float arrowSpeedScale2 = 1;
  16. public static Billboard ins;
  17. void Awake() {
  18. ins = this;
  19. if (TextAutoLanguage2.GetLanguage() == LanguageEnum.Chinese) {
  20. speedLabel2.transform.localPosition = speedLabel.transform.localPosition = new Vector3(-0.08f, 2.95f, -0.1f);
  21. speedLabel2.transform.localScale = speedLabel.transform.localScale = new Vector3(0.0653898f, 0.1120968f, 0.93414f);
  22. speedLabel2.text = speedLabel.text = "速度 千米/小时";
  23. speedText2.transform.localPosition = speedText.transform.localPosition = new Vector3(-0.85f, 2.86f, -0.1f);
  24. } else {
  25. speedLabel2.transform.localPosition = speedLabel.transform.localPosition = new Vector3(-0.06f, 2.95f, -0.1f);
  26. speedLabel2.transform.localScale = speedLabel.transform.localScale = new Vector3(0.0535241f, 0.0917556f, 0.76463f);
  27. speedLabel2.text = speedLabel.text = "Arrow Speed kmph";
  28. speedText2.transform.localPosition = speedText.transform.localPosition = new Vector3(0.84f, 2.95f, -0.1f);
  29. }
  30. }
  31. void OnDestroy() {
  32. if (ins == this) ins = null;
  33. }
  34. /**speed m/s */
  35. public void SetArrowSpeed(float value) {
  36. //转km/h
  37. this.arrowSpeed = value * 3600f / 1000f;
  38. }
  39. public void SetArrowSpeedScale(float value) {
  40. this.arrowSpeedScale = value;
  41. }
  42. public void ShowSpeed() {
  43. if (speedText) {
  44. speedText.text = (this.arrowSpeed * this.arrowSpeedScale).ToString($"f{CommonConfig.arrowSpeedPrecision}");
  45. }
  46. }
  47. public void SetShootSpeedText(string text) {
  48. if (speedText) {
  49. speedText.text = text;
  50. }
  51. }
  52. public string GetShootSpeedText() {
  53. return speedText.text;
  54. }
  55. /**speed m/s */
  56. public void Second_SetArrowSpeed(float value)
  57. {
  58. //转km/h
  59. this.arrowSpeed2 = value * 3600f / 1000f;
  60. }
  61. public void Second_SetArrowSpeedScale(float value)
  62. {
  63. this.arrowSpeedScale2 = value;
  64. }
  65. public void Second_ShowSpeed()
  66. {
  67. if (speedText2)
  68. {
  69. speedText2.text = (this.arrowSpeed2 * this.arrowSpeedScale2).ToString($"f{CommonConfig.arrowSpeedPrecision}");
  70. }
  71. }
  72. public void Second_SetShootSpeedText(string text)
  73. {
  74. if (speedText2)
  75. {
  76. speedText2.text = text;
  77. }
  78. }
  79. public string Second_GetShootSpeedText()
  80. {
  81. return speedText2.text;
  82. }
  83. }