// Update is called once per frame void Update() { CheckHealth(); if (_playerSpotted) { if (_moveMode && !coroutineRunning) { _anim.SetBool("Moving", true); _anim.SetBool("Shooting", false); MoveToNextSpot(); } else { CheckForFlip(); if (!coroutineRunning) { _anim.SetBool("Shooting", true); _anim.SetBool("Moving", false); StartCoroutine(PhaseAndShoot()); _characterShoot.ShootStop(); } } } }
/// <summary> /// Every frame, check for the player and try and kill it /// </summary> protected virtual void Update() { if ((_character == null) || (_characterShoot == null)) { return; } if ((_character.ConditionState.CurrentState == CharacterStates.CharacterConditions.Dead) || (_character.ConditionState.CurrentState == CharacterStates.CharacterConditions.Frozen)) { _characterShoot.ShootStop(); return; } // determine the direction of the raycast _direction = (_character.IsFacingRight) ? transform.right : -transform.right; // we cast a ray in front of the agent to check for a Player _raycastOrigin.x = _character.IsFacingRight ? transform.position.x + RaycastOriginOffset.x : transform.position.x - RaycastOriginOffset.x; _raycastOrigin.y = transform.position.y + RaycastOriginOffset.y; _raycast = MMDebug.RayCast(_raycastOrigin, _direction, ShootDistance, TargetLayerMask, Color.yellow, true); // if the raycast has hit something, we shoot if (_raycast) { _characterShoot.ShootStart(); } // otherwise we stop shooting else { _characterShoot.ShootStop(); } if (_characterShoot.CurrentWeapon != null) { if (_characterShoot.CurrentWeapon.GetComponent <WeaponAim>() != null) { if (LevelManager.Instance.Players[0] != null) { Vector3 direction = LevelManager.Instance.Players[0].transform.position - this.transform.position; _characterShoot.CurrentWeapon.GetComponent <WeaponAim>().SetCurrentAim(direction); } } } }
/// <summary> /// When exiting the state we make sure we're not shooting anymore /// </summary> public override void OnExitState() { base.OnExitState(); if (anim != null) { anim.speed = 1; anim.SetBool("Charging", false); } TurnOffChargeEffect(); _characterHandleWeapon.ShootStop(); _shooting = false; }
protected virtual IEnumerator DropProjectile() { _characterShoot.ShootStart(); //Start shooter, ****weapon must have delay before firing**** yield return(new WaitForSeconds(TimeItTakesToRotate)); //time it takes to flip roughly yield return(new WaitForSeconds(TimeUpsideDown)); //time to wait before rotating back. _characterShoot.ShootStop(); //Turn off weapon _playerSpotted = false; //disable spotted mode FlipBackMode = true; //enable flip back mode yield return(new WaitForSeconds(TimeItTakesToRotate * 3f)); //time it takes to flip plus some extra time to allow for a little hover mode. FlipBackMode = false; _detectorActive = true; }
/// <summary> /// When exiting the state we make sure we're not shooting anymore /// </summary> public override void OnExitState() { base.OnExitState(); _characterHandleWeapon.ShootStop(); _shooting = false; }