/
domahes
/
Arcade
Обзор
Документация
Войти
/
domahes
/
Arcade
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
js/data/DProject.js
117 строк
3 KB
domahes
Update game scripts and data configurations
01 июн 2026, 10:11
01 июн 2026, 10:11
83cd2f8
Код
Авторство
О чём код?
/** * Created by Yitian Chen on 2019/1/4. * Project data · General structure */ function DProject(onload){ var _sf = this; //Project name this.name = ""; //Project unique Key this.key = ""; //Project data version code this.code = 0; //Project block size this.blockSize = 48; //Project resolution · Width this.gameWidth = 960; //Project resolution · Height this.gameHeight = 540; //Project game type 0, ACT 1, ARPG 2, AVG this.gameType = 0; //Initial map Id this.startId = 1; //X coordinate of Initial map this.startX = 0; //Y coordinate of Initial map this.startY = 0; //The user of project this.owner = ""; //Whether the project is locked this.isLock = false; //Project map data this.maps = []; //Project variable this.values = []; //Read the project data file var file = "Game.ifaction"; var rd = new IRWFile(file); //You need to set the read callback to IRWFile, because the file of web is read asynchronously. var onloadE = onload; //Read project data rd.onload = function(){ var ms = rd.readMS(8); if(ms == "IFACTION"){ _sf.name = rd.readString(); _sf.key = rd.readString(); _sf.code = rd.readInt(); _sf.blockSize = rd.readInt(); _sf.gameWidth = rd.readInt(); _sf.gameHeight = rd.readInt(); _sf.gameType = rd.readInt(); _sf.startId = rd.readInt(); _sf.startX = rd.readInt(); _sf.startY = rd.readInt(); _sf.owner = rd.readString(); _sf.isLock = rd.readBool(); var length = rd.readInt(); for(var i = 0;i<length;i++){ var mp = new DMap(rd); _sf.maps.push(mp); } length = rd.readInt(); for(i = 0;i<length;i++){ var val = new DValue(rd); _sf.values.push(val); } onloadE(); } }; /** * Initialize the variable library * @param data | raw variable data * @returns {Array} variable data that can be used in game */ this.initValue = function(data){ var vals = []; for(var i = 0;i< _sf.values.length;i++){ var value = _sf.values[i].defValue; if(_sf.values[i].type == 0){ value = value == "1"; }else if(_sf.values[i].type == 1){ value = parseInt(value); } if(_sf.values[i].staticValue && data != null && data[_sf.values[i].id] != null){ vals[_sf.values[i].id] = data[_sf.values[i].id]; }else{ vals[_sf.values[i].id] = value; } } return vals; }; /** * Find the map corresponding to the ID * @param id | MapID * @returns {DMap} Map data instance */ this.findMap = function(id){ for(var i = 0;i<_sf.maps.length;i++){ if(_sf.maps[i].id == id){ return _sf.maps[i]; } } return null; }; }