// Update is called once per frame void FixedUpdate() { if (player != null) { playerPosition = player.transform.position; } if (canChase) { aiAgent.SetDestination(playerPosition); } if (Vector3.Distance(playerPosition, transform.position) <= 1.5f && player != null && canChase) { Attack(); } else { enemyAnim.AttackAnimation(false); } }
public void RunUpdate() { float distance = Vector3.Distance(_target.position, transform.position); if (_enemyModel.CurrentHealth > 0) //(!_anim.GetBool("isDie")) { if (distance <= _enemyView.GetStoppingDistance()) { _enemyView.FaceTarget(_target.position); _enemyView.SetIsStopped(true); if (_enemyAnimation.AttackAnimation()) { _enemyModel.Fire(_target.position + (Vector3.up * 2f)); } //_enemyAnimation.AttackAnimation(ref _anim, _enemyModel.firePoint, _target, ); } else if (distance <= _enemyModel.lookRadius) { _enemyView.SetDestination(_target.position); _enemyView.SetIsStopped(false); _enemyAnimation.WalkAnimation(); } else if (_enemyAnimation.IsIdleAniamtion()) { _enemyView.SetIsStopped(true); _enemyAnimation.IdleAnimation(); } } else if (_enemyAnimation.DieAnimationEnd()) { GameObject loot = Resources.Load("Prefabs/Loot/Loot", typeof(GameObject)) as GameObject; Instantiate(loot, this.transform.position, this.transform.rotation, null); Destroy(gameObject); } else if (_alive)//animacja śmierci nie odpali soię więcej niż raz { Die(); } else if (_enemyModel.isBoss) { _enemyModel.text.text = "You save sthe World, congratulation!"; _enemyModel.gameOverSreen.GetComponent <Image>().color = new Color(0.4f, 0.6f, 0.8f); _enemyModel.text.color = new Color(0.6f, 0.8f, 0.4f); _enemyModel.gameOverSreen.SetActive(true); } }