feat(Console MovePlateform): 实现控制台和移动平台

This commit is contained in:
2025-10-22 11:32:53 +08:00
parent 3d014cd2c2
commit 3cdd41ea49
27 changed files with 936 additions and 46 deletions

View File

@@ -0,0 +1,66 @@
using UnityEngine;
using Script.Gameplay.Connect;
using Script.Gameplay.Interface;
namespace Script.Gameplay.Edit
{
public class MovingPlatformController : MonoBehaviour, IEditableComponent, ISignalReceiver
{
[SerializeField] private GameObject startPositionObject;
[SerializeField] private GameObject targetPositionObject;
public float moveSpeed = 2f;
private Vector3 startPosition;
private Vector3 targetPosition;
private bool isMoving = false;
private bool forward = true;
private void Awake()
{
startPosition = startPositionObject.transform.position;
targetPosition = targetPositionObject.transform.position;
transform.position = startPosition;
}
private void Update()
{
if (!isMoving) return;
Vector3 destination = forward ? targetPosition : startPosition;
transform.position = Vector3.MoveTowards(transform.position, destination, moveSpeed * Time.deltaTime);
if (Vector3.Distance(transform.position, destination) < 0.01f)
{
forward = !forward;
}
}
public void OnSignalReceived(bool active, GameObject sender)
{
if (active)
{
isMoving = true;
}
else
{
isMoving = false;
}
}
// IEditableComponent
private bool isEditable = true;
public bool IsComponentActive
{
get => isEditable;
set
{
isEditable = value;
isMoving = value;
}
}
public string ComponentName { get; set; } = "MovingPlatform";
public LockLevel LockLevel => LockLevel.Red;
}
}