Billboard.cs 3.1 KB

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