public static NMap RoomWallMap(int width, int height) { Grid2DInt map = Grid2D <int> .Create(width, height, 255) as Grid2DInt; NBSP.Division(map, new RectInt(0, 0, map.Width, map.Height)); var blobs = NBlob.Find(map, 0); blobs.FillByLeftBlob(map, 12); blobs.AxisConnect(map, 0); //NLocationRecogition.FindDoor(map, 5); return(map); }
public static NMap MazeWallMap(int width, int height, float rate) { NMap map = new NMap(width, height); map.Noise(rate); CA_Rule rule = new CA_Rule(CAClassicRules.GetClassicRule("Mazectric")); map = rule.Run(map, 3); var blobs = NBlob.Find(map, 0); blobs.NoiseConnect(map, 0); return(map); }
public static NMap ArenaBlockMap(int width, int height, float rate, int holeLeft) { NMap map = new NMap(width, height); map.Noise(rate); CA_Rule rule = new CA_Rule("s45678b5678"); map = rule.Run(map, 3); var blobs = NBlob.Find(map, 255); blobs.FillByLeftBlob(map, holeLeft, 0); blobs = NBlob.Find(map, 0); blobs.NoiseConnect(map, 0); return(map); }
public static NBlob Find(NMap map, byte valid) { var res = new NBlob(); var tmp = new NMap(map); for (int i = 0; i < tmp.DataSize(); i++) { if (tmp.GetBlock(i) == valid) { var set = new NLocateSet(); FloodFillBlob(tmp, new NLocate(i % tmp.Width, i / tmp.Width), set, valid); res.Blobs.Add(set); } } return(res); }
public static NMap CaveWallMap(int width, int height, float rate, int holeLeft)//dig map { NMap map = new NMap(width, height); map.Noise(rate); CellularAutomata2D rule = new CellularAutomata2D("s45678b5678"); map = rule.Run(map, 3); var blobs = NBlob.Find(map, 255); blobs.FillByLeftBlob(map, holeLeft, 0); blobs.NoiseConnect(map, 255); map = map.InverseVal(); bool HorV = RandomNum.Roll(0.5f); NLocate Entrance = new NLocate(); NLocate Exit = new NLocate(); if (HorV) { Entrance = RandomSelect <NLocate> .Select(new List <NLocate>(map.LeftLocates(0))).Right(); Exit = RandomSelect <NLocate> .Select(new List <NLocate>(map.RightLocates(0))).Left(); } else { Entrance = RandomSelect <NLocate> .Select(new List <NLocate>(map.TopLocates(0))).Down(); Exit = RandomSelect <NLocate> .Select(new List <NLocate>(map.BottomLocates(0))).Up(); } map.SetBlock(Entrance.Square(1), 0); map.SetBlock(Exit.Square(1), 0); map.SetBlock(Entrance, (byte)DungeonBuilding.Port); map.SetBlock(Exit, (byte)DungeonBuilding.Port); NLocationRecogition.FindTreasure(map, 3); NLocationRecogition.FindDeadEnd(map, 3); NLocationRecogition.FindPassage(map, 4); return(map); }