// Update is called once per frame void Update() { if (_dialogOpen) { platformerController.DoStop(); } }
public void Stop() { nextFire = Time.time + fireRate; motor.DoStop(); }
void FixedUpdate() { if (!canMove) { return; } //Move //Target direction _targetPosition = target.position + _offsetVector - _cachedTransform.position; _targetDirection = _targetPosition.normalized; //Check if reached limit if (_cachedTransform.position.x < maximumXPosition) { //check if reached target if (_targetPosition.sqrMagnitude > 1 && !_isAttacking) { //Accelerate if (_currentSpeed < maxSpeed) { _currentSpeed += Mathf.Min(maxSpeed * Time.deltaTime, maxSpeed - _currentSpeed); } //Move only forward if (_targetDirection.x > 0) { _cachedTransform.Translate(_targetDirection * _currentSpeed * Time.deltaTime); } } else if (target.position.x < _cachedTransform.position.x + minimumHorizontalOffset) { //Death canMove = false; _canAttack = false; _eventHandler.enabled = false; _platformerControl.DoStop(); StartCoroutine(DoKill()); } else if (_canAttack) { //Play roar //audioSource.PlayOneShot (roarSound); //Reduce speed _currentSpeed = attackSpeed; if (_targetDirection.x > 0) { _cachedTransform.Translate(_targetDirection * _currentSpeed * Time.deltaTime); } //Attack if (!_isInAttack) { StartCoroutine(DoAttack()); } } } else { if (!_playedRoar) { _playedRoar = true; audioSource.PlayOneShot(roarSound); audioFader.fadeDirection = AudioFader.FadeDirection.FadeOut; audioFader.Fade(); } } }