This commit is contained in:
2025-10-25 15:43:10 +08:00
15 changed files with 5081 additions and 19 deletions

View File

@@ -34,7 +34,11 @@ namespace Script.Gameplay.Edit
{
_rigidbody = GetComponent<Rigidbody>();
//应用序列化的初始状态
<<<<<<< HEAD
_rigidbody.isKinematic = !IsEnableEdit;
=======
_rigidbody.isKinematic = !isOpenInEditor;
>>>>>>> 2f1ad467aab3adc0a2a8675567ff130fa4202138
}
#if UNITY_EDITOR
@@ -43,7 +47,11 @@ namespace Script.Gameplay.Edit
//在编辑器中即时生效
_rigidbody = _rigidbody == null ? GetComponent<Rigidbody>() : _rigidbody;
if (_rigidbody != null)
<<<<<<< HEAD
_rigidbody.isKinematic = !IsEnableEdit;
=======
_rigidbody.isKinematic = !isOpenInEditor;
>>>>>>> 2f1ad467aab3adc0a2a8675567ff130fa4202138
}
#endif
}

View File

@@ -0,0 +1,76 @@
using System;
using UnityEngine;
using Script.Gameplay.Edit;
namespace Script.Gameplay.Facility
{
[RequireComponent(typeof(ColliderEditableController))]
[RequireComponent(typeof(MeshRenderEditableController))]
public class HidePlatformController : BaseFacilityController
{
public enum DisappearType
{
ReceiveSignal,
NoReceiveSignal
}
[Tooltip("平台消失的类型")]
[SerializeField] private DisappearType disappearType;
private ColliderEditableController colliderEditableController;
private MeshRenderEditableController meshRenderEditableController;
private void Awake()
{
colliderEditableController = GetComponent<ColliderEditableController>();
meshRenderEditableController = GetComponent<MeshRenderEditableController>();
}
private void Start()
{
if (disappearType == DisappearType.NoReceiveSignal)
{
colliderEditableController.IsOpenInEditor = true;
meshRenderEditableController.IsOpenInEditor = true;
}
if (disappearType == DisappearType.ReceiveSignal)
{
colliderEditableController.IsOpenInEditor = false;
meshRenderEditableController.IsOpenInEditor = false;
}
}
public override void OnSignalReceived(bool active, GameObject sender)
{
base.OnSignalReceived(active, sender);
if (disappearType == DisappearType.ReceiveSignal)
{
if (active)
{
meshRenderEditableController.IsOpenInEditor = true;
colliderEditableController.IsOpenInEditor = true;
}
else
{
meshRenderEditableController.IsOpenInEditor = false;
colliderEditableController.IsOpenInEditor = false;
}
}
if (disappearType == DisappearType.NoReceiveSignal)
{
if (active)
{
meshRenderEditableController.IsOpenInEditor = false;
colliderEditableController.IsOpenInEditor = false;
}
else
{
meshRenderEditableController.IsOpenInEditor = true;
colliderEditableController.IsOpenInEditor = true;
}
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f28214d1465c43208546605ea8a619db
timeCreated: 1761355078

View File

@@ -19,6 +19,12 @@ namespace Script.Gameplay.Player
public event Action OnPlayerEndDialogue;
public event Action<GameObject> OnGazeEnterDialogue;
public event Action<GameObject> OnGazeExitDialogue;
<<<<<<< HEAD
=======
private InputManager inputManager;
>>>>>>> 2f1ad467aab3adc0a2a8675567ff130fa4202138
private Queue<string> dialogueQueue = new Queue<string>();
private PlayerDialogueViewer playerDialogueViewer;
@@ -55,7 +61,12 @@ namespace Script.Gameplay.Player
if (firstPersonRaycaster == null)
Debug.LogWarning("FirstPersonRaycaster not found! Please assign or add it to the player.");
<<<<<<< HEAD
var input = InputManager.Instance.Input;
=======
inputManager = InputManager.Instance;
var input = inputManager.Input;
>>>>>>> 2f1ad467aab3adc0a2a8675567ff130fa4202138
input.Player.Read.performed += ctx =>
{
if (!isEnablePlayerDialogue) return;
@@ -95,6 +106,11 @@ namespace Script.Gameplay.Player
OnPlayerBeginDialogue?.Invoke();
CurrentDialogueTarget.OnBeginDialogue?.Invoke(true);
dialogueQueue = SplitDialogue(CurrentDialogueTarget.DialogueContent);
<<<<<<< HEAD
=======
inputManager.SetInputForLook(false);
inputManager.SetInputForMove(false);
>>>>>>> 2f1ad467aab3adc0a2a8675567ff130fa4202138
PassNextDialogue();
}
}
@@ -124,6 +140,11 @@ namespace Script.Gameplay.Player
isReadingDialogue = false;
OnPlayerEndDialogue?.Invoke();
CurrentDialogueTarget.OnEndDialogue?.Invoke(true);
<<<<<<< HEAD
=======
inputManager.SetInputForLook(true);
inputManager.SetInputForMove(true);
>>>>>>> 2f1ad467aab3adc0a2a8675567ff130fa4202138
if (playerDialogueViewer != null)
{
playerDialogueViewer.ClosePanel();

View File

@@ -7,40 +7,40 @@ namespace Script.Gameplay.Player
{
public class PlayerMoveController : MonoBehaviour
{
[Header("Movement Settings")]
[Tooltip("移动速度(米/秒)")]
[Header("Movement Settings")] [Tooltip("移动速度(米/秒)")]
public float speed = 5f;
[Tooltip("跳跃高度(米)")]
public float jumpHeight = 2f;
[Tooltip("重力加速度(米/秒²)")]
public float gravity = -9.81f;
[Header("Ground Check")]
[Tooltip("检测地面的位置(通常为角色脚下)")]
[Tooltip("跳跃高度(米)")] public float jumpHeight = 2f;
[Tooltip("重力加速度(米/秒²)")] public float gravity = -9.81f;
[Header("Ground Check")] [Tooltip("检测地面的位置(通常为角色脚下)")]
public Transform groundCheck;
[Tooltip("地面检测半径")]
public float groundDistance = 0.4f;
[Tooltip("地面层LayerMask")]
public LayerMask groundMask;
[Tooltip("地面检测半径")] public float groundDistance = 0.4f;
[Tooltip("地面层LayerMask")] public LayerMask groundMask;
private float initSpeed;
private CharacterController characterController;
private Vector3 velocity;
private bool isGrounded;
private IInputManager inputManager;
private float lastGroundY;
private bool wasGroundedLastFrame;
[Tooltip("从高处落下时的伤害阈值(米)")]
[SerializeField] private float fallDamageThreshold = 3f; //伤害阈值
[Tooltip("从高处落下时的伤害阈值(米)")] [SerializeField]
private float fallDamageThreshold = 3f; //伤害阈值
[Tooltip("推动物体的力量")] [SerializeField]
private float pushPower = 2f;
private void Awake()
{
characterController = GetComponent<CharacterController>();
if (characterController == null)
Debug.LogError("PlayerMoveController 需要 CharacterController 组件!");
initSpeed = speed;
}
@@ -76,7 +76,7 @@ namespace Script.Gameplay.Player
}
wasGroundedLastFrame = isCurrentlyGrounded;
// 地面检测
if (groundCheck != null)
isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);
@@ -106,11 +106,25 @@ namespace Script.Gameplay.Player
characterController.Move(velocity * Time.deltaTime);
}
private void OnControllerColliderHit(ControllerColliderHit hit)
{
Rigidbody body = hit.collider.attachedRigidbody;
// 只推动带有刚体且非静态的物体
if (body != null && !body.isKinematic)
{
// 忽略从下方碰撞
if (hit.moveDirection.y < -0.3f) return;
Vector3 pushDir = new Vector3(hit.moveDirection.x, 0, hit.moveDirection.z);
body.AddForce(pushDir * pushPower, ForceMode.Impulse);
}
}
public void SetSpeed(float newSpeed)
{
speed = newSpeed;
}
public void ResetSpeed()
{
speed = initSpeed;