/// <summary> /// 从主循环移除 /// </summary> /// <param name="item"></param> public static void RemoveProcess(IClue item) { if (processFrameDic.ContainsKey(item)) { processFrameDic.Remove(item); removeList.Add(item); Debug.LogFormat("移除IUpdate: {0},当前队列数量 {1}", item, processFrameDic.Count); } }
/// <summary> /// 添加到主循环 /// </summary> /// <param name="item"></param> public static void AddProcess(IClue item) { if (!processFrameDic.ContainsKey(item)) { addList.Add(item); processFrameDic.Add(item, m_runFrame); Debug.LogFormat("添加IUpdate: {0},当前队列数量 {1}", item, processFrameDic.Count); } }
//Special Cases: //Employees in the same department //Manager of the employee public static IClue GenerateRandomClueFromEmployee(Employee employee) { int roll = rnd.Next(1, 101); //Generating random clue type ClueTypes randomClueType = ClueTypes.Useless; switch (employee.rank) { case Person.RankEnum.Employee: randomClueType = PickClueCategory(roll, LowLevelEmployeeClueProbs); break; case Person.RankEnum.Manager: randomClueType = PickClueCategory(roll, ManagerEmployeeClueProbs); break; case Person.RankEnum.Executive: randomClueType = PickClueCategory(roll, ExecEmployeeClueProbs); break; case Person.RankEnum.CEO: randomClueType = PickClueCategory(roll, CEOEmployeeClueProbs); break; default: break; } //if (Employee.currentLocation == Target.currentLocation) //{ // //} IClue generatedClue = null; int clueCategoryRoll = rnd.Next(1, 101); if (clueCategoryRoll <= 70) { var features = Game.S.target.features.getTrueOrnaments(); Feature targetFeature = features.PickRandom(); generatedClue = new ClueFeature(randomClueType, targetFeature); } else if (clueCategoryRoll <= 90) { var floor = Game.S.target.CurrentLocation.floor; generatedClue = new ClueFloor(randomClueType, floor); } else { var room = Game.S.target.CurrentLocation; generatedClue = new ClueRoom(randomClueType, room); } return(generatedClue); }
private static string GenerateDialogueFrom(IClue clue) { if (clue is ClueFeature) { return(generateFeatureDialogue((ClueFeature)clue)); } if (clue is ClueFloor) { return(generateFloorDialogue((ClueFloor)clue)); } if (clue is ClueRoom) { return(generateRoomDialogue((ClueRoom)clue)); } return("Who?"); }
public static void update() { m_runFrame++; int len = removeList.Count; for (int i = 0; i < len; ++i) { processList.Remove(removeList[i]); } removeList.Clear(); len = addList.Count; for (int i = 0; i < len; ++i) { processList.Add(addList[i]); } addList.Clear(); len = processList.Count; for (int i = 0; i < len; ++i) { IClue item = processList[i]; try { if (processFrameDic.ContainsKey(item)) { int lastFrame = m_runFrame - processFrameDic[item]; if (lastFrame % item.interval == 0) { item.ToUpdate(); } } } catch (Exception e) { Debug.LogException(e); continue; } } }
public CrossWordGuardian ToCrossWordModelGuardian(ICrossDictionary dictionary) { var model = new CrossWordGuardian(); var clueList = new List <IClue>(); var patterns = new List <CrossPattern>(); // across = horizontal foreach (var p in _horizontalPatterns) { patterns.Add(p); } // down = vertical foreach (var p in _verticalPatterns) { patterns.Add(p); } var sortedPatterns = patterns.OrderBy(s => s.StartY).ThenBy(s => s.StartX); int gridNumber = 0; CrossPattern lastPattern = null; var coordinateMap = new Dictionary <CrossPattern, Coordinate>(); // when using a database - read in all descriptions once dictionary.AddAllDescriptions(patterns.Select(a => a.GetWord()).ToList()); foreach (var p in sortedPatterns) { if (lastPattern != null && lastPattern.StartX == p.StartX && lastPattern.StartY == p.StartY) { // patterns starts at same index } else { // pattern start at new index, increment gridNumber++; } // store grid number as a part of the coordinate coordinateMap.Add(p, new Coordinate(p.StartX, p.StartY, gridNumber)); // and store the clues var word = p.GetWord(); var description = p.IsPuzzle ? "[PUZZLE]" : GetDescription(dictionary, word); var clue = new IClue(); clue.Id = string.Format("{0}-{1}", gridNumber, p.IsHorizontal ? "across" : "down"); clue.Number = gridNumber; clue.HumanNumber = gridNumber.ToString(); clue.Clue = string.Format("{0} ({1})", description, p.Length); clue.Direction = p.IsHorizontal ? Direction.Across : Direction.Down; clue.Length = p.Length; clue.Group = new string[] { clue.Id }; clue.Position = new IPosition() { X = p.StartX, Y = p.StartY }; clue.Solution = word; clue.SeparatorLocations = new SeparatorLocations(); clueList.Add(clue); // save last pattern to compare with lastPattern = p; } model.Id = null; model.Name = "Generated Crossword"; model.Creator = new ICreator() { Name = "the amazing crossword generator", WebUrl = "" }; model.Entries = clueList.ToArray(); model.Dimensions = new IDimensions { Cols = _sizeX, Rows = _sizeY }; model.CrosswordType = CrosswordType.Quick; model.SolutionAvailable = true; model.Pdf = null; model.Instructions = null; model.Date = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); model.DateSolutionAvailable = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); return(model); }