diff --git a/Assets/Prefab/Gameplay/Door.prefab b/Assets/Prefab/Gameplay/Door.prefab index 78b4261..fb38972 100644 --- a/Assets/Prefab/Gameplay/Door.prefab +++ b/Assets/Prefab/Gameplay/Door.prefab @@ -123,9 +123,11 @@ MonoBehaviour: isEnableInteract: 1 isEnableEdit: 1 isEnableConnect: 1 - componentName: - needSignalCount: 1 isOpenInEditor: 1 + needSignalCount: 1 + currentSignalCount: 0 + componentName: + isEnableSendSignal: 1 --- !u!114 &6634784627554641663 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Prefab/Gameplay/HidePlatform.prefab b/Assets/Prefab/Gameplay/HidePlatform.prefab index aba2ffa..af21b12 100644 --- a/Assets/Prefab/Gameplay/HidePlatform.prefab +++ b/Assets/Prefab/Gameplay/HidePlatform.prefab @@ -184,9 +184,11 @@ MonoBehaviour: isEnableInteract: 1 isEnableEdit: 1 isEnableConnect: 1 - componentName: - needSignalCount: 1 isOpenInEditor: 1 + needSignalCount: 1 + currentSignalCount: 0 + componentName: + isEnableSendSignal: 1 disappearType: 0 --- !u!1 &8796126894100698369 GameObject: diff --git a/Assets/Scenes/Test.unity b/Assets/Scenes/Test.unity index 4015dc0..d974a5e 100644 --- a/Assets/Scenes/Test.unity +++ b/Assets/Scenes/Test.unity @@ -1114,6 +1114,74 @@ PrefabInstance: m_AddedGameObjects: [] m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: be07db3098b709a40a6965f50f8c9640, type: 3} +--- !u!1001 &830739288 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 6191493531679122464, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: m_LocalPosition.x + value: -20 + objectReference: {fileID: 0} + - target: {fileID: 6191493531679122464, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: m_LocalPosition.y + value: 3 + objectReference: {fileID: 0} + - target: {fileID: 6191493531679122464, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6191493531679122464, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 6191493531679122464, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6191493531679122464, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6191493531679122464, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6191493531679122464, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6191493531679122464, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6191493531679122464, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7524217001864027819, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: m_Name + value: HidePlatform (2) + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: fff496640cf3cc748b6a608893c657ba, type: 3} --- !u!1001 &865274353 PrefabInstance: m_ObjectHideFlags: 0 @@ -1572,6 +1640,79 @@ PrefabInstance: m_AddedGameObjects: [] m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: be07db3098b709a40a6965f50f8c9640, type: 3} +--- !u!1001 &1707098865 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 5795370598927137930, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: disappearType + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 6191493531679122464, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: m_LocalPosition.x + value: -20 + objectReference: {fileID: 0} + - target: {fileID: 6191493531679122464, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: m_LocalPosition.y + value: 6.56 + objectReference: {fileID: 0} + - target: {fileID: 6191493531679122464, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6191493531679122464, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 6191493531679122464, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6191493531679122464, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6191493531679122464, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6191493531679122464, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6191493531679122464, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6191493531679122464, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7524217001864027819, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: m_Name + value: HidePlatform (4) + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: fff496640cf3cc748b6a608893c657ba, type: 3} --- !u!1001 &1751629950 PrefabInstance: m_ObjectHideFlags: 0 @@ -1769,6 +1910,79 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1001 &1891511232 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 5795370598927137930, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: disappearType + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 6191493531679122464, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: m_LocalPosition.x + value: -20 + objectReference: {fileID: 0} + - target: {fileID: 6191493531679122464, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: m_LocalPosition.y + value: 4.76 + objectReference: {fileID: 0} + - target: {fileID: 6191493531679122464, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6191493531679122464, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 6191493531679122464, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6191493531679122464, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6191493531679122464, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6191493531679122464, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6191493531679122464, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6191493531679122464, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7524217001864027819, guid: fff496640cf3cc748b6a608893c657ba, + type: 3} + propertyPath: m_Name + value: HidePlatform (3) + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: fff496640cf3cc748b6a608893c657ba, type: 3} --- !u!1001 &1948851238 PrefabInstance: m_ObjectHideFlags: 0 @@ -3433,6 +3647,9 @@ SceneRoots: - {fileID: 6865129841946316189} - {fileID: 2578337202726380610} - {fileID: 4318083913684650404} + - {fileID: 1891511232} + - {fileID: 1707098865} + - {fileID: 830739288} - {fileID: 761528196} - {fileID: 1781028406820323425} - {fileID: 7779342506646282638} diff --git a/Assets/Script/Gameplay/Connect/ConnectionLine.cs b/Assets/Script/Gameplay/Connect/ConnectionLine.cs index f00ef41..107413e 100644 --- a/Assets/Script/Gameplay/Connect/ConnectionLine.cs +++ b/Assets/Script/Gameplay/Connect/ConnectionLine.cs @@ -93,24 +93,23 @@ namespace Script.Gameplay.Connect public void OnSignalReceived(bool active, GameObject sender) { - SendSignal(active, this.gameObject); + SendSignal(active, sender); } public bool IsEnableSendSignal { get; set; } = true; public void SendSignal(bool active, GameObject sender) { - var a = _pointA as ISignalReceiver; - var b = _pointB as ISignalReceiver; - ISignalReceiver senderR = sender.GetComponent(); - if (a != senderR) + if (_pointA.GetGameObject() != sender) { - a.OnSignalReceived(active, this.gameObject); + var pointA = _pointA as ISignalReceiver; + pointA?.OnSignalReceived(active, this.gameObject); } - if (b != senderR) + if (_pointB.GetGameObject() != sender) { - b.OnSignalReceived(active, this.gameObject); + var pointB = _pointB as ISignalReceiver; + pointB?.OnSignalReceived(active, this.gameObject); } } } diff --git a/Assets/Script/Gameplay/Facility/BaseFacilityController.cs b/Assets/Script/Gameplay/Facility/BaseFacilityController.cs index 944c996..a5ec724 100644 --- a/Assets/Script/Gameplay/Facility/BaseFacilityController.cs +++ b/Assets/Script/Gameplay/Facility/BaseFacilityController.cs @@ -108,6 +108,11 @@ namespace Script.Gameplay.Facility public virtual void OnSignalReceived(bool active, GameObject sender) { + if (isEnableSendSignal) + { + SendSignal(active, sender); + } + if (active) { CurrentNeedSignalCount++; @@ -130,20 +135,30 @@ namespace Script.Gameplay.Facility set => isEnableSendSignal = value; } + /// + /// + /// + /// 发送true or false + /// 让此物体触发发送的来源者 public virtual void SendSignal(bool active, GameObject sender) { if(!IsEnableSendSignal) return; if (ConnectionLines != null) { - if (ISignalSender.IsSendToSignalSender(sender)) - { - // 防止信号回传给发送者自己 - BUGManager.Instance.LogStackOverflowBUG(this.transform); - return; - } + // if (ISignalSender.IsSendToSignalSender(this.gameObject)) + // { + // // 防止信号回传给发送者自己 + // BUGManager.Instance.LogStackOverflowBUG(this.transform); + // return; + // } foreach (var line in ConnectionLines) { + // 排除掉为sender的连接线 + if (line.gameObject == sender) + { + continue; + } line.OnSignalReceived(active, this.gameObject); } } diff --git a/Assets/Script/Gameplay/Facility/LeverInteractController.cs b/Assets/Script/Gameplay/Facility/LeverInteractController.cs index e47e611..33fe819 100644 --- a/Assets/Script/Gameplay/Facility/LeverInteractController.cs +++ b/Assets/Script/Gameplay/Facility/LeverInteractController.cs @@ -17,19 +17,13 @@ namespace Script.Gameplay.Facility public override void Interact(GameObject interactor) { if (!IsEnableInteract) return; - PullLever(); + PullLever(this.gameObject); } - public override void OnSignalReceived(bool active, GameObject sender) - { - base.OnSignalReceived(active, sender); - //PullLever(); - } - - private void PullLever() + private void PullLever(GameObject sender = null) { isPulled = !isPulled; - SendSignal(isPulled, this.gameObject); + SendSignal(isPulled, sender); // 可选:拉杆动画 if (isPulled) { @@ -42,6 +36,5 @@ namespace Script.Gameplay.Facility transform.rotation = Quaternion.Euler(0f, 0f, 0f); } } - } } \ No newline at end of file diff --git a/Assets/Script/Gameplay/Facility/PressurePlateController.cs b/Assets/Script/Gameplay/Facility/PressurePlateController.cs index 740c547..eb9c822 100644 --- a/Assets/Script/Gameplay/Facility/PressurePlateController.cs +++ b/Assets/Script/Gameplay/Facility/PressurePlateController.cs @@ -11,19 +11,27 @@ namespace Script.Gameplay.Facility [SerializeField] private Vector3 plateOffset = Vector3.up * 0.1f; private bool lastState = false; + private bool hasObject = false; private void FixedUpdate() { if (!isOpenInEditor) return; - bool hasObject = Physics.CheckBox(transform.position + plateOffset, plateSize * 0.5f, Quaternion.identity, detectLayer); + hasObject = Physics.CheckBox(transform.position + plateOffset, plateSize * 0.5f, Quaternion.identity, detectLayer); if (hasObject != lastState) { SendSignal(hasObject, this.gameObject); lastState = hasObject; + if (hasObject) + { + // 被压下动画 + } + else + { + // 弹起动画 + } } } - - + #if UNITY_EDITOR private void OnDrawGizmosSelected() {