188 lines
4.9 KiB
C#
188 lines
4.9 KiB
C#
using UnityEngine;
|
|
using TMPro;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
public class MainCtrl : MonoBehaviour
|
|
{
|
|
[SerializeField] TMP_Text title_Text;
|
|
[SerializeField] TMP_Text messageText;
|
|
[SerializeField] TMP_InputField email;
|
|
|
|
[SerializeField] GameObject gameStartButton;
|
|
[SerializeField] GameObject loginButton;
|
|
[SerializeField] GameObject gestLoginButton;
|
|
[SerializeField] GameObject message;
|
|
|
|
bool is_On;
|
|
float dtime = 0;
|
|
bool isUpdate;
|
|
|
|
string uuid;
|
|
|
|
private void Awake()
|
|
{
|
|
gameStartButton.SetActive(false);
|
|
loginButton.SetActive(false);
|
|
gestLoginButton.SetActive(false);
|
|
message.SetActive(true);
|
|
isUpdate = false;
|
|
messageText.text = "data °ËÁõÁß....";
|
|
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (GameManager.Instance.isExcel)
|
|
{
|
|
return;
|
|
}
|
|
else if (!isUpdate)
|
|
{
|
|
isUpdate = !isUpdate;
|
|
uuid = PlayerPrefs.GetString("uuid");
|
|
message.SetActive(false);
|
|
if (uuid != "")
|
|
{
|
|
gameStartButton.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
loginButton.SetActive(true);
|
|
}
|
|
}
|
|
if(is_On)
|
|
{
|
|
if(title_Text.color.a >= 1)
|
|
{
|
|
if(dtime > 1f)
|
|
{
|
|
is_On = !is_On;
|
|
dtime = 0;
|
|
}
|
|
else
|
|
{
|
|
dtime += Time.deltaTime;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
title_Text.color += (Color.black * Time.deltaTime);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (title_Text.color.a <= 0.1)
|
|
{
|
|
is_On = !is_On;
|
|
}
|
|
else
|
|
{
|
|
title_Text.color -= (Color.black * Time.deltaTime);
|
|
}
|
|
}
|
|
}
|
|
//#if UNITY_EDITOR
|
|
public void GestLogin()
|
|
{
|
|
gestLoginButton.SetActive(true);
|
|
}
|
|
|
|
public void Join()
|
|
{
|
|
loginButton.SetActive(false);
|
|
gestLoginButton.SetActive(false);
|
|
gameStartButton.SetActive(true);
|
|
|
|
}
|
|
//#endif
|
|
|
|
public void FireBaseLogin()
|
|
{
|
|
|
|
}
|
|
|
|
public void MastodonLogin()
|
|
{
|
|
|
|
}
|
|
|
|
public void NextButton()
|
|
{
|
|
LoginResp resp = new LoginResp();
|
|
LoginReq req = new LoginReq(email.text, uuid);
|
|
|
|
message.SetActive(true);
|
|
messageText.text = "Login...";
|
|
|
|
resp.Request(req, (data) =>
|
|
{
|
|
//·Î±×ÀÎ ¼º°ø½Ã
|
|
if(data.status.Equals(200))
|
|
{
|
|
PlayerPrefs.SetString("uuid", data.uuid);
|
|
Statics.uuid = data.uuid;
|
|
Statics.deck_info = data.deck_info.OrderBy(n => n.id).ToList();
|
|
//´ÙÀ̳ª¹Í µ¥ÀÌÅÍ Set
|
|
foreach (var item in data.dynamic_data)
|
|
Statics.dynamic.Add(item.name, item.value);
|
|
|
|
Statics.itemManager = new ItemManager(data.deck_unit, data.equipment, data.consumable_item, data.etc_item);
|
|
|
|
Statics.nickname = data.nickname;
|
|
Statics.gold = data.gold;
|
|
Statics.cash = data.cash;
|
|
|
|
if(data.new_user) //½Å±Ô À¯Àú
|
|
GameManager.Instance.NextScene(GameManager.eScene.Play);
|
|
else
|
|
GameManager.Instance.NextScene(GameManager.eScene.Game);
|
|
|
|
//data.shop_item
|
|
// Statics.excelDatas.shopItems
|
|
foreach(var item in Statics.excelDatas.shopItemData)
|
|
{
|
|
item.Value.id = -1;
|
|
Statics.shopItems.Add(item.Key, item.Value);
|
|
}
|
|
|
|
for (int n = 0; n < data.shop_item.Count; n++)
|
|
{
|
|
Statics.shopItems[data.shop_item[n].shop_item_data_id].buy_count--;
|
|
|
|
if(Statics.shopItems[data.shop_item[n].shop_item_data_id].buy_count == 0)
|
|
{
|
|
Statics.shopItems.Remove(data.shop_item[n].shop_item_data_id);
|
|
}
|
|
}
|
|
|
|
foreach (var item in data.reset_shop_item)
|
|
{
|
|
ShopItemData itemData = new ShopItemData();
|
|
itemData.id = item.id;
|
|
itemData.index = item.reset_shop_item_data_id;
|
|
itemData.name = item.name;
|
|
itemData.shop_index = item.shop_index;
|
|
itemData.buy_type = item.buy_type;
|
|
itemData.buy = item.buy;
|
|
itemData.reward = item.reward;
|
|
itemData.buy_count = item.buy_count;
|
|
Statics.shopItems.Add(itemData.index, itemData);
|
|
}
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
PlayerPrefs.SetString("uuid", "");
|
|
Awake();
|
|
}
|
|
}, () =>
|
|
{
|
|
|
|
});
|
|
|
|
|
|
}
|
|
}
|