Billboard.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. //子弹部分
  17. public BulletManager bulletManager;
  18. //是否是子弹初始的状态,
  19. public bool isBulletStatus { get; set; } = false;
  20. [SerializeField] private GameObject canvasBB;
  21. public static Billboard ins;
  22. void Awake()
  23. {
  24. ins = this;
  25. if (TextAutoLanguage2.GetLanguage() == LanguageEnum.Chinese)
  26. {
  27. speedLabel.transform.localPosition = new Vector3(-0.08f, 2.95f, -0.1f);
  28. speedLabel.transform.localScale = new Vector3(0.0653898f, 0.1120968f, 0.93414f);
  29. speedLabel.text = "速度 千米/小时";
  30. speedText.transform.localPosition = new Vector3(-0.85f, 2.86f, -0.1f);
  31. }
  32. else
  33. {
  34. speedLabel.transform.localPosition = new Vector3(-0.06f, 2.95f, -0.1f);
  35. speedLabel.transform.localScale = new Vector3(0.0535241f, 0.0917556f, 0.76463f);
  36. speedLabel.text = "Arrow Speed kmph";
  37. speedText.transform.localPosition = new Vector3(0.84f, 2.95f, -0.1f);
  38. }
  39. if (speedLabel2 != null)
  40. {
  41. speedLabel2.transform.localPosition = speedLabel.transform.localPosition;
  42. speedLabel2.transform.localScale = speedLabel.transform.localScale;
  43. speedLabel2.text = speedLabel.text;
  44. speedText2.transform.localPosition = speedText.transform.localPosition;
  45. }
  46. //枪模式连接的情况下显示子弹
  47. isBulletStatus = BluetoothAim.ins && BluetoothAim.ins.isMainConnectToGun();
  48. if (isBulletStatus) {
  49. canvasBB.transform.localPosition = new Vector3(0, -1.2f, 0);
  50. bulletManager.gameObject.SetActive(true);
  51. }
  52. }
  53. void OnDestroy()
  54. {
  55. if (ins == this) ins = null;
  56. }
  57. /**speed m/s */
  58. public void SetArrowSpeed(float value)
  59. {
  60. //转km/h
  61. this.arrowSpeed = value * 3600f / 1000f;
  62. }
  63. public void SetArrowSpeedScale(float value)
  64. {
  65. this.arrowSpeedScale = value;
  66. }
  67. public void ShowSpeed()
  68. {
  69. if (speedText)
  70. {
  71. speedText.text = (this.arrowSpeed * this.arrowSpeedScale).ToString($"f{CommonConfig.arrowSpeedPrecision}");
  72. }
  73. }
  74. public void SetShootSpeedText(string text)
  75. {
  76. if (speedText)
  77. {
  78. speedText.text = text;
  79. }
  80. }
  81. public string GetShootSpeedText()
  82. {
  83. return speedText.text;
  84. }
  85. /**speed m/s */
  86. public void Second_SetArrowSpeed(float value)
  87. {
  88. //转km/h
  89. this.arrowSpeed2 = value * 3600f / 1000f;
  90. }
  91. public void Second_SetArrowSpeedScale(float value)
  92. {
  93. this.arrowSpeedScale2 = value;
  94. }
  95. public void Second_ShowSpeed()
  96. {
  97. if (speedText2)
  98. {
  99. speedText2.text = (this.arrowSpeed2 * this.arrowSpeedScale2).ToString($"f{CommonConfig.arrowSpeedPrecision}");
  100. }
  101. }
  102. public void Second_SetShootSpeedText(string text)
  103. {
  104. if (speedText2)
  105. {
  106. speedText2.text = text;
  107. }
  108. }
  109. public string Second_GetShootSpeedText()
  110. {
  111. return speedText2.text;
  112. }
  113. }