129 lines
5.1 KiB
C#
129 lines
5.1 KiB
C#
using CodeStage.AntiCheat.ObscuredTypes;
|
|
using MiniJSON;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
#if FGB_OneStore
|
|
using Gaa;
|
|
#endif
|
|
|
|
public enum eShopTab { Package }
|
|
public enum ePriceType { Cash, AD, Gem = eItem.Gem, Review }
|
|
|
|
public class ShopTableData : TableDataBase
|
|
{
|
|
public string InappID, Desc, IconSub, BuyCondition;
|
|
public eShopTab Tab;
|
|
public eItem Item, ObtainCheckItem;
|
|
public ePriceType PriceType;
|
|
public ObscuredInt ItemID, ObtainCheckItemID, Mileage, Price, ADGapTime, GoldKillMul, NumUI;
|
|
public ObscuredInt BuyLimit, BuyLimit_Day, BuyLimit_Week, BuyLimit_Month;
|
|
public ObscuredDouble Amount;
|
|
public bool IsBest, IsRocket;
|
|
}
|
|
|
|
public class table_shop : MonoBehaviour
|
|
{
|
|
public static table_shop Ins;
|
|
public static Action Login;
|
|
|
|
public TextAsset m_json;
|
|
|
|
private List<TableDataBase> list_Data = new List<TableDataBase>();
|
|
protected List<int> list_pageids = new List<int>();
|
|
|
|
private void Awake()
|
|
{
|
|
Ins = this;
|
|
|
|
Dictionary<string, object> jsonData = Json.Deserialize(m_json.text) as Dictionary<string, object>;
|
|
|
|
// ["items"]은 items.txt 안의 items를 가리킨다. 툴 우측 하단 파일 종류란에서 설정 가능.
|
|
List<object> obj = jsonData[GetType().Name] as List<object>;
|
|
|
|
foreach (object objt in obj)
|
|
{
|
|
var temp = new ShopTableData();
|
|
Dictionary<string, object> json = objt as Dictionary<string, object>;
|
|
|
|
temp.ID = int.Parse(json["ID"].ToString());
|
|
temp.Tab = DSUtil.StringToEnum<eShopTab>(json["Tab"].ToString());
|
|
temp.InappID = json["InappID"].ToString();
|
|
temp.IconSub = json["IconSub"].ToString();
|
|
temp.Desc = json["Desc"].ToString();
|
|
temp.BuyCondition = json["BuyCondition"].ToString();
|
|
temp.NumUI = int.Parse(json["NumUI"].ToString());
|
|
temp.Item = DSUtil.StringToEnum<eItem>(json["Item"].ToString());
|
|
temp.PriceType = DSUtil.StringToEnum<ePriceType>(json["PriceType"].ToString());
|
|
temp.ItemID = int.Parse(json["ItemID"].ToString());
|
|
temp.Amount = int.Parse(json["Amount"].ToString());
|
|
temp.Mileage = int.Parse(json["Mileage"].ToString());
|
|
temp.Price = int.Parse(json["Price"].ToString());
|
|
temp.BuyLimit_Day = int.Parse(json["BuyLimit_Day"].ToString());
|
|
temp.BuyLimit_Week = int.Parse(json["BuyLimit_Week"].ToString());
|
|
temp.BuyLimit_Month = int.Parse(json["BuyLimit_Month"].ToString());
|
|
temp.ADGapTime = int.Parse(json["ADGapTime"].ToString());
|
|
temp.GoldKillMul = int.Parse(json["GoldKillMul"].ToString());
|
|
temp.BuyLimit = int.Parse(json["BuyLimit"].ToString());
|
|
temp.IsBest = int.Parse(json["IsBest"].ToString()) > 0;
|
|
temp.IsRocket = int.Parse(json["IsRocket"].ToString()) > 0;
|
|
|
|
var split = json["ObtainCheck"].ToString().Split(',');
|
|
temp.ObtainCheckItem = DSUtil.StringToEnum<eItem>(split[0]);
|
|
temp.ObtainCheckItemID = int.Parse(split[1]);
|
|
|
|
list_Data.Add(temp);
|
|
}
|
|
|
|
InappInfo.Ins.Set(Login);
|
|
}
|
|
|
|
#if FGB_OneStore
|
|
public void Buy_OneStore(PurchaseData _pd, Action _act)
|
|
{
|
|
Cal_Item(_pd.productId);
|
|
ServerInfo.Ins.Write_Onestore(_pd, () => { BuyNext(_act); }); // 원스토어 정보 저장 및 서버에서 우편으로 아이템 지급
|
|
}
|
|
#endif
|
|
public void Buy_Inapp(string _inappid, Action _act)
|
|
{
|
|
Cal_Item(_inappid);
|
|
ServerInfo.Ins.Write_UnityInApp(_inappid, () => { BuyNext(_act); }); // 서버에서 우편으로 아이템 지급
|
|
}
|
|
void Cal_Item(string _inappid)
|
|
{
|
|
var sdata = ServerInfo.Ins.m_ServerData;
|
|
var data = Get_Data(_inappid);
|
|
sdata.Add_ShopBuyCount(data.ID, 1, 2, 3, 4); // 현금 결제 후 구매 횟수 추가 (총, 일간, 주간, 월간 모두 올려도 상관없음)
|
|
sdata.Add_Common(eCommon.InAppBuyCount);
|
|
switch (data.Item)
|
|
{
|
|
case eItem.Pass:
|
|
sdata.Add_Item(new ItemData(data.Item, data.ID, 1));
|
|
break;
|
|
}
|
|
}
|
|
|
|
void BuyNext(Action _act)
|
|
{
|
|
GameUI.Ins.LobbyUI.Set_MailNoti(true);
|
|
MyText.Show_CheckMailBox();
|
|
_act?.Invoke();
|
|
}
|
|
|
|
public List<TableDataBase> Get_DataList() { return list_Data; }
|
|
public List<TableDataBase> Get_DataList(eShopTab _tab) { return list_Data.FindAll(f => (f as ShopTableData).Tab == _tab); }
|
|
public List<TableDataBase> Get_AD_DataList() { return list_Data.FindAll(f => (f as ShopTableData).ADGapTime > 0); }
|
|
public ShopTableData Get_Data(int id) { return list_Data.Find(f => f.ID == id) as ShopTableData; }
|
|
public ShopTableData Get_Data(eItem item, int id) { return list_Data.Find(f => (f as ShopTableData).Item == item && f.ID == id) as ShopTableData; }
|
|
public ShopTableData Get_Data(string _inappid)
|
|
{
|
|
for (int i = 0; i < list_Data.Count; i++)
|
|
{
|
|
var data = list_Data[i] as ShopTableData;
|
|
if (data.InappID.Equals(_inappid))
|
|
return data;
|
|
}
|
|
return null;
|
|
}
|
|
} |