コード例 #1
0
    public override IEnumerator RunRoutine()
    {
        while (true)
        {
            if (ShouldJump())
            {
                yield return(_jump.Execute());
            }
            else
            {
                yield return(_roll.Execute());
            }

            StepFinished();
        }
    }
コード例 #2
0
    public override IEnumerator RunRoutine()
    {
        while (true)
        {
            yield return(_roll.Execute());

            var shouldRollSideWays = Random.Range(0f, 1f) < _chanceToRollSideways;
            if (shouldRollSideWays)
            {
                _roll.RollDirection = Random.Range(0f, 1f) < 0.5f ? RollMove.Direction.Left : RollMove.Direction.Right;
            }
            else
            {
                _roll.RollDirection = RollMove.Direction.Forward;
            }

            StepFinished();
        }
    }