refactor(Facility): 使用继承让所有机关都拥有了独自的 可交互 可编辑 可连接设定。大面积重构
This commit is contained in:
38
Assets/Script/Gameplay/Facility/ButtonInteractController.cs
Normal file
38
Assets/Script/Gameplay/Facility/ButtonInteractController.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
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 = true;
|
||||
|
||||
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 = false;
|
||||
// 按钮压下的动画或效果可以在这里添加
|
||||
|
||||
yield return new WaitForSeconds(signalDuration);
|
||||
SendSignal(false, this.gameObject);
|
||||
IsPressing = true;
|
||||
// 按钮弹起的动画或效果可以在这里添加
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user