public CMallMysteryProduct GetProduct(uint itemType, uint itemID) { CMallMysteryProduct product = new CMallMysteryProduct(); if (this.m_ProductDic.TryGetValue(GameDataMgr.GetDoubleKey(itemType, itemID), out product)) { return(product); } return(null); }
private void OnBuyItem(CUIEvent uiEvent) { enPayType tag = (enPayType)uiEvent.m_eventParams.tag; uint payValue = uiEvent.m_eventParams.commonUInt32Param1; string goodName = string.Empty; COM_ITEM_TYPE com_item_type = COM_ITEM_TYPE.COM_OBJTYPE_NULL; uint uniSkinId = 0; long key = 0L; if (uiEvent.m_eventParams.heroSkinParam.skinId != 0) { com_item_type = COM_ITEM_TYPE.COM_OBJTYPE_HEROSKIN; uniSkinId = CSkinInfo.GetSkinCfgId(uiEvent.m_eventParams.heroSkinParam.heroId, uiEvent.m_eventParams.heroSkinParam.skinId); ResHeroSkin heroSkin = CSkinInfo.GetHeroSkin(uniSkinId); DebugHelper.Assert(heroSkin != null, string.Format("找不到皮肤{0}的配置信息", uniSkinId)); if (heroSkin == null) { return; } goodName = StringHelper.UTF8BytesToString(ref heroSkin.szSkinName); } else if (uiEvent.m_eventParams.heroId != 0) { com_item_type = COM_ITEM_TYPE.COM_OBJTYPE_HERO; uniSkinId = uiEvent.m_eventParams.heroId; ResHeroCfgInfo dataByKey = GameDataMgr.heroDatabin.GetDataByKey(uniSkinId); DebugHelper.Assert(dataByKey != null, string.Format("找不到英雄{0}的配置信息", uniSkinId)); if (dataByKey == null) { return; } goodName = StringHelper.UTF8BytesToString(ref dataByKey.szName); } else { DebugHelper.Assert(false, "神秘商店购买不支持该物品类型"); return; } key = GameDataMgr.GetDoubleKey((uint)com_item_type, uniSkinId); CMallMysteryProduct product = new CMallMysteryProduct(); if (!this.m_ProductDic.TryGetValue(key, out product)) { DebugHelper.Assert(false, string.Format("神秘商店找不到该物品{0}/{1}", Enum.GetName(typeof(COM_ITEM_TYPE), com_item_type), uniSkinId)); } else { CUIEvent uIEvent = Singleton <CUIEventManager> .GetInstance().GetUIEvent(); uIEvent.m_eventID = enUIEventID.Mall_Mystery_On_Confirm_Buy_Item; uIEvent.m_eventParams.tag = (int)product.ID; CMallSystem.TryToPay(enPayPurpose.Buy, goodName, tag, payValue, uIEvent.m_eventID, ref uIEvent.m_eventParams, enUIEventID.None, false, true); } }
private void OnOpenBuyForm(CUIEvent uiEvent) { int srcWidgetIndexInBelongedList = uiEvent.m_srcWidgetIndexInBelongedList; if ((this.m_Products != null) && (srcWidgetIndexInBelongedList <= this.m_Products.Count)) { CMallMysteryProduct product = this.m_Products[srcWidgetIndexInBelongedList]; if (product != null) { product.OpenBuy(uiEvent.m_srcFormScript, uiEvent.m_srcWidget.transform); } } }
private void OnElementEnable(CUIEvent uiEvent) { int srcWidgetIndexInBelongedList = uiEvent.m_srcWidgetIndexInBelongedList; if ((this.m_Products != null) && (srcWidgetIndexInBelongedList <= this.m_Products.Count)) { CMallMysteryProduct product = this.m_Products[srcWidgetIndexInBelongedList]; if (product != null) { product.UpdateView(uiEvent); } } }
public static void ReceiveShopBuy(CSPkg msg) { Singleton <CUIManager> .GetInstance().CloseSendMsgAlert(); uint dwShopID = msg.stPkgData.stAkaliShopUpdate.dwShopID; uint dwLeftBuyCnt = msg.stPkgData.stAkaliShopUpdate.dwLeftBuyCnt; uint dwGoodsID = msg.stPkgData.stAkaliShopUpdate.dwGoodsID; byte bGoodsType = msg.stPkgData.stAkaliShopUpdate.bGoodsType; CMallMysteryShop instance = Singleton <CMallMysteryShop> .GetInstance(); if (instance.ShopID == dwShopID) { instance.BoughtCnt++; CMallMysteryProduct product = instance.GetProduct(bGoodsType, dwGoodsID); if (product != null) { uint num5; instance.RefreshBanner(); product.BoughtCnt = (num5 = product.BoughtCnt) + 1; instance.UpdateProduct(bGoodsType, dwGoodsID, num5); } } }
private void OnBuyHeroNotOwn(CUIEvent uiEvent) { uint heroId = uiEvent.m_eventParams.heroId; DebugHelper.Assert(heroId != 0, "未拥有的英雄ID不能为0"); if (heroId != 0) { ResHeroCfgInfo dataByKey = GameDataMgr.heroDatabin.GetDataByKey(heroId); DebugHelper.Assert(dataByKey != null, "神秘商店配置的英雄ID有错,英雄表里不存在"); if (dataByKey != null) { CMallMysteryProduct product = this.GetProduct(4, heroId); if (product != null) { stPayInfoSet lowestPayInfoSetOfGood = CMallSystem.GetLowestPayInfoSetOfGood(dataByKey, CMallSystem.ResBuyTypeToPayType(product.Cfg.bMoneyType)); CHeroSkinBuyManager.OpenBuyHeroForm(uiEvent.m_srcFormScript, heroId, lowestPayInfoSetOfGood, enUIEventID.Mall_Mystery_On_Buy_Item); } else { CHeroSkinBuyManager.OpenBuyHeroForm(uiEvent.m_srcFormScript, heroId, new stPayInfoSet(), enUIEventID.None); } } } }
public static stPayInfoSet GetPayInfoSetOfGood(COM_ITEM_TYPE itemType, uint itemID) { CMallMysteryShop instance = Singleton <CMallMysteryShop> .GetInstance(); stPayInfoSet set = new stPayInfoSet(2); long doubleKey = GameDataMgr.GetDoubleKey((uint)itemType, itemID); CMallMysteryProduct product = new CMallMysteryProduct(); if (!instance.m_ProductDic.TryGetValue(doubleKey, out product)) { return(set); } uint index = (instance.Discount / 10) - 1; stPayInfo info = new stPayInfo(); switch (product.ItemType) { case COM_ITEM_TYPE.COM_OBJTYPE_HERO: { ResHeroCfgInfo dataByKey = GameDataMgr.heroDatabin.GetDataByKey(itemID); DebugHelper.Assert(dataByKey != null, "神秘商店配置的英雄ID有错,英雄表里不存在"); if (dataByKey != null) { info.m_payType = CMallSystem.ResBuyTypeToPayType(product.Cfg.bMoneyType); switch (info.m_payType) { case enPayType.GoldCoin: info.m_oriValue = (uint)dataByKey.dwBuyCoin; goto Label_01A7; case enPayType.DianQuan: info.m_oriValue = (uint)dataByKey.dwBuyCoupons; goto Label_01A7; case enPayType.Diamond: case enPayType.DiamondAndDianQuan: info.m_oriValue = (uint)dataByKey.dwBuyDiamond; goto Label_01A7; } break; } return(set); } case COM_ITEM_TYPE.COM_OBJTYPE_HEROSKIN: { ResHeroSkin heroSkin = CSkinInfo.GetHeroSkin(itemID); DebugHelper.Assert(heroSkin != null, "神秘商店配置的皮肤ID有错,皮肤表里不存在"); if (heroSkin != null) { info.m_payType = CMallSystem.ResBuyTypeToPayType(product.Cfg.bMoneyType); switch (info.m_payType) { case enPayType.DianQuan: info.m_oriValue = heroSkin.dwBuyCoupons; goto Label_01A7; case enPayType.Diamond: case enPayType.DiamondAndDianQuan: info.m_oriValue = heroSkin.dwBuyDiamond; goto Label_01A7; } break; } return(set); } } Label_01A7: if (info.m_oriValue == 0) { info.m_oriValue = (uint)product.Cfg.RouZheKou[product.Cfg.RouZheKou.Length - 1]; } if ((index < 0) || (index >= product.Cfg.RouZheKou.Length)) { info.m_payValue = info.m_oriValue; info.m_discountForDisplay = 0x2710; } else if (instance.IsRandomDiscount) { info.m_payValue = (uint)product.Cfg.RouZheKou[index]; info.m_discountForDisplay = instance.Discount * 100; } else { info.m_payValue = (uint)product.Cfg.iConfirmZheKou; info.m_discountForDisplay = instance.Discount * 100; } set.m_payInfos[set.m_payInfoCount] = info; set.m_payInfoCount++; return(set); }
public void InitData() { DateTime time = new DateTime(0x7f6, 1, 0x12); if (!this.m_Inited) { CRoleInfo masterRoleInfo = Singleton <CRoleInfoManager> .GetInstance().GetMasterRoleInfo(); if (masterRoleInfo != null) { DateTime time2 = Utility.ToUtcTime2Local((long)masterRoleInfo.getCurrentTimeSinceLogin()); DictionaryView <uint, ResAkaliShopCtrl> .Enumerator enumerator = GameDataMgr.mysteryShopCtlDict.GetEnumerator(); DateTime time3 = time; bool flag = false; bool flag2 = false; while (enumerator.MoveNext()) { KeyValuePair <uint, ResAkaliShopCtrl> current = enumerator.Current; ResAkaliShopCtrl ctrl = current.Value; DateTime time4 = Utility.StringToDateTime(Utility.UTF8Convert(ctrl.szOpenTime), DateTime.MinValue); DateTime time5 = Utility.StringToDateTime(Utility.UTF8Convert(ctrl.szCloseTime), DateTime.MinValue); if ((time2.CompareTo(time4) >= 0) && (time2.CompareTo(time5) <= 0)) { this.m_ShopID = ctrl.dwShopID; this.m_Products.Clear(); this.m_ProductDic.Clear(); this.m_StartTime = time4; this.m_EndTime = time5; this.m_LimitBuyCnt = ctrl.dwTotalBuyNumLimit; this.m_BoughtCnt = 0; switch (((RES_AKALISHOPZHEKOU_TYPE)ctrl.bZheKouType)) { case RES_AKALISHOPZHEKOU_TYPE.RES_AKALISHOPZHEKOU_CONFIRM: this.m_IsRandomDiscount = false; this.m_Discount = (uint)ctrl.iConfirmZheKou; this.m_HasGotDiscount = true; break; case RES_AKALISHOPZHEKOU_TYPE.RES_AKALISHOPZHEKOU_RANDOM: this.m_IsRandomDiscount = true; this.m_Discount = 100; this.m_HasGotDiscount = false; break; } DictionaryView <uint, ResAkaliShopGoods> .Enumerator enumerator2 = GameDataMgr.mysteryShopProductDict.GetEnumerator(); while (enumerator2.MoveNext()) { ResHeroCfgInfo dataByKey; ResHeroSkin heroSkin; ResHeroCfgInfo info3; long num; KeyValuePair <uint, ResAkaliShopGoods> pair2 = enumerator2.Current; ResAkaliShopGoods goodsCfg = pair2.Value; if (goodsCfg.dwShopID != ctrl.dwShopID) { continue; } CMallMysteryProduct item = new CMallMysteryProduct(goodsCfg); switch (item.ItemType) { case COM_ITEM_TYPE.COM_OBJTYPE_HERO: { dataByKey = GameDataMgr.heroDatabin.GetDataByKey(item.ItemID); if (dataByKey != null) { break; } continue; } case COM_ITEM_TYPE.COM_OBJTYPE_HEROSKIN: { heroSkin = CSkinInfo.GetHeroSkin(item.ItemID); if (heroSkin != null) { goto Label_0211; } continue; } default: goto Label_025C; } if (dataByKey.bIsPlayerUse > 0) { this.m_Products.Add(item); } goto Label_026E; Label_0211: info3 = GameDataMgr.heroDatabin.GetDataByKey(heroSkin.dwHeroID); if (info3 == null) { continue; } if ((heroSkin.bIsShow > 0) && (info3.bIsPlayerUse > 0)) { this.m_Products.Add(item); } goto Label_026E; Label_025C: this.m_Products.Add(item); Label_026E: num = GameDataMgr.GetDoubleKey((uint)item.ItemType, item.ItemID); if (!this.m_ProductDic.ContainsKey(num)) { this.m_ProductDic.Add(num, item); } } if (this.m_Products.Count == 0) { DebugHelper.Assert(false, "神秘商店配置了开启时段,但商店里没物品可卖"); } else { flag = true; } continue; } if ((time4.CompareTo(time2) > 0) && (time4.CompareTo(time3) < 0)) { time3 = time4; } } TimeSpan span = (TimeSpan)(time3 - time2); Singleton <CTimerManager> .GetInstance().RemoveTimerSafely(ref this.m_NextRefreshTimerSeq); long num2 = (long)(span.TotalSeconds * 1000.0); if ((num2 > 0L) && (num2 < 0x7fffffffL)) { Singleton <CTimerManager> .GetInstance().AddTimer((int)num2, 1, new CTimer.OnTimeUpHandler(this.RefreshShop)); flag2 = true; } TimeSpan span2 = (TimeSpan)(this.m_EndTime - time2); Singleton <CTimerManager> .GetInstance().RemoveTimerSafely(ref this.m_EndTimerSeq); long num3 = ((int)span2.TotalSeconds) * 0x3e8; if ((num3 > 0L) && (num3 < 0x7fffffffL)) { Singleton <CTimerManager> .GetInstance().AddTimer((int)num3, 1, new CTimer.OnTimeUpHandler(this.CloseShop)); } if (flag || flag2) { this.m_Inited = true; } } } }