예제 #1
0
        //随机生成地图内各传送门的目标地图
        public static void CreateRandomGates(int MapCode, FazhenMapData MapData)
        {
            //取得这个地图编号对应的传送门静态数据
            SystemFazhenMapData sysMapData = null;

            if (!m_AllMapGatesStaticData.TryGetValue(MapCode, out sysMapData))
            {
                return;
            }
            if (null == sysMapData)
            {
                return;
            }

            List <int> randgates = new List <int>();

            foreach (int gateid in sysMapData.listGateID)
            {
                   {
                    int index = Global.GetRandomNumber(0, randgates.Count + 1);

                    randgates.Insert(index, gateid);
                }
            }

            if (randgates.Count != sysMapData.listDestMapCode.Count)
            {
                return;
            }

            GameMap gameMap = null;

            if (!GameManager.MapMgr.DictMaps.TryGetValue(MapData.MapCode, out gameMap) || null == gameMap)
            {
                return;
            }

            lock (MapData.Telegates)
            {
                for (int i = 0; i < randgates.Count; i++)
                {
                    MapTeleport mapTeleport = null;
                    if (!gameMap.MapTeleportDict.TryGetValue(sysMapData.listGateID[i], out mapTeleport) || null == mapTeleport)
                    {
                        continue;
                    }

                    SingleFazhenTelegateData newGatedata = new SingleFazhenTelegateData();
                    newGatedata.usedAlready        = false;
                    newGatedata.gateId             = randgates[i];
                    newGatedata.destMapCode        = sysMapData.listDestMapCode[i];
                    newGatedata.SpecialDestMapCode = sysMapData.SpecialDestMapCode;
                    newGatedata.SpecialDestX       = sysMapData.SpecialDestX;
                    newGatedata.SpecialDestY       = sysMapData.SpecialDestY;
                    newGatedata.destX = mapTeleport.ToX;
                    newGatedata.destY = mapTeleport.ToY;
                    MapData.Telegates[newGatedata.gateId] = newGatedata;
                }
            }
        }
예제 #2
0
        public static void CreateRandomGates(int MapCode, FazhenMapData MapData)
        {
            SystemFazhenMapData sysMapData = null;

            if (LuoLanFaZhenCopySceneManager.m_AllMapGatesStaticData.TryGetValue(MapCode, out sysMapData))
            {
                if (null != sysMapData)
                {
                    List <int> randgates = new List <int>();
                    foreach (int gateid in sysMapData.listGateID)
                    {
                        int index = Global.GetRandomNumber(0, randgates.Count + 1);
                        randgates.Insert(index, gateid);
                    }
                    if (randgates.Count == sysMapData.listDestMapCode.Count)
                    {
                        GameMap gameMap = null;
                        if (GameManager.MapMgr.DictMaps.TryGetValue(MapData.MapCode, out gameMap) && null != gameMap)
                        {
                            lock (MapData.Telegates)
                            {
                                for (int i = 0; i < randgates.Count; i++)
                                {
                                    MapTeleport mapTeleport = null;
                                    if (gameMap.MapTeleportDict.TryGetValue(sysMapData.listGateID[i], out mapTeleport) && null != mapTeleport)
                                    {
                                        SingleFazhenTelegateData newGatedata = new SingleFazhenTelegateData();
                                        newGatedata.usedAlready        = false;
                                        newGatedata.gateId             = randgates[i];
                                        newGatedata.destMapCode        = sysMapData.listDestMapCode[i];
                                        newGatedata.SpecialDestMapCode = sysMapData.SpecialDestMapCode;
                                        newGatedata.SpecialDestX       = sysMapData.SpecialDestX;
                                        newGatedata.SpecialDestY       = sysMapData.SpecialDestY;
                                        newGatedata.destX = mapTeleport.ToX;
                                        newGatedata.destY = mapTeleport.ToY;
                                        MapData.Telegates[newGatedata.gateId] = newGatedata;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #3
0
 public static void initialize()
 {
     try
     {
         int[] nParams = GameManager.systemParamsList.GetParamValueIntArrayByName("LuoLanFaZhen", ',');
         if (nParams.Length != 5)
         {
             throw new Exception("systemParamsList.LuoLanFaZhen参数数量应该是5");
         }
         LuoLanFaZhenCopySceneManager.SpecialBossID       = nParams[0];
         LuoLanFaZhenCopySceneManager.SpecialMapCode      = nParams[1];
         LuoLanFaZhenCopySceneManager.SpecialAwardRate    = nParams[2];
         LuoLanFaZhenCopySceneManager.LuoLanFaZhenFubenID = nParams[3];
         LuoLanFaZhenCopySceneManager.SpecialTeleRate     = nParams[4];
         SystemXmlItem systemFuBenItem = null;
         if (GameManager.systemFuBenMgr.SystemXmlItemDict.TryGetValue(LuoLanFaZhenCopySceneManager.LuoLanFaZhenFubenID, out systemFuBenItem) && systemFuBenItem != null)
         {
             LuoLanFaZhenCopySceneManager.FinalBossID = systemFuBenItem.GetIntValue("BossID", -1);
         }
         LuoLanFaZhenCopySceneManager.systemLuoLanFaZhen.LoadFromXMlFile("Config/LuoLanFaZhen.xml", "", "MapID", 0);
         List <int> listMapCode = LuoLanFaZhenCopySceneManager.systemLuoLanFaZhen.SystemXmlItemDict.Keys.ToList <int>();
         foreach (int mapcode in listMapCode)
         {
             SystemXmlItem systemFazhenMap = null;
             if (LuoLanFaZhenCopySceneManager.systemLuoLanFaZhen.SystemXmlItemDict.TryGetValue(mapcode, out systemFazhenMap) && systemFazhenMap != null)
             {
                 SystemFazhenMapData sysMapData = new SystemFazhenMapData();
                 sysMapData.MapCode = mapcode;
                 int[] specailParams = systemFazhenMap.GetIntArrayValue("TeShuMapID", '|');
                 if (specailParams != null && specailParams.Length >= 3)
                 {
                     sysMapData.SpecialDestMapCode = specailParams[0];
                     sysMapData.SpecialDestX       = specailParams[1];
                     sysMapData.SpecialDestY       = specailParams[2];
                 }
                 else
                 {
                     sysMapData.SpecialDestMapCode = -1;
                     sysMapData.SpecialDestX       = -1;
                     sysMapData.SpecialDestY       = -1;
                 }
                 int[]    gateIds         = systemFazhenMap.GetIntArrayValue("ChuanSongMenID", '|');
                 string   strDestMapTemp  = systemFazhenMap.GetStringValue("MuDidiID");
                 string[] strDestMapTemp2 = strDestMapTemp.Split(new char[]
                 {
                     '|'
                 });
                 if (gateIds.Length != strDestMapTemp2.Length)
                 {
                     throw new Exception("LuoLanFaZhen.xml传送门数量和目标地图数量不一致");
                 }
                 for (int i = 0; i < gateIds.Length; i++)
                 {
                     sysMapData.listGateID.Add(gateIds[i]);
                 }
                 for (int i = 0; i < strDestMapTemp2.Length; i++)
                 {
                     string[] strDestMapTemp3 = strDestMapTemp2[i].Split(new char[]
                     {
                         ','
                     });
                     sysMapData.listDestMapCode.Add(Convert.ToInt32(strDestMapTemp3[0]));
                 }
                 LuoLanFaZhenCopySceneManager.m_AllMapGatesStaticData[mapcode] = sysMapData;
             }
         }
     }
     catch (Exception)
     {
         throw new Exception("罗兰法阵配置项出错");
     }
 }