Files
UltimateFishing/Assets/Scripts/Assembly-CSharp/FishDebugMarker.cs
2026-02-21 16:45:37 +08:00

70 lines
1.8 KiB
C#

using BehaviorDesigner.Runtime;
using UnityEngine;
public class FishDebugMarker : MonoBehaviour
{
public Renderer baitLikeMarker;
public TextMesh text;
public Fish parentFish;
public bool likeBait;
private string fishName;
public void NewBait(Bait bait)
{
int num = bait.CheckFishSize(parentFish);
likeBait = num == 0;
text.GetComponent<Renderer>().material.color = ((!likeBait) ? Color.red : Color.green);
}
private void Update()
{
text.transform.rotation = Quaternion.Euler(0f, Camera.main.transform.rotation.eulerAngles.y, 0f);
if ((bool)parentFish && (bool)parentFish.bt)
{
SharedVariable variable = parentFish.bt.GetVariable("Target");
if (variable != null && variable.GetValue() != null)
{
GameObject gameObject = (GameObject)variable.GetValue();
float num = Vector3.Distance(parentFish.transform.position, gameObject.transform.position);
text.text = fishName + "\n" + string.Format("{0:0.0}", parentFish.Weight) + " dis :" + string.Format("{0:0.0}", num) + string.Empty;
text.GetComponent<Renderer>().material.color = Color.cyan;
}
else
{
text.text = fishName + "\n" + string.Format("{0:0.0}", parentFish.Weight);
text.GetComponent<Renderer>().material.color = ((!likeBait) ? Color.red : Color.green);
}
}
}
private void OnEnable()
{
if (!parentFish)
{
parentFish = GetComponentInParent<Fish>();
}
if ((bool)parentFish)
{
string text = parentFish.name;
if (text.IndexOf("Fish_") == 0)
{
text = text.Substring(5);
}
if (text.IndexOf("(") > 0)
{
text = text.Substring(0, text.IndexOf("("));
}
fishName = text;
this.text.text = fishName + "\n" + string.Format("{0:0.0}", parentFish.Weight);
if ((bool)jkmStatistic.Instance.activeBait)
{
NewBait(jkmStatistic.Instance.activeBait);
}
}
}
}