Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (_beingKilled)
        {
            return;
        }

        //If we are dead
        if (_aiHealth.IsDead)
        {
            //Change to death state, activates ragdoll and drops weapons
            stateMachine.ChangeState(AiStateId.Death);

            _player.GetComponent <PlayerController>().AgentInRange = null;
            //Destroy the assassination target component and this ai agent component
            Destroy(GetComponentInChildren <AssassinationTarget>());
            Destroy(this);
        }

        stateMachine.Update();
        _currentState = stateMachine._currentState;

        if (_player.GetComponent <PlayerHealth>().IsDead)
        {
            //Dances, and then stops the AIn from firing and clears the target
            GetComponent <Animator>().SetBool("PlayerDead", true);
            GetComponent <NavMeshAgent>().SetDestination(transform.position);

            _aiWeapon?.SetFiring(false);
            _aiWeapon?.SetTarget(null);
        }
    }
Exemplo n.º 2
0
    private IEnumerator AICycle()
    {
        while (enabled)
        {
            stateMachine?.Update();
            // stateMachine?.SetStateTargetVector(AIBlackboard.Instance.player.transform.position);

            MoveAI();

            if (!targetTransform && !isEngaging)
            {
                isSprinting = false;
                //Stop Sprinting Animation
            }
            else if (Vector3.SqrMagnitude(mTransform.position - stateMachine.TargetVector) <
                     agentStats.distanceFromTargetToSprint && isEngaging)
            {
                //Stop Sprinting Animation

                AdjustSpeed();
            }

            yield return(new WaitForSeconds(AIController.Instance.agentCycleTime));
        }
    }
Exemplo n.º 3
0
 void Update()
 {
     stateMachine.Update();
 }
Exemplo n.º 4
0
 // Update is called once per frame
 void Update()
 {
     machine.Update();
 }