void AttackPlayer() { navAgent.velocity = Vector3.zero; navAgent.isStopped = true; enemy_anim.Walk(false); attack_timer += Time.deltaTime; if (attack_timer > wait_before_Attack) { if (Random.Range(0, 2) > 0) { enemy_anim.Attack_1(); } else { enemy_anim.Attack_2(); } attack_timer = 0f; } if (Vector3.Distance(transform.position, playerTarget.position) > attack_Distance + chase_player_after_attack_distance) { navAgent.isStopped = false; enemy_State = EnemyState.CHASE; } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.J)) { playerAnimation.Defend(true); shield.ActiveShield(true); } if (Input.GetKeyUp(KeyCode.J)) { playerAnimation.UnFreezeAnimation(); playerAnimation.Defend(false); shield.ActiveShield(false); } if (Input.GetKeyDown(KeyCode.K) || joyButton.isPressed && isAttack == false) { if (Random.Range(0, 2) > 0) { playerAnimation.Attack_1(); isAttack = true; soundFX.Attack_1(); } else { playerAnimation.Attack_2(); isAttack = true; soundFX.Attack_2(); } } else { isAttack = false; } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.J)) { playerAnimation.Defend(true); shield.ActiveShield(true); } if (Input.GetKeyUp(KeyCode.J)) { playerAnimation.UnFreezeAnimation(); playerAnimation.Defend(false); shield.ActiveShield(false); } if (Input.GetKeyDown(KeyCode.K) && isAttack == false) { if (!firstAttack) { playerAnimation.Attack_1(); firstAttack = true; } else if (secondAttack == false && firstAttack) { playerAnimation.Attack_2(); secondAttack = true; } else if (thirdAttack == false && secondAttack && firstAttack) { playerAnimation.Attack_3(); thirdAttack = true; } StartCoroutine(backtoAttack()); isAttack = true; } else { isAttack = false; } }