diff --git a/Assets/Scripts/Gameplay/UserInput/ClientInputSender.cs b/Assets/Scripts/Gameplay/UserInput/ClientInputSender.cs
index 2117906..b5a096b 100644
--- a/Assets/Scripts/Gameplay/UserInput/ClientInputSender.cs
+++ b/Assets/Scripts/Gameplay/UserInput/ClientInputSender.cs
@@ -18,7 +18,7 @@ namespace Unity.BossRoom.Gameplay.UserInput
[RequireComponent(typeof(ServerCharacter))]
public class ClientInputSender : NetworkBehaviour
{
- const float k_MouseInputRaycastDistance = 1000f;
+ const float k_MouseInputRaycastDistance = 100f;
//The movement input rate is capped at 40ms (or 25 fps). This provides a nice balance between responsiveness and
//upstream network conservation. This matters when holding down your mouse button to move.
@@ -121,8 +121,7 @@ namespace Unity.BossRoom.Gameplay.UserInput
public AbilitySystem m_AbilitySystem;
ServerCharacter m_TargetServerCharacter;
- private bool IsSwapModeActive = false;
-
+
void Awake()
{
m_MainCamera = Camera.main;
@@ -478,103 +477,105 @@ namespace Unity.BossRoom.Gameplay.UserInput
void Update()
{
- // Toggle Swap Mode with E key
- if (Input.GetKeyDown(KeyCode.E))
- {
- if (!m_AbilitySystem.IsAbilityModeActive() && m_ServerCharacter.IsOnAPlatform) // Prevent swap mode if ability mode is active
- {
- ToggleSwapMode();
- }
- else
- {
- Debug.Log("Cannot activate swap mode while ability mode is active.");
- }
- }
- // Toggle Ability Mode with Q key
+
if (Input.GetKeyDown(KeyCode.Q))
{
- if (!IsSwapModeActive) // Prevent ability mode if swap mode is active
+ if (m_ServerCharacter.IsCrow) // Ensure only the crow can activate the ability
{
- if (m_ServerCharacter.IsCrow) // Ensure only the crow can activate the ability
- {
- m_AbilitySystem.ActivateAbilityByKey(GameDataSource.Instance.SlowDownAbilityKey);
- }
- else
- {
- Debug.Log("You must be the Crow to activate this ability.");
- }
+ m_AbilitySystem.ActivateAbilityByKey(GameDataSource.Instance.SlowDownAbilityKey);
}
else
{
- Debug.Log("Cannot activate ability mode while swap mode is active.");
+ Debug.Log("You must be the Crow to activate this ability.");
}
}
+
if (m_AbilitySystem.IsAbilityModeActive()) return;
- if (!IsSwapModeActive) // Prevent other inputs if swap mode is active
+ if (Input.GetKeyDown(KeyCode.Alpha1) && CharacterClass.Skill1)
{
- if (Input.GetMouseButtonDown(0))
- {
- m_MoveRequest = true;
- }
+ RequestAction(actionState1.actionID, SkillTriggerStyle.Keyboard);
}
- if (!EventSystem.current.IsPointerOverGameObject() && m_CurrentSkillInput == null)
+ else if (Input.GetKeyUp(KeyCode.Alpha1) && CharacterClass.Skill1)
{
- if (Input.GetMouseButtonDown(1))
- {
- RequestAction(CharacterClass.Skill1.ActionID, SkillTriggerStyle.MouseClick);
- }
- if (IsSwapModeActive && Input.GetMouseButtonDown(0)) // Left-click to request swap
- {
- HandleSwapRequest();
- }
+ RequestAction(actionState1.actionID, SkillTriggerStyle.KeyboardRelease);
+ }
+ if (Input.GetKeyDown(KeyCode.Alpha2) && CharacterClass.Skill2)
+ {
+ RequestAction(actionState2.actionID, SkillTriggerStyle.Keyboard);
+ }
+ else if (Input.GetKeyUp(KeyCode.Alpha2) && CharacterClass.Skill2)
+ {
+ RequestAction(actionState2.actionID, SkillTriggerStyle.KeyboardRelease);
+ }
+ if (Input.GetKeyDown(KeyCode.Alpha3) && CharacterClass.Skill3)
+ {
+ RequestAction(actionState3.actionID, SkillTriggerStyle.Keyboard);
+ }
+ else if (Input.GetKeyUp(KeyCode.Alpha3) && CharacterClass.Skill3)
+ {
+ RequestAction(actionState3.actionID, SkillTriggerStyle.KeyboardRelease);
}
- }
- ///
- /// Toggles swap mode on or off.
- ///
- private void ToggleSwapMode()
- {
- IsSwapModeActive = !IsSwapModeActive;
- if (IsSwapModeActive)
+ if (Input.GetKeyDown(KeyCode.Alpha5))
{
- Debug.Log("Swap mode activated. Click on a player to request a swap.");
+ RequestAction(GameDataSource.Instance.Emote1ActionPrototype.ActionID, SkillTriggerStyle.Keyboard);
}
- else
+ if (Input.GetKeyDown(KeyCode.Alpha6))
{
- Debug.Log("Swap mode deactivated.");
+ RequestAction(GameDataSource.Instance.Emote2ActionPrototype.ActionID, SkillTriggerStyle.Keyboard);
}
- }
-
- ///
- /// Handles the swap request when in swap mode.
- ///
- private void HandleSwapRequest()
- {
- var ray = m_MainCamera.ScreenPointToRay(Input.mousePosition);
- int hits = Physics.RaycastNonAlloc(ray, k_CachedHit, k_MouseInputRaycastDistance);
- if (hits > 0)
+ if (Input.GetKeyDown(KeyCode.Alpha7))
+ {
+ RequestAction(GameDataSource.Instance.Emote3ActionPrototype.ActionID, SkillTriggerStyle.Keyboard);
+ }
+ if (Input.GetKeyDown(KeyCode.Alpha8))
{
- for (int i = 0; i < hits; i++)
+ RequestAction(GameDataSource.Instance.Emote4ActionPrototype.ActionID, SkillTriggerStyle.Keyboard);
+ }
+
+ if (!EventSystem.current.IsPointerOverGameObject() && m_CurrentSkillInput == null)
+ {
+ //IsPointerOverGameObject() is a simple way to determine if the mouse is over a UI element. If it is, we don't perform mouse input logic,
+ //to model the button "blocking" mouse clicks from falling through and interacting with the world.
+ bool isCharacterClicked = false;
+ if (Input.GetMouseButtonDown(1))
+ {
+ RequestAction(CharacterClass.Skill1.ActionID, SkillTriggerStyle.MouseClick);
+ }
+
+ if (Input.GetMouseButtonDown(0)) // Left-click to request swap
{
- if (k_CachedHit[i].transform.TryGetComponent(out NetworkObject targetNetObj) &&
- targetNetObj != m_ServerCharacter.NetworkObject)
+ var ray = m_MainCamera.ScreenPointToRay(UnityEngine.Input.mousePosition);
+ int hits = Physics.RaycastNonAlloc(ray, k_CachedHit, k_MouseInputRaycastDistance);
+ if (hits > 0)
{
- // Check if the target is a valid ServerCharacter
- if (targetNetObj.TryGetComponent(out ServerCharacter targetCharacter))
+ for (int i = 0; i < hits; i++)
{
- // Initiate the swap
- targetCharacter.NotifySwapRequestRpc(m_ServerCharacter.NetworkObjectId);
- Debug.Log($"Swap request sent to {targetCharacter.name}.");
- IsSwapModeActive = false; // Automatically deactivate swap mode after a successful request
- return;
+ if (k_CachedHit[i].transform.TryGetComponent(out NetworkObject targetNetObj) &&
+ targetNetObj != m_ServerCharacter.NetworkObject)
+ {
+ // Check if the target is a valid ServerCharacter
+ if (targetNetObj.TryGetComponent(out ServerCharacter targetCharacter))
+ {
+ // Initiate the swap
+ targetCharacter.NotifySwapRequestRpc(m_ServerCharacter.NetworkObjectId);
+ Debug.Log($"Swap request sent to {targetCharacter.name}.");
+ isCharacterClicked = true;
+ break; // Exit the loop after initiating the swap
+ }
+ }
}
}
}
+
+
+ if(!isCharacterClicked && Input.GetMouseButtonDown(0))
+ {
+ m_MoveRequest = true; // Set move request for holding left-click
+ }
}
- Debug.LogWarning("No valid target found for swapping.");
}
-
+
void UpdateAction1()
{