예제 #1
0
    public override void OnStateUpdate(EnemyCar enemyCar)
    {
        // chase ball
        if (enemyCar.enemyAgent.enabled)
        {
            enemyCar.MoveToPointInGameWorld(enemyCar.ball.transform.position);
        }

        if (!enemyCar.isBallWithinRange())
        {
            // exit chase state
            OnStateExit(enemyCar);

            // move to patrol state
            enemyCar.MakeTransitionToNextFSMState(enemyCar.patrolBehavior);
        }
    }
    public override void OnStateUpdate(EnemyCar enemyCar)
    {
        // every few seconds pick a random point and move
        _counter += Time.deltaTime;
        if (_counter >= _patrolTime)
        {
            // pick new position and move
            Vector3 newPatrolPosition = enemyCar.GetRandomPositionWithinRadius(enemyCar.pointOfInterest, GameConstants.ENEMY_PATROL_RADIUS);
            enemyCar.MoveToPointInGameWorld(newPatrolPosition);

            _counter = 0;
        }

        // move to chase if ball is within fov radius
        if (enemyCar.isBallWithinRange())
        {
            // exit current state
            OnStateExit(enemyCar);

            // move to chase state
            enemyCar.MakeTransitionToNextFSMState(enemyCar.chaseBehavior);
        }
    }