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.");
}
private void DeactivateAbilityMode()
public void DeactivateAbilityMode()
{
isAbilityActive = false;
activeAbility = null;

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

Loading…
Cancel
Save