using GUPS.AntiCheat.Protected; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.UI; public class Game_Mini : MonoBehaviour { public Image i_girl, i_girlsd; public MiniGameItemCard[] items; public Slider slider_hp; public Transform tf_obtacleParent; public GameObject go_Obtacle; // 1 평소, 2 맞았을 때 AsyncOperationHandle m_Handle1, m_Handle2, m_HandleSD; ProtectedInt32 m_HP; Dictionary dic_weight = new Dictionary(); List list_MiniGameObtacle = new List(); public void Set() { if (dic_weight.Count == 0) { dic_weight.Add(eMiniGameObtacleType.White, table_GlobalValue.Ins.Get_Int("MiniGameWeight_White")); dic_weight.Add(eMiniGameObtacleType.Red, table_GlobalValue.Ins.Get_Int("MiniGameWeight_Red")); dic_weight.Add(eMiniGameObtacleType.AlbumOpen, table_GlobalValue.Ins.Get_Int("MiniGameWeight_AlbumOpen")); dic_weight.Add(eMiniGameObtacleType.ChatCoin, table_GlobalValue.Ins.Get_Int("MiniGameWeight_ChatCoin")); dic_weight.Add(eMiniGameObtacleType.GachaCoin, table_GlobalValue.Ins.Get_Int("MiniGameWeight_GachaCoin")); dic_weight.Add(eMiniGameObtacleType.HpHeal, table_GlobalValue.Ins.Get_Int("MiniGameWeight_HpHeal")); } gameObject.SetActive(true); for (int i = 0; i < items.Length; i++) items[i].Set(); i_girl.enabled = false; AddrResourceMgr.Ins.LoadObject($"Girl_Game/{SaveMgr.Ins.Get_SelectGirlID()}-1.png", handle => { m_Handle1 = handle; i_girl.enabled = true; i_girl.sprite = handle.Result; }); AddrResourceMgr.Ins.LoadObject($"Girl_Game/{SaveMgr.Ins.Get_SelectGirlID()}-2.png", handle => { m_Handle2 = handle; }); i_girlsd.enabled = false; AddrResourceMgr.Ins.LoadObject($"Girl_Game/{SaveMgr.Ins.Get_SelectGirlID()}sd.png", handle => { m_HandleSD = handle; i_girlsd.enabled = true; i_girlsd.sprite = handle.Result; }); slider_hp.value = 1f; m_HP = table_GlobalValue.Ins.Get_Int("MiniGameHP"); m_HP.Obfuscate(); StartCoroutine(Co_Update()); } IEnumerator Co_Update() { yield return new WaitForSeconds(3f); float gap = 0.5f; list_MiniGameObtacle.ForEach(f => f.gameObject.SetActive(false)); while (true) { if (m_HP <= 0) break; var obtacle = list_MiniGameObtacle.Find(f => !f.gameObject.activeInHierarchy); if (obtacle == null) { obtacle = DSUtil.Get_Clone(go_Obtacle, tf_obtacleParent); list_MiniGameObtacle.Add(obtacle); } obtacle.Set(dic_weight); yield return new WaitForSeconds(gap); gap -= Time.deltaTime; if (gap < 0.1f) gap = 0.1f; } } Coroutine cohit; public void Hit() { if (cohit != null) StopCoroutine(cohit); cohit = StartCoroutine(Co_Hit()); } IEnumerator Co_Hit() { --m_HP; m_HP.Obfuscate(); slider_hp.value = m_HP / table_GlobalValue.Ins.Get_Float("MiniGameHP"); if (m_HP <= 0) GameOver(); i_girl.sprite = m_Handle2.Result; yield return new WaitForSeconds(0.5f); i_girl.sprite = m_Handle1.Result; } void GameOver() { } }