|
|
@ -18,6 +18,12 @@ public class AbilitySystem : NetworkBehaviour
|
|
|
|
[SerializeField] private GameObject currentAbilityIndicator;
|
|
|
|
[SerializeField] private GameObject currentAbilityIndicator;
|
|
|
|
[SerializeField] private GameObject wallIndicator;
|
|
|
|
[SerializeField] private GameObject wallIndicator;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Header("Wall Placement Settings")]
|
|
|
|
|
|
|
|
[SerializeField] private float wallRotationSpeed = 2f;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Vector3 wallSpawnPosition;
|
|
|
|
|
|
|
|
private bool isWallPlacementStarted = false;
|
|
|
|
|
|
|
|
|
|
|
|
void Update()
|
|
|
|
void Update()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
HandleAbilityMode();
|
|
|
|
HandleAbilityMode();
|
|
|
@ -27,25 +33,35 @@ public class AbilitySystem : NetworkBehaviour
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (isAbilityActive)
|
|
|
|
if (isAbilityActive)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (activeAbility.abilityKey == GameDataSource.Instance.VectorWallAbilityKey)
|
|
|
|
if (activeAbility.abilityKey == "VectorFence")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ManageVectorFenceIndicator();
|
|
|
|
ManageVectorFenceIndicator();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!isWallPlacementStarted)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
UpdateWallIndicatorPosition(); // Follow the mouse when ability is activated
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (Input.GetMouseButtonDown(0))
|
|
|
|
if (Input.GetMouseButtonDown(0))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PositionWallIndicator();
|
|
|
|
StartWallPlacement();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Input.GetMouseButton(0))
|
|
|
|
|
|
|
|
|
|
|
|
if (Input.GetMouseButton(0) && isWallPlacementStarted)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
RotateWallIndicator();
|
|
|
|
RotateWallIndicator(); // Rotate while holding LMB
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Input.GetMouseButtonUp(0))
|
|
|
|
|
|
|
|
|
|
|
|
if (Input.GetMouseButtonUp(0) && isWallPlacementStarted)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
UseActiveAbility();
|
|
|
|
UseActiveAbility(); // Place the wall when LMB is released
|
|
|
|
|
|
|
|
isWallPlacementStarted = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ManageStandardAbilityIndicator();
|
|
|
|
ManageStandardAbilityIndicator();
|
|
|
|
|
|
|
|
|
|
|
|
if (Input.GetMouseButtonDown(0))
|
|
|
|
if (Input.GetMouseButtonDown(0))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
UseActiveAbility();
|
|
|
|
UseActiveAbility();
|
|
|
@ -59,38 +75,64 @@ public class AbilitySystem : NetworkBehaviour
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ManageVectorFenceIndicator()
|
|
|
|
private void ManageVectorFenceIndicator()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (wallIndicator != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
wallIndicator.SetActive(true);
|
|
|
|
wallIndicator.SetActive(true);
|
|
|
|
currentAbilityIndicator.SetActive(false);
|
|
|
|
currentAbilityIndicator.SetActive(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Apply ability-specific scale to the wall indicator
|
|
|
|
|
|
|
|
if (activeAbility is VectorFenceAbility vectorFence)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
wallIndicator.transform.localScale = new Vector3(vectorFence.wallLength, vectorFence.wallHeight, vectorFence.wallWidth);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void PositionWallIndicator()
|
|
|
|
private void UpdateWallIndicatorPosition()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out RaycastHit hit))
|
|
|
|
if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out RaycastHit hit))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
wallIndicator.transform.position = hit.point;
|
|
|
|
wallIndicator.transform.position = hit.point; // Update position to follow the mouse
|
|
|
|
var vectorFence = (VectorFenceAbility)activeAbility;
|
|
|
|
}
|
|
|
|
wallIndicator.transform.localScale = new Vector3(vectorFence.wallLength, vectorFence.wallHeight, vectorFence.wallWidth);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void StartWallPlacement()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out RaycastHit hit))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
wallSpawnPosition = hit.point; // Save spawn position
|
|
|
|
|
|
|
|
isWallPlacementStarted = true;
|
|
|
|
|
|
|
|
Debug.Log($"[AbilitySystem] Wall placement started at {wallSpawnPosition}");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void RotateWallIndicator()
|
|
|
|
private void RotateWallIndicator()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (isWallPlacementStarted && wallIndicator != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
float mouseX = Input.GetAxis("Mouse X");
|
|
|
|
float mouseX = Input.GetAxis("Mouse X");
|
|
|
|
wallIndicator.transform.Rotate(Vector3.up, mouseX);
|
|
|
|
wallIndicator.transform.Rotate(Vector3.up, mouseX * wallRotationSpeed); // Rotate Y-axis based on mouse movement
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ManageStandardAbilityIndicator()
|
|
|
|
private void ManageStandardAbilityIndicator()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (currentAbilityIndicator != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
currentAbilityIndicator.SetActive(true);
|
|
|
|
currentAbilityIndicator.SetActive(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wallIndicator != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
wallIndicator.SetActive(false);
|
|
|
|
wallIndicator.SetActive(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
UpdateIndicatorPosition();
|
|
|
|
UpdateIndicatorPosition();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void DeactivateIndicators()
|
|
|
|
private void DeactivateIndicators()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
currentAbilityIndicator.SetActive(false);
|
|
|
|
if (currentAbilityIndicator != null) currentAbilityIndicator.SetActive(false);
|
|
|
|
wallIndicator.SetActive(false);
|
|
|
|
if (wallIndicator != null) wallIndicator.SetActive(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void ActivateAbilityByKey(string key)
|
|
|
|
public void ActivateAbilityByKey(string key)
|
|
|
@ -137,6 +179,7 @@ public class AbilitySystem : NetworkBehaviour
|
|
|
|
{
|
|
|
|
{
|
|
|
|
isAbilityActive = false;
|
|
|
|
isAbilityActive = false;
|
|
|
|
activeAbility = null;
|
|
|
|
activeAbility = null;
|
|
|
|
|
|
|
|
isWallPlacementStarted = false;
|
|
|
|
Debug.Log("Ability mode deactivated.");
|
|
|
|
Debug.Log("Ability mode deactivated.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|