// 상태 종료.. public void Exit(Enemy_StateManager e) { e.m_navAgent.ResetPath(); e.m_anim.SetBool("ISRUN", false); e.m_footstepCycle = 0f; e.m_idleTime = 1.5f; //대기시간없이 바로 attack 상태로 전이되게끔 유도. }
// 상태 진행.. public void Execute(Enemy_StateManager e) { if (e.SearchTarget()) { e.m_anim.SetBool("ISRUN", true); e.m_navAgent.SetDestination(e.m_player.transform.position); #region Footstep e.m_footstepTimer += Time.deltaTime; if (e.m_footstepTimer > e.m_footstepCycle) { e.m_audioSource.clip = e.m_audioClip[0]; e.m_audioSource.PlayOneShot(e.m_audioSource.clip); AudioClip temp = e.m_audioClip[0]; e.m_audioClip[0] = e.m_audioClip[1]; e.m_audioClip[1] = temp; e.m_footstepTimer = 0f; } #endregion if (e.canAttack()) { e.ChangeState(Enemy_IDLE.Instance); } } else { e.ChangeState(Enemy_IDLE.Instance); } }
// 상태 진행.. public void Execute(Enemy_StateManager e) { e.m_dieTime += Time.deltaTime; if (e.m_dieTime >= 5f) { e.gameObject.SetActive(false); } }
// 상태 진행.. public void Execute(Enemy_StateManager e) { if (!e.SearchTarget()) { if (!e.m_navAgent.hasPath) { //랜덤 패트롤링 NavMeshHit hit; Vector3 finalPosition = Vector3.zero; Vector3 randomDirection = Random.insideUnitSphere * 5f; randomDirection += e.gameObject.transform.position; //randomDirection위치에 navMesh가 존재하여 갈 수 있는지 체크 if (NavMesh.SamplePosition(randomDirection, out hit, 1f, 1)) { finalPosition = hit.position; } e.m_anim.SetBool("ISWALK", true); e.m_navAgent.SetDestination(finalPosition); } else { #region Footstep e.m_footstepTimer += Time.deltaTime; if (e.m_footstepTimer > e.m_footstepCycle) { e.m_audioSource.clip = e.m_audioClip[0]; e.m_audioSource.PlayOneShot(e.m_audioSource.clip); AudioClip temp = e.m_audioClip[0]; e.m_audioClip[0] = e.m_audioClip[1]; e.m_audioClip[1] = temp; e.m_footstepTimer = 0f; } #endregion if (e.m_navAgent.remainingDistance <= e.m_navAgent.stoppingDistance) { e.m_navAgent.ResetPath(); e.ChangeState(Enemy_IDLE.Instance); } } } else { e.ChangeState(Enemy_IDLE.Instance); } }
// 상태 진행.. public void Execute(Enemy_StateManager e) { e.m_idleTime += Time.deltaTime; if (e.m_idleTime >= 1.5f) { if (e.SearchTarget()) { if (e.canAttack()) { e.ChangeState(Enemy_ATTACK.Instance); } else { e.ChangeState(Enemy_RUN.Instance); } } else { e.ChangeState(Enemy_PATROL.Instance); } } }
// 상태 진행.. public void Execute(Enemy_StateManager e) { if (e.SearchTarget()) { Vector3 dir = e.m_player.transform.position - e.gameObject.transform.position; e.gameObject.transform.forward = Vector3.Lerp(e.gameObject.transform.forward, new Vector3(dir.x, 0f, dir.z), Time.deltaTime * 3f); //e.m_upperBody.transform.forward = Vector3.Lerp(e.m_upperBody.transform.forward, dir, Time.deltaTime * 3f); //슛포인트도 조정해야함. if (e.canAttack()) { e.m_anim.SetBool("ISATTACK", true); } else { e.m_idleTime = 1f;//빠르게 재추적하도록 유도. e.ChangeState(Enemy_IDLE.Instance); } } else { e.ChangeState(Enemy_IDLE.Instance); } }
// 상태 진입.. public void Enter(Enemy_StateManager e) { }
// 상태 종료.. public void Exit(Enemy_StateManager e) { e.m_anim.SetBool("ISATTACK", false); }
public override void Fire() { if (m_fireTimer < m_fireRate) { return; } m_audioSource.PlayOneShot(m_audioClip[(int)eAudioClip.FIRE], 0.8f); RaycastHit hit; int layerMask = ((1 << LayerMask.NameToLayer("Player")) | (1 << LayerMask.NameToLayer("Sfx"))); layerMask = ~layerMask; if (Physics.Raycast(m_shootPoint.position, m_shootPoint.transform.forward + Random.onUnitSphere * m_accuracy, out hit, m_range, layerMask)) { if (hit.collider.gameObject.layer == LayerMask.NameToLayer("Enemy")) { var blood = GunEffectObjPool.Instance.m_bloodPool.Get(); blood.gameObject.transform.position = hit.point; blood.gameObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, hit.normal); blood.gameObject.SetActive(true); Enemy_StateManager enemy = hit.transform.GetComponentInParent <Enemy_StateManager>(); if (enemy) { if (hit.collider.name.Equals("swat:HeadTop_End")) { m_audioSource.PlayOneShot(m_audioClip[(int)eAudioClip.HEADSHOT], 5f); enemy.Damaged(m_power * 100f); } else { m_audioSource.PlayOneShot(m_audioClip[(int)eAudioClip.HIT], 3f); enemy.Damaged(m_power); } } } else { var hitHole = GunEffectObjPool.Instance.m_hitHoleObjPool.Get(); hitHole.gameObject.transform.position = hit.point; hitHole.gameObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, hit.normal); hitHole.transform.SetParent(hit.transform); // 탄흔이 오브젝트를 따라가게끔 유도하기 위해 리턴되기 전까지만 부모로 지정 hitHole.gameObject.SetActive(true); var hitSpark = GunEffectObjPool.Instance.m_hitSparkPool.Get(); hitSpark.gameObject.transform.position = hit.point; hitSpark.gameObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, hit.normal); hitSpark.gameObject.SetActive(true); if (hit.transform.gameObject.layer.Equals(LayerMask.NameToLayer("Interactable"))) { Rigidbody rig = hit.transform.GetComponent <Rigidbody>(); if (rig) { rig.AddForceAtPosition(m_shootPoint.forward * m_power * 5f, m_shootPoint.position); } } } } m_currentBullets--; m_fireTimer = 0.0f; m_anim.CrossFadeInFixedTime("FIRE", 0.01f); muzzleFlash.Play(); Recoil(); CasingEffect(); }
// 상태 진입.. public void Enter(Enemy_StateManager e) { e.m_navAgent.stoppingDistance = 0.5f; e.m_navAgent.speed = 1f; e.m_footstepCycle = 0.8f; }
// 상태 종료.. public void Exit(Enemy_StateManager e) { e.m_navAgent.ResetPath(); e.m_anim.SetBool("ISWALK", false); e.m_footstepCycle = 0f; }
// 상태 진입.. public void Enter(Enemy_StateManager e) { e.m_anim.Rebind(); e.m_navAgent.ResetPath(); }
// 상태 종료.. public void Exit(Enemy_StateManager e) { e.m_idleTime = 0f; }
// 상태 진입.. public void Enter(Enemy_StateManager e) { e.RagdollOnOff(false); }
// 상태 종료.. public void Exit(Enemy_StateManager e) { }
// 상태 진입.. public void Enter(Enemy_StateManager e) { e.m_navAgent.speed = 2.5f; e.m_footstepCycle = 0.5f; //e.m_navAgent.stoppingDistance = e.m_attackSight; }