@@ -18,10 +18,10 @@ namespace Camera
|
|||||||
{
|
{
|
||||||
var mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
|
var mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
|
||||||
var mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;
|
var mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;
|
||||||
|
|
||||||
_xRotation -= mouseY;
|
_xRotation -= mouseY;
|
||||||
_xRotation = Mathf.Clamp(_xRotation, -90f, 90f);
|
_xRotation = Mathf.Clamp(_xRotation, -90f, 90f);
|
||||||
|
|
||||||
transform.localRotation = Quaternion.Euler(_xRotation, 0f, 0f);
|
transform.localRotation = Quaternion.Euler(_xRotation, 0f, 0f);
|
||||||
playerBody.Rotate(Vector3.up * mouseX);
|
playerBody.Rotate(Vector3.up * mouseX);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace Camera
|
|||||||
{
|
{
|
||||||
[SerializeField] private int maxInterActDistance = 10;
|
[SerializeField] private int maxInterActDistance = 10;
|
||||||
[SerializeField] private GameObject target;
|
[SerializeField] private GameObject target;
|
||||||
|
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ namespace Camera
|
|||||||
{
|
{
|
||||||
private UnityEngine.Camera _camera;
|
private UnityEngine.Camera _camera;
|
||||||
private PostProcessVolume _processVolume;
|
private PostProcessVolume _processVolume;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
_camera = GetComponent<UnityEngine.Camera>();
|
_camera = GetComponent<UnityEngine.Camera>();
|
||||||
@@ -23,12 +24,14 @@ namespace Camera
|
|||||||
private void PostProcess()
|
private void PostProcess()
|
||||||
{
|
{
|
||||||
_camera.fieldOfView = Mathf.Lerp(_camera.fieldOfView, 90f, Time.deltaTime * 10f);
|
_camera.fieldOfView = Mathf.Lerp(_camera.fieldOfView, 90f, Time.deltaTime * 10f);
|
||||||
_processVolume.profile.GetSetting<ChromaticAberration>().intensity.value = Mathf.Lerp(_processVolume.profile.GetSetting<ChromaticAberration>().intensity.value, 1f, Time.deltaTime * 10f);
|
_processVolume.profile.GetSetting<ChromaticAberration>().intensity.value = Mathf.Lerp(
|
||||||
|
_processVolume.profile.GetSetting<ChromaticAberration>().intensity.value, 1f, Time.deltaTime * 10f);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ProcessingStop()
|
private void ProcessingStop()
|
||||||
{
|
{
|
||||||
_processVolume.profile.GetSetting<ChromaticAberration>().intensity.value = Mathf.Lerp(_processVolume.profile.GetSetting<ChromaticAberration>().intensity.value, 0f, Time.deltaTime * 10f);
|
_processVolume.profile.GetSetting<ChromaticAberration>().intensity.value = Mathf.Lerp(
|
||||||
|
_processVolume.profile.GetSetting<ChromaticAberration>().intensity.value, 0f, Time.deltaTime * 10f);
|
||||||
_camera.fieldOfView = Mathf.Lerp(_camera.fieldOfView, 60f, Time.deltaTime * 10f);
|
_camera.fieldOfView = Mathf.Lerp(_camera.fieldOfView, 60f, Time.deltaTime * 10f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ namespace Camera
|
|||||||
private Vector3 _originalPos;
|
private Vector3 _originalPos;
|
||||||
private bool _isRunning;
|
private bool _isRunning;
|
||||||
private bool _isWalking;
|
private bool _isWalking;
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
_originalPos = cameraTransform.localPosition;
|
_originalPos = cameraTransform.localPosition;
|
||||||
@@ -20,8 +21,8 @@ namespace Camera
|
|||||||
EventManager.Instance.PlayerWalking += OnPlayerWalking;
|
EventManager.Instance.PlayerWalking += OnPlayerWalking;
|
||||||
EventManager.Instance.PlayerWalkStop += StopWalking;
|
EventManager.Instance.PlayerWalkStop += StopWalking;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void OnPlayerRunning()
|
private void OnPlayerRunning()
|
||||||
{
|
{
|
||||||
_isRunning = true;
|
_isRunning = true;
|
||||||
@@ -31,7 +32,7 @@ namespace Camera
|
|||||||
{
|
{
|
||||||
_isWalking = true;
|
_isWalking = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StopRunning()
|
private void StopRunning()
|
||||||
{
|
{
|
||||||
_isRunning = false;
|
_isRunning = false;
|
||||||
@@ -48,7 +49,7 @@ namespace Camera
|
|||||||
{
|
{
|
||||||
var xShake = Mathf.Sin(Time.time * frequency) * amplitude;
|
var xShake = Mathf.Sin(Time.time * frequency) * amplitude;
|
||||||
var yShake = Mathf.Cos(Time.time * frequency * 2) * amplitude * 0.5f;
|
var yShake = Mathf.Cos(Time.time * frequency * 2) * amplitude * 0.5f;
|
||||||
|
|
||||||
cameraTransform.localPosition = _originalPos + new Vector3(xShake, yShake, 0);
|
cameraTransform.localPosition = _originalPos + new Vector3(xShake, yShake, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -57,12 +58,12 @@ namespace Camera
|
|||||||
{
|
{
|
||||||
var xShake = Mathf.Sin(Time.time * frequency / 2) * amplitude;
|
var xShake = Mathf.Sin(Time.time * frequency / 2) * amplitude;
|
||||||
var yShake = Mathf.Cos(Time.time * frequency / 2 * 2) * amplitude * 0.5f;
|
var yShake = Mathf.Cos(Time.time * frequency / 2 * 2) * amplitude * 0.5f;
|
||||||
|
|
||||||
cameraTransform.localPosition = _originalPos + new Vector3(xShake, yShake, 0);
|
cameraTransform.localPosition = _originalPos + new Vector3(xShake, yShake, 0);
|
||||||
}else
|
}
|
||||||
|
else
|
||||||
cameraTransform.localPosition = _originalPos;
|
cameraTransform.localPosition = _originalPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
public struct DialogData
|
public struct DialogData
|
||||||
{
|
{
|
||||||
public int index;
|
public int index;
|
||||||
public string content;
|
public string content;
|
||||||
}
|
}
|
||||||
@@ -34,10 +34,10 @@ namespace Event
|
|||||||
|
|
||||||
public event CameraInterActHandler CameraInterAct;
|
public event CameraInterActHandler CameraInterAct;
|
||||||
public event DialogPopHandler DialogPop;
|
public event DialogPopHandler DialogPop;
|
||||||
|
|
||||||
public event PlayerRunStartHandler PlayerRunStart;
|
public event PlayerRunStartHandler PlayerRunStart;
|
||||||
public event PlayerRunningHandler PlayerRunning;
|
public event PlayerRunningHandler PlayerRunning;
|
||||||
|
|
||||||
public event PlayerRunStopHandler PlayerRunStop;
|
public event PlayerRunStopHandler PlayerRunStop;
|
||||||
public event PlayerWalkStartHandler PlayerWalkStart;
|
public event PlayerWalkStartHandler PlayerWalkStart;
|
||||||
public event PlayerWalkStopHandler PlayerWalkStop;
|
public event PlayerWalkStopHandler PlayerWalkStop;
|
||||||
@@ -67,11 +67,12 @@ namespace Event
|
|||||||
{
|
{
|
||||||
PlayerWalking?.Invoke();
|
PlayerWalking?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnPlayerRunStart()
|
public void OnPlayerRunStart()
|
||||||
{
|
{
|
||||||
PlayerRunStart?.Invoke();
|
PlayerRunStart?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnPlayerRunning()
|
public void OnPlayerRunning()
|
||||||
{
|
{
|
||||||
PlayerRunning?.Invoke();
|
PlayerRunning?.Invoke();
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using Items.Interface;
|
|||||||
|
|
||||||
namespace Items
|
namespace Items
|
||||||
{
|
{
|
||||||
public class TestItem : ItemBase , IItem
|
public class TestItem : ItemBase, IItem
|
||||||
{
|
{
|
||||||
protected override void ActivateItem()
|
protected override void ActivateItem()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace Keyboard
|
|||||||
public string filePath;
|
public string filePath;
|
||||||
|
|
||||||
private static KeySettingManager _instance;
|
private static KeySettingManager _instance;
|
||||||
|
|
||||||
public static KeySettingManager Instance
|
public static KeySettingManager Instance
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -37,6 +37,7 @@ namespace Keyboard
|
|||||||
{
|
{
|
||||||
_instance = this;
|
_instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
DontDestroyOnLoad(gameObject);
|
DontDestroyOnLoad(gameObject);
|
||||||
filePath = Application.persistentDataPath + "/" + "KeySetting.json";
|
filePath = Application.persistentDataPath + "/" + "KeySetting.json";
|
||||||
LoadKeySettings();
|
LoadKeySettings();
|
||||||
@@ -88,7 +89,7 @@ namespace Keyboard
|
|||||||
|
|
||||||
SaveKeySettings();
|
SaveKeySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
//更新Direction
|
//更新Direction
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
@@ -121,12 +122,12 @@ namespace Keyboard
|
|||||||
{
|
{
|
||||||
Direction = new Vector2(0, Direction.y);
|
Direction = new Vector2(0, Direction.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Input.GetKey(GetKey("Up")) && Input.GetKey(GetKey("Down")))
|
if (Input.GetKey(GetKey("Up")) && Input.GetKey(GetKey("Down")))
|
||||||
{
|
{
|
||||||
Direction = new Vector2(Direction.x, 0);
|
Direction = new Vector2(Direction.x, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Input.GetKey(GetKey("Up")) && !Input.GetKey(GetKey("Down")))
|
if (!Input.GetKey(GetKey("Up")) && !Input.GetKey(GetKey("Down")))
|
||||||
{
|
{
|
||||||
Direction = new Vector2(Direction.x, 0);
|
Direction = new Vector2(Direction.x, 0);
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ namespace Player
|
|||||||
|
|
||||||
private void Run()
|
private void Run()
|
||||||
{
|
{
|
||||||
_velocity = KeySettingManager.Instance.Direction.x * transform.right + KeySettingManager.Instance.Direction.y * transform.forward;
|
_velocity = KeySettingManager.Instance.Direction.x * transform.right +
|
||||||
|
KeySettingManager.Instance.Direction.y * transform.forward;
|
||||||
rb.AddForce(_velocity.normalized * (Time.deltaTime * 50), ForceMode.Impulse);
|
rb.AddForce(_velocity.normalized * (Time.deltaTime * 50), ForceMode.Impulse);
|
||||||
if (_velocity == Vector3.zero)
|
if (_velocity == Vector3.zero)
|
||||||
{
|
{
|
||||||
@@ -32,7 +33,9 @@ namespace Player
|
|||||||
temp.y = rb.velocity.y;
|
temp.y = rb.velocity.y;
|
||||||
rb.velocity = temp;
|
rb.velocity = temp;
|
||||||
}
|
}
|
||||||
if (Input.GetKey(KeySettingManager.Instance.GetKey("Run")) && KeySettingManager.Instance.Direction != Vector2.zero)
|
|
||||||
|
if (Input.GetKey(KeySettingManager.Instance.GetKey("Run")) &&
|
||||||
|
KeySettingManager.Instance.Direction != Vector2.zero)
|
||||||
{
|
{
|
||||||
if (!_isRunning)
|
if (!_isRunning)
|
||||||
{
|
{
|
||||||
@@ -41,10 +44,13 @@ namespace Player
|
|||||||
EventManager.Instance.OnPlayerWalkStop();
|
EventManager.Instance.OnPlayerWalkStop();
|
||||||
EventManager.Instance.OnPlayerRunStart();
|
EventManager.Instance.OnPlayerRunStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
EventManager.Instance.OnPlayerRunning();
|
EventManager.Instance.OnPlayerRunning();
|
||||||
rb.velocity = Vector3.ClampMagnitude(rb.velocity, maxVelocity+2);
|
rb.velocity = Vector3.ClampMagnitude(rb.velocity, maxVelocity + 2);
|
||||||
}
|
}
|
||||||
if (!Input.GetKey(KeySettingManager.Instance.GetKey("Run")) && KeySettingManager.Instance.Direction != Vector2.zero)
|
|
||||||
|
if (!Input.GetKey(KeySettingManager.Instance.GetKey("Run")) &&
|
||||||
|
KeySettingManager.Instance.Direction != Vector2.zero)
|
||||||
{
|
{
|
||||||
if (!_isWalking)
|
if (!_isWalking)
|
||||||
{
|
{
|
||||||
@@ -53,6 +59,7 @@ namespace Player
|
|||||||
EventManager.Instance.OnPlayerRunStop();
|
EventManager.Instance.OnPlayerRunStop();
|
||||||
EventManager.Instance.OnPlayerWalkStart();
|
EventManager.Instance.OnPlayerWalkStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
EventManager.Instance.OnPlayerWalking();
|
EventManager.Instance.OnPlayerWalking();
|
||||||
rb.velocity = Vector3.ClampMagnitude(rb.velocity, maxVelocity);
|
rb.velocity = Vector3.ClampMagnitude(rb.velocity, maxVelocity);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,15 +11,16 @@ namespace UI
|
|||||||
{
|
{
|
||||||
[SerializeField] private string dialogsPath;
|
[SerializeField] private string dialogsPath;
|
||||||
[SerializeField] private string dialogJson;
|
[SerializeField] private string dialogJson;
|
||||||
private Dictionary<int,string> _dialogsMap = new();
|
private Dictionary<int, string> _dialogsMap = new();
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
dialogsPath = Application.persistentDataPath + "/" + "Dialogs.json";
|
dialogsPath = Application.persistentDataPath + "/" + "Dialogs.json";
|
||||||
|
|
||||||
if (File.Exists(dialogsPath))
|
if (File.Exists(dialogsPath))
|
||||||
{
|
{
|
||||||
dialogJson = File.ReadAllText(dialogsPath);
|
dialogJson = File.ReadAllText(dialogsPath);
|
||||||
_dialogsMap = JsonConvert.DeserializeObject<Dictionary<int,string>>(dialogJson);
|
_dialogsMap = JsonConvert.DeserializeObject<Dictionary<int, string>>(dialogJson);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user