몬스터 스킬 코드 복구 누락파일

This commit is contained in:
Mingu Kim
2025-06-01 21:59:02 +09:00
parent 9500707cb2
commit 9577cb05b4
10 changed files with 454 additions and 0 deletions

View File

@@ -0,0 +1,100 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace TON
{
public class AttackPattern
{
protected MonsterBase _monsterBase;
protected float _lastSkillTime;
protected float _skill1Cooldown = 5f;
protected float _skill2Cooldown = 8f;
public AttackPattern(MonsterBase monsterBase)
{
_monsterBase = monsterBase;
// 쿨다운 값을 MonsterData에서 가져오기
_skill1Cooldown = _monsterBase.GetSkillCooldown(1);
_skill2Cooldown = _monsterBase.GetSkillCooldown(2);
_lastSkillTime = -_skill1Cooldown;
}
public virtual void Attack()
{
}
}
public class Monster1AttackPattern : AttackPattern
{
public Monster1AttackPattern(MonsterBase monsterBase) : base(monsterBase)
{
}
public override void Attack()
{
if (Time.time >= _lastSkillTime + _skill1Cooldown)
{
Skill1();
_lastSkillTime = Time.time;
}
else
{
MeleeAttack();
}
}
private void Skill1()
{
_monsterBase.MonsterSkillLaunch();
}
private void MeleeAttack()
{
_monsterBase.PlayerAttack();
}
}
public class Monster2AttackPattern : AttackPattern
{
private float _lastSkill2Time;
public Monster2AttackPattern(MonsterBase monsterBase) : base(monsterBase)
{
_lastSkill2Time = -_skill2Cooldown;
}
public override void Attack()
{
if (Time.time >= _lastSkillTime + _skill1Cooldown)
{
Skill1();
_lastSkillTime = Time.time;
}
else if (Time.time >= _lastSkill2Time + _skill2Cooldown)
{
Skill2();
_lastSkill2Time = Time.time;
}
else
{
MeleeAttack();
}
}
private void Skill1()
{
_monsterBase.MonsterSkillLaunch(1); // 스킬 1 발사
}
private void Skill2()
{
_monsterBase.MonsterSkillLaunch(2); // 스킬 2 발사
}
private void MeleeAttack()
{
_monsterBase.PlayerAttack();
}
}
}