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

40 lines
1.0 KiB
C#

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(this.gameObject);
}
private void PullLever(GameObject sender = null)
{
isPulled = !isPulled;
SendSignal(isPulled, sender);
// 可选:拉杆动画
if (isPulled)
{
// 旋转拉杆到下拉位置
transform.rotation = Quaternion.Euler(0f, 0f, 45f);
}
else
{
// 旋转拉杆回到初始位置
transform.rotation = Quaternion.Euler(0f, 0f, 0f);
}
}
}
}