310 lines
10 KiB
C#
310 lines
10 KiB
C#
using CodeStage.AntiCheat.ObscuredTypes;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class DungeonInfo : MonoBehaviourSingletonTemplate<DungeonInfo>
|
|
{
|
|
public Action<float> act_Time;
|
|
public Action<int> act_MobDieCount;
|
|
public Action<double> act_DamageUI;
|
|
public Action<int> act_WaveScoreUI, act_WaveLifeUI, act_WaveGold;
|
|
|
|
public float m_TotalTime, WaveMakeGapTime;
|
|
Dictionary<int, ObscuredFloat> dic_time = new Dictionary<int, ObscuredFloat>();
|
|
public void Set_Time(int floor, float time)
|
|
{
|
|
if (!dic_time.ContainsKey(MyValue.MyChoiceMapData.n_DungeonLv))
|
|
dic_time.Add(MyValue.MyChoiceMapData.n_DungeonLv, 0f);
|
|
dic_time[MyValue.MyChoiceMapData.n_DungeonLv] = time;
|
|
dic_time[MyValue.MyChoiceMapData.n_DungeonLv].RandomizeCryptoKey();
|
|
}
|
|
public float Get_Time(int floor) { return dic_time.ContainsKey(floor) ? dic_time[floor] : 0f; }
|
|
|
|
private ObscuredInt _MaxDieMobCount;
|
|
public int m_MaxDieMobCount
|
|
{
|
|
get { return _MaxDieMobCount; }
|
|
set { _MaxDieMobCount = value; _MaxDieMobCount.RandomizeCryptoKey(); }
|
|
}
|
|
|
|
private ObscuredInt _DieCount;
|
|
public int m_DieCount
|
|
{
|
|
get { return _DieCount; }
|
|
set { _DieCount = value; _DieCount.RandomizeCryptoKey(); }
|
|
}
|
|
|
|
private ObscuredInt _MazeClear;
|
|
public int m_MazeClear
|
|
{
|
|
get { return _MazeClear; }
|
|
set { _MazeClear = value; _MazeClear.RandomizeCryptoKey(); }
|
|
}
|
|
|
|
protected ObscuredDouble _TotalDamage;
|
|
public double m_TotalDamage
|
|
{
|
|
get { return _TotalDamage; }
|
|
set { _TotalDamage = value; _TotalDamage.RandomizeCryptoKey(); }
|
|
}
|
|
|
|
protected ObscuredInt _WaveScore;
|
|
public int WaveScore
|
|
{
|
|
get { return _WaveScore; }
|
|
set { _WaveScore = value; _WaveScore.RandomizeCryptoKey(); }
|
|
}
|
|
|
|
protected ObscuredInt _WaveLife;
|
|
public int WaveLife
|
|
{
|
|
get { return _WaveLife; }
|
|
set { _WaveLife = value; _WaveLife.RandomizeCryptoKey(); }
|
|
}
|
|
|
|
protected ObscuredInt _WaveGold;
|
|
public int WaveGold
|
|
{
|
|
get { return _WaveGold; }
|
|
set { _WaveGold = value; _WaveGold.RandomizeCryptoKey(); }
|
|
}
|
|
|
|
public Dictionary<eMainStatType, ObscuredInt> dic_WaveStat = new Dictionary<eMainStatType, ObscuredInt>
|
|
{ { eMainStatType.STR, 0 }, { eMainStatType.DEX, 0 }, { eMainStatType.INT, 0 } };
|
|
|
|
eDungeon m_Dungeon;
|
|
bool bTotalTimeUpdate = false;
|
|
|
|
private void Update()
|
|
{
|
|
if (bTotalTimeUpdate)
|
|
m_TotalTime += Time.deltaTime;
|
|
}
|
|
|
|
public void Stop_Dungeon(bool? win)
|
|
{
|
|
act_Time = null;
|
|
StopAllCoroutines();
|
|
Time.timeScale = 0f;
|
|
WaveGold = 0;
|
|
dic_WaveStat[eMainStatType.STR] = 0; dic_WaveStat[eMainStatType.STR].RandomizeCryptoKey();
|
|
dic_WaveStat[eMainStatType.DEX] = 0; dic_WaveStat[eMainStatType.DEX].RandomizeCryptoKey();
|
|
dic_WaveStat[eMainStatType.INT] = 0; dic_WaveStat[eMainStatType.INT].RandomizeCryptoKey();
|
|
Ingame_DungeonResult.Ins.Show_Result(win);
|
|
}
|
|
IEnumerator Co_Update_Time()
|
|
{
|
|
while (dic_time[MyValue.MyChoiceMapData.n_DungeonLv] > 0f)
|
|
{
|
|
yield return null;
|
|
dic_time[MyValue.MyChoiceMapData.n_DungeonLv] -= Time.deltaTime;
|
|
dic_time[MyValue.MyChoiceMapData.n_DungeonLv].RandomizeCryptoKey();
|
|
act_Time?.Invoke(dic_time[MyValue.MyChoiceMapData.n_DungeonLv]);
|
|
}
|
|
|
|
// 시간 오버
|
|
Stop_Dungeon(false);
|
|
}
|
|
void Set_MobDie(int mobid)
|
|
{
|
|
++m_DieCount;
|
|
act_MobDieCount?.Invoke(m_DieCount);
|
|
if (m_DieCount == m_MaxDieMobCount)
|
|
{
|
|
bTotalTimeUpdate = false;
|
|
switch (m_Dungeon)
|
|
{
|
|
case eDungeon.d1_Mimic: Stop_Dungeon(true); break;
|
|
case eDungeon.d2_Maze:
|
|
StopAllCoroutines();
|
|
LoadMapMgr.Ins.Set_MazeNextPortal(MyValue.MyChoiceMapData.n_PortalIndex, true);
|
|
break;
|
|
case eDungeon.d3_Nightmare:
|
|
break;
|
|
case eDungeon.d4_Wave:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
void Make_Mob(eSubRol subrol, MonsterTableData mobData, DungeonMapConfigTableData dgData, Vector3 makepos,
|
|
float minDist, float MaxDist, Action<MobActor> act = null)
|
|
{
|
|
AddrResourceMgr.Ins.LoadObject<GameObject>(mobData.s_MonsterPrefab, handle =>
|
|
{
|
|
var mob = DSUtil.Get_Clone<MobActor>(handle.Result);
|
|
ActorInfo.Ins.Add_Actor(mob, eRole.Mob, dgData.n_SpawnID, mobData.s_MonsterPrefab);
|
|
mob.Set(true, null, null, dgData.n_SpawnID, false);
|
|
var rdnpos = DSUtil.Get_RandomPos_onNavMesh(makepos, minDist, MaxDist);
|
|
mob.Set(mobData, rdnpos, Set_MobDie, 0);
|
|
mob.m_SubRole = subrol;
|
|
act?.Invoke(mob);
|
|
});
|
|
}
|
|
|
|
public void Start_Dungeon(bool first)
|
|
{
|
|
m_DieCount = 0;
|
|
if (first)
|
|
{
|
|
m_TotalTime = 0f;
|
|
m_MazeClear = 0;
|
|
m_TotalDamage = 0f;
|
|
}
|
|
bTotalTimeUpdate = true;
|
|
|
|
m_Dungeon = MyValue.MyChoiceMapData.Get_MapData().e_Dungeon;
|
|
switch (m_Dungeon)
|
|
{
|
|
case eDungeon.d1_Mimic: StartCoroutine(Co_Update_Mimic()); break;
|
|
case eDungeon.d2_Maze: StartCoroutine(Co_Update_Maze()); break;
|
|
case eDungeon.d3_Nightmare: StartCoroutine(Co_Update_Nightmare()); break;
|
|
case eDungeon.d4_Wave: StartCoroutine(Co_Update_Wave()); break;
|
|
}
|
|
}
|
|
IEnumerator Co_Update_Mimic()
|
|
{
|
|
yield return new WaitForSeconds(1f);
|
|
StartCoroutine(Co_Update_Time());
|
|
|
|
float min = 3f, max = 10f;
|
|
var mapdata = MyValue.MyChoiceMapData.Get_MapData();
|
|
var dungeonData = MyValue.MyChoiceMapData.Get_DungeonMapData_orNull();
|
|
var mimicData = table_monsterlist.Ins.Get_Data_orNull(dungeonData.n_MobID);
|
|
var mobCount = dungeonData.n_MobCount;
|
|
while (mobCount > 0)
|
|
{
|
|
--mobCount;
|
|
Make_Mob(eSubRol.Mimic, mimicData, dungeonData, MyValue.MyPC.Get_position(), min, max);
|
|
yield return new WaitForSeconds(dungeonData.f_MakeGap);
|
|
}
|
|
}
|
|
|
|
IEnumerator Co_Update_Maze()
|
|
{
|
|
float min = 10f, max = 20f;
|
|
var dgData = MyValue.MyChoiceMapData.Get_DungeonMapData_orNull();
|
|
for (int i = 0; i < dgData.n_MobCount; i++)
|
|
Make_Mob(eSubRol.None, table_monsterlist.Ins.Get_RandomData(eSubRol.None), dgData, MyValue.MyPC.Get_position(), min, max);
|
|
|
|
if (m_MazeClear >= 5)
|
|
{
|
|
m_MazeClear = 0;
|
|
Make_Mob(eSubRol.Boss, table_monsterlist.Ins.Get_RandomData(eSubRol.Boss), dgData, MyValue.MyPC.Get_position(), min, max);
|
|
}
|
|
|
|
yield return new WaitForSeconds(1f);
|
|
StartCoroutine(Co_Update_Time());
|
|
}
|
|
public void ClearMazeFloor()
|
|
{
|
|
++m_MazeClear;
|
|
NewGameUI.Ins.Refresh_DungeonUI(m_MazeClear >= 5 ? 1 : 0);
|
|
Start_Dungeon(false);
|
|
}
|
|
|
|
IEnumerator Co_Update_Nightmare()
|
|
{
|
|
yield return new WaitForSeconds(1f);
|
|
StartCoroutine(Co_Update_Time());
|
|
|
|
|
|
var dgData = MyValue.MyChoiceMapData.Get_DungeonMapData_orNull();
|
|
for (int i = 0; i < dgData.n_MobCount; i++)
|
|
{
|
|
var boss = table_monsterlist.Ins.Get_RandomData(eSubRol.Boss);
|
|
Make_Mob(eSubRol.Boss, boss, dgData, MyValue.MyPC.Get_position(), 10, 25);
|
|
yield return new WaitForSeconds(30f);
|
|
}
|
|
}
|
|
public void Set_Nightmare(Action<double> actui)
|
|
{
|
|
act_DamageUI = actui;
|
|
Add_TotalDmg(-m_TotalDamage);
|
|
}
|
|
public void Add_TotalDmg(double dmg)
|
|
{
|
|
m_TotalDamage += dmg;
|
|
act_DamageUI?.Invoke(m_TotalDamage);
|
|
}
|
|
|
|
IEnumerator Co_Update_Wave()
|
|
{
|
|
yield return new WaitForSeconds(1f);
|
|
StartCoroutine(Co_Update_Time());
|
|
|
|
var mapdata = MyValue.MyChoiceMapData.Get_MapData();
|
|
var dungeonData = MyValue.MyChoiceMapData.Get_DungeonMapData_orNull();
|
|
float min = 0f, max = 15f;
|
|
int iteration = 0;
|
|
while (true)
|
|
{
|
|
WaveMakeGapTime = dungeonData.f_MakeGap;
|
|
var mobCount = dungeonData.n_MobCount;
|
|
while (mobCount > 0)
|
|
{
|
|
--mobCount;
|
|
var mobData = table_monsterlist.Ins.Get_RandomData(eSubRol.None);
|
|
Make_Mob(eSubRol.None, mobData, dungeonData, Vector3.zero, min, max,
|
|
mob => { mob.Set(iteration, true, 25f); });
|
|
yield return new WaitForSeconds(0.5f);
|
|
}
|
|
|
|
while (WaveMakeGapTime > 0f)
|
|
{
|
|
yield return null;
|
|
WaveMakeGapTime -= Time.deltaTime;
|
|
LoadMapMgr.Ins.Set_MazeNextPortal(MyValue.MyChoiceMapData.n_PortalIndex,
|
|
DSUtil.CheckNull(ActorInfo.Ins.Get_Nearest_EnemyActor_orNull(false, Vector3.zero, 1000f)));
|
|
}
|
|
|
|
LoadMapMgr.Ins.Set_MazeNextPortal(MyValue.MyChoiceMapData.n_PortalIndex, false);
|
|
++iteration;
|
|
}
|
|
}
|
|
public void Set_Wave(Action<int> actscoreui, Action<int> actlifeui, Action<int> actgoldui)
|
|
{
|
|
WaveScore = 0;
|
|
act_WaveScoreUI = actscoreui;
|
|
act_WaveScoreUI(WaveScore);
|
|
|
|
WaveLife = 3;
|
|
act_WaveLifeUI = actlifeui;
|
|
act_WaveLifeUI(WaveLife);
|
|
|
|
WaveGold = 0;
|
|
dic_WaveStat[eMainStatType.STR] = 0; dic_WaveStat[eMainStatType.STR].RandomizeCryptoKey();
|
|
dic_WaveStat[eMainStatType.DEX] = 0; dic_WaveStat[eMainStatType.DEX].RandomizeCryptoKey();
|
|
dic_WaveStat[eMainStatType.INT] = 0; dic_WaveStat[eMainStatType.INT].RandomizeCryptoKey();
|
|
act_WaveGold = actgoldui;
|
|
act_WaveGold(WaveGold);
|
|
}
|
|
public void Add_WaveScore(int score)
|
|
{
|
|
if (MyValue.MyChoiceMapData.Get_MapData().e_Dungeon == eDungeon.d4_Wave)
|
|
{
|
|
WaveScore += score;
|
|
act_WaveScoreUI(WaveScore);
|
|
}
|
|
}
|
|
public void Sub_WaveLife()
|
|
{
|
|
if (MyValue.MyChoiceMapData.Get_MapData().e_Dungeon == eDungeon.d4_Wave && WaveLife > 0)
|
|
{
|
|
--WaveLife;
|
|
act_WaveLifeUI(WaveLife);
|
|
|
|
if (WaveLife == 0)
|
|
Stop_Dungeon(false);
|
|
}
|
|
}
|
|
public void Add_WaveGold(int gold)
|
|
{
|
|
if (MyValue.MyChoiceMapData.Get_MapData().e_Dungeon == eDungeon.d4_Wave)
|
|
{
|
|
WaveGold += gold;
|
|
act_WaveGold(WaveGold);
|
|
}
|
|
}
|
|
} |