224 lines
7.5 KiB
C#
224 lines
7.5 KiB
C#
using System.Collections;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class LobbyUI : MonoBehaviourSingletonTemplate<LobbyUI>
|
|
{
|
|
[SerializeField] TextMeshProUGUI[] texts_money; // 0 앨범 개방 재화, 1 채팅 재화, 2 뽑기 재화, 3 4 미니게임 체력
|
|
public GameObject go_minigamechargingbtn;
|
|
public Image i_minigamechargingbtn;
|
|
public Slider slider_minigamecharging;
|
|
public TextMeshProUGUI t_minigamechargingtime;
|
|
float minigamechargingTime = 0f;
|
|
|
|
[Header("Popup UI")]
|
|
[SerializeField] AttandanceUI m_AttandanceUI;
|
|
[SerializeField] OptionUI m_OptionUI;
|
|
[SerializeField] ProfileUI m_ProfileUI;
|
|
public ToastUI m_ToastUI;
|
|
public PopupUI m_PopupUI;
|
|
|
|
[Header("Center UI")]
|
|
public LobbyCenterProfileUI m_LobbyCenterProfileUI;
|
|
public AlbumUI m_AlbumUI;
|
|
[SerializeField] GachaUI m_GachaUI;
|
|
public ChatUI m_ChatUI;
|
|
public ChangeGirlUI m_ChangeGirlUI;
|
|
|
|
[Header("Bot UI")]
|
|
[SerializeField] GameObject[] gos_homeBot; // 게임 버튼
|
|
|
|
[Header("Games")]
|
|
public Game_Lucky m_Game_Lucky;
|
|
public Game_Mini m_Game_Mini;
|
|
public HorseRushPanel m_MiniGame;
|
|
[SerializeField] GameObject go_shop;
|
|
|
|
public Image[] images_botbtn; // 0 앨범, 1 상점
|
|
int CurMenu = 2;
|
|
bool bUpdate = false;
|
|
|
|
IEnumerator Start()
|
|
{
|
|
bUpdate = false;
|
|
|
|
yield return null;
|
|
if (SaveMgr.Ins.CanGet_Attandance())
|
|
m_AttandanceUI.Set();
|
|
ADInfo.Ins.Set_Banner(true);
|
|
m_LobbyCenterProfileUI.Set();
|
|
minigamechargingTime = (float)(SaveMgr.Ins.Get_MiniGameTime() - InternetTime.Ins.Time).TotalMilliseconds * 0.001f;
|
|
go_minigamechargingbtn.SetActive(minigamechargingTime > 0f);
|
|
if (minigamechargingTime <= 0f) Check_MiniGameCharging();
|
|
Set_i_minigamechargingbtn();
|
|
|
|
bUpdate = true;
|
|
}
|
|
|
|
protected override void Update()
|
|
{
|
|
base.Update();
|
|
if (!bUpdate) return;
|
|
|
|
var cal = SaveMgr.Ins.Get_MiniGameTime() - InternetTime.Ins.Time;
|
|
if (!SaveMgr.Ins.Check_Money(eMoney.MiniGameHP, table_GlobalValue.Ins.Get_Int("MiniGame_TotalEnterMoney"), false))
|
|
{
|
|
minigamechargingTime -= Time.deltaTime;
|
|
t_minigamechargingtime.text = minigamechargingTime > 0f ? $"{minigamechargingTime:F1}s" : "0s";
|
|
var fRefillTimeMax = table_GlobalValue.Ins.Get_Float("MiniGame_EnterMoney_Time");
|
|
slider_minigamecharging.value = DSUtil.Get_SliderValue(minigamechargingTime / fRefillTimeMax);
|
|
|
|
if (cal.TotalSeconds <= 0 && minigamechargingTime <= 0f)
|
|
MiniGameCharging();
|
|
}
|
|
}
|
|
void MiniGameCharging()
|
|
{
|
|
SaveMgr.Ins.Add_Money(eMoney.MiniGameHP);
|
|
m_ToastUI.Set($"생명력이 충전되었습니다.");
|
|
Check_MiniGameCharging();
|
|
Set_Money();
|
|
SaveMgr.Ins.Save();
|
|
}
|
|
void Check_MiniGameCharging()
|
|
{
|
|
if (!SaveMgr.Ins.Check_Money(eMoney.MiniGameHP, table_GlobalValue.Ins.Get_Int("MiniGame_TotalEnterMoney"), false))
|
|
{
|
|
var cal = SaveMgr.Ins.Get_MiniGameTime() - InternetTime.Ins.Time;
|
|
if (cal.TotalMilliseconds <= 0f)
|
|
{
|
|
SaveMgr.Ins.Set_MiniGameTime();
|
|
minigamechargingTime = table_GlobalValue.Ins.Get_Int("MiniGame_EnterMoney_Time");
|
|
}
|
|
}
|
|
|
|
if (CurMenu == 2) go_minigamechargingbtn.SetActive(minigamechargingTime > 0f);
|
|
Set_i_minigamechargingbtn();
|
|
}
|
|
void Set_i_minigamechargingbtn()
|
|
{
|
|
if (!SaveMgr.Ins.Check_Money(eMoney.MiniGameHP, 1, false))
|
|
i_minigamechargingbtn.sprite = UIAtlasMgr.Ins.Get_Sprite("MiniGameGray_btn");
|
|
else
|
|
i_minigamechargingbtn.sprite = UIAtlasMgr.Ins.Get_Sprite("red btn");
|
|
}
|
|
|
|
public void OnClick_Button(GameObject btn)
|
|
{
|
|
switch (btn.name)
|
|
{
|
|
case "btn_attendance": m_AttandanceUI.Set(); break;
|
|
case "btn_option": m_OptionUI.Set(); break;
|
|
|
|
case "btn_album":
|
|
if (CurMenu != 1)
|
|
{
|
|
CurMenu = 1;
|
|
Go_Home();
|
|
m_AlbumUI.Set();
|
|
DSUtil.InActivateGameObjects(gos_homeBot);
|
|
|
|
Btn_Init();
|
|
images_botbtn[0].sprite = UIAtlasMgr.Ins.Get_Sprite("btn x");
|
|
(images_botbtn[0].transform as RectTransform).sizeDelta = new Vector2(91, 91);
|
|
}
|
|
else
|
|
{
|
|
CurMenu = 2;
|
|
Go_Home();
|
|
Btn_Init();
|
|
}
|
|
break;
|
|
case "btn_home":
|
|
if (CurMenu != 2)
|
|
{
|
|
CurMenu = 2;
|
|
Go_Home();
|
|
Btn_Init();
|
|
}
|
|
break;
|
|
case "btn_gacha": m_GachaUI.Set(); break;
|
|
case "btn_shop":
|
|
if (CurMenu != 3)
|
|
{
|
|
CurMenu = 3;
|
|
Go_Home();
|
|
go_shop.SetActive(true);
|
|
DSUtil.InActivateGameObjects(gos_homeBot);
|
|
|
|
Btn_Init();
|
|
images_botbtn[1].sprite = UIAtlasMgr.Ins.Get_Sprite("btn x");
|
|
(images_botbtn[1].transform as RectTransform).sizeDelta = new Vector2(91, 91);
|
|
}
|
|
else
|
|
{
|
|
CurMenu = 2;
|
|
Go_Home();
|
|
Btn_Init();
|
|
}
|
|
break;
|
|
|
|
case "btn_minigame":
|
|
if (SaveMgr.Ins.IsInfinityMiniGame())
|
|
{
|
|
m_MiniGame.GameStart(true);
|
|
return;
|
|
}
|
|
|
|
if (SaveMgr.Ins.Check_Money(eMoney.MiniGameHP, 1, true))
|
|
m_MiniGame.GameStart(false);
|
|
break;
|
|
}
|
|
}
|
|
|
|
void Btn_Init()
|
|
{
|
|
images_botbtn[0].sprite = UIAtlasMgr.Ins.Get_Sprite("album icon");
|
|
(images_botbtn[0].transform as RectTransform).sizeDelta = new Vector2(91, 83);
|
|
images_botbtn[1].sprite = UIAtlasMgr.Ins.Get_Sprite("shop icon");
|
|
(images_botbtn[1].transform as RectTransform).sizeDelta = new Vector2(91, 83);
|
|
}
|
|
|
|
public void MiniGameResult()
|
|
{
|
|
SaveMgr.Ins.Add_Money(eMoney.MiniGameHP, -1);
|
|
Check_MiniGameCharging();
|
|
}
|
|
|
|
public void Go_Home()
|
|
{
|
|
SoundInfo.Ins.Play_BGM(eBGM.b001_BGM);
|
|
m_AlbumUI.gameObject.SetActive(false);
|
|
m_GachaUI.gameObject.SetActive(false);
|
|
go_shop.SetActive(false);
|
|
DSUtil.ActivateGameObjects(gos_homeBot);
|
|
go_minigamechargingbtn.SetActive(minigamechargingTime > 0f);
|
|
}
|
|
|
|
public void Go_Album(int girlid)
|
|
{
|
|
Go_Home();
|
|
m_AlbumUI.Set(girlid);
|
|
DSUtil.InActivateGameObjects(gos_homeBot);
|
|
|
|
CurMenu = 1;
|
|
Btn_Init();
|
|
images_botbtn[0].sprite = UIAtlasMgr.Ins.Get_Sprite("btn x");
|
|
(images_botbtn[0].transform as RectTransform).sizeDelta = new Vector2(91, 91);
|
|
}
|
|
|
|
public 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();
|
|
//if (SaveMgr.Ins.Get_Money(eMoney.MiniGameHP) > 0)
|
|
texts_money[3].text = texts_money[4].text = SaveMgr.Ins.Get_Money(eMoney.MiniGameHP).ToString();
|
|
}
|
|
|
|
public void Show_Profile(int girlid)
|
|
{
|
|
m_ProfileUI.Set(girlid);
|
|
}
|
|
} |