protected virtual void Shoot() { if (_numberOfShoots < 1) { Instantiate(soundEffect); GetComponentInParent <Character>().MovementState.ChangeState(CharacterStates.MovementStates.Attacking); StartCoroutine("endAnimation"); Vector3 target = new Vector3(_brain.Target.position.x + UnityEngine.Random.Range(-1f, 1f), _brain.Target.position.y + UnityEngine.Random.Range(-1f, 1f), _brain.Target.position.z); Instantiate(aoeProjectile, target, Quaternion.identity, StaticManager.ObjectPool.transform); StaticManager.addObjectToPool(); _numberOfShoots++; } }
public virtual IEnumerator waitBeforeShooting(float x) { yield return(new WaitForSecondsRealtime(x)); //play animation GetComponentInParent <Character>().MovementState.ChangeState(CharacterStates.MovementStates.Attacking); StartCoroutine("endAnimation"); explosions = 0; currentLocation = transform.position; float mult = (10 / (_brain.Target.position - currentLocation).magnitude); targetLocation = currentLocation + (_brain.Target.position - currentLocation) * mult; distanceBetweenExplosions = (targetLocation - transform.position) / totalExplosions; StartCoroutine("chainExplosion"); StaticManager.addObjectToPool(); }