-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathduplicateMapFile.py
48 lines (36 loc) · 1.19 KB
/
duplicateMapFile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import os
import shutil
mapFolder = r'C:\Work\Source\bound\Assets\Maps'
sceneFolder = r'C:\Work\Source\bound\Assets\Scenes'
isSceneMode = False
fileExtension = 'unity' if isSceneMode else 'tmx'
sourceFolder = sceneFolder if isSceneMode else mapFolder
class Range:
x = 0
y = 0
class DestinationMaps:
start = Range()
end = Range()
class Map:
x = 0
y = 0
def __init__(self, x, y):
self.x = x
self.y = y
def getFileName(self):
global sourceFolder
global fileExtension
return os.path.join(sourceFolder, 'map' + str(self.x) + '-' + str(self.y) + '.' + fileExtension)
def isSame(self, otherMap):
return self.x == otherMap.x and self.y == otherMap.y
sourceMap = Map(10, 10)
destinationMaps = DestinationMaps()
destinationMaps.start.x = 5
destinationMaps.start.y = 5
destinationMaps.end.x = 15
destinationMaps.end.y = 15
for x in range(destinationMaps.start.x, destinationMaps.end.x + 1):
for y in range(destinationMaps.start.y, destinationMaps.end.y + 1):
destinationMap = Map(x, y)
if not sourceMap.isSame(destinationMap):
shutil.copyfile(sourceMap.getFileName(), destinationMap.getFileName())