+玩家行为事件
+视角摇晃 +相机后处理
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using Keyboard;
|
||||
using Event;
|
||||
using Keyboard;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering.PostProcessing;
|
||||
|
||||
namespace Player
|
||||
{
|
||||
@@ -8,7 +10,11 @@ namespace Player
|
||||
[SerializeField] private Rigidbody rb;
|
||||
[SerializeField] private Animator animator;
|
||||
[SerializeField] private float maxVelocity;
|
||||
[SerializeField] private PostProcessVolume postProcessVolume;
|
||||
[SerializeField] private UnityEngine.Camera postProcessCamera;
|
||||
private Vector3 _velocity;
|
||||
private bool _isRunning;
|
||||
private bool _isWalking;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
@@ -26,7 +32,36 @@ namespace Player
|
||||
temp.y = rb.velocity.y;
|
||||
rb.velocity = temp;
|
||||
}
|
||||
rb.velocity = Vector3.ClampMagnitude(rb.velocity, maxVelocity);
|
||||
if (Input.GetKey(KeySettingManager.Instance.GetKey("Run")) && KeySettingManager.Instance.Direction != Vector2.zero)
|
||||
{
|
||||
if (!_isRunning)
|
||||
{
|
||||
_isRunning = true;
|
||||
_isWalking = false;
|
||||
EventManager.Instance.OnPlayerWalkStop();
|
||||
EventManager.Instance.OnPlayerRunStart();
|
||||
}
|
||||
EventManager.Instance.OnPlayerRunning();
|
||||
rb.velocity = Vector3.ClampMagnitude(rb.velocity, maxVelocity+2);
|
||||
}
|
||||
if (!Input.GetKey(KeySettingManager.Instance.GetKey("Run")) && KeySettingManager.Instance.Direction != Vector2.zero)
|
||||
{
|
||||
if (!_isWalking)
|
||||
{
|
||||
_isRunning = false;
|
||||
_isWalking = true;
|
||||
EventManager.Instance.OnPlayerRunStop();
|
||||
EventManager.Instance.OnPlayerWalkStart();
|
||||
}
|
||||
EventManager.Instance.OnPlayerWalking();
|
||||
rb.velocity = Vector3.ClampMagnitude(rb.velocity, maxVelocity);
|
||||
}
|
||||
|
||||
if (KeySettingManager.Instance.Direction == Vector2.zero)
|
||||
{
|
||||
EventManager.Instance.OnPlayerRunStop();
|
||||
EventManager.Instance.OnPlayerWalkStop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user