//-------------------------------------------------------- // [Author]: 第二世界 // [ Date ]: Wednesday, July 18, 2018 //-------------------------------------------------------- using Snxxz.UI; using System; using System.Collections.Generic; using LitJson; [XLua.LuaCallCSharp] public class DayPackageItemClassModel : Model, IPlayerLoginOk, IOpenServerActivity { int m_SelectIndex = 0; VipModel vipModel { get { return ModelCenter.Instance.GetModel(); } } public int selectIndex { get { return m_SelectIndex; } set { if (m_SelectIndex != value) { m_SelectIndex = value; if (selectUpdate != null) { selectUpdate(value); } } } } public class DayGift { public string title; // 礼包名 public int getCount; // 已获得次数 public int[][] items; public int money; public string orderInfo; } public int[] recordIDs; public Dictionary m_RechargeDict = new Dictionary(); public event Action selectUpdate; public event Action onStateUpdate; public override void Init() { OpenServerActivityCenter.Instance.Register(23, this); recordIDs = ConfigParse.GetMultipleStr(FuncConfigConfig.Get("DayFreeGoldGift").Numerical2); if (!m_RechargeDict.ContainsKey(0)) { var _sortArray = JsonMapper.ToObject(FuncConfigConfig.Get("DayFreeGoldGift").Numerical1); foreach (int recordID in recordIDs) { if (recordID == 0) { m_RechargeDict[recordID] = new DayGift() { title = "免费礼包", items = _sortArray, getCount = 0, money = 0, }; } else { var ctg = CTGConfig.Get(recordID); OrderInfoConfig config; vipModel.TryGetOrderInfo(recordID, out config); m_RechargeDict[recordID] = new DayGift() { title = ctg.Title, items = LitJson.JsonMapper.ToObject(ctg.GainItemList), getCount = 0, money = (int)config.PayRMBNum, orderInfo = config.OrderInfo, }; } } } } private const int Redpoint_key1 = 20923; public Redpoint redPointStre1 = new Redpoint(209, Redpoint_key1); //每日免费礼包 public bool IsOpen { get { return FuncOpen.Instance.IsFuncOpen(185); } } public bool priorityOpen { get { return redPointStre1.state == RedPointState.Simple || redPointStre1.state == RedPointState.GetReward; } } public bool IsAdvance { get { return false; } } public override void UnInit() { } public void OnPlayerLoginOk() { IsShowTip(); } public DayGift GetDayGift(int index) { return m_RechargeDict[recordIDs[index]]; } public void IsShowTip() { if (!FuncOpen.Instance.IsFuncOpen(185)) return; if (m_RechargeDict.ContainsKey(0) && m_RechargeDict[0].getCount == 0) redPointStre1.state = RedPointState.Simple; else redPointStre1.state = RedPointState.None; } public void UpdateRechargeCount(HA110_tagMCCoinToGoldCountInfo package) { for (int i = 0; i < package.RecordCount; i++) { var _data = package.CTGCountInfoList[i]; if (m_RechargeDict.ContainsKey(_data.RecordID)) m_RechargeDict[_data.RecordID].getCount = _data.TodayPayCount; } if (onStateUpdate != null) onStateUpdate(selectIndex); } public void FreeGoldGiftState(HAA24_tagMCDayFreeGoldGiftState package) { m_RechargeDict[0].getCount = package.DayFreeGoldGiftState; if (onStateUpdate != null) onStateUpdate(selectIndex); IsShowTip(); } public void OpenFreePlat(string Title, float RMBNum, string OrderInfo) { if (!WindowCenter.Instance.IsOpen()) { WindowCenter.Instance.Open(true); } SDKUtility.Instance.FreePlatformPay(Title, RMBNum, OrderInfo); // DesignDebug.LogErrorFormat("礼包标题{0},所需金额{1},商品编号{2}", Title, RMBNum, OrderInfo); } public void RequestReward() { var sendInfo = new CA504_tagCMPlayerGetReward(); sendInfo.RewardType = (int)GotServerRewardType.Def_RewardType_DayPackageFree; sendInfo.DataEx = 0; sendInfo.DataExStrLen = 0; sendInfo.DataExStr = string.Empty; GameNetSystem.Instance.SendInfo(sendInfo); } }