using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; /* 静止靶场景的小黑板 */ public class Billboard : MonoBehaviour { public TextMeshProUGUI speedText; public TextMeshProUGUI speedLabel; private float arrowSpeed; private float arrowSpeedScale = 1; public TextMeshProUGUI speedText2; public TextMeshProUGUI speedLabel2; private float arrowSpeed2; private float arrowSpeedScale2 = 1; //子弹部分 public BulletManager bulletManager; public BulletManager bulletManagerSecond; //是否是子弹初始的状态, public bool isBulletStatus { get; set; } = false; [SerializeField] private GameObject canvasBB; [SerializeField] private GameObject canvasBBSecond; public static Billboard ins; void Awake() { ins = this; if (TextAutoLanguage2.GetLanguage() == LanguageEnum.Chinese) { speedLabel.transform.localPosition = new Vector3(-0.08f, 2.95f, -0.1f); speedLabel.transform.localScale = new Vector3(0.0653898f, 0.1120968f, 0.93414f); speedLabel.text = "速度 千米/小时"; speedText.transform.localPosition = new Vector3(-0.85f, 2.86f, -0.1f); } else { speedLabel.transform.localPosition = new Vector3(-0.06f, 2.95f, -0.1f); speedLabel.transform.localScale = new Vector3(0.0535241f, 0.0917556f, 0.76463f); speedLabel.text = "Arrow Speed kmph"; speedText.transform.localPosition = new Vector3(0.84f, 2.95f, -0.1f); } if (speedLabel2 != null) { speedLabel2.transform.localPosition = speedLabel.transform.localPosition; speedLabel2.transform.localScale = speedLabel.transform.localScale; speedLabel2.text = speedLabel.text; speedText2.transform.localPosition = speedText.transform.localPosition; } //枪模式连接的情况下显示子弹 isBulletStatus = GlobalData.MyDeviceMode == DeviceMode.Gun; //BluetoothAim.ins && BluetoothAim.ins.isMainConnectToGun(); if (isBulletStatus) { if (canvasBB) canvasBB.transform.localPosition = new Vector3(0, -1.2f, 0); if(bulletManager) bulletManager.gameObject.SetActive(true); if(canvasBBSecond) canvasBBSecond.transform.localPosition = new Vector3(0, -1.2f, 0); if(bulletManagerSecond) bulletManagerSecond.gameObject.SetActive(true); } } private void Start() { if (GameMgr.HideBillboard) { gameObject.SetActive(false); GameMgr.HideBillboard = false; } } void OnDestroy() { if (ins == this) ins = null; } /**speed m/s */ public void SetArrowSpeed(float value) { //转km/h this.arrowSpeed = value * 3600f / 1000f; } public void SetArrowSpeedScale(float value) { this.arrowSpeedScale = value; } public void ShowSpeed() { if (speedText) { speedText.text = (this.arrowSpeed * this.arrowSpeedScale).ToString($"f{CommonConfig.arrowSpeedPrecision}"); } } public void SetShootSpeedText(string text) { if (speedText) { speedText.text = text; } } public string GetShootSpeedText() { return speedText.text; } /**speed m/s */ public void Second_SetArrowSpeed(float value) { //转km/h this.arrowSpeed2 = value * 3600f / 1000f; } public void Second_SetArrowSpeedScale(float value) { this.arrowSpeedScale2 = value; } public void Second_ShowSpeed() { if (speedText2) { speedText2.text = (this.arrowSpeed2 * this.arrowSpeedScale2).ToString($"f{CommonConfig.arrowSpeedPrecision}"); } } public void Second_SetShootSpeedText(string text) { if (speedText2) { speedText2.text = text; } } public string Second_GetShootSpeedText() { return speedText2.text; } }