|
|
|
@ -11,6 +11,7 @@ using UnityEngine.AI;
|
|
|
|
|
|
|
|
|
|
public class AbilitySystem : NetworkBehaviour
|
|
|
|
|
{
|
|
|
|
|
private Camera mainCamera;
|
|
|
|
|
[Header("Assigned Abilities")]
|
|
|
|
|
public List<Ability> abilities = new List<Ability>();
|
|
|
|
|
public AbilityUI[] abilitiesUI;
|
|
|
|
@ -40,6 +41,9 @@ public class AbilitySystem : NetworkBehaviour
|
|
|
|
|
[Header("Executioner Settings")]
|
|
|
|
|
[SerializeField] private LineRenderer lineIndicator;
|
|
|
|
|
private bool _isPlacingExecutioner;
|
|
|
|
|
private Vector3 executionerStartPos;
|
|
|
|
|
private Vector3 executionerEndPos;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void InitializeAbilityCursorMap()
|
|
|
|
|
{
|
|
|
|
@ -57,6 +61,7 @@ public class AbilitySystem : NetworkBehaviour
|
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
|
|
|
|
m_Agent = GetComponent<NavMeshAgent>();
|
|
|
|
|
mainCamera = Camera.main;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Start()
|
|
|
|
@ -129,18 +134,19 @@ public class AbilitySystem : NetworkBehaviour
|
|
|
|
|
DeactivateIndicators();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private Vector3 executionerStartPos;
|
|
|
|
|
private Vector3 executionerEndPos;
|
|
|
|
|
|
|
|
|
|
private void HandleExecutionerPlacement()
|
|
|
|
|
{
|
|
|
|
|
lineIndicator.gameObject.SetActive(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Input.GetMouseButtonDown(0))
|
|
|
|
|
{
|
|
|
|
|
if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out var hit))
|
|
|
|
|
if (Physics.Raycast(mainCamera.ScreenPointToRay(Input.mousePosition), out var hit))
|
|
|
|
|
{
|
|
|
|
|
executionerStartPos = hit.point;
|
|
|
|
|
executionerEndPos = hit.point;
|
|
|
|
|
|
|
|
|
|
lineIndicator.positionCount = 2; // Ensure it has enough positions before setting them
|
|
|
|
|
lineIndicator.SetPosition(0, executionerStartPos);
|
|
|
|
|
lineIndicator.SetPosition(1, executionerEndPos);
|
|
|
|
|
}
|
|
|
|
@ -148,7 +154,7 @@ public class AbilitySystem : NetworkBehaviour
|
|
|
|
|
|
|
|
|
|
if (Input.GetMouseButton(0))
|
|
|
|
|
{
|
|
|
|
|
if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out var hit))
|
|
|
|
|
if (Physics.Raycast(mainCamera.ScreenPointToRay(Input.mousePosition), out var hit))
|
|
|
|
|
{
|
|
|
|
|
executionerEndPos = hit.point;
|
|
|
|
|
lineIndicator.SetPosition(1, executionerEndPos);
|
|
|
|
@ -158,10 +164,14 @@ public class AbilitySystem : NetworkBehaviour
|
|
|
|
|
if (Input.GetMouseButtonUp(0))
|
|
|
|
|
{
|
|
|
|
|
UseActiveAbility();
|
|
|
|
|
lineIndicator.positionCount = 0;
|
|
|
|
|
|
|
|
|
|
lineIndicator.positionCount = 2; // Reset to a valid number to prevent out-of-bounds errors
|
|
|
|
|
lineIndicator.SetPosition(0, Vector3.zero); // Reset positions to avoid old values
|
|
|
|
|
lineIndicator.SetPosition(1, Vector3.zero);
|
|
|
|
|
lineIndicator.gameObject.SetActive(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void ManageVectorFenceIndicator()
|
|
|
|
|
{
|
|
|
|
@ -180,7 +190,7 @@ public class AbilitySystem : NetworkBehaviour
|
|
|
|
|
|
|
|
|
|
private void UpdateWallIndicatorPosition()
|
|
|
|
|
{
|
|
|
|
|
if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out RaycastHit hit))
|
|
|
|
|
if (Physics.Raycast(mainCamera.ScreenPointToRay(Input.mousePosition), out RaycastHit hit))
|
|
|
|
|
{
|
|
|
|
|
//wallIndicator.transform.position = hit.point; // Update position to follow the mouse
|
|
|
|
|
wallIndicator.transform.position = new Vector3(hit.point.x, 0, hit.point.z);
|
|
|
|
@ -190,7 +200,7 @@ public class AbilitySystem : NetworkBehaviour
|
|
|
|
|
|
|
|
|
|
private void StartWallPlacement()
|
|
|
|
|
{
|
|
|
|
|
if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out RaycastHit hit))
|
|
|
|
|
if (Physics.Raycast(mainCamera.ScreenPointToRay(Input.mousePosition), out RaycastHit hit))
|
|
|
|
|
{
|
|
|
|
|
wallSpawnPosition = new Vector3(hit.point.x, 0, hit.point.z); // Save spawn position
|
|
|
|
|
initialMousePosition = Input.mousePosition; // Store the initial mouse position on click
|
|
|
|
@ -212,7 +222,7 @@ public class AbilitySystem : NetworkBehaviour
|
|
|
|
|
// Check if the movement exceeds the threshold
|
|
|
|
|
if (mouseDistance >= mouseMoveThreshold)
|
|
|
|
|
{
|
|
|
|
|
Ray ray = Camera.main.ScreenPointToRay(currentMousePosition);
|
|
|
|
|
Ray ray = mainCamera.ScreenPointToRay(currentMousePosition);
|
|
|
|
|
if (Physics.Raycast(ray, out RaycastHit hit))
|
|
|
|
|
{
|
|
|
|
|
Vector3 direction = (new Vector3(hit.point.x, 0, hit.point.z) - wallIndicator.transform.position).normalized;
|
|
|
|
@ -408,7 +418,7 @@ public class AbilitySystem : NetworkBehaviour
|
|
|
|
|
|
|
|
|
|
private void UpdateIndicatorPosition()
|
|
|
|
|
{
|
|
|
|
|
if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out RaycastHit hit))
|
|
|
|
|
if (Physics.Raycast(mainCamera.ScreenPointToRay(Input.mousePosition), out RaycastHit hit))
|
|
|
|
|
{
|
|
|
|
|
currentAbilityIndicator.transform.position = new Vector3(hit.point.x, 0, hit.point.z);
|
|
|
|
|
currentAbilityIndicator.transform.localScale = Vector3.one * activeAbility.abilityRadius;
|
|
|
|
|