RiftMayhem/Assets/Scripts/AbilitySystem/Base/CastingStateController.cs
Pedro Gomes 81f2ac424e Insane update
Abilities:

- area of effect ability with impact event/chain reaction type added
- melee slash timing bugfix
- melee slash VFX added
- blizzard (second mage ability) added
- holy circle (ultimate priest ability) added
- consecration (ultimate knight ability) added
- whirling axes (second barbarian ability) added
- glacial bomb (ultimate mage ability) added
- ice shard (first mage ability) added

Others:

- aoe location snapshot on cast mechanic added
- reduced realtime shadows on rifthunters inn
2024-07-04 21:27:15 +01:00

71 lines
1.9 KiB
C#

using Photon.Pun;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class CastingStateController : MonoBehaviour
{
public bool isCasting;
public PlayerMovement playerMovement;
public LayerMask movementMask;
Camera cam;
Ray ray;
RaycastHit hit;
PhotonView photonView;
ProjectileSpawnLocationController projectileSpawnLocationController;
private void Awake()
{
cam = Camera.main;
photonView = GetComponentInParent<PhotonView>();
projectileSpawnLocationController = transform.root.GetComponentInChildren<ProjectileSpawnLocationController>();
}
private void Start()
{
if (!photonView.IsMine) this.enabled = false;
}
public void RequestAbilityCast(BaseAbility ability, Action abilityExecution)
{
if (isCasting) return;
if (!ability.castableWhileMoving)
playerMovement.ToggleAgentMoving(true);
StartCoroutine(Casting(ability, abilityExecution));
}
private IEnumerator Casting(BaseAbility ability, Action abilityExecution)
{
isCasting = true;
CastBarHandler.Instance.ShowCastBar(ability, abilityExecution);
playerMovement.InstantFaceCast(projectileSpawnLocationController.GetLookat());
//cast animation
yield return new WaitForSeconds(ability.castTime);
if (ability.animationType != AbilityAnimationType.Melee)
{
abilityExecution.Invoke();
isCasting = false;
if (!ability.castableWhileMoving)
playerMovement.ToggleAgentMoving(false);
}
Debug.Log("$$sCastbar Done casting");
}
public void ResetCastingOnMeleeAnimationEvent()
{
isCasting = false;
playerMovement.ToggleAgentMoving(false);
StopAllCoroutines();
Debug.Log("$$ResetCastingState On Event");
}
}