91 lines
1.8 KiB
C#
91 lines
1.8 KiB
C#
using Obi;
|
|
using UnityEngine;
|
|
|
|
public class LineHandler : 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 Transform LineConnector_0;
|
|
|
|
public SpringJoint LineConnector_1;
|
|
|
|
public SpringJoint LineConnector_2;
|
|
|
|
public SpringJoint LineConnector_3;
|
|
|
|
[HideInInspector]
|
|
public FishingLine currentRodFishingLineComponent;
|
|
|
|
[HideInInspector]
|
|
public ObiParticleAttachment toRodConnector;
|
|
|
|
public float PhisicsLineOut;
|
|
|
|
public float ObiLineOut;
|
|
|
|
public Rigidbody EndLineRigidbody_1;
|
|
|
|
public Rigidbody EndLineRigidbody_2;
|
|
|
|
public Rigidbody EndLineRigidbody_3;
|
|
|
|
public Material pointConnectorColorValid;
|
|
|
|
public Material pointConnectorColorInvalid;
|
|
|
|
private void Start()
|
|
{
|
|
ObiLineOut = obiRopeSegment_1.stretchingScale;
|
|
PhisicsLineOut = LineConnector_1.maxDistance;
|
|
if ((bool)LineConnector_1)
|
|
{
|
|
EndLineRigidbody_1 = LineConnector_1.GetComponent<Rigidbody>();
|
|
}
|
|
if ((bool)LineConnector_2)
|
|
{
|
|
EndLineRigidbody_2 = LineConnector_2.GetComponent<Rigidbody>();
|
|
}
|
|
if ((bool)LineConnector_3)
|
|
{
|
|
EndLineRigidbody_3 = LineConnector_3.GetComponent<Rigidbody>();
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if ((bool)currentRodFishingLineComponent)
|
|
{
|
|
if (PhisicsLineOut == 0f)
|
|
{
|
|
ObiLineOut = 0f;
|
|
}
|
|
ObiLineOut = Mathf.MoveTowards(ObiLineOut, PhisicsLineOut + PhisicsLineOut * 0.2f, Time.deltaTime * 2f);
|
|
obiRopeSegment_1.stretchingScale = ObiLineOut;
|
|
LineConnector_1.maxDistance = PhisicsLineOut;
|
|
}
|
|
}
|
|
|
|
public void SetSegmentTwoLenght(float value)
|
|
{
|
|
if ((bool)LineConnector_2)
|
|
{
|
|
LineConnector_2.maxDistance = value;
|
|
obiRopeSegment_2.stretchingScale = value;
|
|
}
|
|
}
|
|
}
|