Merge branch 'dev' of https://github.com/2aurore/Gameton-06 into dev
This commit is contained in:
@@ -15,17 +15,16 @@ namespace TON
|
||||
if (other.CompareTag("Player"))
|
||||
{
|
||||
_monsterBase.IsAttacking = true;
|
||||
// _monsterBase.SetTransition(new AttackState());
|
||||
// _monsterBase.SetTransition(new MonsterSkillState());
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerExit2D(Collider2D other)
|
||||
{
|
||||
_monsterBase.IsAttacking = false;
|
||||
// _monsterBase.SetTransition(new ChasingState());
|
||||
|
||||
// Debug.Log("감지 벗어남");
|
||||
if (other.CompareTag("Player"))
|
||||
{
|
||||
_monsterBase.IsAttacking = false;
|
||||
_monsterBase.IsFisnishAttack = true; // 공격 종료 상태로 설정
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ namespace TON
|
||||
{
|
||||
protected MonsterBase _monsterBase;
|
||||
|
||||
|
||||
public AttackPattern(MonsterBase monsterBase)
|
||||
{
|
||||
_monsterBase = monsterBase;
|
||||
|
||||
@@ -36,6 +36,8 @@ namespace TON
|
||||
public bool IsDetect { get; set; } // 몬스터가 대상을 인식했는지 여부
|
||||
public bool IsAttacking { get; set; } // 몬스터가 공격했는지 여부
|
||||
public bool IsFisnishAttack { get; set; } // 몬스터 공격 모션이 끝났는지 여부
|
||||
public bool IsHit { get; set; } // 몬스터 공격 모션이 끝났는지 여부
|
||||
public bool IsDead { get; set; } // 몬스터 공격 모션이 끝났는지 여부
|
||||
|
||||
[SerializeField] private GameObject _target; // 몬스터의 타겟
|
||||
|
||||
@@ -162,7 +164,8 @@ namespace TON
|
||||
if (prevHP > 0 && currentHP <= 0)
|
||||
{
|
||||
// 몬스터가 죽었을 때 처리 (죽는 애니메이션은 주석 처리됨)
|
||||
Destroy(gameObject); // 몬스터 파괴
|
||||
// Destroy(gameObject); // 몬스터 파괴
|
||||
DestroyMonster();
|
||||
}
|
||||
else if (prevHP > 0 && currentHP > 0)
|
||||
{
|
||||
@@ -248,5 +251,10 @@ namespace TON
|
||||
newSkill.transform.position = transform.position + new Vector3(0, 1f, 0);
|
||||
newSkill.GetComponent<MonsterSkill>().Direction = new Vector2(0, 1);
|
||||
}
|
||||
|
||||
public void DestroyMonster()
|
||||
{
|
||||
Destroy(gameObject); // 몬스터 파괴
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -291,4 +291,79 @@ namespace TON
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public class HitState : IState
|
||||
{
|
||||
private const string AniHit = "Hit";
|
||||
private MonsterBase _monsterBase;
|
||||
private float _hitDuration = 0.5f;
|
||||
private float _hitStartTime;
|
||||
|
||||
public void Enter(MonsterBase monsterBase)
|
||||
{
|
||||
_monsterBase = monsterBase;
|
||||
_monsterBase.ChangeAnimationState(AniHit);
|
||||
_hitStartTime = Time.time;
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (Time.time >= _hitStartTime + _hitDuration)
|
||||
{
|
||||
_monsterBase.IsHit = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void Exit()
|
||||
{
|
||||
}
|
||||
|
||||
public IState CheckTransition()
|
||||
{
|
||||
if (_monsterBase.IsHit)
|
||||
return new HitState();
|
||||
|
||||
if (_monsterBase.IsDead)
|
||||
return new DeathState();
|
||||
|
||||
if (Time.time >= _hitStartTime + _hitDuration)
|
||||
return new IdleState();
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public class DeathState : IState
|
||||
{
|
||||
private const string AniDeath = "Death";
|
||||
private MonsterBase _monsterBase;
|
||||
private float _deathDuration = 1f;
|
||||
private float _deathStartTime;
|
||||
private bool _deathAnimationStarted = false;
|
||||
|
||||
public void Enter(MonsterBase monsterBase)
|
||||
{
|
||||
_monsterBase = monsterBase;
|
||||
_monsterBase.ChangeAnimationState(AniDeath);
|
||||
_deathStartTime = Time.time;
|
||||
_deathAnimationStarted = true;
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (_deathAnimationStarted && Time.time >= _deathStartTime + _deathDuration)
|
||||
{
|
||||
_monsterBase.DestroyMonster();
|
||||
}
|
||||
}
|
||||
|
||||
public void Exit()
|
||||
{
|
||||
}
|
||||
|
||||
public IState CheckTransition()
|
||||
{
|
||||
return this; // Death는 다른 상태로 전환되지 않음
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user