Billboard.cs 4.1 KB

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