using System.Collections.Generic; using UnityEngine; using Script.Gameplay.Interface; using Script.Gameplay.Connect; namespace Script.Gameplay.Facility { public class LeverInteractController : BaseFacilityController { private bool isPulled = false; [SerializeField] private GameObject rotationPrefab; [SerializeField] private AudioClip turnSound; [SerializeField] private AudioClip returnSound; [SerializeField] private AudioSource LeverSound; public override string GetInteractPrompt() { return "按F拉动拉杆"; } public override void Interact(GameObject interactor) { if (!IsEnableInteract) return; PullLever(this.gameObject); } private void PullLever(GameObject sender = null) { isPulled = !isPulled; SendSignal(isPulled, sender); // 可选:拉杆动画 if (isPulled) { // 旋转拉杆到下拉位置 rotationPrefab.transform.rotation = Quaternion.Euler(0f, 0f, 45f); LeverSound.clip = turnSound; LeverSound.Play(); } else { // 旋转拉杆回到初始位置 rotationPrefab.transform.rotation = Quaternion.Euler(0f, 0f, 0f); LeverSound.clip = returnSound; LeverSound.Play(); } } } }