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; public Material mat_Dissolve; List list_HUDDMGUI = new List(); List list_HUDUI = new List(); HUDLvUp m_HUDLvUp; Dictionary> dic_str_Effect = new Dictionary>(); Dictionary> dic_Skill = new Dictionary>(); Dictionary dic_Obj = new Dictionary(); eGameMode m_GameMode; List list_dropitems = new List(); List list_projectileData = new List(); private void Awake() { Ins = this; } void Set_Init() { for (eEffect i = 0; i < eEffect.Max; i++) dic_Skill.Add(i, new List()); for (int i = 0; i < 14; i++) list_quickamount.Add(0); for (eObj i = 0; i < eObj.Max; i++) dic_Obj.Add(i, null); AddrResourceMgr.Ins.LoadObject("Assets/Res_Addr/Obj/MobMark.prefab", handle => { if (handle.IsDone && handle.Status == AsyncOperationStatus.Succeeded) { var mm = DSUtil.Get_Clone(handle.Result, tf_Objs); AddrResourceMgr.Ins.Set_AddressableReleaseSelf(mm); dic_Obj[eObj.MobMark] = 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("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()); 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("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(handle.Result, NewGameUI.Ins.tf_HUD)); list_HUDDMGUI.ForEach(f => f.Off(true)); } }); AddrResourceMgr.Ins.LoadObject("Assets/Res_Addr/Ingame/HUDUI.prefab", handle => { for (int i = 0; i < 100; i++) list_HUDUI.Add(DSUtil.Get_Clone(handle.Result, NewGameUI.Ins.tf_HUD)); list_HUDUI.ForEach(f => f.Off(true)); }); //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; } public void AllEffectOff() { foreach (var item in dic_str_Effect) for (int i = 0; i < item.Value.Count; i++) item.Value[i].SetActive(false); foreach (var item in dic_Obj) item.Value.SetActive(false); list_HUDDMGUI.ForEach(f => f.Off(true)); list_HUDUI.ForEach(f => f.Off(true)); } 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; } /// /// -1 로비, 0 농장, 1 스테이지, 2 던전 /// /// public void Load_Map(int id) { LoadingUI.Ins.Start_Loading(); AllEffectOff(); if (ProjectileInfo.isIns) ProjectileInfo.Ins.AllOff(); if (DropItemInfo.isIns) DropItemInfo.Ins.AllOff(); MyValue.MyChoiceMapData.n_MapID = id; var Tdata = table_battlemapconfig.Ins.Get_Data(MyValue.MyChoiceMapData.n_MapID); m_GameMode = Tdata.e_MapType; ServerInfo.Ins.m_ServerData.Add_MissionCount(ePurpose.ARRIVAL_MAP_LIMIT, id); m_SceneInfo.Load_AddScene(Tdata, () => { StartCam(); NewGameUI.Ins.SetUI_byGameMode(m_GameMode); }); } public void StartCam() { StartCoroutine(Co_StartCam()); } IEnumerator Co_StartCam() { while (!MyValue.bMyPC) yield return null; MyValue.MyPC.StartCam(null); } #region HUD public HUDUI Get_HUDUI() { HUDUI temp = null; for (int i = 0; i < list_HUDUI.Count; i++) { if (list_HUDUI[i].Get_Check()) { temp = list_HUDUI[i]; break; } } if (DSUtil.CheckNull(temp) && list_HUDUI.Count > 0) { temp = DSUtil.Get_Clone(list_HUDUI[0].gameObject, NewGameUI.Ins.tf_HUD); list_HUDUI.Add(temp); } return temp; } 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) && list_HUDDMGUI.Count > 0) { temp = DSUtil.Get_Clone(list_HUDDMGUI[0].gameObject, NewGameUI.Ins.tf_HUD); list_HUDDMGUI.Add(temp); } return temp; } public HUDLvUp Get_HUDLvUp() { if (m_HUDLvUp == null) m_HUDLvUp = DSUtil.Get_Clone("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, Action cceffect = 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 => { var effect = temp.GetComponent(); effect.Set(target, pd, lifeTime); effect.Set_EffectwhenOff(stcData.s_SkillEffectWhenOff); temp.transform.localScale = stcData.v3_Scale; var chekers = temp.GetComponentsInChildren(true); for (int i = 0; i < chekers.Length; i++) chekers[i].Set(pd.m_ProjectileBase); cceffect?.Invoke(effect); }); } } } 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: case eSkillTarget.SelfEnemy: _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: if (_ptd.shooter.IsRole(eRole.Pet)) _ptd.target = _ptd.shooter.Get_Owner(); else _ptd.target = _ptd.shooter.Get_MyPet(); 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().Set(_ptd); return; } } Load_Skill(effect, _ptd, firstload); } void Load_Skill(eEffect effect, ProjectileData _ptd, bool firstload = false) { AddrResourceMgr.Ins.LoadObject(Get_SkillPrefabPath(effect), handle => { var temp = DSUtil.Get_Clone(handle.Result, tf_Effects); dic_Skill[effect].Add(temp); if (!firstload) temp.GetComponent().Set(_ptd); }); } void Load_Effect(string prefab, Action act) { AddrResourceMgr.Ins.LoadObject(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 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()); Load_Effect(prefab, act); } public void Show_Effect(string prefab, Actor target) { Get_Effect(prefab, temp => { var turnoff = temp.GetComponent(); turnoff.Set_PrefabInfo(target); }); } public void Show_Effect(string prefab, Vector3 pos, Vector3? _eulerAngles = null, string showEffectwhenOff = "") { Get_Effect(prefab, temp => { temp.transform.position = pos; if (_eulerAngles.HasValue) temp.transform.eulerAngles = _eulerAngles.Value; temp.SetActive(true); temp.GetComponent().Set_EffectwhenOff(showEffectwhenOff); }); } public void Show_Effect(string prefab, Actor actor, eEffectLocation loca, float lifetime, Action actEffect = null) { Get_Effect(prefab, temp => { var turnoff = temp.GetComponent(); turnoff.Set(actor, loca, lifetime); actEffect?.Invoke(turnoff); }); } public GameObject Get_Obj(eObj obj) { return dic_Obj[obj]; } 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); } #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; }, 0.5f); } public void Return_To_Lobby() { Time.timeScale = 1f; // 일시정지에서 돌아오면 0임 m_GameMode = eGameMode.Lobby; Init_IngameData(); NewGameUI.Ins.SetUI_byGameMode(m_GameMode); MyValue.MyChoiceMapData.n_PortalIndex = 0; Load_Map(-1); } public void Return_To_ChapterLobby() { Return_To_Lobby(); } #endregion }