2025-09-14 04:12:35 +00:00
|
|
|
using GUPS.AntiCheat.Protected;
|
|
|
|
|
using System.Collections;
|
2025-09-14 05:09:31 +00:00
|
|
|
using System.Collections.Generic;
|
2025-09-14 18:34:04 +00:00
|
|
|
using System.Linq;
|
|
|
|
|
using TMPro;
|
2025-09-14 04:12:35 +00:00
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.ResourceManagement.AsyncOperations;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
public class Game_Mini : MonoBehaviour
|
|
|
|
|
{
|
2025-09-14 19:25:46 +00:00
|
|
|
public Game_Mini_Result m_Game_Mini_Result;
|
2025-09-14 18:34:04 +00:00
|
|
|
public TextMeshProUGUI[] texts_money; // 0 하트, 1 챗코인, 2 가챠 코인
|
2025-09-14 04:12:35 +00:00
|
|
|
public Image i_girl, i_girlsd;
|
|
|
|
|
public MiniGameItemCard[] items;
|
|
|
|
|
public Slider slider_hp;
|
2025-09-14 05:09:31 +00:00
|
|
|
public Transform tf_obtacleParent;
|
|
|
|
|
public GameObject go_Obtacle;
|
2025-09-14 07:05:38 +00:00
|
|
|
public GameObject[] gos_hiteffect;
|
|
|
|
|
public RectTransform tf_pc;
|
|
|
|
|
public Joystick m_Joystick;
|
2025-09-14 04:12:35 +00:00
|
|
|
|
|
|
|
|
// 1 평소, 2 맞았을 때
|
|
|
|
|
AsyncOperationHandle<Sprite> m_Handle1, m_Handle2, m_HandleSD;
|
|
|
|
|
ProtectedInt32 m_HP;
|
2025-09-14 07:24:49 +00:00
|
|
|
bool bStartGame;
|
|
|
|
|
float PcPosLimit;
|
2025-09-14 18:34:04 +00:00
|
|
|
Dictionary<eMiniGameObtacleType, ProtectedInt32> dic_Money = new Dictionary<eMiniGameObtacleType, ProtectedInt32>();
|
|
|
|
|
Dictionary<eMiniGameObtacleType, TextMeshProUGUI> dic_MoneyText = new Dictionary<eMiniGameObtacleType, TextMeshProUGUI>();
|
2025-09-14 04:12:35 +00:00
|
|
|
|
2025-09-14 05:09:31 +00:00
|
|
|
Dictionary<eMiniGameObtacleType, int> dic_weight = new Dictionary<eMiniGameObtacleType, int>();
|
|
|
|
|
List<MiniGameObtacle> list_MiniGameObtacle = new List<MiniGameObtacle>();
|
|
|
|
|
|
2025-09-14 07:24:49 +00:00
|
|
|
private void Awake()
|
|
|
|
|
{
|
|
|
|
|
PcPosLimit = (Screen.width >> 1) - 70f;
|
2025-09-14 18:34:04 +00:00
|
|
|
dic_MoneyText.Add(eMiniGameObtacleType.AlbumOpen, texts_money[0]);
|
|
|
|
|
dic_MoneyText.Add(eMiniGameObtacleType.ChatCoin, texts_money[1]);
|
|
|
|
|
dic_MoneyText.Add(eMiniGameObtacleType.GachaCoin, texts_money[2]);
|
2025-09-14 07:24:49 +00:00
|
|
|
}
|
|
|
|
|
|
2025-09-14 04:12:35 +00:00
|
|
|
public void Set()
|
|
|
|
|
{
|
2025-09-14 05:09:31 +00:00
|
|
|
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"));
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-14 04:12:35 +00:00
|
|
|
gameObject.SetActive(true);
|
2025-09-14 19:25:46 +00:00
|
|
|
m_Game_Mini_Result.gameObject.SetActive(false);
|
2025-09-14 07:05:38 +00:00
|
|
|
|
2025-09-14 18:39:05 +00:00
|
|
|
list_MiniGameObtacle.ForEach(f=>f.gameObject.SetActive(false));
|
|
|
|
|
|
2025-09-14 18:34:04 +00:00
|
|
|
for (int i = 0; i < dic_Money.Keys.ToList().Count; i++)
|
|
|
|
|
{
|
|
|
|
|
var key = dic_Money.Keys.ToList()[i];
|
|
|
|
|
dic_Money[key] = 0;
|
|
|
|
|
dic_Money[key].Obfuscate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < texts_money.Length; i++)
|
|
|
|
|
texts_money[i].text = "0";
|
|
|
|
|
|
2025-09-14 07:05:38 +00:00
|
|
|
tf_pc.anchoredPosition = new Vector2(0f, 325f);
|
|
|
|
|
|
|
|
|
|
DSUtil.InActivateGameObjects(gos_hiteffect);
|
2025-09-14 04:12:35 +00:00
|
|
|
for (int i = 0; i < items.Length; i++)
|
|
|
|
|
items[i].Set();
|
|
|
|
|
|
|
|
|
|
i_girl.enabled = false;
|
|
|
|
|
AddrResourceMgr.Ins.LoadObject<Sprite>($"Girl_Game/{SaveMgr.Ins.Get_SelectGirlID()}-1.png", handle =>
|
|
|
|
|
{
|
|
|
|
|
m_Handle1 = handle;
|
|
|
|
|
i_girl.enabled = true;
|
|
|
|
|
i_girl.sprite = handle.Result;
|
|
|
|
|
});
|
|
|
|
|
AddrResourceMgr.Ins.LoadObject<Sprite>($"Girl_Game/{SaveMgr.Ins.Get_SelectGirlID()}-2.png", handle =>
|
|
|
|
|
{
|
|
|
|
|
m_Handle2 = handle;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
i_girlsd.enabled = false;
|
|
|
|
|
AddrResourceMgr.Ins.LoadObject<Sprite>($"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();
|
2025-09-14 05:09:31 +00:00
|
|
|
|
|
|
|
|
StartCoroutine(Co_Update());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IEnumerator Co_Update()
|
|
|
|
|
{
|
2025-09-14 07:24:49 +00:00
|
|
|
bStartGame = false;
|
2025-09-14 05:09:31 +00:00
|
|
|
yield return new WaitForSeconds(3f);
|
2025-09-14 07:24:49 +00:00
|
|
|
bStartGame = true;
|
2025-09-14 05:09:31 +00:00
|
|
|
|
|
|
|
|
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<MiniGameObtacle>(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;
|
|
|
|
|
}
|
2025-09-14 04:12:35 +00:00
|
|
|
}
|
|
|
|
|
|
2025-09-14 07:24:49 +00:00
|
|
|
private void Update()
|
|
|
|
|
{
|
|
|
|
|
if (bStartGame)
|
|
|
|
|
{
|
|
|
|
|
if (m_HP <= 0) return;
|
|
|
|
|
|
|
|
|
|
var PcSpeed = table_GlobalValue.Ins.Get_Float("MiniGamePCSpeed");
|
|
|
|
|
if (m_Joystick.Direction.x < 0f)
|
|
|
|
|
{
|
|
|
|
|
tf_pc.anchoredPosition = new Vector2(tf_pc.anchoredPosition.x - Time.deltaTime * PcSpeed, tf_pc.anchoredPosition.y);
|
|
|
|
|
if (tf_pc.anchoredPosition.x < -PcPosLimit)
|
|
|
|
|
tf_pc.anchoredPosition = new Vector2(-PcPosLimit, tf_pc.anchoredPosition.y);
|
|
|
|
|
}
|
|
|
|
|
else if (m_Joystick.Direction.x > 0f)
|
|
|
|
|
{
|
|
|
|
|
tf_pc.anchoredPosition = new Vector2(tf_pc.anchoredPosition.x + Time.deltaTime * PcSpeed, tf_pc.anchoredPosition.y);
|
|
|
|
|
if (tf_pc.anchoredPosition.x > PcPosLimit)
|
|
|
|
|
tf_pc.anchoredPosition = new Vector2(PcPosLimit, tf_pc.anchoredPosition.y);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-14 05:09:31 +00:00
|
|
|
Coroutine cohit;
|
2025-09-14 18:34:04 +00:00
|
|
|
public void Hit(eMiniGameObtacleType type, int val)
|
2025-09-14 05:09:31 +00:00
|
|
|
{
|
|
|
|
|
if (cohit != null) StopCoroutine(cohit);
|
2025-09-14 18:39:05 +00:00
|
|
|
|
|
|
|
|
if (m_HP <= 0)
|
|
|
|
|
{
|
|
|
|
|
cohit = null;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-14 18:34:04 +00:00
|
|
|
cohit = StartCoroutine(Co_Hit(type, val));
|
2025-09-14 05:09:31 +00:00
|
|
|
}
|
2025-09-14 18:34:04 +00:00
|
|
|
IEnumerator Co_Hit(eMiniGameObtacleType type, int val)
|
2025-09-14 04:12:35 +00:00
|
|
|
{
|
2025-09-14 18:34:04 +00:00
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case eMiniGameObtacleType.White:
|
|
|
|
|
case eMiniGameObtacleType.Red:
|
|
|
|
|
m_HP -= val;
|
|
|
|
|
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;
|
|
|
|
|
break;
|
|
|
|
|
case eMiniGameObtacleType.HpHeal:
|
|
|
|
|
m_HP += val;
|
|
|
|
|
m_HP.Obfuscate();
|
|
|
|
|
slider_hp.value = m_HP / table_GlobalValue.Ins.Get_Float("MiniGameHP");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
if (!dic_Money.ContainsKey(type))
|
|
|
|
|
dic_Money.Add(type, 0);
|
|
|
|
|
dic_Money[type] += val;
|
|
|
|
|
dic_Money[type].Obfuscate();
|
|
|
|
|
if (dic_MoneyText.ContainsKey(type))
|
|
|
|
|
dic_MoneyText[type].text = dic_Money[type].ToString();
|
|
|
|
|
break;
|
|
|
|
|
}
|
2025-09-14 04:12:35 +00:00
|
|
|
|
|
|
|
|
yield return new WaitForSeconds(0.5f);
|
|
|
|
|
i_girl.sprite = m_Handle1.Result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GameOver()
|
|
|
|
|
{
|
2025-09-14 19:25:46 +00:00
|
|
|
m_Game_Mini_Result.Set();
|
2025-09-14 04:12:35 +00:00
|
|
|
}
|
2025-09-14 07:05:38 +00:00
|
|
|
|
2025-09-15 00:23:06 +00:00
|
|
|
public void Save_GameResult()
|
|
|
|
|
{
|
|
|
|
|
if (dic_Money.ContainsKey(eMiniGameObtacleType.AlbumOpen))
|
|
|
|
|
SaveMgr.Ins.Add_Money(eMoney.AlbumOpen, dic_Money[eMiniGameObtacleType.AlbumOpen]);
|
|
|
|
|
if (dic_Money.ContainsKey(eMiniGameObtacleType.ChatCoin))
|
|
|
|
|
SaveMgr.Ins.Add_Money(eMoney.Chat, dic_Money[eMiniGameObtacleType.ChatCoin]);
|
|
|
|
|
if (dic_Money.ContainsKey(eMiniGameObtacleType.GachaCoin))
|
|
|
|
|
SaveMgr.Ins.Add_Money(eMoney.Gacha, dic_Money[eMiniGameObtacleType.GachaCoin]);
|
|
|
|
|
SaveMgr.Ins.Save();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Dictionary<eMiniGameObtacleType, ProtectedInt32> Get_ResultMoney() { return dic_Money; }
|
|
|
|
|
|
2025-09-14 07:05:38 +00:00
|
|
|
public void Show_HitEffect(Vector3 pos)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < gos_hiteffect.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
if (!gos_hiteffect[i].activeInHierarchy)
|
|
|
|
|
{
|
|
|
|
|
StartCoroutine(Co_HitEffect(gos_hiteffect[i], pos));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IEnumerator Co_HitEffect(GameObject effect, Vector3 pos)
|
|
|
|
|
{
|
|
|
|
|
effect.SetActive(true);
|
|
|
|
|
effect.GetComponent<RectTransform>().position = pos;
|
|
|
|
|
yield return new WaitForSeconds(1.5f);
|
|
|
|
|
effect.SetActive(false);
|
|
|
|
|
}
|
2025-09-14 04:12:35 +00:00
|
|
|
}
|