public static void Read() { bool newFile = false; FC_StoreDataList dataList = null; UnityEngine.Object oldFile = AssetDatabase.LoadAssetAtPath(outFileName, typeof(FC_StoreDataList)); if (oldFile == null) { newFile = true; dataList = ScriptableObject.CreateInstance(typeof(FC_StoreDataList)) as FC_StoreDataList; } else { dataList = oldFile as FC_StoreDataList; } dataList.dataList.Clear(); string jsonStr = File.ReadAllText(fileName); JsonHashtable ht = FCJson.jsonDecode(jsonStr) as JsonHashtable; foreach (System.Object obj in ht.ValueList) { Hashtable ht2 = obj as Hashtable; FC_StoreData sd = new FC_StoreData(); sd.id = (int)ht2["id"]; sd.name = ht2["name"] as string; sd.count = (int)ht2["count"]; sd.displayNameIds = ht2["displayNameIds"] as string; sd.order = (int)ht2["order"]; sd.storeIconName = ht2["storeIconName"] as string; dataList.dataList.Add(sd); } if (newFile) { AssetDatabase.CreateAsset(dataList, outFileName); } else { EditorUtility.SetDirty(dataList); } Debug.Log(string.Format("Store data imported OK. {0} records.", dataList.dataList.Count)); }
public override void Decode(BinaryReader reader) { errorCode = reader.ReadInt16(); if (Succeeded) { GoodsOnSellDataList = new List <FC_StoreData>(); int goodsNum = reader.ReadInt16(); for (int i = 0; i < goodsNum; i++) { int id = reader.ReadInt32(); FC_StoreData storeData = DataManager.Instance.storeDataList.GetStoreById(id); storeData.price = reader.ReadInt32(); storeData.status = reader.ReadByte(); if (storeData.IsLimitDisappear) { storeData.limitDisappear = reader.ReadInt32(); } if (storeData.IsDiscount) { storeData.discount = reader.ReadByte(); storeData.discountPrice = reader.ReadInt32(); storeData.discountExpire = reader.ReadInt32(); } GoodsOnSellDataList.Add(storeData); } ExchangeSCDataList = new List <StoreSCExchangeData>(); int exchangeNum = reader.ReadInt16(); for (int i = 0; i < exchangeNum; i++) { StoreSCExchangeData exData = new StoreSCExchangeData(); exData.Type = reader.ReadByte(); exData.Count = reader.ReadByte(); exData.CountMax = reader.ReadByte(); exData.SC = reader.ReadInt32(); exData.CoseHC = reader.ReadInt32(); exData.ExpireTime = reader.ReadInt32(); ExchangeSCDataList.Add(exData); } } }
void OnBuyButtonClickHandler(FC_StoreData storeData) { _currentStoreData = storeData; int price = storeData.price; if (storeData.IsDiscount) { price = storeData.discountPrice; } string hint = null; if (!_currentStoreData.IsSC && price > PlayerInfo.Instance.HardCurrency) { hint = Localization.Localize("IDS_MESSAGE_GLOBAL_HC_NOTENOUGH"); } else if (_currentStoreData.IsSC && price > PlayerInfo.Instance.SoftCurrency) { hint = Localization.Localize("IDS_MESSAGE_GLOBAL_NOTENOUGHSC"); } if (!string.IsNullOrEmpty(hint)) { UIMessageBoxManager.Instance.ShowMessageBox(hint, "", MB_TYPE.MB_OK, OnBuyNotEnoughHandler); } else { if (!storeData.IsSC) { hint = string.Format(Localization.instance.Get("IDS_MESSAGE_GLOBAL_BUY_CONFIRM_HC"), price, Localization.Localize(storeData.displayNameIds) + " * " + storeData.count); } else { hint = string.Format(Localization.instance.Get("IDS_MESSAGE_GLOBAL_BUY_CONFIRM_SC"), price, Localization.Localize(storeData.displayNameIds) + " * " + storeData.count); } UIMessageBoxManager.Instance.ShowMessageBox(hint, "", MB_TYPE.MB_OKCANCEL, OnClickBuyCallBack); } }
FCUIStoreItem MakeFCUIStoreItem(FC_StoreData storeData) { FCUIStoreItem item = null; if (_cacheBuyItems.ContainsKey(storeData.id)) { item = _cacheBuyItems[storeData.id]; } else { GameObject go = GameObject.Instantiate(templateStoreItem.gameObject) as GameObject; go.transform.parent = grid.transform; go.transform.localScale = Vector3.one; go.transform.localPosition = templateStoreItem.transform.localPosition; item = go.GetComponent <FCUIStoreItem>(); item.OnBuyButtonClickHandler = OnBuyButtonClickHandler; _cacheBuyItems[storeData.id] = item; } item.StoreData = storeData; item.gameObject.SetActive(true); return(item); }