using DG.Tweening; using System.Collections; using System.Collections.Generic; using Unity.VisualScripting.Antlr3.Runtime; using UnityEngine; /// /// 接线盖子 /// public class Device_Cover : Device_Base { /// /// 盖子是否已打开 /// public bool isOpen; /// /// 是否检查接线完好 /// public bool isCheckOK; [Tooltip("左盖子螺丝")] public Tool_Screw cover_screw_Left; [Tooltip("右盖子螺丝")] public Tool_Screw cover_screw_Right; [Tooltip("左盖子封印")] public Device_Seal cover_seal_Left; [Tooltip("右盖子封印")] public Device_Seal cover_seal_Right; protected override void OnMDown() { base.OnMDown(); if (!isMoving) { if ((triggerAction == null ? 0 : triggerAction.Invoke(triggerName, false)) == 0) { isCheckOK = true; if (!isOpen) { //螺丝都拧松才能拆盖子 if (!cover_screw_Left.isInstall && !cover_screw_Right.isInstall) { Open(); } } else { Close(); } } } } /// /// 打开盖子 /// public void Open() { //盖子螺丝不在动才能动盖子 if (!cover_screw_Left.isMoving && !cover_screw_Right.isMoving) { isMoving = true; Debug.Log("打开盖子"); startAction?.Invoke(); Transform parent = cover_screw_Left.transform.parent; cover_screw_Left.transform.parent = transform; cover_screw_Right.transform.parent = transform; transform.DOLocalMove(new Vector3(transform.localPosition.x, -0.1388763f, -0.2485413f), 2).OnComplete(() => { isOpen = true; cover_screw_Left.transform.parent = parent; cover_screw_Right.transform.parent = parent; isMoving = false; int result = (triggerAction == null ? 0 : triggerAction.Invoke(triggerName, true)); endAction?.Invoke(); }); } } /// /// 盖上盖子 /// public void Close() { //盖子螺丝不在动才能动盖子 if (!cover_screw_Left.isMoving && !cover_screw_Right.isMoving) { isMoving=true; Debug.Log("盖上盖子"); startAction?.Invoke(); Transform parent = cover_screw_Left.transform.parent; cover_screw_Left.transform.parent = transform; cover_screw_Right.transform.parent = transform; transform.DOLocalMove(new Vector3(transform.localPosition.x, 0.01112366f, -0.09854126f), 2).OnComplete(() => { isOpen = false; cover_screw_Left.transform.parent = parent; cover_screw_Right.transform.parent = parent; isMoving = false; int result = (triggerAction == null ? 0 : triggerAction.Invoke(triggerName, true)); endAction?.Invoke(); }); } } }