Exemplo n.º 1
0
    public Chase(SkullAI skull, GameObject player, GameObject leftEye, GameObject rightEye, float eyeRotationLeftBound, float eyeRotationRightBound, float eyeRotationSpeed,
                 float moveSpeed, float rotationSpeed)
    {
        _skull                 = skull;
        _player                = player;
        _leftEye               = leftEye;
        _rightEye              = rightEye;
        _eyeRotationLeftBound  = eyeRotationLeftBound;
        _eyeRotationRightBound = eyeRotationRightBound;
        _eyeRotationSpeed      = eyeRotationSpeed;
        _moveSpeed             = moveSpeed;
        _rotationSpeed         = rotationSpeed;

        speedDifficultyAdjustment = GameController.gC.fails * -0.15f;
    }
Exemplo n.º 2
0
    public Patrol(SkullAI skull, GameObject patrolDestination, GameObject player, GameObject leftEye, GameObject rightEye, float eyeRotationLeftBound, float eyeRotationRightBound, float eyeRotationTimeMax, float eyeRotationSpeed,
                  float moveSpeed, float rotationSpeed)
    {
        rotateLeft   = true;
        rotationTime = 0f;

        _skull                 = skull;
        _patrolDestination     = patrolDestination;
        _player                = player;
        _leftEye               = leftEye;
        _rightEye              = rightEye;
        _eyeRotationLeftBound  = eyeRotationLeftBound;
        _eyeRotationRightBound = eyeRotationRightBound;
        _eyeRotationTimeMax    = eyeRotationTimeMax;
        _eyeRotationSpeed      = eyeRotationSpeed;
        _moveSpeed             = moveSpeed;
        _rotationSpeed         = rotationSpeed;

        speedDifficultyAdjustment = GameController.gC.fails * -0.15f;
    }
Exemplo n.º 3
0
    private void Start()
    {
        sAI = this;

        player = GameObject.FindGameObjectWithTag("Player");

        // State machine initialization
        _stateMachine = new StateMachine();

        var patrol = new Patrol(this, patrolDestination, player, leftEye, rightEye, eyeRotationLeftBound, eyeRotationRightBound, eyeRotationTimeMax, eyeRotationSpeed, moveSpeed, rotationSpeed);
        var chase  = new Chase(this, player, leftEye, rightEye, eyeRotationLeftBound, eyeRotationRightBound, eyeRotationSpeed, moveSpeed, rotationSpeed);

        AddT(patrol, chase, () => {
            if (PlayerInEyeRange())
            {
                leaveVisionRangeTime = 0f;
                return(true);
            }
            return(false);
        });
        AddT(chase, patrol, () => {
            if (!PlayerInEyeRange())
            {
                leaveVisionRangeTime += Time.deltaTime;
            }
            if (leaveVisionRangeTime > 0.66f)
            {
                return(true);
            }
            return(false);
        });

        _stateMachine.SetState(chase);

        void AddT(IState from, IState to, Func <bool> condition) => _stateMachine.AddTransition(from, to, condition);

        visionMask = LayerMask.GetMask("Player", "BlockSkullVision");
    }