Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.J))//defend when J pressed is down
        {
            playerAnimation.Defend(true);
            playerShield.ActivatedShield(true);
        }

        if (Input.GetKeyUp(KeyCode.J))//release defence when J is released
        {
            playerAnimation.UnFreezeAnimation();
            playerAnimation.Defend(false);
            playerShield.ActivatedShield(false);
        }

        if (Input.GetKeyDown(KeyCode.K))
        {
            attackMovement.Attack(playerAnimation);
        }
    }
Exemplo n.º 2
0
    void AttackPlayer()
    {
        navAgent.velocity  = Vector3.zero;
        navAgent.isStopped = true;

        enemyAnim.Walk(false);
        attackTimer += Time.deltaTime;

        if (attackTimer > waitBeforeAttackTime)
        {
            attackBehaivor.Attack(enemyAnim);
            attackTimer = 0f;
        }//if we can attack

        if (Vector3.Distance(transform.position, playerTarget.position) > attackDistance + chasePlayerAfterAttackDistance)
        {
            navAgent.isStopped = false;
            enemyState         = EnemyState.CHASE;
        }
    }