parent
9b1709b92c
commit
39379da300
BIN
Assets/JYY/Animator/PldDogControl.controller
(Stored with Git LFS)
BIN
Assets/JYY/Animator/PldDogControl.controller
(Stored with Git LFS)
Binary file not shown.
BIN
Assets/JYY/Scenes/MonsterTest.unity
(Stored with Git LFS)
BIN
Assets/JYY/Scenes/MonsterTest.unity
(Stored with Git LFS)
Binary file not shown.
@ -114,7 +114,7 @@ public abstract class EnemyController : CharacterBase
|
||||
public virtual void BattleSequence()
|
||||
{
|
||||
// 이 메서드는 자식 요소에서 오버라이드하여 구현합니다.
|
||||
Debug.LogWarning("BattleSequence가 구현되지 않았습니다.");
|
||||
Debug.LogWarning("BattleSequence가 구현되지 않음 : " + "BattleSequence()를 오버라이드하여 구현하십시오.");
|
||||
}
|
||||
|
||||
public override void Die()
|
||||
|
@ -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()
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
// 순환 패턴과 별개로 동작하는 특수 패턴
|
||||
|
Loading…
x
Reference in New Issue
Block a user