feat():完成3种模式的基本运行框架
This commit is contained in:
44
Assets/Script/Gameplay/Facility/DoorInteractController.cs
Normal file
44
Assets/Script/Gameplay/Facility/DoorInteractController.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using Gameplay.Player;
|
||||
using UnityEngine;
|
||||
using Interface;
|
||||
|
||||
namespace Script.Gameplay.Facility
|
||||
{
|
||||
public class DoorInteractController : InteractableBaseController, IEditableComponent
|
||||
{
|
||||
[SerializeField] private LockLevel lockLevel;
|
||||
private bool isOpened = false;
|
||||
public override void Interact(GameObject interactor)
|
||||
{
|
||||
if (isOpened)
|
||||
{
|
||||
CloseDoor();
|
||||
isOpened = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
OpenDoor();
|
||||
isOpened = true;
|
||||
}
|
||||
}
|
||||
|
||||
public LockLevel LockLevel => lockLevel;
|
||||
|
||||
public void SetActive(bool active)
|
||||
{
|
||||
// 实现激活或禁用门的逻辑
|
||||
Interactable = active;
|
||||
}
|
||||
|
||||
private void OpenDoor()
|
||||
{
|
||||
Debug.Log("Open door");
|
||||
}
|
||||
|
||||
private void CloseDoor()
|
||||
{
|
||||
Debug.Log("Close door");
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3bdc5380046d4cacb0dd579877f320eb
|
||||
timeCreated: 1760693181
|
@@ -1,7 +0,0 @@
|
||||
namespace Script.Gameplay.Facility
|
||||
{
|
||||
public class EditComponent
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@@ -1,69 +0,0 @@
|
||||
using System;
|
||||
using Gameplay.Player;
|
||||
using UnityEngine;
|
||||
using Interface;
|
||||
|
||||
namespace Script.Gameplay.Facility
|
||||
{
|
||||
public class FacilityController : MonoBehaviour, IInteractable, IEditable
|
||||
{
|
||||
public FacilityModifier facilityModifier;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (facilityModifier == null)
|
||||
{
|
||||
facilityModifier = GetComponent<FacilityModifier>();
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
}
|
||||
|
||||
public string GetInteractPrompt()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
public void Interact(GameObject interactor)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnGazeEnter(GameObject editor)
|
||||
{
|
||||
// 物体弹出按F可交互菜单
|
||||
}
|
||||
|
||||
public void OnGazeExit(GameObject editor)
|
||||
{
|
||||
// 物体取消菜单
|
||||
}
|
||||
|
||||
public void OnGazeEnter(PlayerEditController editor)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnGazeExit(PlayerEditController editor)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void BeginEdit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void EndEdit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public IEditable GetEditable()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Gameplay.Player;
|
||||
using UnityEngine;
|
||||
using Interface;
|
||||
|
||||
namespace Script.Gameplay.Facility
|
||||
{
|
||||
public class FacilityEditableController : MonoBehaviour, IEditable
|
||||
{
|
||||
public void OnGazeEnter(PlayerEditController editor)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnGazeExit(PlayerEditController editor)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void BeginEdit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void EndEdit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public List<IEditableComponent> GetEditableComponents()
|
||||
{
|
||||
var components = new List<IEditableComponent>();
|
||||
foreach (var mb in GetComponentsInChildren<MonoBehaviour>(true))
|
||||
{
|
||||
if (mb is IEditableComponent editableComponent)
|
||||
{
|
||||
components.Add(editableComponent);
|
||||
}
|
||||
}
|
||||
return components;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,27 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.Gameplay.Facility
|
||||
{
|
||||
public class FacilityModifier : MonoBehaviour
|
||||
{
|
||||
private Transform _transform;
|
||||
private Collider _collider;
|
||||
private Rigidbody _rigidbody;
|
||||
|
||||
public void ModifyComponent<T>(bool isOpen, T component) where T : Component
|
||||
{
|
||||
var targetComponent = this.GetComponent<T>();
|
||||
if (targetComponent != null)
|
||||
{
|
||||
if (isOpen)
|
||||
{
|
||||
targetComponent.gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
targetComponent.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1db33a437984a1a8fae09ab8c5de7e4
|
||||
timeCreated: 1760667210
|
15
Assets/Script/Gameplay/Facility/IEditableComponent.cs
Normal file
15
Assets/Script/Gameplay/Facility/IEditableComponent.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace Script.Gameplay.Facility
|
||||
{
|
||||
public enum LockLevel
|
||||
{
|
||||
Red,
|
||||
Blue,
|
||||
Yellow,
|
||||
}
|
||||
|
||||
public interface IEditableComponent
|
||||
{
|
||||
public LockLevel LockLevel { get; }
|
||||
public void SetActive(bool active);
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
using UnityEngine;
|
||||
using Interface;
|
||||
|
||||
namespace Script.Gameplay.Facility
|
||||
{
|
||||
public abstract class InteractableBaseController : MonoBehaviour, IInteractable
|
||||
{
|
||||
public bool Interactable = true;
|
||||
public string GetInteractPrompt()
|
||||
{
|
||||
return "按F进行交互";
|
||||
}
|
||||
|
||||
public virtual void Interact(GameObject interactor)
|
||||
{
|
||||
if (!Interactable) return;
|
||||
Debug.Log($"{gameObject.name} 被 {interactor.name} 交互了!");
|
||||
}
|
||||
|
||||
public void OnGazeEnter(GameObject editor)
|
||||
{
|
||||
// 修改鼠标指针或高亮显示物体等
|
||||
}
|
||||
|
||||
public void OnGazeExit(GameObject editor)
|
||||
{
|
||||
// 恢复鼠标指针或取消高亮显示物体等
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f5781ad9dd2842a584b8ef333ae75e60
|
||||
timeCreated: 1760693365
|
Reference in New Issue
Block a user