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

40 lines
1.3 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Script.Gameplay.Interface;
using Script.Gameplay.Connect;
namespace Script.Gameplay.Facility
{
public class ButtonInteractController : BaseFacilityController
{
[SerializeField] private float signalDuration = 1.0f; // 信号持续时间(秒)
private bool isPressing = false;
public override string GetInteractPrompt()
{
return "按F按下按钮";
}
public override void Interact(GameObject interactor)
{
if (isPressing) return;
StartCoroutine(SendSignalCoroutine());
//Debug.Log("Button pressed");
}
private IEnumerator SendSignalCoroutine()
{
SendSignal(true, this.gameObject);
isPressing = true;
// 按钮压下的动画或效果可以在这里添加
transform.localScale = new Vector3(0.3f, 0.3f, 0.1f);
yield return new WaitForSeconds(signalDuration);
SendSignal(false, this.gameObject);
isPressing = false;
// 按钮弹起的动画或效果可以在这里添加
transform.localScale = new Vector3(0.3f, 0.3f, 0.15f);
}
}
}