public void QuestNext(string qname) { int fromId = UserProfile.InfoBasic.Position; while (true) { int index = MathTool.GetRandom(sceneItems.Count); var targetCell = sceneItems[index]; if (targetCell.Id == fromId) { continue; } if (!targetCell.CanBeReplaced()) { continue; } int qId = SceneBook.GetSceneQuestByName(qname); sceneItems[index] = new SceneQuest(targetCell.Id, targetCell.X, targetCell.Y, targetCell.Width, targetCell.Height, qId); sceneItems[index].MapSetting = true; UserProfile.InfoWorld.UpdatePosInfo(targetCell.Id, qId); UserProfile.InfoWorld.UpdatePosMapSetting(targetCell.Id, true); break; } parent.Invalidate(); }
public void HiddenWay() { int fromId = UserProfile.InfoBasic.Position; foreach (var sceneObject in sceneItems) { if (sceneObject is SceneQuest) { var config = ConfigData.GetSceneQuestConfig((sceneObject as SceneQuest).EventId); if (config.Ename == "hiddeway" && sceneObject.Id != fromId) { UserProfile.InfoBasic.Position = sceneObject.Id; parent.Invalidate(); return; } } } while (true) { int index = MathTool.GetRandom(sceneItems.Count); var targetCell = sceneItems[index]; if (targetCell.Id == fromId) { continue; } if (!targetCell.CanBeReplaced()) { continue; } int qId = SceneBook.GetSceneQuestByName("hiddeway"); sceneItems[index] = new SceneQuest(targetCell.Id, targetCell.X, targetCell.Y, targetCell.Width, targetCell.Height, qId); sceneItems[index].MapSetting = true; UserProfile.InfoBasic.Position = targetCell.Id; UserProfile.InfoWorld.UpdatePosInfo(targetCell.Id, qId); UserProfile.InfoWorld.UpdatePosMapSetting(targetCell.Id, true); parent.Invalidate(); break; } }
public static List <SceneObject> RefreshSceneObjects(int id, int mapWidth, int mapHeight, SceneFreshReason reason) { List <ScenePosData> cachedMapData = new List <ScenePosData>(); var cachedSpecialData = new Dictionary <int, DbSceneSpecialPosData>(); var filePath = ConfigData.GetSceneConfig(id).TilePath; List <DbSceneSpecialPosData> specialDataList = new List <DbSceneSpecialPosData>(); if (reason != SceneFreshReason.Load || UserProfile.Profile.InfoWorld.PosInfos == null || UserProfile.Profile.InfoWorld.PosInfos.Count <= 0) {//重新生成 UserProfile.InfoBasic.DungeonRandomSeed = MathTool.GetRandom(int.MaxValue); Random r = new Random(UserProfile.InfoBasic.DungeonRandomSeed); SceneQuestBook.LoadSceneFile(mapWidth, mapHeight, filePath, r, cachedMapData, specialDataList); FilterSpecialData(specialDataList, cachedSpecialData); var questCellCount = cachedMapData.Count - cachedSpecialData.Count; GenerateSceneRandomInfo(id, questCellCount, cachedMapData, cachedSpecialData); } else {//从存档加载 Random r = new Random(UserProfile.InfoBasic.DungeonRandomSeed); SceneQuestBook.LoadSceneFile(mapWidth, mapHeight, filePath, r, cachedMapData, specialDataList); foreach (var posData in UserProfile.Profile.InfoWorld.PosInfos) { cachedSpecialData[posData.Id] = posData; } } List <SceneObject> sceneObjects = new List <SceneObject>(); foreach (var scenePosData in cachedMapData) { DbSceneSpecialPosData cachedData; cachedSpecialData.TryGetValue(scenePosData.Id, out cachedData); SceneObject so; if (cachedData != null) { switch (cachedData.Type) { case "Quest": so = new SceneQuest(scenePosData.Id, scenePosData.X, scenePosData.Y, scenePosData.Width, scenePosData.Height, cachedData.Info); so.Disabled = cachedData.Disabled; break; case "Warp": so = new SceneWarp(scenePosData.Id, scenePosData.X, scenePosData.Y, scenePosData.Width, scenePosData.Height, cachedData.Info); so.Disabled = cachedData.Disabled; if (ConfigData.GetSceneConfig(id).Type == SceneTypes.Common && reason == SceneFreshReason.Warp) { cachedData.Disabled = true; so.Disabled = true;//如果是切场景,切到战斗场景,所有传送门自动关闭 } break; default: so = new SceneTile(scenePosData.Id, scenePosData.X, scenePosData.Y, scenePosData.Width, scenePosData.Height); break; } so.Flag = cachedData.Flag; so.MapSetting = cachedData.MapSetting; } else { so = new SceneTile(scenePosData.Id, scenePosData.X, scenePosData.Y, scenePosData.Width, scenePosData.Height); break; so.Disabled = true; //throw new Exception("RefreshSceneObjects error"); } sceneObjects.Add(so); } return(sceneObjects); }