454 lines
15 KiB
C#
454 lines
15 KiB
C#
using CodeStage.AntiCheat.Detectors;
|
|
using CodeStage.AntiCheat.Storage;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.ResourceManagement.AsyncOperations;
|
|
|
|
public partial class InGameInfo : MyCoroutine
|
|
{
|
|
public static InGameInfo Ins;
|
|
public SceneInfo m_SceneInfo;
|
|
public Transform tf_Effects, tf_Objs;
|
|
|
|
List<HUDDMGUI> list_HUDDMGUI = new List<HUDDMGUI>();
|
|
HUDLvUp m_HUDLvUp;
|
|
|
|
Dictionary<string, List<GameObject>> dic_str_Effect = new Dictionary<string, List<GameObject>>();
|
|
|
|
Dictionary<eEffect, List<GameObject>> dic_Skill = new Dictionary<eEffect, List<GameObject>>();
|
|
Dictionary<eObj, List<GameObject>> dic_Obj = new Dictionary<eObj, List<GameObject>>();
|
|
eGameMode m_GameMode;
|
|
public float m_Time { get; private set; }
|
|
List<GameObject> list_dropitems = new List<GameObject>();
|
|
List<ProjectileData> list_projectileData = new List<ProjectileData>();
|
|
|
|
private void Awake() { Ins = this; }
|
|
|
|
void Set_Init()
|
|
{
|
|
for (eEffect i = 0; i < eEffect.Max; i++)
|
|
dic_Skill.Add(i, new List<GameObject>());
|
|
|
|
for (int i = 0; i < 14; i++)
|
|
list_quickamount.Add(0);
|
|
|
|
for (eObj i = 0; i < eObj.Max; i++)
|
|
dic_Obj.Add(i, new List<GameObject>());
|
|
|
|
AddrResourceMgr.Ins.LoadObject<GameObject>("Assets/Res_Addr/Obj/MobMark.prefab", handle =>
|
|
{
|
|
if (handle.IsDone && handle.Status == AsyncOperationStatus.Succeeded)
|
|
{
|
|
for (int i = 0; i < 4; i++)
|
|
{
|
|
var mm = DSUtil.Get_Clone(handle.Result, tf_Objs);
|
|
AddrResourceMgr.Ins.Set_AddressableReleaseSelf(mm);
|
|
dic_Obj[eObj.MobMark].Add(mm);
|
|
mm.SetActive(false);
|
|
}
|
|
}
|
|
});
|
|
|
|
for (int i = 0; i < 200; i++) // 너무 많나?
|
|
list_projectileData.Add(new ProjectileData());
|
|
|
|
#if UNITY_EDITOR
|
|
if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name == "StatTest")
|
|
return;
|
|
#endif
|
|
|
|
AddrResourceMgr.Ins.LoadObject<GameObject>("Assets/Res_Addr/MainUI/NewGameUI.prefab", handle =>
|
|
{
|
|
if (handle.IsDone && handle.Status == AsyncOperationStatus.Succeeded)
|
|
{
|
|
DSUtil.Get_Clone(handle.Result);
|
|
InappInfo.Ins.Check_Retrieved();
|
|
}
|
|
});
|
|
}
|
|
|
|
IEnumerator Start()
|
|
{
|
|
Set_Init();
|
|
|
|
while (!TableChecker.Ins.CheckAllLoad()) yield return new WaitForSeconds(0.1f);
|
|
|
|
var lst = table_effectlist.Ins.Get_DataList(1);
|
|
for (int i = 0; i < lst.Count; i++)
|
|
{
|
|
dic_str_Effect.Add(lst[i].s_EffectPrefab, new List<GameObject>());
|
|
for (int j = 0; j < lst[i].n_PreLoadCount; j++)
|
|
Load_Effect(lst[i].s_EffectPrefab, effect => { effect.transform.position = Vector3.one * 100000f; });
|
|
}
|
|
|
|
var skilllst = table_skilllist.Ins.Get_DataList();
|
|
for (int i = 0; i < skilllst.Count; i++)
|
|
{
|
|
if (skilllst[i].e_SkillType == eSkillType.Active && skilllst[i].e_Skill != eEffect.None)
|
|
{
|
|
for (int j = 0; j < 2; j++)
|
|
Load_Skill(skilllst[i].e_Skill, list_projectileData[0], true);
|
|
}
|
|
}
|
|
|
|
#if UNITY_EDITOR
|
|
if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name == "StatTest") yield break;
|
|
#endif
|
|
|
|
ObscuredCheatingDetector.StartDetection(OnCheaterDetected);
|
|
ObscuredPrefs.OnAlterationDetected += OnCheaterDetected;
|
|
SpeedHackDetector.StartDetection(OnCheaterDetected);
|
|
|
|
while (DSUtil.CheckNull(NewGameUI.Ins)) yield return null;
|
|
|
|
AddrResourceMgr.Ins.LoadObject<GameObject>("Assets/Res_Addr/Ingame/HUDDMGUI.prefab", handle =>
|
|
{
|
|
if (handle.IsDone && handle.Status == AsyncOperationStatus.Succeeded)
|
|
{
|
|
for (int i = 0; i < 150; i++)
|
|
list_HUDDMGUI.Add(DSUtil.Get_Clone<HUDDMGUI>(handle.Result, NewGameUI.Ins.tf_HUD));
|
|
list_HUDDMGUI.ForEach(f => f.Off());
|
|
}
|
|
});
|
|
|
|
//var sinfo = ServerInfo.Ins;
|
|
|
|
//Init_StageInfo(eGameMode.Stage, sinfo.m_ServerData.Get_Common(eCommon.TotalStage));
|
|
|
|
//Set_Coroutine(() =>
|
|
//{
|
|
// if (sinfo.IsNewUser())
|
|
// {
|
|
// var pc = MyValue.MyPC;
|
|
// pc.Stop_PC();
|
|
// StoryUI.Ins.Set(() => { pc.FindNextTarget(); DataCheckMgr.Ins.Set(); });
|
|
// }
|
|
// else
|
|
// {
|
|
// sinfo.Check_OfflineReward();
|
|
// DataCheckMgr.Ins.Set();
|
|
// }
|
|
//}, Time.deltaTime);
|
|
|
|
//BossGemCoolTime = sinfo.m_ServerData.Get_Common(eCommon.BossGemCoolTime);
|
|
//DropEventCoolTime = 60f;
|
|
}
|
|
|
|
void OnCheaterDetected()
|
|
{
|
|
Time.timeScale = 0f;
|
|
Popup.Ins.Set(ePopupType.One, -99, DSUtil.Quit, DSUtil.Quit);
|
|
}
|
|
|
|
public eGameMode Get_GameMode() { return m_GameMode; }
|
|
public bool IsGameMode(eGameMode _mode) { return m_GameMode == _mode; }
|
|
|
|
/// <summary>
|
|
/// 1 로비, 2 농장, 3 스테이지
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
public void Load_Map(int id)
|
|
{
|
|
MyValue.MyChoiceMapData.n_MapID = id;
|
|
var Tdata = table_battlemapconfig.Ins.Get_Data(MyValue.MyChoiceMapData.n_MapID);
|
|
m_GameMode = Tdata.e_MapType;
|
|
m_SceneInfo.Load_AddScene(Tdata, ()=>
|
|
{
|
|
StartCam();
|
|
NewGameUI.Ins.SetUI_byGameMode(m_GameMode);
|
|
m_Time = 0f;
|
|
});
|
|
}
|
|
public void StartCam() { StartCoroutine(Co_StartCam()); }
|
|
IEnumerator Co_StartCam()
|
|
{
|
|
while (DSUtil.CheckNull(MyValue.MyPC)) yield return null;
|
|
MyValue.MyPC.StartCam();
|
|
}
|
|
|
|
#region HUD
|
|
public void Get_HUDUI(Action<HUDUI> act)
|
|
{
|
|
AddrResourceMgr.Ins.LoadObject<GameObject>("Assets/Res_Addr/Ingame/HUDUI.prefab", handle =>
|
|
{
|
|
var hud = DSUtil.Get_Clone<HUDUI>(handle.Result, NewGameUI.Ins.tf_HUD);
|
|
AddrResourceMgr.Ins.Set_AddressableReleaseSelf(hud.gameObject);
|
|
act(hud);
|
|
});
|
|
}
|
|
|
|
public HUDDMGUI Get_HUDDMGUI()
|
|
{
|
|
HUDDMGUI temp = null;
|
|
for (int i = 0; i < list_HUDDMGUI.Count; i++)
|
|
{
|
|
if (!list_HUDDMGUI[i].gameObject.activeInHierarchy)
|
|
{
|
|
temp = list_HUDDMGUI[i];
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (DSUtil.CheckNull(temp))
|
|
{
|
|
temp = DSUtil.Get_Clone<HUDDMGUI>("InGame/HUDDMGUI", NewGameUI.Ins.tf_HUD);
|
|
list_HUDDMGUI.Add(temp);
|
|
}
|
|
|
|
return temp;
|
|
}
|
|
public HUDLvUp Get_HUDLvUp()
|
|
{
|
|
if (m_HUDLvUp == null) m_HUDLvUp = DSUtil.Get_Clone<HUDLvUp>("InGame/HUDLvUp", NewGameUI.Ins.tf_HUD);
|
|
return m_HUDLvUp;
|
|
}
|
|
#endregion
|
|
|
|
public void AllEffect_Off()
|
|
{
|
|
foreach (var item in dic_Skill)
|
|
{
|
|
for (int i = 0; i < item.Value.Count; i++)
|
|
item.Value[i].gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
public void Show_SkillTypeEffect(ProjectileData pd, Actor target, float lifeTime, CCData ccdata = null)
|
|
{
|
|
var stcData = pd.m_skillTypeConfigTable;
|
|
if (!DSUtil.CheckNull(stcData) && !stcData.e_SkillEffect.Equals("None"))
|
|
{
|
|
if (!DSUtil.CheckNull(target))
|
|
{
|
|
Get_Effect(stcData.e_SkillEffect, temp =>
|
|
{
|
|
temp.GetComponent<TurnOff_GO>().Set(target, pd, lifeTime);
|
|
temp.transform.localScale = Vector3.one * stcData.n_EffectScale;
|
|
|
|
if (!DSUtil.CheckNull(ccdata))
|
|
ccdata.EffectObj = temp;
|
|
|
|
var chekers = temp.GetComponentsInChildren<ProjectileHitChecker>(true);
|
|
for (int i = 0; i < chekers.Length; i++)
|
|
chekers[i].Set(pd.m_ProjectileBase);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
public void Shoot_Effect(ProjectileData _ptd)
|
|
{
|
|
var isskill = _ptd.IsSkill();
|
|
eEffect effect;
|
|
if (isskill)
|
|
{
|
|
effect = _ptd.m_SkillListTableData.e_Skill;
|
|
switch (_ptd.m_SkillListTableData.e_SkillTarget)
|
|
{
|
|
case eSkillTarget.Self:
|
|
_ptd.target = _ptd.shooter;
|
|
break;
|
|
case eSkillTarget.Team:
|
|
_ptd.target = _ptd.shooter;
|
|
var myteam = ActorInfo.Ins.Get_AlliesActors(_ptd.shooter.IsEnemy(), _ptd.shooter.Get_position(),
|
|
table_GlobalValue.Ins.Get_Float("f_SkillTeamRange"));
|
|
for (int i = 0; i < myteam.Count; i++)
|
|
{
|
|
_ptd.Copy(list_projectileData[i]);
|
|
list_projectileData[i].target = myteam[i];
|
|
Shoot_Skill(effect, list_projectileData[i]);
|
|
}
|
|
return;
|
|
case eSkillTarget.Pet:
|
|
_ptd.target = _ptd.shooter.Get_MyPet();
|
|
//if (DSUtil.CheckNull(_ptd.target)) return; // 펫이 없으면 발동x
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
effect = _ptd.m_Skill;
|
|
|
|
Shoot_Skill(effect, _ptd);
|
|
}
|
|
void Shoot_Skill(eEffect effect, ProjectileData _ptd, bool firstload = false)
|
|
{
|
|
for (int i = 0; i < dic_Skill[effect].Count; i++)
|
|
{
|
|
if (!dic_Skill[effect][i].activeInHierarchy)
|
|
{
|
|
dic_Skill[effect][i].GetComponent<ProjectileBase>().Set(_ptd);
|
|
return;
|
|
}
|
|
}
|
|
|
|
Load_Skill(effect, _ptd, firstload);
|
|
}
|
|
void Load_Skill(eEffect effect, ProjectileData _ptd, bool firstload = false)
|
|
{
|
|
AddrResourceMgr.Ins.LoadObject<GameObject>(Get_SkillPrefabPath(effect), handle =>
|
|
{
|
|
var temp = DSUtil.Get_Clone(handle.Result, tf_Effects);
|
|
dic_Skill[effect].Add(temp);
|
|
if (!firstload) temp.GetComponent<ProjectileBase>().Set(_ptd);
|
|
});
|
|
}
|
|
|
|
void Load_Effect(string prefab, Action<GameObject> act)
|
|
{
|
|
AddrResourceMgr.Ins.LoadObject<GameObject>(DSUtil.Format("Assets/Res_Addr/Effect/{0}.prefab", prefab), handle =>
|
|
{
|
|
if (handle.IsDone && handle.Status == AsyncOperationStatus.Succeeded)
|
|
{
|
|
var temp = DSUtil.Get_Clone(handle.Result, tf_Effects);
|
|
dic_str_Effect[prefab].Add(temp);
|
|
act?.Invoke(temp);
|
|
}
|
|
});
|
|
}
|
|
void Get_Effect(string prefab, Action<GameObject> act)
|
|
{
|
|
if (dic_str_Effect.ContainsKey(prefab))
|
|
{
|
|
for (int i = 0; i < dic_str_Effect[prefab].Count; i++)
|
|
if (!dic_str_Effect[prefab][i].activeInHierarchy)
|
|
{
|
|
act(dic_str_Effect[prefab][i]);
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
dic_str_Effect.Add(prefab, new List<GameObject>());
|
|
|
|
Load_Effect(prefab, act);
|
|
}
|
|
public void Show_Effect(string prefab, Actor target)
|
|
{
|
|
Get_Effect(prefab, temp =>
|
|
{
|
|
var turnoff = temp.GetComponent<TurnOff_GO>();
|
|
turnoff.Set_PrefabInfo(target);
|
|
});
|
|
}
|
|
public void Show_Effect(string prefab, Vector3 pos, Vector3? _eulerAngles = null)
|
|
{
|
|
Get_Effect(prefab, temp =>
|
|
{
|
|
temp.transform.position = pos;
|
|
if (!DSUtil.CheckNull(_eulerAngles))
|
|
temp.transform.eulerAngles = _eulerAngles.Value;
|
|
temp.SetActive(true);
|
|
});
|
|
}
|
|
public void Show_Effect(string prefab, Actor actor, eEffectLocation loca, float lifetime)
|
|
{
|
|
Get_Effect(prefab, temp =>
|
|
{
|
|
var turnoff = temp.GetComponent<TurnOff_GO>();
|
|
if (!DSUtil.CheckNull(turnoff)) turnoff.Set(actor, loca, lifetime);
|
|
});
|
|
}
|
|
|
|
public GameObject Get_Obj(eObj obj)
|
|
{
|
|
GameObject temp = null;
|
|
for (int i = 0; i < dic_Obj[obj].Count; i++)
|
|
{
|
|
if (!dic_Obj[obj][i].activeInHierarchy)
|
|
{
|
|
temp = dic_Obj[obj][i];
|
|
break;
|
|
}
|
|
}
|
|
|
|
return temp;
|
|
}
|
|
|
|
string Get_SkillPrefabPath(eEffect effect)
|
|
{
|
|
if (effect.ToString().Contains("Select"))
|
|
return DSUtil.Format("Assets/Res_Addr/SelectSkill/{0}.prefab", effect);
|
|
else if (effect.ToString().Contains("Skill"))
|
|
return DSUtil.Format("Assets/Res_Addr/Skill/{0}.prefab", effect);
|
|
else
|
|
return DSUtil.Format("Assets/Res_Addr/Effect/{0}.prefab", effect);
|
|
}
|
|
|
|
public void Set_TimeScale(float _scale, float _delay) { Set_Coroutine(() => { Time.timeScale = _scale; }, _delay); }
|
|
|
|
public List<GameObject> Get_DropItems()
|
|
{
|
|
list_dropitems.Clear();
|
|
foreach (var item in dic_Skill)
|
|
{
|
|
if (DSUtil.IsDropItem(item.Key))
|
|
{
|
|
for (int i = 0; i < item.Value.Count; i++)
|
|
{
|
|
if (item.Value[i].activeInHierarchy && item.Value[i].GetComponent<DropItem>().Get_IsReady())
|
|
list_dropitems.Add(item.Value[i]);
|
|
}
|
|
}
|
|
}
|
|
return list_dropitems;
|
|
}
|
|
public GameObject Get_NearstDropItem(Vector3 _pos)
|
|
{
|
|
var items = Get_DropItems();
|
|
if (items.Count > 0)
|
|
{
|
|
GameObject temp = items[0];
|
|
for (int i = 1; i < items.Count; i++)
|
|
{
|
|
float dist_a = Vector3.Distance(_pos, temp.transform.position);
|
|
float dist_b = Vector3.Distance(_pos, items[i].transform.position);
|
|
if (dist_b < dist_a)
|
|
temp = items[i];
|
|
}
|
|
|
|
return temp;
|
|
}
|
|
return null;
|
|
}
|
|
#region 인게임 제어 (게임 시작, 게임 재시작, 보스 만남, 보스 킬, 보스에게 짐, 컨텐츠 종료 조건)
|
|
public void Clear_Chapter()
|
|
{
|
|
GameUI.Ins.IngameUI.m_StageResult.Set(true, false, Return_To_Lobby);
|
|
}
|
|
public void Boss_Meet()
|
|
{
|
|
}
|
|
public void Kill_Boss()
|
|
{
|
|
}
|
|
public void Defeat_byMonster()
|
|
{
|
|
// 죽으면 부활의 성소로 가므로 필요없음
|
|
//if (m_CurStageData.Chapter == 104)
|
|
// GameUI.Ins.IngameUI.m_MemoryWitchResult.Set();
|
|
//else
|
|
// GameUI.Ins.IngameUI.m_StageResult.Set(false, false, Return_To_Lobby);
|
|
}
|
|
public void PetBattleResult(bool _win)
|
|
{
|
|
Time.timeScale = 0.3f;
|
|
Set_Coroutine(() =>
|
|
{
|
|
Time.timeScale = 1f;
|
|
GameUI.Ins.IngameUI.m_PetBattleResult.Set(_win, Return_To_Lobby);
|
|
}, 0.5f);
|
|
}
|
|
public void Return_To_Lobby()
|
|
{
|
|
Time.timeScale = 1f; // 일시정지에서 돌아오면 0임
|
|
m_GameMode = eGameMode.Lobby;
|
|
Init_IngameData();
|
|
NewGameUI.Ins.SetUI_byGameMode(m_GameMode);
|
|
Load_Map(1);
|
|
}
|
|
public void Return_To_ChapterLobby()
|
|
{
|
|
Return_To_Lobby();
|
|
}
|
|
#endregion
|
|
} |