private Func <int, int> GetHolesInLine(int largestDimension, Func <string> GetAtt, Func <string> GetCh, string getNumbType, ref string var) { switch (getNumbType) { case ("manyForMedium"): var = "max"; int max = Int32.Parse(GetCh()); return(RDMazeGenSettings.ManyHolesForMediumLine(4, largestDimension)); case ("oneHole"): return(RDMazeGenSettings.OneHoleInLine); case ("constantHoles"): var = "numbHoles"; int numb = Int32.Parse(GetCh()); return(RDMazeGenSettings.ConstantHolesInLine(numb)); default: throw new ArgumentException("Not a valid way to get the number of holes in a line."); } }
private Func <int, int, int> GetSplitLocation(Func <string> GetAtt, Func <string> GetCh, string splitLocType, ref string var) { switch (splitLocType) { case ("randomWithBorder"): var = "border"; int border = Int32.Parse(GetCh()); return(RDMazeGenSettings.RandomSplitLocation(border)); case ("random"): return(RDMazeGenSettings.RandomSplitLocation()); case ("centerAsRegionShrinks"): var = "maxSize"; int maxSize = Int32.Parse(GetCh()); var = "variation"; int variation = Int32.Parse(GetCh()); var = "shouldReverse"; bool shouldReverse = Boolean.Parse(GetCh()); return(RDMazeGenSettings.CenterSplitAsRegionShrinks(maxSize, variation, shouldReverse)); default: throw new ArgumentException("Not a valid way to get the split location."); } }
private Func <Region, double> GetIgnoreRegionChance(Func <string> GetAtt, Func <string> GetCh, string igType, ref string var) { switch (igType) { case ("idealRegionDims"): var = "idealWidth"; int idealWidth = Int32.Parse(GetCh()); var = "idealHeight"; int idealHeight = Int32.Parse(GetCh()); var = "minimumWidth"; int minimumWidth = Int32.Parse(GetCh()); var = "minimumHeight"; int minimumHeight = Int32.Parse(GetCh()); var = "ignoreWidthBelow"; int ignoreWidthBelow = Int32.Parse(GetCh()); var = "ignoreHeightBelow"; int ignoreHeightBelow = Int32.Parse(GetCh()); return(RDMazeGenSettings.IdealRegionFunc(new Location(idealWidth, idealHeight), new Location(minimumWidth, minimumHeight), new Location(ignoreWidthBelow, ignoreHeightBelow))); case ("idealRegionArea"): var = "idealArea"; int idealArea = Int32.Parse(GetCh()); var = "minimumArea"; int minimumArea = Int32.Parse(GetCh()); var = "ignoredAreaBelow"; int ignoreBelow = Int32.Parse(GetCh()); return(RDMazeGenSettings.IdealRegionFunc(idealArea, minimumArea, ignoreBelow)); case ("ratio"): var = "idealRatio"; float idealRatio = Single.Parse(GetCh()); var = "farthestRatio"; float farthestRatio = Single.Parse(GetCh()); return(RDMazeGenSettings.IdealDimensionsFunc(idealRatio, farthestRatio)); default: throw new ArgumentException("Not a valid \"Ignore Region Chance\" structure."); } }
private Func <Location, bool> GetSplitDir(Func <string> GetAtt, Func <string> GetCh, string splitDirType, ref string var) { switch (splitDirType) { case ("constantSplitChance"): var = "chanceHorizontal"; float chanceHor = Single.Parse(GetCh()); return(RDMazeGenSettings.ConstantSplitChance(chanceHor)); case ("splitLargerDimension"): return(RDMazeGenSettings.SplitLargerDimension()); default: throw new ArgumentException("Not a valid way to choose the split direction."); } }
public void SetSettings(GeneratorSettings s) { Settings = s as RDMazeGenSettings; }
private Generator GetBaseGenerator(string genType, XmlNode genNode) { string var = ""; bool wrapX, wrapY; Func <string> GetAtt = () => GetAttribute(genNode, var), GetCh = () => GetChild(genNode, var).InnerText, GetAtt2, GetCh2; Generator ret; switch (genType) { case ("RDMaze"): ret = new RDMazeGen(); var = "sizeX"; int sizeX = Int32.Parse(GetCh()); var = "sizeY"; int sizeY = Int32.Parse(GetCh()); RDMazeGenSettings sett = new RDMazeGenSettings(new Location(sizeX, sizeY)); sett.FillPatterns.Clear(); var = "wrapX"; wrapX = Boolean.Parse(GetCh()); sett.WrapX = wrapX; var = "wrapY"; wrapY = Boolean.Parse(GetCh()); sett.WrapY = wrapY; XmlNode igRegNode = GetChild(genNode, "ignoreRegionChance"); GetAtt2 = () => GetAttribute(igRegNode, var); GetCh2 = () => GetChild(igRegNode, var).InnerText; var = "type"; string igType = GetAtt2(); sett.IgnoreRegionChance = GetIgnoreRegionChance(GetAtt2, GetCh2, igType, ref var); XmlNode splitDirNode = GetChild(genNode, "splitDirection"); GetAtt2 = () => GetAttribute(splitDirNode, var); GetCh2 = () => GetChild(splitDirNode, var).InnerText; var = "type"; string splDrType = GetAtt2(); sett.ShouldSplitHorizontally = GetSplitDir(GetAtt2, GetCh2, splDrType, ref var); XmlNode splitLocationNode = GetChild(genNode, "splitLocation"); GetAtt2 = () => GetAttribute(splitLocationNode, var); GetCh2 = () => GetChild(splitLocationNode, var).InnerText; var = "type"; string splLocType = GetAtt2(); sett.SplitLocation = GetSplitLocation(GetAtt2, GetCh2, splLocType, ref var); XmlNode numbHolesNode = GetChild(genNode, "numbHoles"); GetAtt2 = () => GetAttribute(numbHolesNode, var); GetCh2 = () => GetChild(numbHolesNode, var).InnerText; var = "type"; string getNumbType = GetAtt2(); sett.HolesInLine = GetHolesInLine(Math.Max(sizeX, sizeY), GetAtt2, GetCh2, getNumbType, ref var); ret.SetSettings(sett); return(ret); case ("Roguelike"): ret = new RoguelikeGen(); RoguelikeGenSettings set = new RoguelikeGenSettings(); set.FillPatterns.Clear(); var = "wrapX"; set.WrapAroundX = Boolean.Parse(GetCh()); var = "wrapY"; set.WrapAroundY = Boolean.Parse(GetCh()); var = "roomColumns"; int roomCols = Int32.Parse(GetCh()); var = "roomRows"; int roomRows = Int32.Parse(GetCh()); set.NumberOfNodes = new Location(roomCols, roomRows); var = "roomWidth"; int roomWidth = Int32.Parse(GetCh()); var = "roomHeight"; int roomHeight = Int32.Parse(GetCh()); set.RoomDimensions = new Location(roomWidth, roomHeight); var = "roomWidthVarianceMin"; int roomWidthVarianceMin = Int32.Parse(GetCh()); var = "roomWidthVarianceMax"; int roomWidthVarianceMax = Int32.Parse(GetCh()); set.RoomXVariance = new Interval(roomWidthVarianceMin, roomWidthVarianceMax, true, 0); var = "roomHeightVarianceMin"; int roomHeightVarianceMin = Int32.Parse(GetCh()); var = "roomHeightVarianceMax"; int roomHeightVarianceMax = Int32.Parse(GetCh()); set.RoomYVariance = new Interval(roomHeightVarianceMin, roomHeightVarianceMax, true, 0); var = "verticalTunnelThickness"; int verticalTunnelThickness = Int32.Parse(GetCh()); var = "horizontalTunnelThickness"; int horizontalTunnelThickness = Int32.Parse(GetCh()); set.TunnelThickness = new Location(horizontalTunnelThickness, verticalTunnelThickness); var = "verticalTunnelLength"; int verticalTunnelLength = Int32.Parse(GetCh()); var = "horizontalTunnelLength"; int horizontalTunnelLength = Int32.Parse(GetCh()); set.TunnelLength = new Location(horizontalTunnelLength, verticalTunnelLength); var = "roomChance"; set.PercentRooms = Single.Parse(GetCh()); ret.SetSettings(set); return(ret); default: throw new ArgumentException(); } }