From 39379da3009df615f21395a50dcd8ca0c362017a Mon Sep 17 00:00:00 2001 From: fiore Date: Fri, 25 Apr 2025 15:46:54 +0900 Subject: [PATCH] =?UTF-8?q?DEG-95=20[Fix]=20=ED=8C=94=EB=9D=BC=EB=94=98=20?= =?UTF-8?q?=EB=AA=AC=EC=8A=A4=ED=84=B0=20=ED=8F=AD=ED=83=84=20=EB=8D=98?= =?UTF-8?q?=EC=A7=80=EB=8A=94=20=EC=95=A0=EB=8B=88=EB=A9=94=EC=9D=B4?= =?UTF-8?q?=EC=85=98=20=EB=88=84=EB=9D=BD=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 공격 패턴 순차 실행 -> 랜덤 실행으로 변경 --- Assets/JYY/Animator/PldDogControl.controller | 4 ++-- Assets/JYY/Scenes/MonsterTest.unity | 2 +- Assets/Scripts/Character/Enemy/EnemyController.cs | 2 +- .../Enemy/EnemyState/Caster/EnemyStateFlee.cs | 11 ++--------- Assets/Scripts/Character/Enemy/PldDogController.cs | 14 +++++++++++--- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/Assets/JYY/Animator/PldDogControl.controller b/Assets/JYY/Animator/PldDogControl.controller index 7b80e503..9a22018c 100644 --- a/Assets/JYY/Animator/PldDogControl.controller +++ b/Assets/JYY/Animator/PldDogControl.controller @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9473c357cb74d4228523205a76d0a1a1cc71d82baf736270906c82a171efe7e6 -size 16154 +oid sha256:7c8e0126546f60a0df64adf8fb366d479da5eb832ec0453ea51dfc7c731e2084 +size 17507 diff --git a/Assets/JYY/Scenes/MonsterTest.unity b/Assets/JYY/Scenes/MonsterTest.unity index d772a68e..e6211594 100644 --- a/Assets/JYY/Scenes/MonsterTest.unity +++ b/Assets/JYY/Scenes/MonsterTest.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:efc792ecb073a66263abf936bd751584b41224bde07c7f02418d10223d0c07f4 +oid sha256:1423d99c1df3a3bb884799cdc72b7eca0f11c1b831f7414e56921662d826d6f9 size 22331 diff --git a/Assets/Scripts/Character/Enemy/EnemyController.cs b/Assets/Scripts/Character/Enemy/EnemyController.cs index 64002b75..059a109d 100644 --- a/Assets/Scripts/Character/Enemy/EnemyController.cs +++ b/Assets/Scripts/Character/Enemy/EnemyController.cs @@ -114,7 +114,7 @@ public abstract class EnemyController : CharacterBase public virtual void BattleSequence() { // 이 메서드는 자식 요소에서 오버라이드하여 구현합니다. - Debug.LogWarning("BattleSequence가 구현되지 않았습니다."); + Debug.LogWarning("BattleSequence가 구현되지 않음 : " + "BattleSequence()를 오버라이드하여 구현하십시오."); } public override void Die() diff --git a/Assets/Scripts/Character/Enemy/EnemyState/Caster/EnemyStateFlee.cs b/Assets/Scripts/Character/Enemy/EnemyState/Caster/EnemyStateFlee.cs index 47d7c03f..56718a5b 100644 --- a/Assets/Scripts/Character/Enemy/EnemyState/Caster/EnemyStateFlee.cs +++ b/Assets/Scripts/Character/Enemy/EnemyState/Caster/EnemyStateFlee.cs @@ -26,7 +26,7 @@ public class EnemyStateFlee :IEnemyState public void Update() { - // 도망치는 방향 계산 + // 도망치는 방향 계산 Vector3 fleeDirection = (_enemyController.transform.position - _detectPlayerTransform.position).normalized; Vector3 fleeTarget = _enemyController.transform.position + fleeDirection * _fleeDistance; @@ -34,14 +34,7 @@ public class EnemyStateFlee :IEnemyState float distance = Vector3.Distance(_enemyController.transform.position, _detectPlayerTransform.position); - // 일정 범위 안으로 플레이어가 접근하면 공격 시퀸스 - if (distance <= _attackRange) - { - - return; - } - - + _enemyController.BattleSequence(); } public void Exit() diff --git a/Assets/Scripts/Character/Enemy/PldDogController.cs b/Assets/Scripts/Character/Enemy/PldDogController.cs index aa1ac14a..cc0887b0 100644 --- a/Assets/Scripts/Character/Enemy/PldDogController.cs +++ b/Assets/Scripts/Character/Enemy/PldDogController.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Linq; using Unity.VisualScripting; using UnityEngine; using UnityEngine.Serialization; @@ -37,7 +38,7 @@ public class PldDogController : EnemyController [SerializeField] private GameObject horizontalSlash; [SerializeField] private float _patternTimer = 0f; - private int _currentPatternIndex = 0; + private int _lastPatternIndex = -1; private bool _isPatternRunning = false; private bool _isFirstAttack = true; @@ -92,9 +93,16 @@ public class PldDogController : EnemyController Agent.isStopped = true; IsMeleeCombat = true; - _patternActions[_currentPatternIndex]?.Invoke(); + var available = Enumerable + .Range(0, _patternActions.Count) + .Where(i => i != _lastPatternIndex) + .ToList(); - _currentPatternIndex = (_currentPatternIndex + 1) % _patternActions.Count; // 패턴 순환 + int nextIndex = available[Random.Range(0, available.Count)]; + + _patternActions[nextIndex]?.Invoke(); + + _lastPatternIndex = nextIndex; } // 순환 패턴과 별개로 동작하는 특수 패턴