This commit is contained in:
2025-01-25 13:29:46 +08:00
parent b47b29f996
commit 5703efd59e
10 changed files with 392 additions and 67 deletions
@@ -1,4 +1,5 @@
using System;
using DG.Tweening.Plugins.Core.PathCore;
using UnityEngine;
namespace AibisDream.FixSystem
@@ -7,6 +8,8 @@ namespace AibisDream.FixSystem
public class Cable : MonoBehaviour
{
private Transform _start;
public Transform _controlPoint;
private Transform _end;
private LineRenderer _lineRenderer;
@@ -65,6 +68,7 @@ namespace AibisDream.FixSystem
float t = Mathf.InverseLerp(config.dstMin, config.dstMax, (_start.position - _end.position).magnitude);
float F = Mathf.Lerp(config.forceMin, config.forceMax, t);
_points[0] = _start.position;
_points[1] = _controlPoint.position;
_points[^1] = _end.position;
for (int ik = 0; ik < config.k; ik++)
@@ -1,5 +1,6 @@
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.PlayerLoop;
using Yarn.Unity;
namespace AibisDream.FixSystem
@@ -10,7 +11,11 @@ namespace AibisDream.FixSystem
public Plug PlugRef { get; private set; }
public Cable CableRef { get; private set; }
public PhysicCable PhysicCableRef { get; private set; }
public Transform CableRootPos { get; private set; }
public Transform ControlPoint { get; private set; }
public ISocket InitSocket { get; private set; }
public BodyModuleSystem BodyModuleSystem { get; private set; }
@@ -55,13 +60,19 @@ namespace AibisDream.FixSystem
CableRef = transform.Find("Cable").GetComponent<Cable>();
CableRootPos = transform.Find("Cable Root Pos").transform;
InitSocket = transform.Find("Init Socket").GetComponent<ISocket>();
PhysicCableRef = transform.Find("PhysicCable").GetComponent<PhysicCable>();
BodyModuleSystem = transform.parent.GetComponent<BodyModuleSystem>();
}
private void InitSystem()
{
PlugRef.InitPlug(InitSocket);
//PlugRef.InitPlug(InitSocket);
PhysicCableRef.Init();
}
public void Update()
{
}
public void ResetPlug()
+25 -5
View File
@@ -1,6 +1,7 @@
using AibisDream.Framework;
using AibisDream.Utility;
using DG.Tweening;
using MeadowGames.UINodeConnect4.GraphicRenderer;
using UnityEngine;
using UnityEngine.EventSystems;
@@ -52,7 +53,12 @@ namespace AibisDream.FixSystem
public void InitPlug(ISocket initSocket)
{
InsertSocket(initSocket);
//InsertSocket(initSocket);
}
public void InitPlug()
{
_cableSystem.PhysicCableRef.Init();
//_cableSystem.PhysicCableRef.physicLine.UpdatePlug(this.transform);
}
/// <summary>
@@ -143,12 +149,26 @@ namespace AibisDream.FixSystem
else
{
// 没找到就插回初始Socket,需要播动画
transform.DOMove(_cableSystem.InitSocket.GetSocketPos(), 0.1f).OnComplete(() =>
{
InsertSocket(_cableSystem.InitSocket);
});
// transform.DOMove(_cableSystem.InitSocket.GetSocketPos(), 0.1f).OnComplete(() =>
// {
// InsertSocket(_cableSystem.InitSocket);
// });
}
}
public void Update()
{
_cableSystem.PhysicCableRef.physicLine.UpdateEndPoint(this.transform.position);
// if(_cableSystem.curSocket!=null&&_isDragging==false)
// {
// _cableSystem.PhysicCableRef.physicLine.UpdatePlug(this.transform);
// }
// else
// {
// _cableSystem.PhysicCableRef.physicLine.UpdateLine(this.transform);
// }
}
private void AdjustPlugPos()
{