2026-01-12 12:33:09 +00:00
|
|
|
using System.Collections;
|
|
|
|
|
using TMPro;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
public class IngameMgr : MonoBehaviour
|
|
|
|
|
{
|
2026-01-12 22:13:54 +00:00
|
|
|
[Header("UI")]
|
2026-01-12 12:33:09 +00:00
|
|
|
public TextMeshProUGUI[] texts_money; // 0 코인, 1 아이템, 2 웨이브
|
|
|
|
|
public Text t_timer, t_hp, t_exp;
|
|
|
|
|
public Slider slider_wave, slider_exp;
|
|
|
|
|
|
2026-01-12 22:13:54 +00:00
|
|
|
[Header("Monster")]
|
|
|
|
|
public Transform[] tfs_mobparent;
|
|
|
|
|
|
2026-01-12 12:33:09 +00:00
|
|
|
int m_Wave, m_HP, m_Coin, m_Item, m_Lv, m_Exp;
|
|
|
|
|
StageConfigTableData CurStageData;
|
|
|
|
|
|
|
|
|
|
private void OnEnable()
|
|
|
|
|
{
|
|
|
|
|
CurStageData = table_stageconfig.Ins.Get_Data(10001);
|
|
|
|
|
var unitdata = table_unit.Ins.Get_Data(1000);
|
|
|
|
|
|
|
|
|
|
m_HP = unitdata.n_DefaultHp;
|
|
|
|
|
m_Lv = m_Wave = 1;
|
|
|
|
|
m_Exp = m_Coin = m_Item = 0;
|
|
|
|
|
|
|
|
|
|
Set_Texts();
|
|
|
|
|
|
|
|
|
|
StartCoroutine(Co_MakeMob());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Set_Texts()
|
|
|
|
|
{
|
|
|
|
|
texts_money[0].text = m_Coin.ToString();
|
|
|
|
|
texts_money[1].text = m_Item.ToString();
|
|
|
|
|
texts_money[2].text = $"Wave {m_Wave}/{CurStageData.n_MaxWave}";
|
|
|
|
|
slider_wave.value = ((m_Wave - 1) / (float)CurStageData.n_MaxWave);
|
|
|
|
|
|
|
|
|
|
t_hp.text = m_HP.ToString();
|
|
|
|
|
slider_exp.value = 0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IEnumerator Co_MakeMob()
|
|
|
|
|
{
|
|
|
|
|
var wavedata = table_wavepattern.Ins.Get_Data(CurStageData.n_WavePatternGroupID, m_Wave);
|
|
|
|
|
if (wavedata == null)
|
|
|
|
|
{ // 클리어
|
|
|
|
|
yield break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 일반 몬스터 생성
|
|
|
|
|
int meleemobcount = 0, rangemobcount = 0;
|
|
|
|
|
var totalmobcount = wavedata.n_AppearMeleeMonster + wavedata.n_AppearRangeMonster;
|
|
|
|
|
for (int i = 0; i < totalmobcount; i++)
|
|
|
|
|
{
|
|
|
|
|
yield return new WaitForSeconds(wavedata.f_AppearDelay);
|
|
|
|
|
for (int j = 0; j < wavedata.n_OverlapUnitCount; j++)
|
|
|
|
|
{ // 근거리 or 원거리 몹 생성 후 카운팅
|
2026-01-12 22:13:54 +00:00
|
|
|
if (totalmobcount < meleemobcount + rangemobcount) break;
|
|
|
|
|
|
|
|
|
|
bool canMelee = meleemobcount < wavedata.n_AppearMeleeMonster;
|
|
|
|
|
bool canRange = rangemobcount < wavedata.n_AppearRangeMonster;
|
|
|
|
|
|
|
|
|
|
if (!canMelee && !canRange)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
bool meleemob;
|
|
|
|
|
if (canMelee && canRange)
|
|
|
|
|
meleemob = Random.Range(0, 2) == 0;
|
|
|
|
|
else
|
|
|
|
|
meleemob = canMelee;
|
|
|
|
|
|
|
|
|
|
int mobid = 0;
|
|
|
|
|
if (meleemob && meleemobcount < wavedata.n_AppearMeleeMonster)
|
|
|
|
|
{
|
|
|
|
|
++meleemobcount;
|
|
|
|
|
mobid = CurStageData.list_monster_melee[Random.Range(0, CurStageData.list_monster_melee.Count)];
|
|
|
|
|
}
|
|
|
|
|
else if(!meleemob && rangemobcount < wavedata.n_AppearRangeMonster)
|
|
|
|
|
{
|
|
|
|
|
++rangemobcount;
|
|
|
|
|
mobid = CurStageData.list_monster_range[Random.Range(0, CurStageData.list_monster_range.Count)];
|
|
|
|
|
}
|
2026-01-12 12:33:09 +00:00
|
|
|
|
2026-01-12 22:13:54 +00:00
|
|
|
var mobdata = table_monster.Ins.Get_Data(mobid);
|
|
|
|
|
DSUtil.Get_Clone<MobActor>(mobdata.s_MonsterPrefabPath, tfs_mobparent[Random.Range(0, tfs_mobparent.Length)],
|
|
|
|
|
null, Vector3.one * mobdata.f_Scale);
|
2026-01-12 12:33:09 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
yield return new WaitForSeconds(wavedata.f_NextWaveDelay);
|
|
|
|
|
++m_Wave;
|
|
|
|
|
Set_Texts();
|
|
|
|
|
StartCoroutine(Co_MakeMob());
|
|
|
|
|
}
|
|
|
|
|
}
|