Пример #1
0
        public static int GetNextMapCodeByNPCID(int mapCode, int npcID)
        {
            WuXingNPCItem wuXingNPCItem = null;
            string        key           = string.Format("{0}_{1}", mapCode, npcID);
            int           dayID         = TimeUtil.NowDateTime().DayOfYear;

            lock (WuXingMapMgr.WuXingNPCDict)
            {
                if (!WuXingMapMgr.WuXingNPCDict.TryGetValue(key, out wuXingNPCItem))
                {
                    return(-1);
                }
                if (null == wuXingNPCItem.MapItem)
                {
                    return(-1);
                }
                if (dayID != wuXingNPCItem.MapItem.DayID)
                {
                    wuXingNPCItem.MapItem.DayID           = dayID;
                    wuXingNPCItem.MapItem.GoToMapCodeList = WuXingMapMgr.RandomIntList(wuXingNPCItem.MapItem.GoToMapCodeList);
                }
                if (wuXingNPCItem.MapItem.GoToMapCodeList == null || wuXingNPCItem.MapItem.OtherNPCIDList == null || wuXingNPCItem.MapItem.GoToMapCodeList.Count != wuXingNPCItem.MapItem.OtherNPCIDList.Count)
                {
                    return(-1);
                }
                for (int i = 0; i < wuXingNPCItem.MapItem.OtherNPCIDList.Count; i++)
                {
                    if (npcID == wuXingNPCItem.MapItem.OtherNPCIDList[i])
                    {
                        return(wuXingNPCItem.MapItem.GoToMapCodeList[i]);
                    }
                }
            }
            return(-1);
        }
Пример #2
0
        /// <summary>
        /// 获取要传送的地图编号根据NPCID和当前地图的ID
        /// </summary>
        /// <param name="mapCode"></param>
        /// <param name="npcID"></param>
        /// <returns></returns>
        public static int GetNeedGoodsIDByNPCID(int mapCode, int npcID)
        {
            WuXingNPCItem wuXingNPCItem = null;
            string        key           = string.Format("{0}_{1}", mapCode, npcID);

            //先锁定
            lock (WuXingNPCDict)
            {
                if (!WuXingNPCDict.TryGetValue(key, out wuXingNPCItem))
                {
                    return(-1);
                }

                return(wuXingNPCItem.NeedGoodsID);
            }
        }
Пример #3
0
        public static int GetNeedGoodsIDByNPCID(int mapCode, int npcID)
        {
            WuXingNPCItem wuXingNPCItem = null;
            string        key           = string.Format("{0}_{1}", mapCode, npcID);
            int           result;

            lock (WuXingMapMgr.WuXingNPCDict)
            {
                if (!WuXingMapMgr.WuXingNPCDict.TryGetValue(key, out wuXingNPCItem))
                {
                    result = -1;
                }
                else
                {
                    result = wuXingNPCItem.NeedGoodsID;
                }
            }
            return(result);
        }
Пример #4
0
        private static void ParseWuXingXmlItem(SystemXmlItem systemXmlItem)
        {
            int           npcID         = systemXmlItem.GetIntValue("NPCID", -1);
            int           mapCode       = systemXmlItem.GetIntValue("MapCode", -1);
            int           needGoodsID   = systemXmlItem.GetIntValue("NeedGoodsID", -1);
            int           globalID      = systemXmlItem.GetIntValue("GlobalID", -1);
            string        otherNPCIDs   = systemXmlItem.GetStringValue("OtherNPCIDs");
            string        goToMaps      = systemXmlItem.GetStringValue("GoToMaps");
            WuXingMapItem wuXingMapItem = WuXingMapMgr.ParseGlobalConfigItem(globalID, otherNPCIDs, goToMaps);
            WuXingNPCItem wuXingNPCItem = new WuXingNPCItem
            {
                NPCID       = npcID,
                MapCode     = mapCode,
                NeedGoodsID = needGoodsID,
                MapItem     = wuXingMapItem
            };
            string key = string.Format("{0}_{1}", mapCode, npcID);

            WuXingMapMgr.WuXingNPCDict[key] = wuXingNPCItem;
        }