2025-09-19 05:15:39 +00:00
|
|
|
using System.Collections;
|
2025-09-12 05:23:34 +00:00
|
|
|
using System.Collections.Generic;
|
2025-09-12 05:45:25 +00:00
|
|
|
using TMPro;
|
2025-09-12 04:10:11 +00:00
|
|
|
using UnityEngine;
|
2025-09-12 05:23:34 +00:00
|
|
|
using UnityEngine.UI;
|
2025-09-12 04:10:11 +00:00
|
|
|
|
2025-09-12 05:23:34 +00:00
|
|
|
public class GachaUI : uScrollViewMgr
|
2025-09-12 04:10:11 +00:00
|
|
|
{
|
2025-09-12 05:23:34 +00:00
|
|
|
public GameObject[] gos_grade;
|
2025-09-12 05:45:25 +00:00
|
|
|
public Slider slider_lucky, slider_lucky2;
|
2025-09-18 05:28:09 +00:00
|
|
|
public TextMeshProUGUI[] texts_money; // 0 앨범 오픈 재화, 1 챗 코인, 2 가챠 코인
|
2025-09-12 05:45:25 +00:00
|
|
|
public TextMeshProUGUI[] texts; // 0 럭키 %
|
2025-09-13 02:54:32 +00:00
|
|
|
public GameObject go_CanEnterLuckyGame;
|
2025-09-12 05:23:34 +00:00
|
|
|
|
|
|
|
|
List<(eMoney, int)> list_log = new List<(eMoney, int)>();
|
|
|
|
|
|
2025-09-12 04:10:11 +00:00
|
|
|
public void Set()
|
|
|
|
|
{
|
|
|
|
|
gameObject.SetActive(true);
|
2025-09-19 19:31:06 +00:00
|
|
|
SoundInfo.Ins.Play_BGM(eBGM.b005_Gacha);
|
2025-09-12 05:23:34 +00:00
|
|
|
DSUtil.InActivateGameObjects(gos_grade);
|
2025-09-19 05:15:39 +00:00
|
|
|
Set_UI(false);
|
2025-09-12 05:39:25 +00:00
|
|
|
}
|
|
|
|
|
|
2025-09-19 05:15:39 +00:00
|
|
|
void Set_UI(bool updateSlider)
|
2025-09-12 05:39:25 +00:00
|
|
|
{
|
2025-09-19 05:15:39 +00:00
|
|
|
if (updateSlider)
|
|
|
|
|
{
|
|
|
|
|
StartCoroutine(Co_UpdateSlider());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var cal = SaveMgr.Ins.Get_Money(eMoney.Lucky) / table_GlobalValue.Ins.Get_Float("LuckyPoint");
|
|
|
|
|
slider_lucky.value = DSUtil.Get_SliderValue(cal);
|
|
|
|
|
slider_lucky2.value = DSUtil.Get_SliderValue(cal - 1f);
|
|
|
|
|
texts[0].text = MyText.Get_PercentValueText_100(cal > 2f ? 2f : cal);
|
|
|
|
|
}
|
2025-09-13 02:54:32 +00:00
|
|
|
|
|
|
|
|
go_CanEnterLuckyGame.SetActive(SaveMgr.Ins.Get_Money(eMoney.Lucky) >= table_GlobalValue.Ins.Get_Float("LuckyPoint"));
|
2025-09-18 05:28:09 +00:00
|
|
|
|
|
|
|
|
Set_Money();
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-19 05:15:39 +00:00
|
|
|
IEnumerator Co_UpdateSlider()
|
|
|
|
|
{
|
|
|
|
|
float lucky = SaveMgr.Ins.Get_Money(eMoney.Lucky) / table_GlobalValue.Ins.Get_Float("LuckyPoint");
|
|
|
|
|
float targetValue1 = Mathf.Min(lucky, 1f); // slider_lucky 목표
|
|
|
|
|
float targetValue2 = Mathf.Max(lucky - 1f, 0f); // slider_lucky2 목표
|
|
|
|
|
|
|
|
|
|
float duration = 0.5f; // 각 슬라이더당 시간
|
|
|
|
|
float elapsed = 0f;
|
|
|
|
|
|
|
|
|
|
// slider_lucky 먼저
|
|
|
|
|
float startValue1 = slider_lucky.value;
|
|
|
|
|
while (elapsed < duration)
|
|
|
|
|
{
|
|
|
|
|
elapsed += Time.deltaTime;
|
|
|
|
|
float t = Mathf.Clamp01(elapsed / duration);
|
|
|
|
|
slider_lucky.value = Mathf.Lerp(startValue1, targetValue1, t);
|
|
|
|
|
texts[0].text = MyText.Get_PercentValueText_100(slider_lucky.value + slider_lucky2.value);
|
|
|
|
|
yield return null;
|
|
|
|
|
}
|
|
|
|
|
slider_lucky.value = targetValue1;
|
|
|
|
|
texts[0].text = MyText.Get_PercentValueText_100(slider_lucky.value + slider_lucky2.value);
|
|
|
|
|
|
|
|
|
|
// slider_lucky2 다음
|
|
|
|
|
elapsed = 0f;
|
|
|
|
|
float startValue2 = slider_lucky2.value;
|
|
|
|
|
while (elapsed < duration)
|
|
|
|
|
{
|
|
|
|
|
elapsed += Time.deltaTime;
|
|
|
|
|
float t = Mathf.Clamp01(elapsed / duration);
|
|
|
|
|
slider_lucky2.value = Mathf.Lerp(startValue2, targetValue2, t);
|
|
|
|
|
texts[0].text = MyText.Get_PercentValueText_100(slider_lucky.value + slider_lucky2.value);
|
|
|
|
|
yield return null;
|
|
|
|
|
}
|
|
|
|
|
slider_lucky2.value = targetValue2;
|
|
|
|
|
texts[0].text = MyText.Get_PercentValueText_100(slider_lucky.value + slider_lucky2.value);
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-18 05:28:09 +00:00
|
|
|
void Set_Money()
|
|
|
|
|
{
|
|
|
|
|
texts_money[0].text = SaveMgr.Ins.Get_Money(eMoney.AlbumOpen).ToString();
|
|
|
|
|
texts_money[1].text = SaveMgr.Ins.Get_Money(eMoney.Chat).ToString();
|
|
|
|
|
texts_money[2].text = SaveMgr.Ins.Get_Money(eMoney.Gacha).ToString();
|
2025-09-12 05:23:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnClick_Lucky()
|
|
|
|
|
{
|
2025-09-18 20:21:29 +00:00
|
|
|
if (SaveMgr.Ins.Check_Money(eMoney.Lucky, table_GlobalValue.Ins.Get_Int("LuckyPoint")))
|
2025-09-13 02:42:04 +00:00
|
|
|
{
|
2025-09-18 20:21:29 +00:00
|
|
|
SaveMgr.Ins.Add_Money(eMoney.Lucky, -table_GlobalValue.Ins.Get_Int("LuckyPoint"));
|
2025-09-13 02:42:04 +00:00
|
|
|
SaveMgr.Ins.Save();
|
|
|
|
|
LobbyUI.Ins.m_Game_Lucky.Set();
|
2025-09-19 05:15:39 +00:00
|
|
|
Set_UI(false);
|
2025-09-13 02:42:04 +00:00
|
|
|
}
|
2025-09-12 04:10:11 +00:00
|
|
|
}
|
2025-09-12 04:54:04 +00:00
|
|
|
|
2025-09-13 21:57:57 +00:00
|
|
|
public void OnClick_AD()
|
|
|
|
|
{
|
|
|
|
|
if (SaveMgr.Ins.CanShowGachaAD())
|
|
|
|
|
{
|
2025-09-15 21:41:59 +00:00
|
|
|
ADInfo.Ins.Show_AD(false, () =>
|
|
|
|
|
{
|
|
|
|
|
SaveMgr.Ins.Add_Money(eMoney.Gacha, table_GlobalValue.Ins.Get_Int("GachaAD_Reward"));
|
|
|
|
|
SaveMgr.Ins.Add_GachaADTime(table_GlobalValue.Ins.Get_Int("ADSec_Gacha"));
|
|
|
|
|
LobbyUI.Ins.m_ToastUI.Set($"가챠 코인 {table_GlobalValue.Ins.Get_Int("GachaAD_Reward")}개를 획득했습니다.");
|
2025-09-19 05:15:39 +00:00
|
|
|
Set_Money();
|
2025-09-15 21:41:59 +00:00
|
|
|
});
|
2025-09-13 21:57:57 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-12 04:54:04 +00:00
|
|
|
public void OnClick_Gacha()
|
|
|
|
|
{
|
2025-09-13 21:57:57 +00:00
|
|
|
if (SaveMgr.Ins.Check_Money(eMoney.Gacha, table_GlobalValue.Ins.Get_Int("GachaAmount")))
|
|
|
|
|
{
|
2025-09-19 20:16:42 +00:00
|
|
|
SoundInfo.Ins.Play_OneShot((eSound)Random.Range(12, 14));
|
2025-09-13 21:57:57 +00:00
|
|
|
SaveMgr.Ins.Add_Money(eMoney.Gacha, -table_GlobalValue.Ins.Get_Int("GachaAmount"));
|
|
|
|
|
var gradedata = table_gacharateconfig.Ins.Get_RadomData();
|
|
|
|
|
DSUtil.InActivateGameObjects(gos_grade, gradedata.n_GachaGrade - 1);
|
|
|
|
|
var reward = table_gachareward.Ins.Get_Reward(gradedata.n_GachaGrade);
|
|
|
|
|
SaveMgr.Ins.Add_Money(reward.Item1, reward.Item2);
|
2025-09-19 20:16:42 +00:00
|
|
|
switch (reward.Item1)
|
|
|
|
|
{
|
|
|
|
|
case eMoney.AlbumOpen:
|
|
|
|
|
SoundInfo.Ins.Play_OneShot(eSound.s006_MiniGameGetHeart);
|
|
|
|
|
break;
|
|
|
|
|
case eMoney.Chat:
|
|
|
|
|
SoundInfo.Ins.Play_OneShot(eSound.s007_MiniGameGetChatCoint);
|
|
|
|
|
break;
|
|
|
|
|
case eMoney.Gacha:
|
|
|
|
|
SoundInfo.Ins.Play_OneShot(eSound.s008_MiniGameGetGachaCoin);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2025-09-13 21:57:57 +00:00
|
|
|
SaveMgr.Ins.Add_Money(eMoney.Lucky, reward.Item3);
|
|
|
|
|
SaveMgr.Ins.Save();
|
|
|
|
|
list_log.Add((reward.Item1, reward.Item2));
|
2025-09-19 05:15:39 +00:00
|
|
|
//list_log.Add((eMoney.Lucky, reward.Item3));
|
2025-09-13 21:57:57 +00:00
|
|
|
Set_ScrollView(list_log);
|
|
|
|
|
Set_Vertical_ScrollEnd(0);
|
2025-09-19 05:15:39 +00:00
|
|
|
Set_UI(true);
|
2025-09-13 21:57:57 +00:00
|
|
|
}
|
2025-09-12 04:54:04 +00:00
|
|
|
}
|
2025-09-12 04:10:11 +00:00
|
|
|
}
|