From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Assets/Scripts/XMainClient/XNormalShopGoods.cs | 160 +++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XNormalShopGoods.cs (limited to 'Client/Assets/Scripts/XMainClient/XNormalShopGoods.cs') diff --git a/Client/Assets/Scripts/XMainClient/XNormalShopGoods.cs b/Client/Assets/Scripts/XMainClient/XNormalShopGoods.cs new file mode 100644 index 00000000..2b343c7a --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XNormalShopGoods.cs @@ -0,0 +1,160 @@ +using System; +using KKSG; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XNormalShopGoods + { + public XItem item; + + public int priceType; + + public int priceValue; + + public int soldNum; + + public int totalSoldNum; + + public int needLevel; + + public bool isLevelEnough; + + public uint weeklyBuyCount; + + public void UpdateData(ShopItem data) + { + this.item = XBagDocument.MakeXItem(data.Item); + ShopTable.RowData dataById = XNormalShopDocument.GetDataById((uint)data.Item.uid); + bool flag = dataById != null; + if (flag) + { + this.priceType = (int)dataById.ConsumeItem[0]; + this.priceValue = (int)dataById.ConsumeItem[1]; + this.soldNum = (int)data.dailybuycount; + this.totalSoldNum = (int)data.buycount; + this.weeklyBuyCount = data.weekbuycount; + this.needLevel = (int)dataById.LevelCondition; + this.SetLevelCondition(dataById.Type, (uint)dataById.LevelCondition); + } + } + + public static XNormalShopGoods MakeGoodsFromData(ShopItem data) + { + XNormalShopGoods xnormalShopGoods = new XNormalShopGoods(); + xnormalShopGoods.UpdateData(data); + return xnormalShopGoods; + } + + public void UpdateData(PartnerShopItemClient data) + { + ShopTable.RowData dataById = XNormalShopDocument.GetDataById(data.id); + bool flag = dataById == null; + if (flag) + { + XSingleton.singleton.AddErrorLog("not find this shopItem,shopid is :" + data.id, null, null, null, null, null); + } + else + { + ItemList.RowData itemConf = XBagDocument.GetItemConf((int)dataById.ItemId); + bool flag2 = itemConf == null; + if (flag2) + { + XSingleton.singleton.AddErrorLog("not find this item,shopid is :" + data.id, "itemid is :" + dataById.ItemId, null, null, null, null); + } + else + { + bool flag3 = itemConf.ItemType == 1; + int itemID; + if (flag3) + { + itemID = XBagDocument.ConvertTemplate(itemConf); + } + else + { + itemID = itemConf.ItemID; + } + this.item = XBagDocument.MakeXItem(itemID, dataById.IsNotBind); + this.item.uid = (ulong)data.id; + this.item.itemCount = 0; + this.priceType = (int)dataById.ConsumeItem[0]; + this.priceValue = (int)dataById.ConsumeItem[1]; + this.soldNum = (int)data.buy_count; + this.totalSoldNum = (int)dataById.DailyCountCondition; + this.weeklyBuyCount = (uint)dataById.WeekCountCondition; + this.needLevel = (int)dataById.LevelCondition; + this.SetLevelCondition(dataById.Type, (uint)dataById.LevelCondition); + } + } + } + + public void UpdateData(DragonGuildShopItemClient data) + { + ShopTable.RowData dataById = XNormalShopDocument.GetDataById(data.id); + bool flag = dataById == null; + if (flag) + { + XSingleton.singleton.AddErrorLog("not find this shopItem,shopid is :" + data.id, null, null, null, null, null); + } + else + { + ItemList.RowData itemConf = XBagDocument.GetItemConf((int)dataById.ItemId); + bool flag2 = itemConf == null; + if (flag2) + { + XSingleton.singleton.AddErrorLog("not find this item,shopid is :" + data.id, "itemid is :" + dataById.ItemId, null, null, null, null); + } + else + { + bool flag3 = itemConf.ItemType == 1; + int itemID; + if (flag3) + { + itemID = XBagDocument.ConvertTemplate(itemConf); + } + else + { + itemID = itemConf.ItemID; + } + this.item = XBagDocument.MakeXItem(itemID, dataById.IsNotBind); + this.item.uid = (ulong)data.id; + this.item.itemCount = 0; + this.priceType = (int)dataById.ConsumeItem[0]; + this.priceValue = (int)dataById.ConsumeItem[1]; + this.soldNum = (int)data.buy_count; + this.totalSoldNum = (int)dataById.DailyCountCondition; + this.weeklyBuyCount = (uint)dataById.WeekCountCondition; + this.needLevel = (int)dataById.LevelCondition; + this.SetLevelCondition(dataById.Type, (uint)dataById.LevelCondition); + } + } + } + + public static XNormalShopGoods MakeGoodsFromData(PartnerShopItemClient data) + { + XNormalShopGoods xnormalShopGoods = new XNormalShopGoods(); + xnormalShopGoods.UpdateData(data); + return xnormalShopGoods; + } + + public static XNormalShopGoods MakeGoodsFromData(DragonGuildShopItemClient data) + { + XNormalShopGoods xnormalShopGoods = new XNormalShopGoods(); + xnormalShopGoods.UpdateData(data); + return xnormalShopGoods; + } + + private void SetLevelCondition(uint type, uint level) + { + bool flag = type == 20u; + if (flag) + { + this.isLevelEnough = (XPartnerDocument.Doc.CurPartnerLevel >= level); + } + else + { + this.isLevelEnough = (XSingleton.singleton.XPlayerData.Level >= level); + } + } + } +} -- cgit v1.1-26-g67d0