Billboard.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. private void Start()
  54. {
  55. if (GameMgr.HideBillboard) {
  56. gameObject.SetActive(false);
  57. GameMgr.HideBillboard = false;
  58. }
  59. }
  60. void OnDestroy()
  61. {
  62. if (ins == this) ins = null;
  63. }
  64. /**speed m/s */
  65. public void SetArrowSpeed(float value)
  66. {
  67. //转km/h
  68. this.arrowSpeed = value * 3600f / 1000f;
  69. }
  70. public void SetArrowSpeedScale(float value)
  71. {
  72. this.arrowSpeedScale = value;
  73. }
  74. public void ShowSpeed()
  75. {
  76. if (speedText)
  77. {
  78. speedText.text = (this.arrowSpeed * this.arrowSpeedScale).ToString($"f{CommonConfig.arrowSpeedPrecision}");
  79. }
  80. }
  81. public void SetShootSpeedText(string text)
  82. {
  83. if (speedText)
  84. {
  85. speedText.text = text;
  86. }
  87. }
  88. public string GetShootSpeedText()
  89. {
  90. return speedText.text;
  91. }
  92. /**speed m/s */
  93. public void Second_SetArrowSpeed(float value)
  94. {
  95. //转km/h
  96. this.arrowSpeed2 = value * 3600f / 1000f;
  97. }
  98. public void Second_SetArrowSpeedScale(float value)
  99. {
  100. this.arrowSpeedScale2 = value;
  101. }
  102. public void Second_ShowSpeed()
  103. {
  104. if (speedText2)
  105. {
  106. speedText2.text = (this.arrowSpeed2 * this.arrowSpeedScale2).ToString($"f{CommonConfig.arrowSpeedPrecision}");
  107. }
  108. }
  109. public void Second_SetShootSpeedText(string text)
  110. {
  111. if (speedText2)
  112. {
  113. speedText2.text = text;
  114. }
  115. }
  116. public string Second_GetShootSpeedText()
  117. {
  118. return speedText2.text;
  119. }
  120. }