IEnumerator Attack(Transform targetToHit) { StartCoroutine(Movements.Move(_target.transform, targetToHit, _attackingCurve, _attackingDuration, _playerYOffset, _playerRandomHitRange)); yield return(new WaitForSeconds(_attackingDuration)); StartCoroutine(Recover()); }
protected virtual IEnumerator moveToNextTarget() { if (attackPlayer) { float moveDuration = Vector2.Distance(_movingObject.transform.position, player.position) * _TimeToTargetPlayer; IEnumerator attack = Movements.Move(_movingObject.transform, player, _moveCurve, moveDuration, 1.5f, 2); StartCoroutine(attack); yield return(new WaitForSeconds(moveDuration)); StartCoroutine(moveToNextTarget()); } else { GenerateRandomTarget(); float moveDuration = Vector2.Distance(_movingObject.transform.position, _target.transform.position) * _TimeToTarget; IEnumerator move = Movements.Move(_movingObject.transform, _target.transform, _moveCurve, moveDuration); StartCoroutine(move); float timer = 0; while (timer < moveDuration) { if (attackPlayer) { StopCoroutine(move); timer = moveDuration; } timer += Time.deltaTime; yield return(null); } StartCoroutine(moveToNextTarget()); } }
IEnumerator Recover() { StartCoroutine(Movements.Move(_target.transform, basePosition, _recoveringCurve, _recoveringDuration)); yield return(new WaitForSeconds(_recoveringDuration)); attacking = false; }
IEnumerator PrepareAttack(Transform targetToHit) { detectionEvent.MonsterAttack(new MonsterDetectionEvent.MonsterAttackEventArgs { }); StartCoroutine(Movements.Move(_target.transform, anticipationPosition.transform, _preparingAttackCurve, _prepareDuration)); yield return(new WaitForSeconds(_prepareDuration)); StartCoroutine(Attack(targetToHit)); }
private void OnShiftDirectionHandler(object sender, MonsterDetectionEvent.ShiftDirectionEventArgs e) { if (e.newDir == Vector2.left) { StartCoroutine(Movements.Move(transform, leftDirPos, animCurve, animDuration)); } if (e.newDir == Vector2.right) { StartCoroutine(Movements.Move(transform, rightDirPos, animCurve, animDuration)); } }
IEnumerator NeckRecover() { while (inMovement) { yield return(null); } inMovement = true; StartCoroutine(Movements.Move(neckBase, originalNeckPos, neckRecoverCurve, neckRecoverDuration, 0, 0, true)); yield return(new WaitForSeconds(neckRecoverDuration)); inMovement = false; }
IEnumerator NeckDown() { while (inMovement) { yield return(null); } inMovement = true; StartCoroutine(Movements.Move(neckBase, targetPos, neckDownCurve, neckDownDuration, 0, 0, true)); yield return(new WaitForSeconds(neckDownDuration)); inMovement = false; }
protected override IEnumerator moveToNextTarget() { float rng = Random.Range(0, 100); if (rng <= chanceToGoToInterestPoints && _interestPoints.Count > 0 && !attackPlayer) { Transform targetPoint = _interestPoints[0]; bool targetFound = false; if (_interestPoints.Count == 1) { targetFound = true; } int iterationDebug = 0; while (!targetFound) { targetPoint = _interestPoints[Random.Range(0, _interestPoints.Count)]; if (Vector2.Distance(targetPoint.position, _movingObject.position) > 0.1f) { targetFound = true; } iterationDebug++; if (iterationDebug > 100) { targetFound = true; } } float moveDuration = Vector2.Distance(_movingObject.transform.position, targetPoint.position) * _TimeToTarget; IEnumerator move = Movements.Move(_movingObject.transform, targetPoint, _moveCurve, moveDuration); StartCoroutine(move); yield return(new WaitForSeconds(moveDuration)); yield return(new WaitForSeconds(timeStayingAtInterestPoints)); StartCoroutine(moveToNextTarget()); } else { yield return(StartCoroutine(base.moveToNextTarget())); } yield return(null); }
private void FixedUpdate() { movements.Move(); }