Ejemplo n.º 1
0
	def addOtherDecor(self, TPtr, room, boxSize):
		for square in room.spawnableTiles:
			numToSpawn = random.randint(1, 4)
			for off in [[-1, 0], [1, 0], [0, 1], [0, -1]]:
				if self.climateGrid.getTile([square[0] + off[0], square[1] + off[1]]) != self.climateGrid.getTile(square):
					numToSpawn = 0
			for i in range(numToSpawn):
				coord = square[0] * (boxSize[0] + 1) + random.randint(1, boxSize[0]), square[1] * (boxSize[1] + 1) + random.randint(1, boxSize[1])
				if TPtr.getAtCoord(coord) == 0:
					tileset = int(TPtr.getAtCoord(coord, 0))
					if tileset == 0:
						type = random.randint(0, 9)
						if type == 9:
							#coord = (square[0] * (boxSize[0] + 1) + random.randint(1, boxSize[0]), square[1] * (boxSize[1] + 1) + random.randint(1, boxSize[1] - 1))
							foundOne = False
							for t in room.decorObjects:
								if (t.source[0] == coord[0] and (t.source[1] != coord[1] or t.source[1] != coord[1] + 1)):
									foundOne = True
							if not foundOne:
								for x in range(1):
									for y in range(2):
										layer = 2
										solid = (y == 0)
										room.decorObjects += [Traps.Decoration((coord[0] + x, coord[1] - y), room.floor, 9, 1 - y, layer, solid)]
						else:
							room.decorObjects = room.decorObjects + [Traps.Decoration(coord, room.floor, type, 0, 0, False)]
					elif tileset == 1:
						type = random.randint(0, 4)
						room.decorObjects = room.decorObjects + [Traps.Decoration(coord, room.floor, type, 1, 0, False)]
					elif tileset == 2:
						type = random.randint(0, 7)
						if type in [6, 7]:
							#coord = (square[0] * (boxSize[0] + 1) + random.randint(1, boxSize[0]), square[1] * (boxSize[1] + 1) + random.randint(1, boxSize[1] - 1))
							foundOne = False
							for t in room.decorObjects:
								if (t.source[0] == coord[0] and (t.source[1] != coord[1] or t.source[1] != coord[1] + 1)):
									foundOne = True
							if not foundOne:
								for x in range(1):
									for y in range(2):
										layer = 2
										solid = (y == 0)
										room.decorObjects += [Traps.Decoration((coord[0] + x, coord[1] - y), room.floor, type, 3 - y, layer, solid)]
						else:
							room.decorObjects = room.decorObjects + [Traps.Decoration(coord, room.floor, type, 2, 0, False)]