Files
2025TapTapGameJam/Assets/Script/Gameplay/Facility/LeverInteractController.cs

47 lines
1.2 KiB
C#
Raw Normal View History

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;
public override string GetInteractPrompt()
{
return "按F拉动拉杆";
}
public override void Interact(GameObject interactor)
{
if (!IsEnableInteract) return;
PullLever();
}
public override void OnSignalReceived(bool active, GameObject sender)
{
base.OnSignalReceived(active, sender);
//PullLever();
}
private void PullLever()
{
isPulled = !isPulled;
SendSignal(isPulled, this.gameObject);
// 可选:拉杆动画
if (isPulled)
{
// 旋转拉杆到下拉位置
transform.rotation = Quaternion.Euler(0f, 0f, 45f);
}
else
{
// 旋转拉杆回到初始位置
transform.rotation = Quaternion.Euler(0f, 0f, 0f);
}
}
}
}