diff --git a/Assets/Prefab/Scene/qiu8.prefab b/Assets/Prefab/Scene/qiu8.prefab index 291cdd3..bb09fc6 100644 --- a/Assets/Prefab/Scene/qiu8.prefab +++ b/Assets/Prefab/Scene/qiu8.prefab @@ -385,6 +385,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 557728369502303064} + - component: {fileID: 1499280950172909919} m_Layer: 0 m_Name: qiu8 m_TagString: Untagged @@ -424,6 +425,32 @@ Transform: - {fileID: 5115764902991000897} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 95.01, z: 0} +--- !u!114 &1499280950172909919 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2989472596451924024} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b8f77d0a85f044dcb710f54ed56f5479, type: 3} + m_Name: + m_EditorClassIdentifier: + isEnableInteract: 0 + isEnableEdit: 0 + isEnableConnect: 0 + isOpenInEditor: 1 + needSignalCount: 1 + currentSignalCount: 0 + componentName: + isEnableSendSignal: 0 + lidPrefab: {fileID: 7234780928249722040} + openSound: {fileID: 0} + audioSource: {fileID: 0} + closedPos: {x: 0, y: 0, z: 0} + openPos: {x: 0, y: 25, z: 0} + lidMoveDuration: 6 --- !u!1 &3064490981391950781 GameObject: m_ObjectHideFlags: 0 @@ -1476,7 +1503,7 @@ Transform: m_GameObject: {fileID: 7234780928249722040} serializedVersion: 2 m_LocalRotation: {x: -0.7071068, y: 0, z: -0, w: 0.7071067} - m_LocalPosition: {x: -0, y: -3, z: -0.8} + m_LocalPosition: {x: -0, y: 0, z: 0} m_LocalScale: {x: 4442.731, y: 4442.731, z: 4442.731} m_ConstrainProportionsScale: 0 m_Children: [] diff --git a/Assets/Scenes/Test.unity b/Assets/Scenes/Test.unity index 9ecde56..8d63fbf 100644 --- a/Assets/Scenes/Test.unity +++ b/Assets/Scenes/Test.unity @@ -547,7 +547,7 @@ PrefabInstance: - target: {fileID: 40184683368772887, guid: 85652dd0e36597644aa5b3bc9603797b, type: 3} propertyPath: m_LocalPosition.x - value: 25.97 + value: 27.73 objectReference: {fileID: 0} - target: {fileID: 40184683368772887, guid: 85652dd0e36597644aa5b3bc9603797b, type: 3} @@ -562,12 +562,12 @@ PrefabInstance: - target: {fileID: 40184683368772887, guid: 85652dd0e36597644aa5b3bc9603797b, type: 3} propertyPath: m_LocalRotation.w - value: 1 + value: 0.7071068 objectReference: {fileID: 0} - target: {fileID: 40184683368772887, guid: 85652dd0e36597644aa5b3bc9603797b, type: 3} propertyPath: m_LocalRotation.x - value: 0 + value: -0.7071068 objectReference: {fileID: 0} - target: {fileID: 40184683368772887, guid: 85652dd0e36597644aa5b3bc9603797b, type: 3} @@ -582,7 +582,7 @@ PrefabInstance: - target: {fileID: 40184683368772887, guid: 85652dd0e36597644aa5b3bc9603797b, type: 3} propertyPath: m_LocalEulerAnglesHint.x - value: 0 + value: -90 objectReference: {fileID: 0} - target: {fileID: 40184683368772887, guid: 85652dd0e36597644aa5b3bc9603797b, type: 3} @@ -594,6 +594,16 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} + - target: {fileID: 3535959014221630543, guid: 85652dd0e36597644aa5b3bc9603797b, + type: 3} + propertyPath: sendSignalMode + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3535959014221630543, guid: 85652dd0e36597644aa5b3bc9603797b, + type: 3} + propertyPath: controlTarget.Array.data[0] + value: + objectReference: {fileID: 914217104} - target: {fileID: 6268190613584218029, guid: 85652dd0e36597644aa5b3bc9603797b, type: 3} propertyPath: m_Name @@ -925,6 +935,86 @@ PrefabInstance: m_AddedGameObjects: [] m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: ddd89e93db279184daa80d86bd4e770f, type: 3} +--- !u!1001 &914217103 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 557728369502303064, guid: 4a0c054b49059364d824805325150487, + type: 3} + propertyPath: m_LocalPosition.x + value: -0.67113495 + objectReference: {fileID: 0} + - target: {fileID: 557728369502303064, guid: 4a0c054b49059364d824805325150487, + type: 3} + propertyPath: m_LocalPosition.y + value: 41.5 + objectReference: {fileID: 0} + - target: {fileID: 557728369502303064, guid: 4a0c054b49059364d824805325150487, + type: 3} + propertyPath: m_LocalPosition.z + value: 69.1 + objectReference: {fileID: 0} + - target: {fileID: 557728369502303064, guid: 4a0c054b49059364d824805325150487, + type: 3} + propertyPath: m_LocalRotation.w + value: 0.67552584 + objectReference: {fileID: 0} + - target: {fileID: 557728369502303064, guid: 4a0c054b49059364d824805325150487, + type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 557728369502303064, guid: 4a0c054b49059364d824805325150487, + type: 3} + propertyPath: m_LocalRotation.y + value: 0.7373363 + objectReference: {fileID: 0} + - target: {fileID: 557728369502303064, guid: 4a0c054b49059364d824805325150487, + type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 557728369502303064, guid: 4a0c054b49059364d824805325150487, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 557728369502303064, guid: 4a0c054b49059364d824805325150487, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 95.01 + objectReference: {fileID: 0} + - target: {fileID: 557728369502303064, guid: 4a0c054b49059364d824805325150487, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2989472596451924024, guid: 4a0c054b49059364d824805325150487, + type: 3} + propertyPath: m_Name + value: qiu8 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 4a0c054b49059364d824805325150487, type: 3} +--- !u!114 &914217104 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 1499280950172909919, guid: 4a0c054b49059364d824805325150487, + type: 3} + m_PrefabInstance: {fileID: 914217103} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b8f77d0a85f044dcb710f54ed56f5479, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1001 &993640446 PrefabInstance: m_ObjectHideFlags: 0 @@ -1061,6 +1151,74 @@ PrefabInstance: m_AddedGameObjects: [] m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: be07db3098b709a40a6965f50f8c9640, type: 3} +--- !u!1001 &1079319502 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 2356242250385391551, guid: be07db3098b709a40a6965f50f8c9640, + type: 3} + propertyPath: m_LocalPosition.x + value: 25.15 + objectReference: {fileID: 0} + - target: {fileID: 2356242250385391551, guid: be07db3098b709a40a6965f50f8c9640, + type: 3} + propertyPath: m_LocalPosition.y + value: 0.37 + objectReference: {fileID: 0} + - target: {fileID: 2356242250385391551, guid: be07db3098b709a40a6965f50f8c9640, + type: 3} + propertyPath: m_LocalPosition.z + value: -9.8 + objectReference: {fileID: 0} + - target: {fileID: 2356242250385391551, guid: be07db3098b709a40a6965f50f8c9640, + type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 2356242250385391551, guid: be07db3098b709a40a6965f50f8c9640, + type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2356242250385391551, guid: be07db3098b709a40a6965f50f8c9640, + type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2356242250385391551, guid: be07db3098b709a40a6965f50f8c9640, + type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2356242250385391551, guid: be07db3098b709a40a6965f50f8c9640, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2356242250385391551, guid: be07db3098b709a40a6965f50f8c9640, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2356242250385391551, guid: be07db3098b709a40a6965f50f8c9640, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6227019518059310355, guid: be07db3098b709a40a6965f50f8c9640, + type: 3} + propertyPath: m_Name + value: Lever (1) + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: be07db3098b709a40a6965f50f8c9640, type: 3} --- !u!1001 &1240498723 PrefabInstance: m_ObjectHideFlags: 0 @@ -3267,4 +3425,6 @@ SceneRoots: - {fileID: 6671531601154661223} - {fileID: 668609047} - {fileID: 1067528595} + - {fileID: 1079319502} - {fileID: 1087152227488215159} + - {fileID: 914217103} diff --git a/Assets/Script/Gameplay/Facility/TianHeController.cs b/Assets/Script/Gameplay/Facility/TianHeController.cs new file mode 100644 index 0000000..6246c69 --- /dev/null +++ b/Assets/Script/Gameplay/Facility/TianHeController.cs @@ -0,0 +1,46 @@ +using UnityEngine; +using System.Collections; + +namespace Script.Gameplay.Facility +{ + public class TianHeController : BaseFacilityController + { + [SerializeField] private GameObject lidPrefab; + [SerializeField] private AudioClip openSound; + [SerializeField] private AudioSource audioSource; + + private Coroutine lidCoroutine; + [SerializeField] private Vector3 closedPos = new Vector3(0f, 0f, 0f); + [SerializeField] private Vector3 openPos = new Vector3(0f, 0.5f, 0f); + [SerializeField] private float lidMoveDuration = 1f; // 盖子动画时长 + + public override void OnSignalReceived(bool active, GameObject sender) + { + base.OnSignalReceived(active, sender); + // 停止之前的动画 + if (lidCoroutine != null) + StopCoroutine(lidCoroutine); + // 启动新的动画 + lidCoroutine = StartCoroutine(MoveLid(active ? openPos : closedPos)); + if (audioSource != null && openSound != null && active) + { + audioSource.clip = openSound; + audioSource.Play(); + } + } + + private IEnumerator MoveLid(Vector3 targetPos) + { + Vector3 startPos = lidPrefab.transform.localPosition; + float elapsed = 0f; + while (elapsed < lidMoveDuration) + { + elapsed += Time.deltaTime; + lidPrefab.transform.localPosition = Vector3.Lerp(startPos, targetPos, elapsed / lidMoveDuration); + yield return null; + } + + lidPrefab.transform.localPosition = targetPos; + } + } +} \ No newline at end of file diff --git a/Assets/Script/Gameplay/Facility/TianHeController.cs.meta b/Assets/Script/Gameplay/Facility/TianHeController.cs.meta new file mode 100644 index 0000000..898d256 --- /dev/null +++ b/Assets/Script/Gameplay/Facility/TianHeController.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b8f77d0a85f044dcb710f54ed56f5479 +timeCreated: 1761745727 \ No newline at end of file