首次提交

This commit is contained in:
Bob.Song
2026-03-05 18:07:55 +08:00
commit e125bb869e
4534 changed files with 563920 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
using NBF;
using UnityEngine;
public class FBait : FPlayerGear
{
// private float takeRange = 5f;
public BaitAsset baitAsset;
private void Awake()
{
baitAsset = GetComponent<BaitAsset>();
}
// public bool CheckBaitEfficacy(float distanceToFish)
// {
// float num = 0f;
//
// 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;
// }
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6b3aaf527fc746ea93d9233dc8ec7ca0
timeCreated: 1742313561

View File

@@ -0,0 +1,57 @@
using NBF;
using UnityEngine;
public class FFeeder : FPlayerGear
{
[HideInInspector]
public Rigidbody rigidbody;
[HideInInspector]
public FWaterDisplacement waterDisplacement;
public ParticleSystem smuuggeParticle;
[HideInInspector]
public FRod currentRod;
protected override void OnStart()
{
rigidbody = GetComponent<Rigidbody>();
waterDisplacement = GetComponent<FWaterDisplacement>();
}
protected override void OnUpdate()
{
ShowWaterFX();
if ((bool)currentRod)
{
if ((bool)currentRod.currentFish)
{
waterDisplacement.isFreeze = true;
}
else
{
waterDisplacement.isFreeze = false;
}
}
}
private void ShowWaterFX()
{
if (smuuggeParticle == null)
{
return;
}
if (waterDisplacement.waterHeightPosition - 0.1f <= transform.position.y && waterDisplacement.waterHeightPosition + 0.1f > transform.position.y)
{
if (!smuuggeParticle.isEmitting)
{
smuuggeParticle.Play();
}
}
else if (smuuggeParticle.isPlaying)
{
smuuggeParticle.Stop();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6b9877b136184e20a98cd45d0e067a2b
timeCreated: 1742313572

View File

@@ -0,0 +1,248 @@
// using UltimateWater;
using NBF;
using UnityEngine;
public class FFloat : FPlayerGear
{
[HideInInspector] public Rigidbody rigidbody;
[HideInInspector] public FWaterDisplacement waterDisplacement;
public float currentFloatDeepth = 0.2f;
public float newDeepth { get; set; } = 0.21f;
public float floatDisplacement;
// private BoxCollider collider;
private float startWaterInteractiveMultiple = 5f;
private Transform currentWaterDrop;
// [SerializeField] public Transform scallingObject;
private bool destroyDropFx;
protected override void OnStart()
{
rigidbody = GetComponent<Rigidbody>();
waterDisplacement = GetComponent<FWaterDisplacement>();
waterDisplacement.objectDisplacement = floatDisplacement;
// collider = GetComponent<BoxCollider>();
if (Owner.Gears.Rod)
{
Owner.Gears.Rod.lineHandler.SetSegmentTwoLenght(currentFloatDeepth);
}
// if ((bool)waterInteractive)
// {
// waterInteractive.enabled = false;
// startWaterInteractiveMultiple = waterInteractive.Multiplier;
// }
Invoke("EnableWaterInteractive", 3f);
}
protected override void OnUpdate()
{
if ((bool)Owner.Gears.Rod)
{
if ((bool)Owner.Gears.Rod.currentFish)
{
waterDisplacement.isFreeze = true;
waterDisplacement.useSplashes = false;
}
else
{
waterDisplacement.isFreeze = false;
waterDisplacement.useSplashes = true;
}
ShowWaterFX();
SetDeepth();
// Scalling();
}
}
protected override void OnFixedUpdate()
{
DisplcementController();
}
// private void Scalling()
// {
// if ((bool)Owner.Gears.Rod.lineHandler &&
// (bool)Owner.Gears.Rod.lineHandler.EndLineRigidbody_0)
// {
// // float floatSize = GameManager.Instance._playerData
// // .Player[GameManager.Instance._playerData.currentPlayerProfileIndex].floatSize;
//
// float floatSize = 1; //Owner.Data.currentGear.bobber.Config.weight;
// float num = Vector3.Distance(
// Owner.Gears.Rod.lineHandler.EndLineRigidbody_0.transform.position,
// scallingObject.transform.position);
// // if ((bool)waterInteractive)
// // {
// // waterInteractive.Multiplier = startWaterInteractiveMultiple / (scallingObject.localScale.x * 2f);
// // }
//
// // if (FScriptsHandler.Instance.m_PlayerMain.currentCameraView !=
// // FScriptsHandler.Instance.m_PlayerMain.m_Camera)
// // {
// // scallingObject.localScale = Vector3.one;
// // }
// // else
// if (waterDisplacement.isInWater && !Owner.Gears.Rod.currentFish)
// {
// float value = 1f + num * 0.4f / floatSize * floatSize;
// value = Mathf.Clamp(value, 0f, floatSize);
// scallingObject.localScale =
// Vector3.MoveTowards(scallingObject.localScale, Vector3.one * value, Time.deltaTime * 5f);
// }
// else
// {
// scallingObject.localScale =
// Vector3.MoveTowards(scallingObject.localScale, Vector3.one, Time.deltaTime * 10f);
// }
// }
// }
private void EnableWaterInteractive()
{
// if ((bool)waterInteractive)
// {
// waterInteractive.enabled = true;
// }
}
private void DisplcementController()
{
if (!Owner.Gears.Rod || !Owner.Gears.Weight)
{
return;
}
if (waterDisplacement.isInWater)
{
float value = floatDisplacement - Owner.Gears.Weight.weight + 1f;
value = Mathf.Clamp(value, -1f, 2f);
waterDisplacement.objectDisplacement = value;
// if ((value > 1.5f && rigidbody.linearVelocity.magnitude < 1f) || ProbeDeep(transform) < currentFloatDeepth)
// {
// collider.center = new Vector3(0f, collider.center.y, 0.07f);
// }
// else
// {
// collider.center = new Vector3(0f, collider.center.y, 0f);
// }
}
else
{
// collider.center = new Vector3(0f, collider.center.y, 0f);
}
}
private float ProbeDeep(Transform probeObject)
{
int mask = LayerMask.GetMask("Terrain");
float result = 0f;
if (Physics.Raycast(probeObject.transform.position, -Vector3.up, out var hitInfo, float.PositiveInfinity, mask))
{
result = hitInfo.distance;
}
return result;
}
private void SetDeepth()
{
if ((bool)Owner.Gears.Rod && (bool)Owner.Gears.Hook &&
!(Owner.Data.lineLength > 2f) && !Owner.Gears.Rod.currentFish)
{
if (newDeepth != currentFloatDeepth)
{
Owner.Gears.Rod.lineHandler.SetSegmentTwoLenght(newDeepth);
currentFloatDeepth = newDeepth;
}
// if (InputManager.isDeepthFloatUp)
// {
// newDeepth += 0.1f;
// newDeepth = Mathf.Clamp(newDeepth, 0.15f, 2.5f);
// Owner.Data.currentGear.SetBobberLastSetGroundValue(newDeepth);
// // GameManager.Instance.ShowMessagePopup(LanguageManager.Instance.GetText("SET_FLOAT_DEEPTH_TO") + newDeepth.ToString("F2") + " m", FScriptsHandler.Instance.m_Canvas.transform, deleteLast: true);
// }
//
// if (InputManager.isDeepthFloatDown)
// {
// newDeepth -= 0.1f;
// newDeepth = Mathf.Clamp(newDeepth, 0.15f, 2.5f);
//
// Owner.Data.currentGear.SetBobberLastSetGroundValue(newDeepth);
// // GameManager.Instance.ShowMessagePopup(LanguageManager.Instance.GetText("SET_FLOAT_DEEPTH_TO") + newDeepth.ToString("F2") + " m", FScriptsHandler.Instance.m_Canvas.transform, deleteLast: true);
// }
if (Owner.Data.selectorRodSetting == SelectorRodSetting.Leeder &&
Input.mouseScrollDelta.y != 0f && Time.timeScale != 0f)
{
newDeepth += Input.mouseScrollDelta.y * 0.02f;
newDeepth = Mathf.Clamp(newDeepth, 0.15f, 2.5f);
Owner.Data.currentGear.SetBobberLastSetGroundValue(newDeepth);
// GameManager.Instance.ShowMessagePopup(LanguageManager.Instance.GetText("SET_FLOAT_DEEPTH_TO") + newDeepth.ToString("F2") + " m", FScriptsHandler.Instance.m_Canvas.transform, deleteLast: true);
}
}
}
private void DestroyDelayFxDrop()
{
if ((bool)currentWaterDrop)
{
Destroy(currentWaterDrop.gameObject);
destroyDropFx = false;
}
}
private void ShowWaterFX()
{
// float num = 0f - transform.position.y;
// if (num < 0.1f && num > -0.1f)
// {
// if (!currentWaterDrop)
// {
// currentWaterDrop = Instantiate(FScriptsHandler.Instance.waterFishSplash[2],
// transform.position, Quaternion.identity, transform.parent).transform;
// }
// else
// {
// currentWaterDrop.position = new Vector3(transform.position.x, 0f, transform.position.z);
// }
// }
// else if ((bool)currentWaterDrop)
// {
// if (!destroyDropFx)
// {
// Invoke("DestroyDelayFxDrop", 4f);
// }
//
// destroyDropFx = true;
// }
}
private void OnDestroy()
{
if ((bool)currentWaterDrop)
{
Destroy(currentWaterDrop.gameObject);
}
}
#region Test
public void Test(int type)
{
}
#endregion
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: fe65a4c7c8124d9eaaee85e579b4d341
timeCreated: 1742313491

View File

@@ -0,0 +1,114 @@
using NBF;
using UnityEngine;
public class FHook : FPlayerGear
{
[HideInInspector] public Rigidbody rigidbody;
[HideInInspector] public FWaterDisplacement waterDisplacement;
// [HideInInspector] public FRod currentRod;
[Tooltip("Punkt połaczenia z rybą")] public Rigidbody fishJoiner;
public Vector3 rotationInFishJaw = Vector3.zero;
public bool isLookingDisable;
private float hookTimer;
public int hookNotAcceptFishCounter;
public HookAsset hookAsset;
private void Awake()
{
hookAsset = GetComponent<HookAsset>();
}
protected override void OnStart()
{
rigidbody = GetComponent<Rigidbody>();
waterDisplacement = GetComponent<FWaterDisplacement>();
}
protected override void OnUpdate()
{
if (!Owner.Gears.Rod)
{
return;
}
if ((bool)Owner.Gears.Rod.currentFish)
{
waterDisplacement.isFreeze = true;
waterDisplacement.useSplashes = false;
AddHookNotAcceptedCount(reset: true);
}
else
{
waterDisplacement.isFreeze = false;
waterDisplacement.useSplashes = true;
if (waterDisplacement.isInWater)
{
Quaternion b = Quaternion.Euler(0f, rigidbody.transform.localEulerAngles.y,
rigidbody.linearVelocity.x - 1f);
rigidbody.rotation = Quaternion.Slerp(rigidbody.rotation, b, Time.deltaTime * 1f);
if ((bool)Owner.Gears.Rod.takeFish)
{
AddHookNotAcceptedCount(reset: true);
}
else
{
AddHookNotAcceptedCount(reset: false);
}
}
else
{
AddHookNotAcceptedCount(reset: true);
}
}
if (!Owner.Gears.Rod.takeFish && !Owner.Gears.Rod.currentFish && isLookingDisable)
{
isLookingDisable = false;
}
}
private void AddHookNotAcceptedCount(bool reset)
{
// if (GameManager.Instance._playerData.Player[GameManager.Instance._playerData.currentPlayerProfileIndex]
// .gameMode == GameManager.PlayerData.CPlayer.GameMode.Realistic ||
// FScriptsHandler.Instance.m_PlayerMain.currentRod != currentRod)
// {
// return;
// }
if (reset)
{
hookTimer = 0f;
hookNotAcceptFishCounter = 0;
return;
}
hookTimer += Time.deltaTime;
if (hookTimer >= 300f && hookNotAcceptFishCounter > 5)
{
hookTimer = 0f;
hookNotAcceptFishCounter = 0;
// GameManager.Instance.ShowMessagePopup(LanguageManager.Instance.GetText("HOOK_NOT_ACCEPT_FISH_INFO"), FScriptsHandler.Instance.m_Canvas.transform);
}
}
private void OnCollisionEnter(Collision collision)
{
// if (!waterDisplacement.isInWater && (bool)Owner.Gears.Rod &&
// (bool)Owner.Gears.Rod.lineHandler && !Owner.Gears.Rod.currentFish &&
// Owner.Data.lineLength > 5f &&
// Vector3.Distance(transform.position, Owner.Gears.Rod.transform.position) > 5f)
// {
// GameManager.Instance.ShowMessagePopup(LanguageManager.Instance.GetText("HOOK_ON_THE_GROUND"), FScriptsHandler.Instance.m_Canvas.transform, deleteLast: true);
// }
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8caddc7ca53a49f488f61f5ab8475cdb
timeCreated: 1742313498

View File

@@ -0,0 +1,17 @@
using NBF;
using UnityEngine;
public class FLine : FPlayerGear
{
public Material szpulaMat;
public Material lineMat;
protected override void OnStart()
{
}
protected override void OnUpdate()
{
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c385b627bfeb489fa629ea1a77730b8e
timeCreated: 1742313472

View File

@@ -0,0 +1,190 @@
using System;
using NBF;
using Obi;
using Unity.VisualScripting;
using UnityEngine;
public class FLineHandler : MonoBehaviour
{
public enum LineType
{
None = 0,
OneSegment = 1,
TwoSegment = 2,
ThereSegment = 3
}
public LineType lineType = LineType.TwoSegment;
public ObiRope obiRopeSegment_1;
public ObiRope obiRopeSegment_2;
public ObiRope obiRopeSegment_3;
public FixedLine LineConnector_0;
public SpringJoint LineConnector_1;
public SpringJoint LineConnector_2;
public SpringJoint LineConnector_3;
// [HideInInspector] public FFishingLine currentRodFishingLineComponent;
// public ObiParticleAttachment toRodConnector;
// public float PhisicsLineOut { get; set; }
public float ObiLineOut;
[HideInInspector] public Rigidbody EndLineRigidbody_0;
[HideInInspector] public Rigidbody EndLineRigidbody_1;
[HideInInspector] public Rigidbody EndLineRigidbody_2;
[HideInInspector] public Rigidbody EndLineRigidbody_3;
public JointPinchController pinchController;
public FRod Rod;
private Transform waterPlane;
// public float ropeToHookDistance;
void Start()
{
ObiLineOut = obiRopeSegment_1.stretchingScale;
if ((bool)LineConnector_0)
{
EndLineRigidbody_0 = LineConnector_0.GetComponent<Rigidbody>();
}
if ((bool)LineConnector_1)
{
EndLineRigidbody_1 = LineConnector_1.GetComponent<Rigidbody>();
}
if ((bool)LineConnector_2)
{
EndLineRigidbody_2 = LineConnector_2.GetComponent<Rigidbody>();
// var fixedJoint = LineConnector_2.GetComponent<FixedJoint>();
pinchController = LineConnector_2.gameObject.AddComponent<JointPinchController>();
}
if ((bool)LineConnector_3)
{
EndLineRigidbody_3 = LineConnector_3.GetComponent<Rigidbody>();
}
waterPlane = GameObject.FindGameObjectWithTag("Water").transform;
Debug.LogError($"rope.restLength={obiRopeSegment_1.restLength} LineConnector_1={LineConnector_1.maxDistance}");
}
void Update()
{
if (!Rod) return;
// ropeToHookDistance = Vector3.Distance(toRodConnector.transform.position, LineConnector_1.transform.position);
ObiLineOut = 0.1f + Rod.Owner.Data.lineLength;
float target = (0f - Mathf.Clamp(Rod.linelenghtDiferent, -1f, 0f)) * 0.1f;
if (Rod.linelenghtDiferent >= 0f)
{
obiRopeSegment_1.stretchCompliance = Mathf.MoveTowards(obiRopeSegment_1.stretchCompliance, target,
Time.smoothDeltaTime * (1f * Rod.linelenghtDiferent));
}
else
{
obiRopeSegment_1.stretchCompliance = Mathf.MoveTowards(obiRopeSegment_1.stretchCompliance, target,
Time.smoothDeltaTime * 0.1f);
}
if (Rod.Owner.Data.lineLength == 0f)
{
obiRopeSegment_1.stretchCompliance = 0f;
}
if ((bool)obiRopeSegment_2)
{
if (!Rod.currentFish)
{
obiRopeSegment_2.stretchCompliance = obiRopeSegment_2.stretchingScale * 0.004f;
}
else
{
obiRopeSegment_2.stretchCompliance = 0f;
}
//TODO:TEST
obiRopeSegment_2.stretchingScale = 0.13F;
}
obiRopeSegment_1.stretchingScale = ObiLineOut;
obiRopeSegment_1.stretchingScale = 1;
LineConnector_1.maxDistance = 0.1f + Rod.Owner.Data.lineLength;
if (Input.GetKey(KeyCode.E))
{
// var speed = 1;
// obiRopeCursor_1.ChangeLength(LineConnector_1.maxDistance);
// Debug.Log(obiRopeSegment_1.restLength);
}
// var addLength = LineConnector_1.maxDistance - obiRopeSegment_1.restLength;
// if (Mathf.Abs(addLength) > 0.001f)
// {
// obiRopeCursor_1.ChangeLength(LineConnector_1.maxDistance);
// }
// if (!Mathf.Approximately(LineConnector_1.maxDistance, obiRopeSegment_1.restLength))
// {
// obiRopeCursor_1.ChangeLength(LineConnector_1.maxDistance);
// }
// obiRopeCursor_1.pos
// LineConnector_1.minDistance = LineConnector_1.maxDistance;
}
public void SetSegmentTwoLenght(float lenght)
{
LineConnector_2.maxDistance = lenght;
// obiRopeCursor_2.ChangeLength(lenght);
// LineConnector_2.minDistance = LineConnector_2.maxDistance;
}
private void FixedUpdate()
{
// BindRod();
LineWaterDisplacement();
}
private void BindRod()
{
if (!Rod || !Rod.rodAsset) return;
LineConnector_0.transform.position = Rod.rodAsset.lineConnector.position;
}
private void LineWaterDisplacement()
{
if (!waterPlane)
{
return;
}
for (int i = 0; i < obiRopeSegment_1.activeParticleCount; i++)
{
if (obiRopeSegment_1.GetParticlePosition(i).y < waterPlane.position.y)
{
// obiRopeSegment_1.AddForceParticle(i, Vector3.up * 10f, ForceMode.Acceleration);
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7a4deeedd2674b1ca2aad8d40f519ceb
timeCreated: 1742313668

View File

@@ -0,0 +1,248 @@
using NBF;
using UnityEngine;
public class FLure : FPlayerGear
{
public enum MoveType
{
None = 0,
PowolnyWleczony = 1,
Wleczony = 2,
Opadający = 3,
PowolnyOpadający = 4
}
[HideInInspector] public Rigidbody rigidbody;
[HideInInspector] public FWaterDisplacement waterDisplacement;
public Rigidbody fishJoiner;
public bool isLookingDisable;
// private Animator animator;
[HideInInspector] public FFish currentFish;
[HideInInspector] public float percentEfficacy;
public MoveType LureMoveType = MoveType.Wleczony;
[HideInInspector] public MoveType currentMoveType;
private MoveType newMoveType;
private float delayMoveTypeTimer;
private float moveTowardsFactor;
private float moveUpperFactor;
private float waterHeightPosition;
private Transform currentWaterDrop;
private float rotateVelo;
private bool destroyDropFx;
public LureAsset lureAsset;
private void Awake()
{
lureAsset = GetComponent<LureAsset>();
}
protected override void OnStart()
{
rigidbody = GetComponent<Rigidbody>();
waterDisplacement = GetComponent<FWaterDisplacement>();
// animator = GetComponent<Animator>();
waterHeightPosition = SceneSettings.Instance.WaterObject.position.y;
if (!fishJoiner)
{
return;
}
FixedJoint component = fishJoiner.GetComponent<FixedJoint>();
if ((bool)component && !component.connectedBody)
{
if ((bool)component.transform.parent.GetComponent<Rigidbody>())
{
component.connectedBody = component.transform.parent.GetComponent<Rigidbody>();
}
else
{
component.connectedBody = transform.GetComponent<Rigidbody>();
}
}
}
protected override void OnUpdate()
{
// transform.position = Rod.lineHandler.LineConnector_1.transform.position;
RotationToVelocity();
// ShowWaterFX();
MoveTypeController();
if ((bool)currentFish)
{
waterDisplacement.isFreeze = true;
if (fishJoiner) fishJoiner.gameObject.SetActive(true);
if (!currentFish.isGetFish && transform.parent == currentFish.baitContainer)
{
transform.localPosition = Vector3.zero;
transform.localEulerAngles = lureAsset.rotationInFishJaw;
}
}
else
{
waterDisplacement.isFreeze = false;
if (fishJoiner) fishJoiner.gameObject.SetActive(false);
}
if (!Rod.takeFish && !Rod.currentFish && isLookingDisable)
{
isLookingDisable = false;
}
// if ((bool)animator && transform.position.y < 0.2f && animator.runtimeAnimatorController != null)
// {
// animator.SetFloat("Speed", rigidbody.linearVelocity.magnitude);
// }
// CheckDistance(Rod.lineHandler.LineConnector_1.transform);
}
private void RotationToVelocity()
{
if (!waterDisplacement)
{
return;
}
if (transform.position.y > 0.02f)
{
// if (transform.position.y > 0.2f && (bool)animator)
// {
// animator.SetFloat("Speed", 0f);
// }
rigidbody.freezeRotation = false;
}
else
{
if (Rod.linelenghtDiferent <= 0f)
{
return;
}
rigidbody.freezeRotation = true;
Vector3 vector = new Vector3(rigidbody.linearVelocity.x, 0f, rigidbody.linearVelocity.z);
if (vector != Vector3.zero)
{
Quaternion b = Quaternion.LookRotation(vector, Vector3.up);
transform.rotation = Quaternion.Slerp(transform.rotation, b,
rigidbody.linearVelocity.magnitude * 5f * Time.deltaTime);
}
if (lureAsset.rotateVeloMaxAngle > 0f)
{
rotateVelo = lureAsset.rotateVeloMaxAngle *
(1f - Mathf.PingPong(
Time.time * rigidbody.linearVelocity.normalized.magnitude *
lureAsset.rotateVeloMaxSpeed, 2f));
}
else if (lureAsset.rotateVeloMaxAngle == 0f)
{
rotateVelo = Time.time * rigidbody.linearVelocity.normalized.magnitude * lureAsset.rotateVeloMaxSpeed;
}
if (rigidbody.linearVelocity.magnitude > 0f)
{
if (lureAsset.rotateVeloMaxAngle == 0f)
{
transform.Rotate(Vector3.forward, rotateVelo);
return;
}
transform.Rotate(Vector3.up, rotateVelo);
rigidbody.AddForce(transform.right * rotateVelo, ForceMode.Acceleration);
}
}
}
private void MoveTypeController()
{
if (transform.position.y > waterHeightPosition + 0.1f ||
Vector3.Distance(Rod.transform.position, transform.position) < 5f)
{
moveTowardsFactor = 0f;
moveUpperFactor = 0f;
percentEfficacy = 0f;
currentMoveType = MoveType.None;
newMoveType = MoveType.None;
return;
}
float num = (Mathf.Abs(rigidbody.linearVelocity.x) + Mathf.Abs(rigidbody.linearVelocity.z)) * 0.5f;
moveTowardsFactor = Mathf.MoveTowards(moveTowardsFactor, Mathf.Clamp01(num * 1.5f), Time.deltaTime * 0.5f);
moveUpperFactor = Mathf.MoveTowards(moveUpperFactor, Mathf.Clamp01((0f - rigidbody.linearVelocity.y) * 1.3f),
Time.deltaTime * 0.5f);
if (moveTowardsFactor > 0.01f && moveTowardsFactor < 0.5f)
{
newMoveType = MoveType.PowolnyWleczony;
}
else if (moveTowardsFactor >= 0.5f && moveTowardsFactor < 1f)
{
newMoveType = MoveType.Wleczony;
}
else if (moveTowardsFactor <= 0.1f)
{
if (moveUpperFactor > 0f && moveUpperFactor < 0.4f)
{
newMoveType = MoveType.PowolnyOpadający;
}
else if (moveUpperFactor >= 0.4f && moveUpperFactor < 0.8f)
{
newMoveType = MoveType.Opadający;
}
else
{
newMoveType = MoveType.None;
}
}
else
{
newMoveType = MoveType.None;
}
if (currentMoveType == LureMoveType)
{
percentEfficacy = Mathf.MoveTowards(percentEfficacy, 1f, Time.deltaTime * 0.4f);
}
else
{
percentEfficacy = Mathf.MoveTowards(percentEfficacy, 0f, Time.deltaTime * 0.2f);
}
if (newMoveType != currentMoveType)
{
delayMoveTypeTimer += Time.deltaTime;
if (delayMoveTypeTimer > 1f)
{
currentMoveType = newMoveType;
delayMoveTypeTimer = 0f;
}
}
}
private void OnDestroy()
{
if ((bool)currentWaterDrop)
{
Destroy(currentWaterDrop.gameObject);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 50530999eb5a4f0299ebc5a90e94b229
timeCreated: 1742313444

View File

@@ -0,0 +1,53 @@
using NBF;
using UnityEngine;
using UnityEngine.Serialization;
public class FReel : FPlayerGear
{
public bool isBlockLineByFinger { get; set; }
[SerializeField] public float reelingDrag = 1f;
public ReelAsset reelAsset;
public ReelAnimator AnimatorCtrl;
private void Awake()
{
reelAsset = GetComponent<ReelAsset>();
AnimatorCtrl = reelAsset.animator.gameObject.GetComponent<ReelAnimator>();
if (AnimatorCtrl == null)
{
AnimatorCtrl = reelAsset.animator.gameObject.AddComponent<ReelAnimator>();
}
}
protected override void OnStart()
{
}
protected override void OnUpdate()
{
AnimatorCtrl.Reeling = Owner.Data.reelSpeed;
if (Owner.Data.reelSpeed > 0)
{
Unlock();
}
// Reeling();
}
public void Unlock(bool unlock = true)
{
if (unlock)
{
AnimatorCtrl.Unlock = true;
}
else
{
AnimatorCtrl.Unlock = false;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5a31a2780ddb4a7890a8d8769ed0ff5e
timeCreated: 1742313407

View File

@@ -0,0 +1,324 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NBC;
using NBF;
using Obi;
using RootMotion.FinalIK;
using UnityEngine;
public class FRod : FPlayerGear
{
private CCDIK _ccdik;
[HideInInspector] public float throwPowerForSounds;
public bool isThrowing { get; set; }
public FWaterDisplacement LureHookWaterDisplacement;
[HideInInspector] public FFish currentFish;
[HideInInspector] public FFish takeFish;
private float bendSmooth;
public FRodData RodData { get; private set; }
/// <summary>
/// 鱼竿资产组件
/// </summary>
public RodAsset rodAsset;
// public RodRingAsset RodRingAsset { get; private set; }
public RodRingNode[] rings;
/// <summary>
/// 鱼线处理器
/// </summary>
public FLineHandler lineHandler;
public float currentLineTension;
public float linelenghtDiferent;
public float currentLineStrenght;
private void Awake()
{
rodAsset = GetComponent<RodAsset>();
_ccdik = GetComponent<CCDIK>();
}
protected override void OnStart()
{
RodData = GearData as FRodData;
IKSolverCCD solver = _ccdik.solver;
solver.OnPostUpdate =
(IKSolver.UpdateDelegate)Delegate.Combine(solver.OnPostUpdate, new IKSolver.UpdateDelegate(OnPostUpdate));
// fishingLine = GetComponent<FFishingLine>();
// fishingLine.Initialize(Owner);
for (int i = 0; i < _ccdik.solver.bones.Length; i++)
{
_ccdik.solver.bones[i].weight = 0.06f;
}
// CheckCreateFishingHandler();
}
public void SetRing(RodRingAsset ringAsset)
{
if (rodAsset.rings == null || rodAsset.rings.Length < 1) return;
var trans = ringAsset.rings;
RodRingNode lastRingNode = null;
List<RodRingNode> list = new List<RodRingNode>();
for (int i = 0; i < rodAsset.rings.Length; i++)
{
var ring = rodAsset.rings[i];
if (ring == null)
{
Log.Error($"ring is null,index={i}");
continue;
}
var lastName = ring.name.GetLastString();
foreach (var tran in trans)
{
var ringNode = tran.ring;
var lastName2 = ringNode.name.GetLastString();
if (lastName != lastName2) continue;
list.Add(tran);
ringNode.SetParent(ring);
ringNode.localPosition = Vector3.zero;
ringNode.localRotation = Quaternion.identity;
lastRingNode = tran;
break;
}
}
if (lastRingNode != null)
{
rodAsset.lineConnector = lastRingNode.point;
}
rings = list.ToArray();
}
private void OnPostUpdate()
{
BendControll();
RenderLine();
}
protected override void OnUpdate()
{
linelenghtDiferent = getLineDiferent();
float num = RodData.Config.strength * 0.01f;
currentLineStrenght = Mathf.Clamp01(linelenghtDiferent) * (Owner.Data.currentGear.line.Config.strength + num);
if ((bool)currentFish)
{
currentLineTension = linelenghtDiferent * (currentFish.fishWeight * currentFish.fishStamina);
}
else
{
currentLineTension = Mathf.Clamp(linelenghtDiferent, 0f, 50f) * 0.3f;
}
}
private void BendControll()
{
_ccdik.solver.SetIKPositionWeight(0f);
return;
if (lineHandler == null)
{
_ccdik.solver.target = null;
_ccdik.solver.SetIKPositionWeight(0f);
return;
}
if (!_ccdik.solver.target)
{
_ccdik.solver.target = lineHandler.LineConnector_1.transform;
return;
}
float num = 0.15f;
float max = 0.3f;
if ((bool)takeFish)
{
num = 10f;
max = 1f;
}
else if ((bool)currentFish)
{
num = 0.5f + currentLineTension * currentFish.fishWeight * 0.3f;
max = 1f;
}
else if (Owner.Gears.Reel && Owner.Data.currentReelingSpeed > 0f)
{
num = Owner.Data.currentReelingSpeed * 0.3f;
max = 0.3f;
}
float num2 = Mathf.Clamp01(Mathf.Clamp01(getLineDiferent()) * num);
if (num2 < 0.05f)
{
num2 = 0f;
}
bendSmooth = Mathf.MoveTowards(bendSmooth, num2,
Time.deltaTime * (1f - Mathf.Clamp01(getLineDiferent())));
if ((bool)currentFish && currentFish.isGetFish)
{
bendSmooth = 0f;
}
bendSmooth = Mathf.Clamp(bendSmooth, 0.001f, max);
_ccdik.solver.SetIKPositionWeight(Mathf.MoveTowards(_ccdik.solver.IKPositionWeight, bendSmooth,
Time.deltaTime * 0.5f));
}
public float getLineDiferent()
{
if (!lineHandler)
{
return 0f;
}
return Vector3.Distance(lineHandler.LineConnector_1.transform.position,
rodAsset.lineConnector.position) - Owner.Data.lineLength;
}
public void DestroyCurrentFish()
{
Debug.Log("Destroy fish frod");
// if ((bool)currentPlayer.currentChwytak)
// {
// Destroy(currentPlayer.currentChwytak.gameObject);
// currentPlayer.currentChwytak = null;
// Debug.Log("Destroy chwytak");
// }
if ((bool)currentFish)
{
Destroy(currentFish.gameObject);
currentFish = null;
}
}
private void OnDestroy()
{
// GameManager.Instance._playerData.PlayerSlotsEquip[indexOfslot].rod.status =
// GameManager.PlayerData.CRods.Status.InEquip;
if ((bool)lineHandler)
{
ObiSolver component = lineHandler.GetComponent<ObiSolver>();
SceneSettings.Instance.obiFixedUpdater.solvers.Remove(component);
Destroy(lineHandler.gameObject);
lineHandler = null;
}
}
public void CreateFishingHandler()
{
if (lineHandler == null)
{
if (Owner.Data.currentGear != null && Owner.Data.currentGear.rod != null)
{
Debug.LogError("创建钓组=====");
var rodType = Owner.Data.currentGear.Type;
if (rodType == GearType.Pole || rodType == GearType.SpinningFloat)
{
CreateObiFishingLine(0);
}
else if (rodType == GearType.Spinning)
{
CreateObiFishingLine(1);
}
}
}
}
public void CreateObiFishingLine(int currentLineTypeIndex)
{
// if ((bool)Owner.Gears.Reel && !currentLineHandler)
if (!lineHandler)
{
var indexNames = new[] { "FFishingLine_0", "FFishingLine_1", "FFishingLine_3" };
var path = $"GameItemsPrefabs/Lines/{indexNames[currentLineTypeIndex]}";
var prefab = Resources.Load<GameObject>(path);
// var toRodConnector = rodAsset.lineConnector.GetComponent<Rigidbody>();
GameObject obj = Instantiate(prefab, Owner.Gears.GearParent.position,
Quaternion.identity, Owner.Gears.GearParent);
lineHandler = obj.GetComponent<FLineHandler>();
// lineHandler.transform.SetParent(toRodConnector.transform);
lineHandler.transform.position = rodAsset.lineConnector.position;
lineHandler.LineConnector_0.target = rodAsset.lineConnector;//.GetComponent<Rigidbody>();
// lineHandler.toRodConnector.target = rodAsset.lineConnector;
lineHandler.Rod = this;
var obiSolver = lineHandler.GetComponent<ObiSolver>();
SceneSettings.Instance.obiFixedUpdater.solvers.Add(obiSolver);
}
}
public void RenderLine()
{
if (!lineHandler)
{
return;
}
if (!Owner.Gears.Reel) return;
if (!rodAsset.lineRenderer) return;
var reel = Owner.Gears.Reel;
int num = 0;
bool isBlockLineByFinger = reel.isBlockLineByFinger;
if (reel.AnimatorCtrl.Unlock && isBlockLineByFinger && reel.reelAsset.type == ReelAsset.Type.Normal)
{
rodAsset.lineRenderer.positionCount = rings.Length + 3;
}
else
{
rodAsset.lineRenderer.positionCount = rings.Length + 2;
}
rodAsset.lineRenderer.SetPosition(num, reel.reelAsset.lineIntersectHelper.position);
num++;
if (reel.AnimatorCtrl.Unlock && reel.reelAsset.type == ReelAsset.Type.Normal)
{
rodAsset.lineRenderer.SetPosition(num, reel.reelAsset.lineIntersect.position);
num++;
if (isBlockLineByFinger)
{
// rodAsset.lineRenderer.SetPosition(num, reel.reelAsset.lineFingerPoint.position);
// num++;
}
}
else
{
rodAsset.lineRenderer.SetPosition(num, reel.reelAsset.lineConnector.position);
num++;
}
for (int num2 = 0; num2 < rings.Length; num2++)
{
rodAsset.lineRenderer.SetPosition(num, rings[num2].point.position);
num++;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 06ad550de17c4d38a067e55dab08ab76
timeCreated: 1742313397

View File

@@ -0,0 +1,18 @@
using NBF;
using UnityEngine;
public class FWeight : FPlayerGear
{
public GameObject[] weightObjects;
[HideInInspector]
public float weight;
protected override void OnStart()
{
}
protected override void OnUpdate()
{
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: fb488c96da0743448485e27c40bd889f
timeCreated: 1742313433

View File

@@ -0,0 +1,81 @@
using UnityEngine;
namespace NBF
{
public class JointPinchController : MonoBehaviour
{
// 配置参数
[SerializeField] private float moveSpeed = 5f;
[SerializeField] private float snapDistance = 0.1f;
// 组件引用
private SpringJoint originalSpringJoint;
private FixedJoint pinchJoint;
private Rigidbody rb;
private Transform targetTransform;
private float originalSpring;
public bool isPinched { get; private set; }
private bool moveToTargetDone;
private float _speed;
void Start()
{
rb = GetComponent<Rigidbody>();
originalSpringJoint = GetComponent<SpringJoint>();
}
void FixedUpdate()
{
if (isPinched && targetTransform != null)
{
transform.position =
Vector3.MoveTowards(transform.position, targetTransform.position, Time.deltaTime * _speed);
if (!moveToTargetDone)
{
if (Vector3.Distance(transform.position, targetTransform.position) < 0.1f)
{
moveToTargetDone = true;
}
}
if (moveToTargetDone)
{
transform.position = targetTransform.position;
}
}
}
// 外部调用:开始捏住流程
public void StartPinch(Transform fingerTransform, float speed = 3)
{
_speed = speed;
Rigidbody fingerRb = fingerTransform.GetComponent<Rigidbody>();
if (fingerRb == null)
{
Debug.LogError("目标必须带有Rigidbody");
return;
}
isPinched = true;
rb.useGravity = false;
rb.isKinematic = true;
moveToTargetDone = false;
targetTransform = fingerTransform;
}
// 外部调用:释放捏住
public void ReleasePinch()
{
isPinched = false;
rb.useGravity = true;
rb.isKinematic = false;
targetTransform = null;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: be4c06ad8ef348508e21a2b926e71823
timeCreated: 1743941434