快捷键重构
This commit is contained in:
@@ -56,10 +56,12 @@ namespace NBF
|
||||
transform.rotation = _player.Data.rotation;
|
||||
|
||||
App.Inst.SetMouseCurrsor(false);
|
||||
InputManager.OnRunAction += OnRunAction;
|
||||
InputManager.OnQuickIndexAction += OnQuickIndexAction;
|
||||
InputManager.OnUseTorchAction += OnUseTorchAction;
|
||||
InputManager.OnUseTelescopeAction += OnUseTelescopeAction;
|
||||
InputManager.OnPlayerCanceled += OnPlayerCanceled;
|
||||
InputManager.OnPlayerPerformed += OnPlayerPerformed;
|
||||
// InputManager.OnRunAction += OnRunAction;
|
||||
// InputManager.OnQuickIndexAction += OnQuickIndexAction;
|
||||
// InputManager.OnUseTorchAction += OnUseTorchAction;
|
||||
// InputManager.OnUseTelescopeAction += OnUseTelescopeAction;
|
||||
|
||||
interactableLayer = LayerMask.GetMask("Interactive");
|
||||
}
|
||||
@@ -93,9 +95,8 @@ namespace NBF
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
InputManager.OnQuickIndexAction -= OnQuickIndexAction;
|
||||
InputManager.OnUseTorchAction -= OnUseTorchAction;
|
||||
InputManager.OnUseTelescopeAction -= OnUseTelescopeAction;
|
||||
InputManager.OnPlayerCanceled -= OnPlayerCanceled;
|
||||
InputManager.OnPlayerPerformed -= OnPlayerPerformed;
|
||||
}
|
||||
|
||||
#region 交互检测
|
||||
@@ -283,28 +284,29 @@ namespace NBF
|
||||
|
||||
#region 按键输入事件
|
||||
|
||||
private void OnRunAction(bool performed)
|
||||
private void OnPlayerPerformed(string action)
|
||||
{
|
||||
if (performed) Sprint();
|
||||
else StopSprinting();
|
||||
}
|
||||
|
||||
private void OnQuickIndexAction(int index)
|
||||
{
|
||||
nextShowSlotIndex = index;
|
||||
}
|
||||
|
||||
private void OnUseTorchAction(bool ret)
|
||||
{
|
||||
if (!ret)
|
||||
if (action == "Run")
|
||||
{
|
||||
_player.Data.openLight = !_player.Data.openLight;
|
||||
Sprint();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnUseTelescopeAction(bool ret)
|
||||
private void OnPlayerCanceled(string action)
|
||||
{
|
||||
if (!ret)
|
||||
if (action == "Run")
|
||||
{
|
||||
StopSprinting();
|
||||
}
|
||||
else if (action.StartsWith("Quick"))
|
||||
{
|
||||
nextShowSlotIndex = int.Parse(action.Substring("Quick".Length));
|
||||
}
|
||||
else if (action == "UseTorch")
|
||||
{
|
||||
_player.Data.openLight = !_player.Data.openLight;
|
||||
}
|
||||
else if (action == "UseTelescope")
|
||||
{
|
||||
_player.Data.openTelescope = !_player.Data.openTelescope;
|
||||
_player.ToggleTelescope();
|
||||
|
||||
Reference in New Issue
Block a user