RiftMayhem/Assets/Scripts/AoERayHitLocationSnapshotController.cs
Pedro Gomes 8e18305573 Spells update
- shield wall (second knight ability) added
- ragestorm (ultimate barbarian ability) added
- anti projectile type of spell
- channeled ability type
- small balance changes on abilities and statpoints per level
2024-07-05 19:37:02 +01:00

61 lines
1.4 KiB
C#

using Photon.Pun;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AoERayHitLocationSnapshotController : MonoBehaviour
{
public Transform aoeRayHitLocationSnapshot;
public LayerMask movementMask;
protected PhotonView photonView;
Ray ray;
protected RaycastHit hit;
protected Vector3 targetPoint = new Vector3();
bool isCasting;
protected virtual void Awake()
{
photonView = GetComponentInParent<PhotonView>();
aoeRayHitLocationSnapshot.parent = null;
}
private void OnEnable()
{
CastBarHandler.Instance.OnCastingStateChanged.AddListener(UpdateIsCastingState);
}
private void OnDisable()
{
CastBarHandler.Instance.OnCastingStateChanged.RemoveListener(UpdateIsCastingState);
}
protected virtual void Start()
{
if (!photonView.IsMine) this.enabled = false;
}
private void UpdateIsCastingState(bool isCasting)
{
this.isCasting = isCasting;
if (isCasting)
{
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit, 100f, movementMask))
{
aoeRayHitLocationSnapshot.position = hit.point;
}
}
}
private void OnDestroy()
{
if (aoeRayHitLocationSnapshot != null)
Destroy(aoeRayHitLocationSnapshot.gameObject);
}
}