Esempio n. 1
0
        private static void ParseXmlItem(SystemXmlItem systemXmlItem, List <PopupWinItem> popupWinItemList)
        {
            int    id         = systemXmlItem.GetIntValue("ID", -1);
            int    hintFileID = systemXmlItem.GetIntValue("HintFileID", -1);
            string times      = systemXmlItem.GetStringValue("Times");

            if (!string.IsNullOrEmpty(times))
            {
                PopupWinTimeItem[] popupWinTimeItemArray = PopupWinMgr.ParsePopupWinTimeItems(times);
                if (null == popupWinTimeItemArray)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("解析弹窗配置表中的时间项为数组时失败, ID={0}", id), null, true);
                }
                else
                {
                    PopupWinItem popupWinItem = new PopupWinItem
                    {
                        ID         = id,
                        HintFileID = hintFileID,
                        Times      = popupWinTimeItemArray
                    };
                    popupWinItemList.Add(popupWinItem);
                }
            }
        }
Esempio n. 2
0
        public static void LoadPopupWinItemList()
        {
            XElement xml      = null;
            string   fileName = "Config/PopupWin.xml";

            try
            {
                xml = XElement.Load(Global.GameResPath(fileName));
                if (null == xml)
                {
                    throw new Exception(string.Format("加载系统xml配置文件:{0}, 失败。没有找到相关XML配置文件!", fileName));
                }
            }
            catch (Exception)
            {
                throw new Exception(string.Format("加载系统xml配置文件:{0}, 失败。没有找到相关XML配置文件!", fileName));
            }
            List <PopupWinItem>    popupWinItemList = new List <PopupWinItem>();
            IEnumerable <XElement> nodes            = xml.Elements();

            foreach (XElement node in nodes)
            {
                SystemXmlItem systemXmlItem = new SystemXmlItem
                {
                    XMLNode = node
                };
                PopupWinMgr.ParseXmlItem(systemXmlItem, popupWinItemList);
            }
            PopupWinMgr.PopupWinItemList = popupWinItemList;
        }
Esempio n. 3
0
 private static int ReloadXmlFile_config_popupwin()
 {
     try
     {
         PopupWinMgr.LoadPopupWinItemList();
     }
     catch (Exception)
     {
         return(-1);
     }
     return(0);
 }
Esempio n. 4
0
        public static void ProcessPopupWins()
        {
            DateTime now    = TimeUtil.NowDateTime();
            int      day    = now.DayOfYear;
            int      hour   = now.Hour;
            int      minute = now.Minute;

            if (day != PopupWinMgr.LastPopupWinDay)
            {
                PopupWinMgr.LastPopupWinDay             = day;
                PopupWinMgr.LastPopupWinTimeItem.Hour   = hour;
                PopupWinMgr.LastPopupWinTimeItem.Minute = minute;
            }
            else if (hour != PopupWinMgr.LastPopupWinTimeItem.Hour || minute != PopupWinMgr.LastPopupWinTimeItem.Minute)
            {
                List <PopupWinItem> popupWinItemList = PopupWinMgr.PopupWinItemList;
                if (popupWinItemList == null || popupWinItemList.Count <= 0)
                {
                    PopupWinMgr.LastPopupWinDay             = day;
                    PopupWinMgr.LastPopupWinTimeItem.Hour   = hour;
                    PopupWinMgr.LastPopupWinTimeItem.Minute = minute;
                }
                else
                {
                    for (int i = 0; i < popupWinItemList.Count; i++)
                    {
                        if (PopupWinMgr.CanPopupWin(popupWinItemList[i], PopupWinMgr.LastPopupWinTimeItem, hour, minute))
                        {
                            string strcmd = string.Format("{0}", popupWinItemList[i].HintFileID);
                            GameManager.ClientMgr.NotifyAllPopupWinMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, null, strcmd);
                        }
                    }
                    PopupWinMgr.LastPopupWinDay             = day;
                    PopupWinMgr.LastPopupWinTimeItem.Hour   = hour;
                    PopupWinMgr.LastPopupWinTimeItem.Minute = minute;
                }
            }
        }