100 lines
2.0 KiB
C#
100 lines
2.0 KiB
C#
using UFS2.Definitions;
|
|
using UFS2.Gameplay;
|
|
using UnityEngine;
|
|
|
|
public class FBait : MonoBehaviour
|
|
{
|
|
[HideInInspector]
|
|
public int gameID = -1;
|
|
|
|
private float takeRange = 5f;
|
|
|
|
private SphereCollider sphereColl;
|
|
|
|
private ConfigurableJoint _CfgJoint;
|
|
|
|
private Rigidbody _Rigidbody;
|
|
|
|
public ConfigurableJoint CfgJoint
|
|
{
|
|
get
|
|
{
|
|
return _CfgJoint;
|
|
}
|
|
private set
|
|
{
|
|
_CfgJoint = value;
|
|
}
|
|
}
|
|
|
|
public Rigidbody Rigidbody
|
|
{
|
|
get
|
|
{
|
|
return _Rigidbody;
|
|
}
|
|
private set
|
|
{
|
|
_Rigidbody = value;
|
|
}
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
sphereColl = base.gameObject.AddComponent<SphereCollider>();
|
|
sphereColl.enabled = true;
|
|
sphereColl.radius = takeRange;
|
|
sphereColl.isTrigger = true;
|
|
base.gameObject.layer = LayerMask.NameToLayer(Layers.BaitLure);
|
|
CfgJoint = GetComponent<ConfigurableJoint>();
|
|
Rigidbody = GetComponent<Rigidbody>();
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
FishEntity.OnBaitLock += _OnBaitLock_FishEntity;
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
FishEntity.OnBaitLock -= _OnBaitLock_FishEntity;
|
|
}
|
|
|
|
private void _OnBaitLock_FishEntity(Transform target)
|
|
{
|
|
if (!(target != base.transform))
|
|
{
|
|
sphereColl.enabled = false;
|
|
}
|
|
}
|
|
|
|
public bool CheckBaitEfficacy(float distanceToFish)
|
|
{
|
|
if ((bool)TutorialManager.Instance)
|
|
{
|
|
return true;
|
|
}
|
|
float num = 0f;
|
|
int gameItemIndexByItemId = GameManager.Instance._playerData.GetGameItemIndexByItemId(GameManager.ItemType.Bait, gameID);
|
|
_ = GameManager.Instance.gameBaits[gameItemIndexByItemId].efficacyBase;
|
|
if (Singleton<SaveDataManager>.Instance.HasCurrentPlayerSkill(GameManager.Skills.attractive_player_10p))
|
|
{
|
|
num = 0.1f;
|
|
}
|
|
else if (Singleton<SaveDataManager>.Instance.HasCurrentPlayerSkill(GameManager.Skills.attractive_player_5p))
|
|
{
|
|
num = 0.05f;
|
|
}
|
|
float num2 = 100f;
|
|
takeRange = 1f + num2 * 0.5f;
|
|
int num3 = Random.Range(0, 1);
|
|
Debug.Log("Bait efficacy range: " + (takeRange + takeRange * num) + " Bait current efficacy < rand: " + num2 + "/" + num3);
|
|
if ((float)num3 > num2)
|
|
{
|
|
Debug.Log("Bait efficacy is too low");
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
}
|