コード例 #1
0
ファイル: LegAttack.cs プロジェクト: CaptainBateau/Guaishou
    IEnumerator Attack(Transform targetToHit)
    {
        StartCoroutine(Movements.Move(_target.transform, targetToHit, _attackingCurve, _attackingDuration, _playerYOffset, _playerRandomHitRange));
        yield return(new WaitForSeconds(_attackingDuration));

        StartCoroutine(Recover());
    }
コード例 #2
0
    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());
        }
    }
コード例 #3
0
ファイル: LegAttack.cs プロジェクト: CaptainBateau/Guaishou
    IEnumerator Recover()
    {
        StartCoroutine(Movements.Move(_target.transform, basePosition, _recoveringCurve, _recoveringDuration));
        yield return(new WaitForSeconds(_recoveringDuration));

        attacking = false;
    }
コード例 #4
0
ファイル: LegAttack.cs プロジェクト: CaptainBateau/Guaishou
    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));
    }
コード例 #5
0
 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));
     }
 }
コード例 #6
0
    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;
    }
コード例 #7
0
    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;
    }
コード例 #8
0
    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);
    }
コード例 #9
0
 private void FixedUpdate()
 {
     movements.Move();
 }