Shifted movement keybinds and prioritized movement over other actions

dev-hazim
Hazim Bin Ijaz 1 week ago
parent d7bf011a37
commit 001cfa8651

@ -175,7 +175,7 @@ public class AbilitySystem : NetworkBehaviour
Debug.Log($"Ability {ability.abilityName} activated! Click to use."); Debug.Log($"Ability {ability.abilityName} activated! Click to use.");
} }
private void DeactivateAbilityMode() public void DeactivateAbilityMode()
{ {
isAbilityActive = false; isAbilityActive = false;
activeAbility = null; activeAbility = null;

@ -480,10 +480,17 @@ namespace Unity.BossRoom.Gameplay.UserInput
} }
void Update() void Update()
{
HandleSwapInput();
HandleAbilityInput();
HandleMovementInput();
}
private void HandleSwapInput()
{ {
if (Input.GetKeyDown(KeyCode.Q)) if (Input.GetKeyDown(KeyCode.Q))
{ {
if (!m_AbilitySystem.IsAbilityModeActive() && m_ServerCharacter.IsOnAPlatform && !m_ServerCharacter.IsCrow) // Prevent swap mode if ability mode is active if (CanActivateSwapMode())
{ {
ToggleSwapMode(); ToggleSwapMode();
} }
@ -492,59 +499,60 @@ namespace Unity.BossRoom.Gameplay.UserInput
m_UIMessageFeed.DisplayMessage("Not on a platform or not a player"); m_UIMessageFeed.DisplayMessage("Not on a platform or not a player");
Debug.Log("Cannot activate swap mode while ability mode is active."); Debug.Log("Cannot activate swap mode while ability mode is active.");
} }
} //Swap }
if (Input.GetKeyDown(KeyCode.E)) //Dash'N'Crash }
private bool CanActivateSwapMode()
{ {
if (!IsSwapModeActive) // Prevent ability mode if swap mode is active return !m_AbilitySystem.IsAbilityModeActive() && m_ServerCharacter.IsOnAPlatform && !m_ServerCharacter.IsCrow;
}
private void HandleAbilityInput()
{ {
if (m_ServerCharacter.IsCrow) // Ensure only the crow can activate the ability if (Input.GetKeyDown(KeyCode.E)) // Dash'N'Crash
{ {
m_UIMessageFeed.DisplayMessage("Activated Ability mode"); ActivateAbilityIfAllowed(GameDataSource.Instance.DashNCrashAbilityKey, "Abilities are only for crow");
m_AbilitySystem.ActivateAbilityByKey(GameDataSource.Instance.DashNCrashAbilityKey);
} }
else if (Input.GetKeyDown(KeyCode.R)) // Freeze Throw
{ {
m_UIMessageFeed.DisplayMessage("Abilities are only for crow"); ActivateAbilityIfAllowed(GameDataSource.Instance.FreezeThrowAbilityKey);
Debug.Log("You must be the Crow to activate this ability.");
}
} }
else if (Input.GetKeyDown(KeyCode.F)) // Vector Wall
{ {
Debug.Log("Cannot activate ability mode while swap mode is active."); ActivateAbilityIfAllowed(GameDataSource.Instance.VectorWallAbilityKey);
} }
} }
if (Input.GetKeyDown(KeyCode.R)) //Freeze Throw
{ private void ActivateAbilityIfAllowed(string abilityKey, string errorMessage = null)
if (!IsSwapModeActive) // Prevent ability mode if swap mode is active
{ {
m_UIMessageFeed.DisplayMessage("Activated Ability mode"); if (IsSwapModeActive)
m_AbilitySystem.ActivateAbilityByKey(GameDataSource.Instance.FreezeThrowAbilityKey);
}
else
{ {
Debug.Log("Cannot activate ability mode while swap mode is active."); Debug.Log("Cannot activate ability mode while swap mode is active.");
return;
} }
}
if (Input.GetKeyDown(KeyCode.F)) //Vector Wall if (abilityKey == GameDataSource.Instance.DashNCrashAbilityKey && !m_ServerCharacter.IsCrow)
{ {
if (!IsSwapModeActive) // Prevent ability mode if swap mode is active if (errorMessage != null)
{ {
m_UIMessageFeed.DisplayMessage("Activated Ability mode"); m_UIMessageFeed.DisplayMessage(errorMessage);
m_AbilitySystem.ActivateAbilityByKey(GameDataSource.Instance.VectorWallAbilityKey);
} }
else Debug.Log("You must be the Crow to activate this ability.");
{ return;
Debug.Log("Cannot activate ability mode while swap mode is active.");
} }
m_UIMessageFeed.DisplayMessage("Activated Ability mode");
m_AbilitySystem.ActivateAbilityByKey(abilityKey);
} }
if (m_AbilitySystem.IsAbilityModeActive()) return;
if (!IsSwapModeActive) // Prevent other inputs if swap mode is active private void HandleMovementInput()
{ {
if (Input.GetMouseButtonDown(1)) if (Input.GetMouseButtonDown(1)) // Right-click for movement
{ {
m_MoveRequest = true; CancelActiveModes();
} m_MoveRequest = true; // Accept movement request
} }
if (!EventSystem.current.IsPointerOverGameObject() && m_CurrentSkillInput == null) if (!EventSystem.current.IsPointerOverGameObject() && m_CurrentSkillInput == null)
{ {
if (IsSwapModeActive && Input.GetMouseButtonDown(0)) // Left-click to request swap if (IsSwapModeActive && Input.GetMouseButtonDown(0)) // Left-click to request swap
@ -554,6 +562,24 @@ namespace Unity.BossRoom.Gameplay.UserInput
} }
} }
private void CancelActiveModes()
{
if (m_AbilitySystem.IsAbilityModeActive())
{
m_UIMessageFeed.DisplayMessage("Ability mode canceled.");
m_AbilitySystem.DeactivateAbilityMode();
Debug.Log("Ability mode deactivated due to move request.");
}
if (IsSwapModeActive)
{
m_UIMessageFeed.DisplayMessage("Swap mode canceled.");
ToggleSwapMode();
Debug.Log("Swap mode deactivated due to move request.");
}
}
/// <summary> /// <summary>
/// Toggles swap mode on or off. /// Toggles swap mode on or off.
/// </summary> /// </summary>

Loading…
Cancel
Save