using System; using System.Collections.Generic; using BitStrap; using EnergyBarToolkit; using UnityEngine; using UnityEngine.UI; public class HUDFishing : MonoBehaviour { public enum TensionWidgetType { STRAIGHT_BOTTOM = 0, GAUGE_BOTTOM = 1, GAUGE_BOTTOM_SHORT = 2 } public Text fishStateText; public GameObject distanceParent; public Text distanceValue; public Text depthValue; public Text distanceValueVR; public Text depthValueVR; public Text lineLengthValue; public Text maxLineLengthValue; public Text fishDurabilityDrainValue; public Slider throwStrengthSlider; public EnergyBar throwStrengthBar; public Slider flyCastSlider; public List reelSpeedWidgets = new List(); public EnergyBar reelSpeedEnergyBar; [Space(10f)] public TensionWidgetType tensionWidgetType; public EnergyBar tensionEnergyBar; public EnergyBar tensionEnergyBarGauge; public EnergyBar tensionEnergyBarGaugeShort; public FilledRendererUGUI filledRendererUGUI; public FilledRendererUGUI filledRendererUGUIGauge; public FilledRendererUGUI filledRendererUGUIGaugeShort; public Transform tensionEnergyBarsParent; public GameObject tensionAlarmParent; public Slider fishDurability; public Slider strengthDifferenceSlider; public Text reelSpeedText; public Text dragText; public Transform dragIndicator; public Image dragRotator; public float dragIndicatorSpeed = 3f; public Text spinningMethodText; public List spinningLevels = new List(); public Text baitStateText; public Text spinningMethodTextVR; public List spinningLevelsVR = new List(); public Text baitStateTextVR; public GameObject floatCameraWidget; public BaitIndicator baitIndicator; [HideInInspector] public AudioObject alarmTensionAudioObject; [ReadOnly] public float alarmTimer; private void Start() { fishDurability.gameObject.SetActive(false); strengthDifferenceSlider.gameObject.SetActive(false); alarmTensionAudioObject = AudioController.Play("TensionAlarm_01"); if ((bool)alarmTensionAudioObject) { alarmTensionAudioObject.Pause(); } UpdateSpinningMethod(SpinningMethodController.SpinningMethod.NONE, 1); UpdateBaitState(0); if ((bool)GlobalSettings.Instance && !GlobalSettings.Instance.turnOnMyCheats) { lineLengthValue.gameObject.SetActive(false); fishDurabilityDrainValue.gameObject.SetActive(false); fishDurability.gameObject.SetActive(false); strengthDifferenceSlider.gameObject.SetActive(false); } if ((bool)GlobalSettings.Instance) { ChangeTensionWidget(GlobalSettings.Instance.playerSettings.tensionWidgetType); } else { ChangeTensionWidget(TensionWidgetType.STRAIGHT_BOTTOM); } } private void Update() { if (alarmTimer > 0f) { alarmTimer -= Time.deltaTime; if (alarmTimer <= 0f) { SetTensionAlarm(true); alarmTimer = 0f; } } } public void RefreshSetting() { UpdateDistance(0f); UpdateDepth(0f); UpdateThrowStrength(0f); UpdateTension(0f); } public void UpdateFishState(string fishState) { fishStateText.text = fishState; } public void UpdateFishDurability(float value) { fishDurability.value = value; } public void UpdateDistance(float value) { value = (float)Math.Round(value, 1); Text text = distanceValueVR; string lengthString = UtilitiesUnits.GetLengthString(value, "F1", false); distanceValue.text = lengthString; text.text = lengthString; if ((bool)baitIndicator) { baitIndicator.distanceValue.text = UtilitiesUnits.GetLengthSimpleString(value, "F1"); } } public void UpdateDepth(float value) { if (value > -0.1f) { value = 0f; } Text text = depthValueVR; string lengthString = UtilitiesUnits.GetLengthString((float)Math.Round(0f - value, 1), "F1", false); depthValue.text = lengthString; text.text = lengthString; if ((bool)baitIndicator) { baitIndicator.depthValue.text = depthValue.text; } } public void UpdateLineLength(float lineLength, float distance) { lineLengthValue.text = string.Empty + lineLength.ToString("F2") + " / " + distance.ToString("F2"); if (lineLength > 0.17f) { lineLengthValue.color = Color.cyan; } else if (distance >= 1f) { lineLengthValue.color = Color.red; } else { lineLengthValue.color = Color.white; } } public void UpdateMaxLineLength(float lineLength) { } public void UpdateFishDurabilityDrain(float value) { if (fishDurabilityDrainValue.gameObject.activeInHierarchy) { fishDurabilityDrainValue.text = string.Empty + (float)Math.Round((double)value * 10.0, 1); } } public void UpdateThrowStrength(float value) { throwStrengthSlider.value = value; throwStrengthBar.valueCurrent = (int)value; } public void UpdateFlyCast(float value) { flyCastSlider.value = value; } public void UpdateTension(float value) { tensionEnergyBar.valueCurrent = Mathf.FloorToInt(value * 100f); tensionEnergyBarGauge.valueCurrent = Mathf.FloorToInt(value * 100f); tensionEnergyBarGaugeShort.valueCurrent = Mathf.FloorToInt(value * 100f); if ((bool)baitIndicator) { baitIndicator.tensionEnergyBar.valueCurrent = tensionEnergyBar.valueCurrent; } } public void UpdateReelSpeed(float value) { reelSpeedEnergyBar.valueCurrent = Mathf.FloorToInt((value + 0.1f) * 100f); } public void UpdateReelSpeedNew(float value) { if (VRManager.Instance.IsVRReeling()) { reelSpeedWidgets[0].enabled = UtilitiesInput.isReelingIn; } else { reelSpeedWidgets[0].enabled = true; } reelSpeedWidgets[1].enabled = value > 0.15f; reelSpeedWidgets[2].enabled = value > 0.35f; reelSpeedWidgets[3].enabled = value > 0.55f; reelSpeedWidgets[4].enabled = value > 0.75f; } public void UpdateDrag(float value, bool isDragActive) { dragText.text = string.Empty + Mathf.RoundToInt(value); dragIndicator.localEulerAngles = new Vector3(0f, 0f, value * dragIndicatorSpeed); Color color = dragText.color; color.a = ((!isDragActive) ? 0.2f : 1f); dragText.color = color; if ((bool)dragRotator) { color = dragRotator.color; color.a = ((!isDragActive) ? 0.2f : 1f); dragRotator.color = color; } } public void UpdateBaitState(int value) { if ((bool)baitStateText) { Text text = baitStateTextVR; string text2 = string.Empty + ((value != 1) ? string.Empty : Utilities.GetTranslation("EQUIPMENT_PARAMETERS/GROUND").ToUpper()); baitStateText.text = text2; text.text = text2; } } public void UpdateSpinningMethod(SpinningMethodController.SpinningMethod spinningMethod, int level) { if (!(spinningMethodText == null)) { for (int i = 0; i < spinningLevels.Count; i++) { spinningLevels[i].SetActive(spinningMethod != SpinningMethodController.SpinningMethod.NONE && i < level); spinningLevelsVR[i].SetActive(spinningLevels[i].activeSelf); } Text text = spinningMethodTextVR; string empty = string.Empty; spinningMethodText.text = empty; text.text = empty; if (spinningMethod != SpinningMethodController.SpinningMethod.NONE) { spinningMethodTextVR.text = (spinningMethodText.text += " "); spinningMethodTextVR.text = (spinningMethodText.text += SpinningMethodController.GetSpinningMethodName(spinningMethod)); } } } public void ShowThrowSlider(bool show) { throwStrengthBar.valueCurrent = 0; throwStrengthBar.transform.parent.parent.localPosition = ((!show) ? (Vector3.down * 9999f) : Vector3.zero); } public void ShowFlyCastSlider(bool show) { flyCastSlider.transform.parent.gameObject.SetActive(show); } public void ShowTensionSlider(bool show) { tensionEnergyBarsParent.localPosition = ((!show) ? (Vector3.down * 9999f) : Vector3.zero); } public void ChangeTensionWidget(TensionWidgetType tensionWidgetType) { tensionEnergyBar.transform.parent.gameObject.SetActive(tensionWidgetType == TensionWidgetType.STRAIGHT_BOTTOM); tensionEnergyBarGauge.transform.parent.gameObject.SetActive(tensionWidgetType == TensionWidgetType.GAUGE_BOTTOM); tensionEnergyBarGaugeShort.transform.parent.gameObject.SetActive(tensionWidgetType == TensionWidgetType.GAUGE_BOTTOM_SHORT); } public void StartTensionAlarm(bool start) { alarmTimer = ((!start) ? 0f : 0.3f); if (!start) { SetTensionAlarm(false); } } public void SetTensionAlarm(bool start) { if ((bool)alarmTensionAudioObject) { if (start) { alarmTensionAudioObject.Unpause(); } else { alarmTensionAudioObject.Pause(); } } filledRendererUGUI.forceBlinking = start; filledRendererUGUIGauge.forceBlinking = start; if ((bool)tensionAlarmParent) { tensionAlarmParent.gameObject.SetActive(start); } } public void InitStrengthDifference(Fish fish) { strengthDifferenceSlider.minValue = 0f - fish.StartStrength; strengthDifferenceSlider.maxValue = 1f; } public void UpdateStrengthDifference(float val) { strengthDifferenceSlider.value = val; if (val >= 0f) { strengthDifferenceSlider.fillRect.GetComponent().color = Color.green; } else { strengthDifferenceSlider.fillRect.GetComponent().color = Color.red; } } }