Merge branch 'develop' into 火山美术合入2.11
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AibisDream.FixSystem
|
||||
{
|
||||
@@ -6,7 +6,7 @@ namespace AibisDream.FixSystem
|
||||
{
|
||||
public void PlugIn();
|
||||
public void PlugOut();
|
||||
public Vector3 GetSocketPos();
|
||||
public Transform GetSocketPos();
|
||||
public bool IsAvailable(); // 新增方法
|
||||
}
|
||||
|
||||
@@ -24,9 +24,9 @@ namespace AibisDream.FixSystem
|
||||
Debug.Log("Plug Out InitSocket");
|
||||
}
|
||||
|
||||
public Vector3 GetSocketPos()
|
||||
public Transform GetSocketPos()
|
||||
{
|
||||
return transform.position;
|
||||
return transform;
|
||||
}
|
||||
|
||||
public bool IsAvailable()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -6,6 +6,7 @@ using AibisDream.Framework;
|
||||
using Cinemachine;
|
||||
using JetBrains.Annotations;
|
||||
using UnityEngine;
|
||||
using AibisDream.Kit;
|
||||
|
||||
namespace AibisDream.FixSystem
|
||||
{
|
||||
@@ -18,7 +19,6 @@ namespace AibisDream.FixSystem
|
||||
private GameObject _bodyModuleGroup;
|
||||
private GameObject _headModuleGroup;
|
||||
|
||||
public CableSystem CableSystem { get; private set; }
|
||||
[HideInInspector] public HeatMapController heatMapController;
|
||||
|
||||
#endregion
|
||||
@@ -28,7 +28,6 @@ namespace AibisDream.FixSystem
|
||||
private readonly ModuleSystemData _data = new();
|
||||
public bool inHotErr;
|
||||
private int _heatValue;
|
||||
public bool isAvailable;
|
||||
|
||||
private int HeatValue
|
||||
{
|
||||
@@ -62,7 +61,6 @@ namespace AibisDream.FixSystem
|
||||
// 处理内部索引
|
||||
_bodyModuleGroup = transform.Find("Body Module Group")?.gameObject;
|
||||
_headModuleGroup = transform.Find("Scalehandler")?.transform.Find("Head Module Group")?.gameObject;
|
||||
CableSystem = transform.Find("Cable System").GetComponent<CableSystem>();
|
||||
if (transform.Find("HeatMapController"))
|
||||
{
|
||||
heatMapController = transform.Find("HeatMapController").GetComponent<HeatMapController>();
|
||||
@@ -70,9 +68,10 @@ namespace AibisDream.FixSystem
|
||||
|
||||
FixSystemCenter.SystemDic.Register(this);
|
||||
|
||||
// 注册到维修系统管理器
|
||||
RepairSystemManager.Register(this);
|
||||
|
||||
// 注册Camera
|
||||
var virtualCam = transform.Find("Body Module Camera").GetComponent<ICinemachineCamera>();
|
||||
CameraKit.Instance.RegisterCamera(CameraEnum.BodyModule, virtualCam);
|
||||
var virtualCam2 = transform.Find("Body Module Camera Center").GetComponent<ICinemachineCamera>();
|
||||
CameraKit.Instance.RegisterCamera(CameraEnum.BodyModuleCenter, virtualCam2);
|
||||
}
|
||||
@@ -80,7 +79,7 @@ namespace AibisDream.FixSystem
|
||||
private void OnDestroy()
|
||||
{
|
||||
StorageSystem.Instance.UnregisterData<ModuleSystemData>();
|
||||
CameraKit.Instance.UnRegisterCamera(CameraEnum.BodyModule);
|
||||
CameraKit.Instance.UnRegisterCamera(CameraEnum.BodyModuleCenter);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -108,7 +107,7 @@ namespace AibisDream.FixSystem
|
||||
continue; // 跳过不可用的模块
|
||||
}
|
||||
|
||||
float tempDistance = Vector3.Distance(sourcePos, bodyModule.GetSocketPos());
|
||||
float tempDistance = Vector3.Distance(sourcePos, bodyModule.GetSocketPos().position);
|
||||
|
||||
if (tempDistance < closestDistance)
|
||||
{
|
||||
@@ -134,6 +133,7 @@ namespace AibisDream.FixSystem
|
||||
|
||||
public void OpenModuleSlots()
|
||||
{
|
||||
AudioManager.Instance.PlaySfx("event:/ActionFB/mods_open");
|
||||
foreach (var module in BodyModules)
|
||||
{
|
||||
module.OpenPlugSlot();
|
||||
@@ -177,7 +177,7 @@ namespace AibisDream.FixSystem
|
||||
{
|
||||
heatMapController.ShowHeatMap();
|
||||
DisableSystem();
|
||||
ResetPlug();
|
||||
FixPanelSystem.GetRepairPanel<CablePanel>().ResetPlug();
|
||||
}
|
||||
|
||||
public void HideHeatMap()
|
||||
@@ -196,20 +196,12 @@ namespace AibisDream.FixSystem
|
||||
_heatValue = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 插头重新插入初始插孔
|
||||
/// </summary>
|
||||
public void ResetPlug()
|
||||
{
|
||||
CableSystem.ResetPlug();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 激活交互系统
|
||||
/// </summary>
|
||||
public void EnableSystem()
|
||||
{
|
||||
isAvailable = true;
|
||||
// isAvailable = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -217,7 +209,7 @@ namespace AibisDream.FixSystem
|
||||
/// </summary>
|
||||
public void DisableSystem()
|
||||
{
|
||||
isAvailable = false;
|
||||
// isAvailable = false;
|
||||
}
|
||||
|
||||
public void SwitchModuleGroup(ModuleState moduleState)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Collections;
|
||||
using System.Collections;
|
||||
using AibisDream.FixSystem;
|
||||
using AibisDream.Framework;
|
||||
using Yarn.Unity;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -10,6 +9,7 @@ namespace AibisDream
|
||||
{
|
||||
private static BodyModuleSystem BodyModuleSystem => FixSystemCenter.SystemDic.Get<BodyModuleSystem>();
|
||||
private static PunchTapeSystem PunchTapeSystem => FixSystemCenter.SystemDic.Get<PunchTapeSystem>();
|
||||
private static CablePanel CablePanel => FixPanelSystem.GetRepairPanel<CablePanel>();
|
||||
|
||||
[YarnCommand("enable_cut")]
|
||||
public static void EnableCut(string moduleName)
|
||||
@@ -22,7 +22,7 @@ namespace AibisDream
|
||||
[YarnCommand("Reset_Plug")]
|
||||
public static void Reset_Plug()
|
||||
{
|
||||
BodyModuleSystem.CableSystem.ResetPlug();
|
||||
CablePanel.ResetPlug();
|
||||
}
|
||||
|
||||
[YarnCommand("ShowHeatMap")]
|
||||
@@ -54,7 +54,7 @@ namespace AibisDream
|
||||
[YarnCommand("Temp_RemoveUFCover")]
|
||||
public static void Temp_RemoveUFCover()
|
||||
{
|
||||
BodyModuleSystem.CableSystem.ResetPlug();
|
||||
CablePanel.ResetPlug();
|
||||
var _UFModule = BodyModuleSystem.FindBodyModuleByName("UF").transform.GetComponent<UFModule>();
|
||||
_UFModule.RemoveUFCover();
|
||||
}
|
||||
@@ -142,13 +142,13 @@ namespace AibisDream
|
||||
[YarnCommand("DropCable")]
|
||||
public static void DropCable()
|
||||
{
|
||||
BodyModuleSystem.CableSystem.DropDownCable();
|
||||
CablePanel.DropDownCable();
|
||||
}
|
||||
|
||||
[YarnCommand("RetractCable")]
|
||||
public static void RetractCable()
|
||||
{
|
||||
BodyModuleSystem.CableSystem.PullUpCable();
|
||||
CablePanel.PullUpCable();
|
||||
}
|
||||
|
||||
[YarnCommand("StartHeadBreathing")]
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace AibisDream.FixSystem
|
||||
private LineRenderer _stiffLineRenderer; // 用于渲染刚性部分
|
||||
private Vector3[] _points;
|
||||
|
||||
private CableSystem _cableSystem;
|
||||
private CablePanel _cablePanel;
|
||||
|
||||
[SerializeField] private CableConfig config = CableConfig.GeneDefaultConfig();
|
||||
|
||||
@@ -49,8 +49,8 @@ namespace AibisDream.FixSystem
|
||||
|
||||
private void InitComponentRefs()
|
||||
{
|
||||
_cableSystem = transform.parent.GetComponent<CableSystem>();
|
||||
|
||||
_cablePanel = transform.GetComponentInParent<CablePanel>();
|
||||
|
||||
// 复制第一个LineRenderer的属性到第二个
|
||||
_stiffLineRenderer.startWidth = _lineRenderer.startWidth;
|
||||
_stiffLineRenderer.endWidth = _lineRenderer.startWidth;
|
||||
@@ -58,12 +58,12 @@ namespace AibisDream.FixSystem
|
||||
_stiffLineRenderer.startColor = _lineRenderer.startColor;
|
||||
_stiffLineRenderer.endColor = _lineRenderer.startColor;
|
||||
_stiffLineRenderer.sortingLayerName =
|
||||
_cableSystem.CableReelRef.GetComponent<SpriteRenderer>().sortingLayerName;
|
||||
_stiffLineRenderer.sortingOrder = _cableSystem.CableReelRef.GetComponent<SpriteRenderer>().sortingOrder - 1;
|
||||
_cablePanel.CableReelRef.GetComponent<SpriteRenderer>().sortingLayerName;
|
||||
_stiffLineRenderer.sortingOrder = _cablePanel.CableReelRef.GetComponent<SpriteRenderer>().sortingOrder - 1;
|
||||
|
||||
// 连线起止点
|
||||
_start = _cableSystem.CableRootPos;
|
||||
_end = _cableSystem.PlugRef.transform;
|
||||
_start = _cablePanel.CableRootPos;
|
||||
_end = _cablePanel.PlugRef.transform;
|
||||
}
|
||||
|
||||
private void InitPoints()
|
||||
@@ -104,7 +104,7 @@ namespace AibisDream.FixSystem
|
||||
float F = Mathf.Lerp(config.forceMin, config.forceMax, t);
|
||||
|
||||
// 计算出线方向(从转盘出线口到起始点)
|
||||
Vector3 dir = (_start.position - _cableSystem.CableReelRef.transform.position).normalized;
|
||||
Vector3 dir = (_start.position - _cablePanel.CableReelRef.transform.position).normalized;
|
||||
|
||||
// 设置刚性部分
|
||||
for (int i = 0; i < config.stiffCount; i++)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AibisDream.FixSystem
|
||||
{
|
||||
@@ -8,7 +8,7 @@ namespace AibisDream.FixSystem
|
||||
[SerializeField] private float torqueStrength = 200f; // 扭矩强度
|
||||
[SerializeField] private float angularDamping = 5f; // 角速度阻尼
|
||||
|
||||
private CableSystem cableSystem;
|
||||
private CablePanel cablePanel;
|
||||
private float angularVelocity; // 角速度
|
||||
private float currentAngle; // 当前角度
|
||||
public Vector3 outletPos { get; private set; } // 出线口位置
|
||||
@@ -17,8 +17,8 @@ namespace AibisDream.FixSystem
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// 获取CableSystem引用
|
||||
cableSystem = transform.parent.GetComponent<CableSystem>();
|
||||
// 获取CablePanel引用
|
||||
cablePanel = transform.GetComponentInParent<CablePanel>();
|
||||
currentAngle = transform.eulerAngles.z;
|
||||
|
||||
// 获取SpriteRenderer并计算半径
|
||||
@@ -56,16 +56,16 @@ namespace AibisDream.FixSystem
|
||||
public void UpdateRotation()
|
||||
{
|
||||
// 如果PhysicCable激活,不进行旋转
|
||||
if (cableSystem == null || cableSystem.PlugRef == null ||
|
||||
cableSystem.PhysicCableRef.GetComponent<LineRenderer>().enabled) return;
|
||||
if (cablePanel == null || cablePanel.PlugRef == null ||
|
||||
cablePanel.PhysicCableRef.GetComponent<LineRenderer>().enabled) return;
|
||||
|
||||
Vector2 center = transform.position;
|
||||
|
||||
|
||||
// 使用当前出线口位置
|
||||
Vector2 outlet = outletPos;
|
||||
|
||||
|
||||
// 力向量(线缆拉力方向)
|
||||
Vector2 force = (Vector2)cableSystem.PlugRef.transform.position - outlet;
|
||||
Vector2 force = (Vector2)cablePanel.PlugRef.transform.position - outlet;
|
||||
|
||||
// 杆臂向量(力作用点相对于圆心的位置)
|
||||
Vector2 r = outlet - center;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using AibisDream.Framework;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using DG.Tweening;
|
||||
using AibisDream.Kit;
|
||||
|
||||
@@ -24,42 +23,24 @@ namespace AibisDream.FixSystem
|
||||
|
||||
#region 系统状态
|
||||
|
||||
public bool isInDialog;
|
||||
public bool isActive = true;
|
||||
public bool isCableRetracted = true; // 线缆是否收起
|
||||
|
||||
[SerializeField] private Transform retractedPos; // 收起位置
|
||||
[SerializeField] private float dropDownDuration = 0.5f; // 放下动画时长
|
||||
[SerializeField] private float swingDuration = 0.3f; // 摆动动画时长
|
||||
[SerializeField] private float swingAngle = 15f; // 摆动角度
|
||||
|
||||
[HideInInspector] public ISocket curSocket;
|
||||
[HideInInspector] public BodyModule curBodyModule;
|
||||
|
||||
#endregion
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
InitComponentRefs();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
InitComponentRefs();
|
||||
|
||||
InitSystem();
|
||||
LoadCableState();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
EnumEventSystem.Global.Register(InteractionEventEnum.DialogEnd, HandleDialogueComplete);
|
||||
EnumEventSystem.Global.Register(InteractionEventEnum.DialogStart, HandleDialogueStart);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
EnumEventSystem.Global.UnRegister(InteractionEventEnum.DialogEnd, HandleDialogueComplete);
|
||||
EnumEventSystem.Global.UnRegister(InteractionEventEnum.DialogStart, HandleDialogueStart);
|
||||
}
|
||||
|
||||
private void InitComponentRefs()
|
||||
{
|
||||
@@ -69,7 +50,7 @@ namespace AibisDream.FixSystem
|
||||
CableRootPos = CableReelRef.transform.Find("Cable Root Pos").transform;
|
||||
PhysicCableRef = transform.Find("PhysicCable").GetComponent<PhysicCable>();
|
||||
|
||||
BodyModuleSystem = transform.parent.GetComponent<BodyModuleSystem>();
|
||||
BodyModuleSystem = FixSystemCenter.SystemDic.Get<BodyModuleSystem>();
|
||||
}
|
||||
|
||||
private void InitSystem()
|
||||
@@ -143,16 +124,6 @@ namespace AibisDream.FixSystem
|
||||
|
||||
#region 系统可用状态
|
||||
|
||||
private void HandleDialogueStart()
|
||||
{
|
||||
isInDialog = true;
|
||||
}
|
||||
|
||||
private void HandleDialogueComplete()
|
||||
{
|
||||
isInDialog = false;
|
||||
}
|
||||
|
||||
public void Disable_plugInput()
|
||||
{
|
||||
isActive = false;
|
||||
@@ -163,15 +134,6 @@ namespace AibisDream.FixSystem
|
||||
isActive = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询插线系统是否可用
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsPlugAvailable()
|
||||
{
|
||||
return isActive && !isInDialog;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public void PullUpCable()
|
||||
@@ -180,7 +142,7 @@ namespace AibisDream.FixSystem
|
||||
//禁用plug交互
|
||||
Disable_plugInput();
|
||||
ResetPlug();
|
||||
PlugRef.SetPhysicCableActive(false);
|
||||
// PlugRef.SetPhysicCableActive(false);
|
||||
PlugRef.GetComponent<SpriteRenderer>().sortingLayerName =
|
||||
CableReelRef.GetComponent<SpriteRenderer>().sortingLayerName;
|
||||
PlugRef.GetComponent<SpriteRenderer>().sortingOrder = 41;
|
||||
@@ -195,12 +157,11 @@ namespace AibisDream.FixSystem
|
||||
public void DropDownCable()
|
||||
{
|
||||
if (!isCableRetracted) return;
|
||||
Debug.Log("DorpDown");
|
||||
PlugRef.PullUpSocket();
|
||||
CableReelRef.ResetRotation();
|
||||
PlugRef.transform.DOMove(PlugRef.GetStartPos(), 0.1f).OnComplete(() =>
|
||||
{
|
||||
PlugRef.SwitchToPhysicCableState();
|
||||
// PlugRef.SwitchToPhysicCableState();
|
||||
isCableRetracted = false;
|
||||
SaveCableState();
|
||||
// 添加一个短暂的延迟来确保状态正确设置
|
||||
@@ -224,7 +185,6 @@ namespace AibisDream.FixSystem
|
||||
CableReelRef.GetComponent<SpriteRenderer>().sortingLayerName;
|
||||
PlugRef.GetComponent<SpriteRenderer>().sortingOrder = 41;
|
||||
isCableRetracted = true;
|
||||
//SaveCableState();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using AibisDream.Framework;
|
||||
using Newtonsoft.Json;
|
||||
using UnityEngine;
|
||||
@@ -35,7 +35,6 @@ namespace AibisDream.FixSystem
|
||||
|
||||
[Header("CutText闪烁效果")] private float cutTextFlickerThreshold = 0.4f; // 开始闪烁的阈值
|
||||
private float cutTextFlickerInterval = 0.1f; // 闪烁间隔
|
||||
private float cutTextFlickerTimer = 0f; // 闪烁计时器
|
||||
private bool isCutTextFlickering = false; // 是否正在闪烁
|
||||
private Coroutine flickerCoroutine; // 闪烁协程引用
|
||||
|
||||
@@ -44,7 +43,6 @@ namespace AibisDream.FixSystem
|
||||
// 模块基本数据
|
||||
[SerializeField] public BodyModuleData data;
|
||||
public bool available = true;
|
||||
private bool _cutting;
|
||||
private bool _isOpen;
|
||||
|
||||
private void Awake()
|
||||
@@ -102,9 +100,9 @@ namespace AibisDream.FixSystem
|
||||
{
|
||||
}
|
||||
|
||||
public Vector3 GetSocketPos()
|
||||
public Transform GetSocketPos()
|
||||
{
|
||||
return _socketPos.position;
|
||||
return _socketPos;
|
||||
}
|
||||
|
||||
public void OpenPlugSlot()
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using AibisDream.Framework;
|
||||
using AibisDream;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using AibisDream.FixSystem;
|
||||
|
||||
public class UFModule : MonoBehaviour
|
||||
{
|
||||
private GameObject _ufCover;
|
||||
private GameObject _ufModule;
|
||||
|
||||
private GameObject _ufSocket;
|
||||
private GameObject _ufSocket;
|
||||
|
||||
private GameObject _ufColor;
|
||||
private UFData _ufData=new ();
|
||||
|
||||
private UFData _ufData = new();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
// 将数据注册到数据容器内
|
||||
@@ -24,9 +23,8 @@ public class UFModule : MonoBehaviour
|
||||
_ufModule = transform.Find("Module Pic").gameObject;
|
||||
_ufSocket = transform.Find("Socket").gameObject;
|
||||
_ufCover = _ufModule.transform.Find("Cover").gameObject;
|
||||
_ufColor=_ufModule.transform.Find("Color").gameObject;
|
||||
_ufColor = _ufModule.transform.Find("Color").gameObject;
|
||||
}
|
||||
// Start is called before the first frame update
|
||||
|
||||
public void RemoveUFCover()
|
||||
{
|
||||
@@ -44,7 +42,7 @@ public class UFModule : MonoBehaviour
|
||||
{
|
||||
_ufModule.SetActive(false);
|
||||
_ufSocket.SetActive(false);
|
||||
|
||||
|
||||
}
|
||||
|
||||
_ufData.isUFRemoved = true;
|
||||
@@ -79,7 +77,7 @@ public class UFModule : MonoBehaviour
|
||||
|
||||
_ufData.isColorRemoved = false;
|
||||
}
|
||||
public void RemoveUFColor()
|
||||
public void RemoveUFColor()
|
||||
{
|
||||
if (_ufColor.activeInHierarchy)
|
||||
{
|
||||
|
||||
@@ -1,268 +0,0 @@
|
||||
using AibisDream.Framework;
|
||||
using AibisDream.Kit;
|
||||
using AibisDream.Utility;
|
||||
using DG.Tweening;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace AibisDream.FixSystem
|
||||
{
|
||||
[RequireComponent(typeof(EventTriggerEx))]
|
||||
public class Plug : MonoBehaviour, IInteraction
|
||||
{
|
||||
private static readonly int ShineFade = Shader.PropertyToID("_ShineFade");
|
||||
|
||||
#region 插头当前信息
|
||||
|
||||
private Vector3 _startPos;
|
||||
|
||||
private readonly Vector3 _pickupOffset = new(0, 0, 0);
|
||||
private readonly Quaternion _pickupRotationOffset = Quaternion.Euler(0, 0, 30);
|
||||
private readonly Quaternion _initRotation = Quaternion.Euler(0, 0, 180);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 索引
|
||||
|
||||
private CableSystem _cableSystem;
|
||||
private SpriteRenderer _sprite;
|
||||
private Transform _plugRootPos;
|
||||
private EventTriggerEx _trigger;
|
||||
|
||||
#endregion
|
||||
|
||||
private bool _isDragging;
|
||||
private bool _isPhysicCableActive;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
InitComponentRef();
|
||||
EventRegister();
|
||||
_startPos = new Vector3(transform.position.x + 0.3f, transform.position.y - 2f,
|
||||
transform.position.z); // 初始化时记录初始位置
|
||||
}
|
||||
|
||||
private void InitComponentRef()
|
||||
{
|
||||
_cableSystem = transform.parent.GetComponent<CableSystem>();
|
||||
_sprite = GetComponent<SpriteRenderer>();
|
||||
_plugRootPos = transform.Find("Plug Root Pos");
|
||||
_trigger = GetComponent<EventTriggerEx>();
|
||||
|
||||
// 处理插头高亮
|
||||
_sprite.material.SetFloat(ShineFade, GlobalVariableKit.IsPlugHighLight ? 1 : 0);
|
||||
}
|
||||
|
||||
private void EventRegister()
|
||||
{
|
||||
_trigger.Register(EventTriggerType.Drag, OnDrag);
|
||||
_trigger.Register(EventTriggerType.PointerDown, OnPointerDown);
|
||||
_trigger.Register(EventTriggerType.PointerUp, OnPointerUp);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 插入某个socket
|
||||
/// </summary>
|
||||
/// <param name="targetSocket">目标socket</param>
|
||||
private void InsertSocket(ISocket targetSocket)
|
||||
{
|
||||
// 修改插头位置
|
||||
transform.position = targetSocket.GetSocketPos();
|
||||
_cableSystem.CableRef.SetEndPos(transform);
|
||||
|
||||
// 处理插槽插入
|
||||
targetSocket.PlugIn();
|
||||
AudioManager.Instance.PlaySfx("event:/FollowInput/plugin");
|
||||
_sprite.enabled = false;
|
||||
|
||||
_cableSystem.curSocket = targetSocket;
|
||||
if (targetSocket is BodyModule bodyModule)
|
||||
{
|
||||
// 插入模块时触发插入事件
|
||||
EnumEventSystem.Global.Send(EventEnum.PlugIn);
|
||||
_cableSystem.curBodyModule = bodyModule;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从某个Socket拔出来
|
||||
/// </summary>
|
||||
public void PullUpSocket()
|
||||
{
|
||||
// 修改线头位置
|
||||
_cableSystem.CableRef.SetEndPos(_plugRootPos);
|
||||
|
||||
_cableSystem.curSocket?.PlugOut();
|
||||
AudioManager.Instance.PlaySfx("event:/FollowInput/plugout");
|
||||
_sprite.enabled = true;
|
||||
|
||||
if (_cableSystem.curSocket is BodyModule)
|
||||
{
|
||||
// 从模块拔出时触发事件
|
||||
EnumEventSystem.Global.Send(EventEnum.PlugOut);
|
||||
_cableSystem.curBodyModule = null;
|
||||
|
||||
// 清除屏幕
|
||||
var screenSystem = FixSystemCenter.SystemDic.Get<ScreenSystem>();
|
||||
if (screenSystem != null)
|
||||
{
|
||||
screenSystem.ClearTextScreen();
|
||||
}
|
||||
}
|
||||
|
||||
_cableSystem.curSocket = null;
|
||||
}
|
||||
|
||||
private void OnDrag(BaseEventData eventData)
|
||||
{
|
||||
// 系统被锁定就返回
|
||||
if (!_cableSystem.IsPlugAvailable())
|
||||
{
|
||||
Debug.Log("OnDrag - System not available");
|
||||
return;
|
||||
}
|
||||
|
||||
// 未被拖拽也返回
|
||||
if (!_isDragging)
|
||||
{
|
||||
Debug.Log("OnDrag - Not dragging");
|
||||
return;
|
||||
}
|
||||
|
||||
if (eventData is PointerEventData pointerData)
|
||||
{
|
||||
transform.position = CameraKit.GetMouseWorldPos(pointerData.position);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPointerDown(BaseEventData eventData)
|
||||
{
|
||||
if (eventData is PointerEventData { button: PointerEventData.InputButton.Right })
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GetComponent<SpriteRenderer>().sortingLayerName = "Tools";
|
||||
GetComponent<SpriteRenderer>().sortingOrder = 48;
|
||||
// 系统被锁定就返回
|
||||
if (!_cableSystem.IsPlugAvailable()) return;
|
||||
|
||||
// 首次拖拽后关闭高亮
|
||||
if (GlobalVariableKit.IsPlugHighLight)
|
||||
{
|
||||
GlobalVariableKit.IsPlugHighLight = false;
|
||||
_sprite.material.SetFloat(ShineFade, 0);
|
||||
DialogController.Instance.StartDialogNode("拿起插头");
|
||||
}
|
||||
|
||||
// 开启拖拽
|
||||
_isDragging = true;
|
||||
|
||||
// 进行插拔动作
|
||||
if (_cableSystem.curSocket != null) PullUpSocket();
|
||||
|
||||
// 调整插头形状
|
||||
AdjustPlugPos();
|
||||
|
||||
// 关闭 PhysicCable 的更新,并显示 Cable 的 LineRenderer
|
||||
_cableSystem.PhysicCableRef.GetComponent<LineRenderer>().enabled = false;
|
||||
_isPhysicCableActive = false;
|
||||
_cableSystem.CableRef.ShowCable();
|
||||
|
||||
// 打开所有模块
|
||||
FixSystemCenter.SystemDic.Get<BodyModuleSystem>().OpenModuleSlots();
|
||||
AudioManager.Instance.PlaySfx("event:/ActionFB/mods_open");
|
||||
AudioManager.Instance.PlaySfx("event:/FollowInput/plugpick");
|
||||
}
|
||||
|
||||
private void OnPointerUp(BaseEventData eventData)
|
||||
{
|
||||
Debug.Log("OnPointerUp");
|
||||
if (eventData is PointerEventData { button: PointerEventData.InputButton.Right })
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 停止拖拽
|
||||
_isDragging = false;
|
||||
|
||||
// 寻找可吸附的Module
|
||||
if (_cableSystem.TryFindClosestModule(transform.position, out var targetModule))
|
||||
{
|
||||
// 找到了就插入目标Module
|
||||
InsertSocket(targetModule);
|
||||
FixSystemCenter.SystemDic.Get<BodyModuleSystem>().CloseModuleSlots(targetModule);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 没找到就回到初始位置
|
||||
ReturnToStartPosition();
|
||||
FixSystemCenter.SystemDic.Get<BodyModuleSystem>().CloseModuleSlots(null);
|
||||
}
|
||||
}
|
||||
|
||||
public void ReturnToStartPosition()
|
||||
{
|
||||
PlugPosBack();
|
||||
transform.DOMove(_startPos, 0.1f).OnComplete(() =>
|
||||
{
|
||||
_cableSystem.CableReelRef.ResetRotation();
|
||||
SwitchToPhysicCableState();
|
||||
});
|
||||
}
|
||||
|
||||
private void AdjustPlugPos()
|
||||
{
|
||||
transform.position += _pickupOffset;
|
||||
transform.rotation = _pickupRotationOffset;
|
||||
}
|
||||
|
||||
private void PlugPosBack()
|
||||
{
|
||||
transform.position -= _pickupOffset;
|
||||
transform.rotation = _initRotation;
|
||||
}
|
||||
|
||||
public void SwitchToPhysicCableState()
|
||||
{
|
||||
_cableSystem.PhysicCableRef.Init(transform.position);
|
||||
_cableSystem.CableRef.HideCable();
|
||||
_cableSystem.PhysicCableRef.GetComponent<LineRenderer>().enabled = true;
|
||||
_isPhysicCableActive = true;
|
||||
}
|
||||
|
||||
public void SetPhysicCableActive(bool active)
|
||||
{
|
||||
_isPhysicCableActive = active;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_isPhysicCableActive && !_cableSystem.isCableRetracted)
|
||||
{
|
||||
_cableSystem.PhysicCableRef.physicLine.UpdatePlug(transform);
|
||||
}
|
||||
}
|
||||
|
||||
void OnDrawGizmosSelected()
|
||||
{
|
||||
Gizmos.color = Color.yellow;
|
||||
Gizmos.DrawWireSphere(transform.position, 0.5f);
|
||||
}
|
||||
|
||||
public bool IsActive => true;
|
||||
|
||||
public bool IsAvailable => _cableSystem.BodyModuleSystem.isAvailable && !_cableSystem.isCableRetracted;
|
||||
|
||||
public GameObject GetGameObject()
|
||||
{
|
||||
return gameObject;
|
||||
}
|
||||
|
||||
public Vector3 GetStartPos()
|
||||
{
|
||||
return _startPos;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eceaf3bcec07439d8391175331323e3c
|
||||
timeCreated: 1731043337
|
||||
Reference in New Issue
Block a user