2026-01-13 07:33:06 +00:00
|
|
|
using CodeStage.AntiCheat.ObscuredTypes;
|
2026-01-13 00:46:52 +00:00
|
|
|
using System.Collections;
|
2026-01-12 22:13:54 +00:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
2026-01-12 22:47:31 +00:00
|
|
|
public enum eMobState { Move, Attack }
|
|
|
|
|
|
2026-01-12 22:13:54 +00:00
|
|
|
public class MobActor : MonoBehaviour
|
|
|
|
|
{
|
2026-01-13 22:18:11 +00:00
|
|
|
public MobShields m_MobShields;
|
|
|
|
|
|
2026-01-12 22:47:31 +00:00
|
|
|
MonsterTableData m_Data;
|
|
|
|
|
float FenceY, m_attackTimer;
|
|
|
|
|
eMobState m_State = eMobState.Move;
|
2026-01-12 23:08:10 +00:00
|
|
|
Animator m_Animator;
|
2026-01-13 21:40:48 +00:00
|
|
|
HUD_HP m_HUD_HP;
|
2026-01-13 20:40:28 +00:00
|
|
|
|
2026-01-13 22:18:11 +00:00
|
|
|
private void OnValidate()
|
|
|
|
|
{
|
|
|
|
|
m_MobShields = GetComponentInChildren<MobShields>();
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-13 20:40:28 +00:00
|
|
|
string poolKey;
|
|
|
|
|
IngameMgr owner;
|
|
|
|
|
public void SetOwner(IngameMgr mgr, string key)
|
|
|
|
|
{
|
|
|
|
|
owner = mgr;
|
|
|
|
|
poolKey = key;
|
|
|
|
|
}
|
|
|
|
|
public void Die()
|
|
|
|
|
{
|
|
|
|
|
owner.ReturnMob(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetPoolKey()
|
|
|
|
|
{
|
|
|
|
|
return poolKey;
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-13 23:57:21 +00:00
|
|
|
ObscuredInt _Attack; public int m_Attack { get { return _Attack; } set { _Attack = value; _Attack.RandomizeCryptoKey(); } }
|
|
|
|
|
ObscuredInt _HP; public int m_HP { get { return _HP; } set { _HP = value; _HP.RandomizeCryptoKey(); } }
|
2026-01-12 22:47:31 +00:00
|
|
|
|
2026-01-12 22:13:54 +00:00
|
|
|
private void Awake()
|
|
|
|
|
{
|
|
|
|
|
var srs = GetComponentsInChildren<SpriteRenderer>(true);
|
|
|
|
|
for (int i = 0; i < srs.Length; i++)
|
|
|
|
|
srs[i].sortingOrder -= 5;
|
2026-01-12 23:08:10 +00:00
|
|
|
m_Animator = GetComponentInChildren<Animator>();
|
2026-01-12 22:13:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
|
{
|
2026-01-12 22:47:31 +00:00
|
|
|
float distToFence = transform.position.y - FenceY;
|
|
|
|
|
|
|
|
|
|
switch (m_State)
|
|
|
|
|
{
|
|
|
|
|
case eMobState.Move:
|
|
|
|
|
if (distToFence <= m_Data.f_AttackRange)
|
|
|
|
|
OnEnterAttack();
|
|
|
|
|
else
|
|
|
|
|
Move();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case eMobState.Attack:
|
|
|
|
|
Attack();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-13 23:57:21 +00:00
|
|
|
public void Set(bool isboss, MonsterTableData data, float fenceY)
|
2026-01-12 22:47:31 +00:00
|
|
|
{
|
2026-01-13 20:40:28 +00:00
|
|
|
gameObject.SetActive(true);
|
2026-01-13 21:40:48 +00:00
|
|
|
if (m_HUD_HP == null)
|
|
|
|
|
m_HUD_HP = DSUtil.Get_Clone<HUD_HP>("HUD/HUD_HP", IngameMgr.Ins.tf_hudparent);
|
2026-01-13 20:40:28 +00:00
|
|
|
|
|
|
|
|
m_State = eMobState.Move;
|
2026-01-12 22:47:31 +00:00
|
|
|
m_Data = data;
|
|
|
|
|
FenceY = fenceY;
|
|
|
|
|
m_attackTimer = m_Data.f_AttackDelay;
|
2026-01-13 23:57:21 +00:00
|
|
|
|
|
|
|
|
var curstagedata = IngameMgr.Ins.Get_CurStageTData();
|
|
|
|
|
m_Attack = m_Data.n_DefaultAttack + (isboss ? curstagedata.n_DefaultBossAttack : curstagedata.n_DefaultEnemyAttack);
|
|
|
|
|
m_HP = m_Data.n_DefaultHp + (isboss ? curstagedata.n_DefaultBossHp : curstagedata.n_DefaultEnemyHp);
|
2026-01-13 21:40:48 +00:00
|
|
|
m_HUD_HP.Set(transform, m_HP);
|
2026-01-13 22:18:11 +00:00
|
|
|
m_MobShields.Set(data);
|
2026-01-12 22:47:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Move()
|
|
|
|
|
{
|
|
|
|
|
transform.position += Vector3.down * Time.deltaTime * m_Data.f_MoveSpeed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OnEnterAttack()
|
|
|
|
|
{
|
2026-01-12 23:08:10 +00:00
|
|
|
m_State = eMobState.Attack;
|
|
|
|
|
|
2026-01-12 22:47:31 +00:00
|
|
|
// 이동 정지 시점 보정 (너무 파고들지 않게)
|
|
|
|
|
Vector3 pos = transform.position;
|
|
|
|
|
pos.y = FenceY + m_Data.f_AttackRange;
|
|
|
|
|
transform.position = pos;
|
|
|
|
|
|
|
|
|
|
// 애니메이션, 공격 쿨타임 초기화 등
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Attack()
|
|
|
|
|
{
|
|
|
|
|
m_attackTimer -= Time.deltaTime;
|
|
|
|
|
if (m_attackTimer > 0f)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_attackTimer = m_Data.f_AttackDelay;
|
|
|
|
|
|
2026-01-12 23:08:10 +00:00
|
|
|
//m_Animator.speed = 2f;
|
|
|
|
|
m_Animator.SetTrigger("att");
|
2026-01-13 00:46:52 +00:00
|
|
|
StartCoroutine(Co_AttackProjectile());
|
2026-01-12 22:47:31 +00:00
|
|
|
}
|
|
|
|
|
|
2026-01-13 00:46:52 +00:00
|
|
|
IEnumerator Co_AttackProjectile()
|
2026-01-12 22:47:31 +00:00
|
|
|
{
|
2026-01-13 00:46:52 +00:00
|
|
|
yield return new WaitForSeconds(1f);
|
2026-01-13 06:20:15 +00:00
|
|
|
|
|
|
|
|
ProjectileMgr.Ins.Shoot_Projectile(new ProjectileData
|
|
|
|
|
{
|
|
|
|
|
IsPC = false,
|
|
|
|
|
m_Data = table_projectile.Ins.Get_Data(m_Data.n_ProjectileID),
|
2026-01-13 07:33:06 +00:00
|
|
|
tf_Start = transform,
|
2026-01-13 23:57:21 +00:00
|
|
|
Dmg = m_Attack
|
2026-01-13 06:20:15 +00:00
|
|
|
});
|
2026-01-12 22:13:54 +00:00
|
|
|
}
|
2026-01-13 07:33:06 +00:00
|
|
|
|
|
|
|
|
public void Get_Dmg(int dmg)
|
|
|
|
|
{
|
|
|
|
|
m_HP -= dmg;
|
2026-01-13 21:40:48 +00:00
|
|
|
m_HUD_HP.Set(m_HP);
|
2026-01-13 07:33:06 +00:00
|
|
|
if (m_HP <= 0)
|
|
|
|
|
{
|
|
|
|
|
gameObject.SetActive(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-01-13 21:40:48 +00:00
|
|
|
|
|
|
|
|
public void Off()
|
|
|
|
|
{
|
|
|
|
|
gameObject.SetActive(false);
|
|
|
|
|
m_HUD_HP.gameObject.SetActive(false);
|
|
|
|
|
}
|
2026-01-12 22:13:54 +00:00
|
|
|
}
|