-
Notifications
You must be signed in to change notification settings - Fork 0
/
levelDesign_export.js
48 lines (38 loc) · 1.34 KB
/
levelDesign_export.js
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
const fs = require('fs')
const xlsx = require('xlsx')
let level = [];
function LoadText(fileName)
{
return new Promise((resolve, reject) => {
const workbook = xlsx.readFile(fileName)
const sheet = workbook.Sheets[workbook.SheetNames[0]]
let rowIndex = 2
let count = 0
let itemNumber = sheet[`A${rowIndex}`]
while(itemNumber) {
let startIndex = parseInt(sheet[`B${rowIndex}`].w);
let directionChangeRate = parseFloat(sheet[`C${rowIndex}`].w);
let diamondSpawnRate = parseFloat(sheet[`D${rowIndex}`].w);
let doubleWay2Rate = parseFloat(sheet[`F${rowIndex}`].w);
let doubleWay1Rate = parseFloat(sheet[`E${rowIndex}`].w);
level[count++] = {
startIndex: startIndex,
directionChangeRate: directionChangeRate,
diamondSpawnRate: diamondSpawnRate,
doubleWay2Rate: doubleWay2Rate,
doubleWay1Rate: doubleWay1Rate,
}
rowIndex++
itemNumber = sheet[`A${rowIndex}`]
}
resolve()
})
}
function SaveData()
{
fs.writeFileSync('assets/levelDesign.js', 'export default ' + JSON.stringify(level))
}
let promises = []
promises.push(LoadText('levelDesign.xlsx'))
Promise.all(promises)
.then(() => SaveData())