80 lines
1.9 KiB
C#
80 lines
1.9 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class RealisticLineTensionBar : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private Transform content;
|
|
|
|
[SerializeField]
|
|
private Image[] leftBarsImage;
|
|
|
|
[SerializeField]
|
|
private Image[] rightBarsImage;
|
|
|
|
private FPlayer playermain;
|
|
|
|
private float currentRoznicaTensionEnd;
|
|
|
|
private int numOfBoxesSide = 8;
|
|
|
|
private void Start()
|
|
{
|
|
if (Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().GameMode != GameManager.PlayerData.CPlayer.GameMode.Realistic)
|
|
{
|
|
base.gameObject.SetActive(value: false);
|
|
}
|
|
else
|
|
{
|
|
content.gameObject.SetActive(value: false);
|
|
}
|
|
}
|
|
|
|
private void FixedUpdate()
|
|
{
|
|
playermain = FScriptsHandler.Instance.m_PlayerMain;
|
|
if (!Singleton<SaveDataManager>.Instance.SettingsData.IsLineIndicatorEnabledOnRealistic)
|
|
{
|
|
content.gameObject.SetActive(value: false);
|
|
}
|
|
else if (!playermain.currentRod)
|
|
{
|
|
content.gameObject.SetActive(value: false);
|
|
}
|
|
else if (!playermain.currentRod.currentFish)
|
|
{
|
|
content.gameObject.SetActive(value: false);
|
|
}
|
|
else
|
|
{
|
|
if (playermain.currentRod.fishingLine == null)
|
|
{
|
|
return;
|
|
}
|
|
if (playermain.currentRod.currentFish.isGetFish)
|
|
{
|
|
content.gameObject.SetActive(value: false);
|
|
return;
|
|
}
|
|
content.gameObject.SetActive(value: true);
|
|
float target = Mathf.Clamp(playermain.currentRod.fishingLine.CurrentLineTension / playermain.currentRod.fishingLine.lineStrenght, 0f, 1f);
|
|
currentRoznicaTensionEnd = Mathf.MoveTowards(currentRoznicaTensionEnd, target, Time.deltaTime * 0.5f);
|
|
float num = 1f / (float)numOfBoxesSide;
|
|
int num2 = Mathf.RoundToInt(currentRoznicaTensionEnd / num);
|
|
for (int i = 0; i < numOfBoxesSide; i++)
|
|
{
|
|
if (num2 - 1 >= i)
|
|
{
|
|
leftBarsImage[i].enabled = true;
|
|
rightBarsImage[i].enabled = true;
|
|
}
|
|
else
|
|
{
|
|
leftBarsImage[i].enabled = false;
|
|
rightBarsImage[i].enabled = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|