Merge pull request #360 from ckcz123/v2.x

V2.x
This commit is contained in:
Zhang Chen 2019-04-23 10:42:35 +08:00 committed by GitHub
commit 4a02b73cae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 3481 additions and 1292 deletions

2133
API列表.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@ -776,7 +776,8 @@ core.getCurrentEnemys(floorId)
core.hasEnemyLeft(enemyId, floorId)
检查某个楼层是否还有剩余的指定怪物。floorId为楼层ID可忽略表示当前楼层。
检查某个楼层是否还有剩余的(指定)怪物。
floorId为楼层ID可忽略表示当前楼层。也可以传数组如["MT0","MT1"]同时检测多个楼层。
enemyId如果不填或null则检查是否剩余任何怪物否则只检查是否剩余指定的某类怪物。
```

View File

@ -587,7 +587,7 @@ default : ["","","",500,false]
colour : this.mapColor
var floorstr = '';
if (EvalString_0 && EvalString_1) {
var pattern1 = /^flag:[0-9a-zA-Z_][0-9a-zA-Z_\-:]*$/;
var pattern1 = /^flag:([a-zA-Z0-9_\u4E00-\u9FCC]+)$/;
if(pattern1.test(EvalString_0) || pattern1.test(EvalString_1)){
EvalString_0=MotaActionFunctions.PosString_pre(EvalString_0);
EvalString_1=MotaActionFunctions.PosString_pre(EvalString_1);
@ -620,7 +620,7 @@ default : ["","","",500,false]
colour : this.mapColor
var floorstr = '';
if (EvalString_0 && EvalString_1) {
var pattern1 = /^flag:[0-9a-zA-Z_][0-9a-zA-Z_\-:]*$/;
var pattern1 = /^flag:([a-zA-Z0-9_\u4E00-\u9FCC]+)$/;
if(pattern1.test(EvalString_0) || pattern1.test(EvalString_1)){
EvalString_0=MotaActionFunctions.PosString_pre(EvalString_0);
EvalString_1=MotaActionFunctions.PosString_pre(EvalString_1);
@ -761,7 +761,7 @@ default : ["","",""]
colour : this.mapColor
var floorstr = '';
if (EvalString_0 && EvalString_1) {
var pattern1 = /^flag:[0-9a-zA-Z_][0-9a-zA-Z_\-:]*$/;
var pattern1 = /^flag:([a-zA-Z0-9_\u4E00-\u9FCC]+)$/;
if(pattern1.test(EvalString_0) || pattern1.test(EvalString_1)){
EvalString_0=MotaActionFunctions.PosString_pre(EvalString_0);
EvalString_1=MotaActionFunctions.PosString_pre(EvalString_1);
@ -792,7 +792,7 @@ default : ["","",""]
colour : this.mapColor
var floorstr = '';
if (EvalString_0 && EvalString_1) {
var pattern1 = /^flag:[0-9a-zA-Z_][0-9a-zA-Z_\-:]*$/;
var pattern1 = /^flag:([a-zA-Z0-9_\u4E00-\u9FCC]+)$/;
if(pattern1.test(EvalString_0) || pattern1.test(EvalString_1)){
EvalString_0=MotaActionFunctions.PosString_pre(EvalString_0);
EvalString_1=MotaActionFunctions.PosString_pre(EvalString_1);
@ -823,7 +823,7 @@ default : ["bg","","",""]
colour : this.mapColor
var floorstr = '';
if (EvalString_0 && EvalString_1) {
var pattern1 = /^flag:[0-9a-zA-Z_][0-9a-zA-Z_\-:]*$/;
var pattern1 = /^flag:([a-zA-Z0-9_\u4E00-\u9FCC]+)$/;
if(pattern1.test(EvalString_0) || pattern1.test(EvalString_1)){
EvalString_0=MotaActionFunctions.PosString_pre(EvalString_0);
EvalString_1=MotaActionFunctions.PosString_pre(EvalString_1);
@ -854,7 +854,7 @@ default : ["bg","","",""]
colour : this.mapColor
var floorstr = '';
if (EvalString_0 && EvalString_1) {
var pattern1 = /^flag:[0-9a-zA-Z_][0-9a-zA-Z_\-:]*$/;
var pattern1 = /^flag:([a-zA-Z0-9_\u4E00-\u9FCC]+)$/;
if(pattern1.test(EvalString_0) || pattern1.test(EvalString_1)){
EvalString_0=MotaActionFunctions.PosString_pre(EvalString_0);
EvalString_1=MotaActionFunctions.PosString_pre(EvalString_1);
@ -1157,7 +1157,7 @@ helpUrl : https://h5mota.com/games/template/docs/#/event?id=animate%EF%BC%9A%E6%
default : ["zone","hero",false]
colour : this.soundColor
if (EvalString_0) {
if(/^flag:[0-9a-zA-Z_][0-9a-zA-Z_\-]*,flag:[0-9a-zA-Z_][0-9a-zA-Z_\-]*$/.test(EvalString_0)) {
if(/^flag:([a-zA-Z0-9_\u4E00-\u9FCC]+),flag:([a-zA-Z0-9_\u4E00-\u9FCC]+)$/.test(EvalString_0)) {
EvalString_0=', "loc": ["'+EvalString_0.split(',').join('","')+'"]';
} else if (/hero|([+-]?\d+),([+-]?\d+)/.test(EvalString_0)) {
if(EvalString_0.indexOf(',')!==-1)EvalString_0='['+EvalString_0+']';
@ -2857,13 +2857,14 @@ MotaActionFunctions.EvalString_pre = function(EvalString){
MotaActionFunctions.IdString_pre = function(IdString){
if (IdString.indexOf('__door__')!==-1) throw new Error('请修改开门变量__door__如door1door2door3等依次向后。请勿存在两个门使用相同的开门变量。');
if (IdString && !(/^[0-9a-zA-Z_][0-9a-zA-Z_\-:]*$/.test(IdString)))throw new Error('id: '+IdString+'中包含了0-9 a-z A-Z _ - :之外的字符');
if (IdString && !(/^flag:([a-zA-Z0-9_\u4E00-\u9FCC]+)$/.test(IdString)) && !(/^[0-9a-zA-Z_][0-9a-zA-Z_\-:]*$/.test(IdString)))
throw new Error('id: '+IdString+'中包含了0-9 a-z A-Z _ - :之外的字符');
return IdString;
}
MotaActionFunctions.PosString_pre = function(PosString){
if (!PosString || /^-?\d+$/.test(PosString)) return PosString;
if (!(/^flag:[0-9a-zA-Z_][0-9a-zA-Z_:]*$/.test(PosString)))throw new Error(PosString+'中包含了0-9 a-z A-Z _ :之外的字符,或者是没有以flag: 开头');
if (!(/^flag:([a-zA-Z0-9_\u4E00-\u9FCC]+)$/.test(PosString)))throw new Error(PosString+'中包含了0-9 a-z A-Z _ 和中文之外的字符,或者是没有以flag: 开头');
return '"'+PosString+'"';
}

View File

@ -50,6 +50,7 @@ editor.prototype.init = function (callback) {
main.init('editor', function () {
editor_util_wrapper(editor);
editor_game_wrapper(editor, main, core);
editor_file_wrapper(editor);
editor_table_wrapper(editor);
editor_unsorted_1_wrapper(editor);
afterMainInit();
@ -65,7 +66,7 @@ editor.prototype.init = function (callback) {
editor_mode = editor_mode(editor);
editor_unsorted_2_wrapper(editor_mode);
editor.mode = editor_mode;
core.resetGame(core.firstData.hero, null, core.firstData.floorId, core.initStatus.maps);
core.resetGame(core.firstData.hero, null, core.firstData.floorId, core.clone(core.initStatus.maps));
core.changeFloor(core.status.floorId, null, core.firstData.hero.loc, null, function () {
afterCoreReset();
}, true);

View File

@ -2,7 +2,11 @@ editor_blockly = function () {
var editor_blockly = {};
initscript = String.raw`
/////////////////initscript start/////////////////////////////
// do not use String.raw because of highlighting
// Comment tagged templates
// https://marketplace.visualstudio.com/items?itemName=bierner.comment-tagged-templates
initscript = /* js */`
(function(){
var getCategory = function(name,custom){
for(var node of document.getElementById('toolbox').children) {
@ -30,7 +34,7 @@ editor_blockly = function () {
"textInList": "1F金币商店",
"use": "money",
"need": "20+10*times*(times+1)",
"text": "勇敢的武士啊,给我\${need}金币就可以:",
"text": "勇敢的武士啊,给我\\\${need}金币就可以:",
"choices": [
{"text": "生命+800", "effect": "status:hp+=800"},
{"text": "攻击+4", "effect": "status:atk+=4"},
@ -188,27 +192,27 @@ editor_blockly = function () {
'<label text="检测音乐如果没有开启则系统提示开启"></label>',
MotaActionFunctions.actionParser.parseList({"type": "if", "condition": "!core.musicStatus.bgmStatus",
"true": [
"\t[系统提示]你当前音乐处于关闭状态,本塔开音乐游戏效果更佳"
"\\t[系统提示]你当前音乐处于关闭状态,本塔开音乐游戏效果更佳"
],
"false": []
}),
'<label text="商店购买属性/钥匙"></label>',
MotaActionFunctions.actionParser.parse([
{"type": "choices", "text": "\t[老人,man]少年,你需要钥匙吗?\n我这里有大把的",
{"type": "choices", "text": "\\t[老人,man]少年,你需要钥匙吗?\\n我这里有大把的",
"choices": [
{"text": "黄钥匙(\${9+flag:shop_times}金币)", "color": [255,255,0,1], "action": [
{"text": "黄钥匙(\\\${9+flag:shop_times}金币)", "color": [255,255,0,1], "action": [
{"type": "if", "condition": "status:money>=9+flag:shop_times",
"true": [
{"type": "addValue", "name": "status:money", "value": "-(9+flag:shop_times)"},
{"type": "addValue", "name": "item:yellowKey", "value": "1"},
],
"false": [
"\t[老人,man]你的金钱不足!",
"\\t[老人,man]你的金钱不足!",
{"type": "revisit"}
]
}
]},
{"text": "蓝钥匙(\${18+2*flag:shop_times}金币)", "color": [0,0,255,1], "action": [
{"text": "蓝钥匙(\\\${18+2*flag:shop_times}金币)", "color": [0,0,255,1], "action": [
]},
{"text": "离开", "action": [
{"type": "exit"}
@ -361,7 +365,7 @@ function omitedcheckUpdateFunction(event) {
}
}
try {
var code = Blockly.JavaScript.workspaceToCode(workspace).replace(/\\i/g, '\\\\i');
var code = Blockly.JavaScript.workspaceToCode(workspace).replace(/\\\\i/g, '\\\\\\\\i');
codeAreaHL.setValue(code);
} catch (error) {
codeAreaHL.setValue(String(error));
@ -433,6 +437,7 @@ function omitedcheckUpdateFunction(event) {
}
})();
`;
/////////////////initscript end /////////////////////////////
var input_ = '';
editor_blockly.runOne = function () {

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,928 @@
editor_file = function (editor, callback) {
var editor_file = new editor_file_proto();
editor.file=editor_file;
editor.file.loadCommentjs(callback);
///////////////////////////////////////////////////////////////////////////
editor.file.getFloorFileList = function (callback) {
checkCallback(callback);
/* var fs = editor.fs;
fs.readdir('project/floors',function(err, data){
callback([data,err]);
}); */
callback([editor.core.floorIds, null]);
}
//callback([Array<String>,err:String])
editor.file.loadFloorFile = function (filename, callback) {
//filename不含'/'不含'.js'
checkCallback(callback);
editor.currentFloorId = editor.core.status.floorId;
editor.currentFloorData = editor.core.floors[editor.currentFloorId];
}
//callback(err:String)
editor.file.saveFloorFile = function (callback) {
checkCallback(callback);
/* if (!isset(editor.currentFloorId) || !isset(editor.currentFloorData)) {
callback('未选中文件或无数据');
} */
var filename = 'project/floors/' + editor.currentFloorId + '.js';
var datastr = ['main.floors.', editor.currentFloorId, '=\n'];
if (editor.currentFloorData.map == 'new') {
/*
editor.currentFloorData.map = editor.map.map(function (v) {
return v.map(function () {
return 0
})
});
*/
var width = parseInt(document.getElementById('newMapWidth').value);
var height = parseInt(document.getElementById('newMapHeight').value);
var row = [];
for (var i=0;i<width;i++) row.push(0);
editor.currentFloorData.map = [];
for (var i=0;i<height;i++) editor.currentFloorData.map.push(row);
}
else{
for(var ii=0,name;name=['map','bgmap','fgmap'][ii];ii++){
var mapArray=editor[name].map(function (v) {
return v.map(function (v) {
return v.idnum || v || 0
})
});
editor.currentFloorData[name]=mapArray;
}
}
// format 更改实现方式以支持undefined删除
var tempJsonObj=Object.assign({},editor.currentFloorData);
var tempMap=[['map',editor.util.guid()],['bgmap',editor.util.guid()],['fgmap',editor.util.guid()]];
tempMap.forEach(function(v){
v[2]=tempJsonObj[v[0]];
tempJsonObj[v[0]]=v[1];
});
var tempJson=JSON.stringify(tempJsonObj, null, 4);
tempMap.forEach(function(v){
tempJson=tempJson.replace('"'+v[1]+'"','[\n'+ formatMap(v[2],v[0]!='map')+ '\n]')
});
datastr = datastr.concat([tempJson]);
datastr = datastr.join('');
alertWhenCompress();
fs.writeFile(filename, encode(datastr), 'base64', function (err, data) {
callback(err);
});
}
//callback(err:String)
editor.file.saveNewFile = function (saveFilename, callback) {
//saveAsFilename不含'/'不含'.js'
checkCallback(callback);
var currData=editor.currentFloorData;
var saveStatus = document.getElementById('newMapStatus').checked;
var title = saveStatus?currData.title:"新建楼层";
var name = saveStatus?currData.name:"0";
if (/^mt\d+$/i.test(saveFilename)) {
name = saveFilename.substring(2);
title = "主塔 "+name+" 层";
}
editor.currentFloorData = {
floorId: saveFilename,
title: title,
name: name,
width: parseInt(document.getElementById('newMapWidth').value),
height: parseInt(document.getElementById('newMapHeight').value),
canFlyTo: saveStatus?currData.canFlyTo:true,
canUseQuickShop: saveStatus?currData.canUseQuickShop:true,
cannotViewMap: saveStatus?currData.cannotViewMap:false,
cannotMoveDirectly: saveStatus?currData.cannotMoveDirectly:false,
images: [],
item_ratio: saveStatus?currData.item_ratio:1,
defaultGround: saveStatus?currData.defaultGround:"ground",
bgm: saveStatus?currData.bgm:null,
upFloor: null,
downFloor: null,
color: saveStatus?currData.color:null,
weather: saveStatus?currData.weather:null,
firstArrive: [],
eachArrive: [],
parallelDo: "",
events: {},
changeFloor: {},
afterBattle: {},
afterGetItem: {},
afterOpenDoor: {},
cannotMove: {}
};
Object.keys(editor.currentFloorData).forEach(function (t) {
if (editor.currentFloorData[t] == null)
delete editor.currentFloorData[t];
})
editor.currentFloorData.map = "new";
editor.currentFloorId = saveFilename;
editor.file.saveFloorFile(callback);
}
editor.file.saveNewFiles = function (floorIdList, from, to, callback) {
checkCallback(callback);
var currData=editor.currentFloorData;
var saveStatus = document.getElementById('newMapsStatus').checked;
var calValue = function (text, i) {
return text.replace(/\${(.*?)}/g, function (word, value) {
return eval(value);
});
}
var width = parseInt(document.getElementById('newMapsWidth').value);
var height = parseInt(document.getElementById('newMapsHeight').value);
var row = [], map = [];
for (var i=0;i<width;i++) row.push(0);
for (var i=0;i<height;i++) map.push(row);
var filenames = floorIdList.map(function (v) {return "project/floors/"+v+".js";});
var datas = [];
for (var i=from;i<=to;i++) {
var datastr = ['main.floors.', floorIdList[i-from], '=\n{'];
var data = {
floorId: floorIdList[i-from],
title: calValue(document.getElementById('newFloorTitles').value, i),
name: calValue(document.getElementById('newFloorNames').value, i),
width: width,
height: height,
map: map,
canFlyTo: saveStatus?currData.canFlyTo:true,
canUseQuickShop: saveStatus?currData.canUseQuickShop:true,
cannotViewMap: saveStatus?currData.cannotViewMap:false,
cannotMoveDirectly: saveStatus?currData.cannotMoveDirectly:false,
images: [],
item_ratio: saveStatus?currData.item_ratio:1,
defaultGround: saveStatus?currData.defaultGround:"ground",
bgm: saveStatus?currData.bgm:null,
upFloor: null,
downFloor: null,
color: saveStatus?currData.color:null,
weather: saveStatus?currData.weather:null,
firstArrive: [],
eachArrive: [],
parallelDo: "",
events: {},
changeFloor: {},
afterBattle: {},
afterGetItem: {},
afterOpenDoor: {},
cannotMove: {}
};
Object.keys(data).forEach(function (t) {
if (data[t] == null)
delete data[t];
else {
if (t=='map') {
datastr = datastr.concat(['\n"', t, '": [\n', formatMap(data[t]), '\n],']);
}
else {
datastr = datastr.concat(['\n"', t, '": ', JSON.stringify(data[t], null, 4), ',']);
}
}
});
datastr = datastr.concat(['\n}']);
datastr = datastr.join('');
datas.push(encode(datastr));
}
alertWhenCompress();
fs.writeMultiFiles(filenames, datas, function (err, data) {
callback(err);
});
}
//callback(err:String)
////////////////////////////////////////////////////////////////////
editor.file.autoRegister = function (info, callback) {
var iconActions = [];
var mapActions = [];
var templateActions = [];
var image = info.images;
if (image=='autotile') {
callback('不能对自动元件进行自动注册!');
return;
}
var c=image.toUpperCase().charAt(0);
// terrains id
var terrainsId = [];
Object.keys(core.material.icons.terrains).forEach(function (id) {
terrainsId[core.material.icons.terrains[id]]=id;
})
var allIds = [];
editor.ids.forEach(function (v) {
if (v.images==image) {
allIds[v.y]=true;
}
})
var per_height = image.endsWith('48')?48:32;
var idnum=300;
for (var y=0; y<editor.widthsX[image][3]/per_height;y++) {
if (allIds[y]) continue;
while (editor.core.maps.blocksInfo[idnum]) idnum++;
// get id num
var id = c+idnum;
if (image=='terrains' && terrainsId[y] != null) {
id=terrainsId[y];
}
else {
iconActions.push(["add", "['" + image + "']['" + id + "']", y])
}
mapActions.push(["add", "['" + idnum + "']", {'cls': image, 'id': id}])
if (image=='items')
templateActions.push(["add", "['items']['" + id + "']", editor.file.comment._data.items_template]);
else if (image.indexOf('enemy')==0)
templateActions.push(["add", "['" + id + "']", editor.file.comment._data.enemys_template]);
idnum++;
}
if (mapActions.length==0) {
callback("没有要注册的项!");
return;
}
var templist = [];
var tempcallback = function (err) {
templist.push(err);
if (templist.length == 3) {
if (templist[0] != null || templist[1] != null || templist[2] != null)
callback((templist[0] || '') + '\n' + (templist[1] || '') + '\n' + (templist[2] || ''));
//这里如果一个成功一个失败会出严重bug
else
callback(null);
}
}
if (iconActions.length>0)
saveSetting('icons', iconActions, tempcallback);
else tempcallback(null);
saveSetting('maps', mapActions, tempcallback);
if (image=='items')
saveSetting('items', templateActions, tempcallback);
else if (image.indexOf('enemy')==0)
saveSetting('enemys', templateActions, tempcallback);
else tempcallback(null);
}
editor.file.registerAutotile = function (filename, callback) {
var idnum = 140;
while (editor.core.maps.blocksInfo[idnum]) idnum++;
var iconActions = [];
var mapActions = [];
iconActions.push(["add", "['autotile']['" + filename + "']", 0]);
mapActions.push(["add", "['" + idnum + "']", {'cls': 'autotile', 'id': filename, 'noPass': true}]);
var templist = [];
var tempcallback = function (err) {
templist.push(err);
if (templist.length == 2) {
if (templist[0] != null || templist[1] != null)
callback((templist[0] || '') + '\n' + (templist[1] || ''));
//这里如果一个成功一个失败会出严重bug
else
callback(null);
}
}
saveSetting('icons', iconActions, tempcallback);
saveSetting('maps', mapActions, tempcallback);
}
editor.file.changeIdAndIdnum = function (id, idnum, info, callback) {
checkCallback(callback);
//检查maps中是否有重复的idnum或id
var change = -1;
for (var ii in editor.core.maps.blocksInfo) {
if (ii == idnum) {
//暂时只允许创建新的不允许修改已有的
//if (info.idnum==idnum){change=ii;break;}//修改id
callback('idnum重复了');
return;
}
if (editor.core.maps.blocksInfo[ii].id == id) {
//if (info.id==id){change=ii;break;}//修改idnum
callback('id重复了');
return;
}
}
/*
if (change!=-1 && change!=idnum){//修改idnum
editor.core.maps.blocksInfo[idnum] = editor.core.maps.blocksInfo[change];
delete(editor.core.maps.blocksInfo[change]);
} else if (change==idnum) {//修改id
var oldid = editor.core.maps.blocksInfo[idnum].id;
editor.core.maps.blocksInfo[idnum].id = id;
for(var ii in editor.core.icons.icons){
if (ii.hasOwnProperty(oldid)){
ii[id]=ii[oldid];
delete(ii[oldid]);
}
}
} else {//创建新的
editor.core.maps.blocksInfo[idnum]={'cls': info.images, 'id':id};
editor.core.icons.icons[info.images][id]=info.y;
}
*/
var templist = [];
var tempcallback = function (err) {
templist.push(err);
if (templist.length == 2) {
if (templist[0] != null || templist[1] != null)
callback((templist[0] || '') + '\n' + (templist[1] || ''));
//这里如果一个成功一个失败会出严重bug
else
callback(null);
}
}
saveSetting('maps', [["add", "['" + idnum + "']", {'cls': info.images, 'id': id}]], tempcallback);
saveSetting('icons', [["add", "['" + info.images + "']['" + id + "']", info.y]], tempcallback);
if (info.images === 'items') {
saveSetting('items', [["add", "['items']['" + id + "']", editor.file.comment._data.items_template]], function (err) {
if (err) {
printe(err);
throw(err)
}
});
}
if (info.images === 'enemys' || info.images === 'enemy48') {
saveSetting('enemys', [["add", "['" + id + "']", editor.file.comment._data.enemys_template]], function (err) {
if (err) {
printe(err);
throw(err)
}
});
}
callback(null);
}
//callback(err:String)
editor.file.editItem = function (id, actionList, callback) {
/*actionList:[
["change","['items']['name']","红宝石的新名字"],
["add","['items']['新的和name同级的属性']",123],
["change","['itemEffectTip']","',攻击力+'+editor.core.values.redJewel"],
]
[]时只查询不修改
*/
checkCallback(callback);
if (isset(actionList) && actionList.length > 0) {
actionList.forEach(function (value) {
var tempindex = value[1].indexOf(']') + 1;
value[1] = [value[1].slice(0, tempindex), "['" + id + "']", value[1].slice(tempindex)].join('');
});
saveSetting('items', actionList, function (err) {
callback([err]);
});
} else {
callback([
(function () {
var locObj_ = {};
Object.keys(editor.file.comment._data.items._data).forEach(function (v) {
if (isset(editor.core.items[v][id]) && v !== 'items')
locObj_[v] = editor.core.items[v][id];
else
locObj_[v] = null;
});
locObj_['items'] = (function () {
var locObj = Object.assign({}, editor.core.items.items[id]);
Object.keys(editor.file.comment._data.items._data.items._data).forEach(function (v) {
if (!isset(editor.core.items.items[id][v]))
locObj[v] = null;
});
return locObj;
})();
return locObj_;
})(),
editor.file.comment._data.items,
null]);
}
//只有items.cls是items的才有itemEffect和itemEffectTip,keys和constants和tools只有items
}
//callback([obj,commentObj,err:String])
editor.file.editEnemy = function (id, actionList, callback) {
/*actionList:[
["change","['name']","初级巫师的新名字"],
["add","['新的和name同级的属性']",123],
["change","['bomb']",null],
]
[]时只查询不修改
*/
checkCallback(callback);
if (isset(actionList) && actionList.length > 0) {
actionList.forEach(function (value) {
value[1] = "['" + id + "']" + value[1];
});
saveSetting('enemys', actionList, function (err) {
callback([err]);
});
} else {
callback([
(function () {
var locObj = Object.assign({}, editor.core.enemys.enemys[id]);
Object.keys(editor.file.comment._data.enemys._data).forEach(function (v) {
if (!isset(editor.core.enemys.enemys[id][v]))
/* locObj[v]=editor.core.enemys.enemys[id][v];
else */
locObj[v] = null;
});
return locObj;
})(),
editor.file.comment._data.enemys,
null]);
}
}
//callback([obj,commentObj,err:String])
editor.file.editMapBlocksInfo = function (idnum, actionList, callback) {
/*actionList:[
["change","['events']",["\t[老人,magician]领域、夹击。\n请注意领域怪需要设置value为伤害数值可参见样板中初级巫师的写法。"]],
["change","['afterBattle']",null],
]
[]时只查询不修改
*/
checkCallback(callback);
if (isset(actionList) && actionList.length > 0) {
var tempmap=[];
for(var ii=0;ii<actionList.length;ii++){
var value=actionList[ii];
// 是tilesets 且未定义 且在这里是第一次定义
if(idnum>=editor.core.icons.tilesetStartOffset && !isset(editor.core.maps.blocksInfo[idnum]) && tempmap.indexOf(idnum)===-1){
actionList.splice(ii,0,["add","['" + idnum + "']",{"cls": "tileset", "id": "X"+idnum, "noPass": true}]);
tempmap.push(idnum);
ii++;
}
value[1] = "['" + idnum + "']" + value[1];
}
saveSetting('maps', actionList, function (err) {
callback([err]);
});
} else {
callback([
(function () {
var sourceobj=editor.core.maps.blocksInfo[idnum];
if(!isset(sourceobj) && idnum>=editor.core.icons.tilesetStartOffset)sourceobj={"cls": "tileset", "id": "X"+idnum, "noPass": true}
var locObj = Object.assign({}, sourceobj);
Object.keys(editor.file.comment._data.maps._data).forEach(function (v) {
if (!isset(sourceobj[v]))
locObj[v] = null;
});
locObj.idnum = idnum;
return locObj;
})(),
editor.file.comment._data.maps,
null]);
}
}
//callback([obj,commentObj,err:String])
////////////////////////////////////////////////////////////////////
editor.file.editLoc = function (x, y, actionList, callback) {
/*actionList:[
["change","['events']",["\t[老人,magician]领域、夹击。\n请注意领域怪需要设置value为伤害数值可参见样板中初级巫师的写法。"]],
["change","['afterBattle']",null],
]
[]时只查询不修改
*/
checkCallback(callback);
if (isset(actionList) && actionList.length > 0) {
actionList.forEach(function (value) {
value[1] = value[1] + "['" + x + "," + y + "']";
});
saveSetting('floorloc', actionList, function (err) {
callback([err]);
});
} else {
callback([
(function () {
var locObj = {};
Object.keys(editor.file.comment._data.floors._data.loc._data).forEach(function (v) {
if (isset(editor.currentFloorData[v][x + ',' + y]))
locObj[v] = editor.currentFloorData[v][x + ',' + y];
else
locObj[v] = null;
});
return locObj;
})(),
editor.file.comment._data.floors._data.loc,
null]);
}
}
//callback([obj,commentObj,err:String])
////////////////////////////////////////////////////////////////////
editor.file.editFloor = function (actionList, callback) {
/*actionList:[
["change","['title']",'样板 3 层'],
["change","['color']",null],
]
[]时只查询不修改
*/
checkCallback(callback);
if (isset(actionList) && actionList.length > 0) {
saveSetting('floors', actionList, function (err) {
callback([err]);
});
} else {
callback([
(function () {
var locObj = Object.assign({}, editor.currentFloorData);
Object.keys(editor.file.comment._data.floors._data.floor._data).forEach(function (v) {
if (!isset(editor.currentFloorData[v]))
/* locObj[v]=editor.currentFloorData[v];
else */
locObj[v] = null;
});
Object.keys(editor.file.comment._data.floors._data.loc._data).forEach(function (v) {
delete(locObj[v]);
});
delete(locObj.map);
delete(locObj.bgmap);
delete(locObj.fgmap);
return locObj;
})(),
editor.file.comment._data.floors._data.floor,
null]);
}
}
//callback([obj,commentObj,err:String])
////////////////////////////////////////////////////////////////////
editor.file.editTower = function (actionList, callback) {
/*actionList:[
["change","['firstData']['version']",'Ver 1.0.1 (Beta)'],
["change","['values']['lavaDamage']",200],
]
[]时只查询不修改
*/
var data_obj = data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d;
checkCallback(callback);
if (isset(actionList) && actionList.length > 0) {
saveSetting('data', actionList, function (err) {
callback([err]);
});
} else {
callback([
(function () {
//var locObj=Object.assign({'main':{}},editor.core.data);
var locObj = Object.assign({}, data_obj, {'main': {}});
Object.keys(editor.file.dataComment._data.main._data).forEach(function (v) {
if (isset(editor.main[v]))
locObj.main[v] = data_obj.main[v];
else
locObj.main[v] = null;
});
return locObj;
})(),
editor.file.dataComment,
null]);
}
}
//callback([obj,commentObj,err:String])
////////////////////////////////////////////////////////////////////
var fmap = {};
var fjson = JSON.stringify(functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a, function (k, v) {
if (v instanceof Function) {
var id_ = editor.util.guid();
fmap[id_] = v.toString();
return id_;
} else return v
}, 4);
var fobj = JSON.parse(fjson);
editor.file.functionsMap = fmap;
editor.file.functionsJSON = fjson;
var buildlocobj = function (locObj) {
for (var key in locObj) {
if (typeof(locObj[key]) !== typeof('')) buildlocobj(locObj[key]);
else locObj[key] = fmap[locObj[key]];
}
};
editor.file.editFunctions = function (actionList, callback) {
/*actionList:[
["change","['events']['afterChangeLight']","function(x,y){console.log(x,y)}"],
["change","['ui']['drawAbout']","function(){...}"],
]
[]时只查询不修改
*/
checkCallback(callback);
if (isset(actionList) && actionList.length > 0) {
saveSetting('functions', actionList, function (err) {
callback([err]);
});
} else {
callback([
(function () {
var locObj = JSON.parse(fjson);
buildlocobj(locObj);
return locObj;
})(),
editor.file.functionsComment,
null]);
}
}
//callback([obj,commentObj,err:String])
////////////////////////////////////////////////////////////////////
editor.file.editCommonEvent = function (actionList, callback) {
/*actionList:[
["change","['test']",['123']],
]
[]时只查询不修改
*/
var data_obj = events_c12a15a8_c380_4b28_8144_256cba95f760.commonEvent;
checkCallback(callback);
if (isset(actionList) && actionList.length > 0) {
actionList.forEach(function (value) {
value[1] = "['commonEvent']" + value[1];
});
saveSetting('events', actionList, function (err) {
callback([err]);
});
} else {
callback([
Object.assign({},data_obj),
editor.file.eventsComment._data.commonEvent,
null]);
}
}
//callback([obj,commentObj,err:String])
////////////////////////////////////////////////////////////////////
var plmap = {};
var pljson = JSON.stringify(plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1, function (k, v) {
if (v instanceof Function) {
var id_ = editor.util.guid();
plmap[id_] = v.toString();
return id_;
} else if(v===null){
var id_ = editor.util.guid();
plmap[id_] = null;
return id_;
} return v
}, 4);
var plobj = JSON.parse(pljson);
editor.file.pluginsMap = plmap;
editor.file.pluginsObj = plobj;
var buildpllocobj = function (locObj) {
for (var key in locObj) {
if (typeof(locObj[key]) !== typeof('')) buildpllocobj(locObj[key]);
else locObj[key] = plmap[locObj[key]];
}
};
editor.file.editPlugins = function (actionList, callback) {
/*actionList:[
["change","['test']","function(x,y){console.log(x,y)}"],
]
[]时只查询不修改
*/
checkCallback(callback);
if (isset(actionList) && actionList.length > 0) {
saveSetting('plugins', actionList, function (err) {
callback([err]);
});
} else {
callback([
(function () {
var locObj = JSON.parse(JSON.stringify(plobj));
buildpllocobj(locObj);
return locObj;
})(),
editor.file.pluginsComment,
null]);
}
}
//callback([obj,commentObj,err:String])
////////////////////////////////////////////////////////////////////
var isset = function (val) {
if (val == undefined || val == null) {
return false;
}
return true
}
var checkCallback=function(callback){
if (!isset(callback)) {
printe('未设置callback');
throw('未设置callback')
}
}
var formatMap = function (mapArr,trySimplify) {
if(!mapArr || JSON.stringify(mapArr)==JSON.stringify([]))return '';
if(trySimplify){
//检查是否是全0二维数组
var jsoncheck=JSON.stringify(mapArr).replace(/\D/g,'');
if(jsoncheck==Array(jsoncheck.length+1).join('0'))return '';
}
//把二维数组格式化
var formatArrStr = '';
var arr = JSON.stringify(mapArr).replace(/\s+/g, '').split('],[');
var si=mapArr.length-1,sk=mapArr[0].length-1;
for (var i = 0; i <= si; i++) {
var a = [];
formatArrStr += ' [';
if (i == 0 || i == si) a = arr[i].split(/\D+/).join(' ').trim().split(' ');
else a = arr[i].split(/\D+/);
for (var k = 0; k <= sk; k++) {
var num = parseInt(a[k]);
formatArrStr += Array(Math.max(4 - String(num).length, 0)).join(' ') + num + (k == sk ? '' : ',');
}
formatArrStr += ']' + (i == si ? '' : ',\n');
}
return formatArrStr;
}
var encode = editor.util.encode64
var alertWhenCompress = function(){
if(editor.useCompress===true){
editor.useCompress='alerted';
setTimeout("alert('当前游戏使用的是压缩文件,修改完成后请使用启动服务.exe->Js代码压缩工具重新压缩,或者把main.js的useCompress改成false来使用原始文件')",1000)
}
}
var saveSetting = function (file, actionList, callback) {
//console.log(file);
//console.log(actionList);
alertWhenCompress();
if (file == 'icons') {
actionList.forEach(function (value) {
eval("icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1" + value[1] + '=' + JSON.stringify(value[2]));
});
var datastr = 'var icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1 = \n';
datastr += JSON.stringify(icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1, null, '\t');
fs.writeFile('project/icons.js', encode(datastr), 'base64', function (err, data) {
callback(err);
});
return;
}
if (file == 'maps') {
actionList.forEach(function (value) {
eval("maps_90f36752_8815_4be8_b32b_d7fad1d0542e" + value[1] + '=' + JSON.stringify(value[2]));
});
var datastr = 'var maps_90f36752_8815_4be8_b32b_d7fad1d0542e = \n';
//datastr+=JSON.stringify(maps_90f36752_8815_4be8_b32b_d7fad1d0542e,null,4);
var emap = {};
var estr = JSON.stringify(maps_90f36752_8815_4be8_b32b_d7fad1d0542e, function (k, v) {
if (v.id != null) {
var id_ = editor.util.guid();
emap[id_] = JSON.stringify(v);
return id_;
} else return v
}, '\t');
for (var id_ in emap) {
estr = estr.replace('"' + id_ + '"', emap[id_])
}
datastr += estr;
fs.writeFile('project/maps.js', encode(datastr), 'base64', function (err, data) {
callback(err);
});
return;
}
if (file == 'items') {
actionList.forEach(function (value) {
eval("items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a" + value[1] + '=' + JSON.stringify(value[2]));
});
var datastr = 'var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = \n';
datastr += JSON.stringify(items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a, null, '\t');
fs.writeFile('project/items.js', encode(datastr), 'base64', function (err, data) {
callback(err);
});
return;
}
if (file == 'enemys') {
actionList.forEach(function (value) {
eval("enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80" + value[1] + '=' + JSON.stringify(value[2]));
});
var datastr = 'var enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80 = \n';
var emap = {};
var estr = JSON.stringify(enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80, function (k, v) {
if (v.hp != null) {
var id_ = editor.util.guid();
emap[id_] = JSON.stringify(v);
return id_;
} else return v
}, '\t');
for (var id_ in emap) {
estr = estr.replace('"' + id_ + '"', emap[id_])
}
datastr += estr;
fs.writeFile('project/enemys.js', encode(datastr), 'base64', function (err, data) {
callback(err);
});
return;
}
if (file == 'data') {
actionList.forEach(function (value) {
eval("data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d" + value[1] + '=' + JSON.stringify(value[2]));
});
if (data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.main.floorIds.indexOf(data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.firstData.floorId) < 0)
data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.firstData.floorId = data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.main.floorIds[0];
var datastr = 'var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = \n';
datastr += JSON.stringify(data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d, null, '\t');
fs.writeFile('project/data.js', encode(datastr), 'base64', function (err, data) {
callback(err);
});
return;
}
if (file == 'functions') {
actionList.forEach(function (value) {
eval("fmap[fobj" + value[1] + ']=' + JSON.stringify(value[2]));
});
var fraw = fjson;
for (var id_ in fmap) {
fraw = fraw.replace('"' + id_ + '"', fmap[id_])
}
var datastr = 'var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = \n';
datastr += fraw;
fs.writeFile('project/functions.js', encode(datastr), 'base64', function (err, data) {
callback(err);
});
return;
}
if (file == 'floorloc') {
actionList.forEach(function (value) {
// 检测null/undefined
if (value[2]==null)
eval("delete editor.currentFloorData" + value[1]);
else
eval("editor.currentFloorData" + value[1] + '=' + JSON.stringify(value[2]));
});
editor.file.saveFloorFile(callback);
return;
}
if (file == 'floors') {
actionList.forEach(function (value) {
eval("editor.currentFloorData" + value[1] + '=' + JSON.stringify(value[2]));
});
editor.file.saveFloorFile(callback);
return;
}
if (file == 'events') {
actionList.forEach(function (value) {
eval("events_c12a15a8_c380_4b28_8144_256cba95f760" + value[1] + '=' + JSON.stringify(value[2]));
});
var datastr = 'var events_c12a15a8_c380_4b28_8144_256cba95f760 = \n';
datastr += JSON.stringify(events_c12a15a8_c380_4b28_8144_256cba95f760, null, '\t');
fs.writeFile('project/events.js', encode(datastr), 'base64', function (err, data) {
callback(err);
});
return;
}
if (file == 'plugins') {
actionList.forEach(function (value) {
if(value[0]==='add'){
eval("plobj" + value[1] + '=' + JSON.stringify(value[2]));
} else {
eval("plmap[plobj" + value[1] + ']=' + JSON.stringify(value[2]));
}
});
var plraw = JSON.stringify(plobj,null,4);
for (var id_ in plmap) {
plraw = plraw.replace('"' + id_ + '"', plmap[id_])
}
var datastr = 'var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = \n';
datastr += plraw;
fs.writeFile('project/plugins.js', encode(datastr), 'base64', function (err, data) {
callback(err);
});
return;
}
callback('出错了,要设置的文件名不识别');
}
return editor_file;
}
//editor_file = editor_file(editor);

View File

@ -1,37 +1,77 @@
editor_game_wrapper = function (editor, main, core) {
// 原则上重构后只有此文件允许`\s(main|core)`形式的调用, 以及其初始化 editor_game_wrapper(editor, main, core)
editor_game = function () {
this.replacerRecord = {}
}
// 三个 replacer 和 replacerRecord 暂时放在此处
editor_game.prototype.replacerForLoading = function (_key, value) {
var rmap = editor.game.replacerRecord;
if (value instanceof Function) {
var guid_ = editor.util.guid()
rmap[guid_] = value.toString()
return guid_
} else if (value === null) {
// 为了包含plugins的新建
var guid_ = editor.util.guid()
rmap[guid_] = null
return guid_
}
return value
}
editor_game.prototype.replacerForSaving = function (_key, value) {
var rmap = editor.game.replacerRecord;
if (rmap.hasOwnProperty(value)) {
return rmap[value]
}
return value
}
editor_game.prototype.getValue = function(field){
var rmap = editor.game.replacerRecord;
var value = eval(field)
if (rmap.hasOwnProperty(oldval)) {
return rmap[value]
} else {
return value
}
}
editor_game.prototype.setValue = function(field,value){
var rmap = editor.game.replacerRecord;
var oldval = eval(field)
if (rmap.hasOwnProperty(oldval)) {
rmap[value]=eval(value)
} else {
eval(field+'='+value)
}
}
editor_game.prototype.replacerWithoutRecord = function (_key, value) {
if (value instanceof Function) {
return value.toString()
} else return value
}
editor_game.prototype.fixFunctionInGameData = function () {
core.floors = JSON.parse(JSON.stringify(core.floors, function (_k, v) {
if (v instanceof Function) {
return v.toString()
} else return v
}));
core.data = JSON.parse(JSON.stringify(core.data, function (_k, v) {
if (v instanceof Function) {
return v.toString()
} else return v
}));
data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = JSON.parse(JSON.stringify(data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d, function (_k, v) {
if (v instanceof Function) {
return v.toString()
} else return v
}));
var rf = editor.game.replacerWithoutRecord
core.floors = JSON.parse(JSON.stringify(core.floors, rf));
core.data = JSON.parse(JSON.stringify(core.data, rf));
data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = JSON.parse(JSON.stringify(data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d, rf));
}
editor_game.prototype.idsInit = function (maps, icons) {
editor.ids = [0];
editor.indexs = [];
var MAX_NUM = 0;
var keys=Object.keys(maps_90f36752_8815_4be8_b32b_d7fad1d0542e);
for(var ii=0;ii<keys.length;ii++){
var v=~~keys[ii];
if(v>MAX_NUM && v<core.icons.tilesetStartOffset)MAX_NUM=v;
var keys = Object.keys(maps_90f36752_8815_4be8_b32b_d7fad1d0542e);
for (var ii = 0; ii < keys.length; ii++) {
var v = ~~keys[ii];
if (v > MAX_NUM && v < core.icons.tilesetStartOffset) MAX_NUM = v;
}
editor.MAX_NUM=MAX_NUM;
editor.MAX_NUM = MAX_NUM;
var getInfoById = function (id) {
var block = maps.initBlock(0, 0, id);
if (Object.prototype.hasOwnProperty.call(block, 'event')) {
@ -46,15 +86,15 @@ editor_game_wrapper = function (editor, main, core) {
var id = indexBlock.event.id;
var indexId = indexBlock.id;
var allCls = Object.keys(icons);
if(i==17){
editor.ids.push({'idnum': 17, 'id': id, 'images': 'terrains'});
if (i == 17) {
editor.ids.push({ 'idnum': 17, 'id': id, 'images': 'terrains' });
point++;
editor.indexs[i].push(point);
continue;
}
for (var j = 0; j < allCls.length; j++) {
if (id in icons[allCls[j]]) {
editor.ids.push({'idnum': indexId, 'id': id, 'images': allCls[j], 'y': icons[allCls[j]][id]});
editor.ids.push({ 'idnum': indexId, 'id': id, 'images': allCls[j], 'y': icons[allCls[j]][id] });
point++;
editor.indexs[i].push(point);
}
@ -62,36 +102,36 @@ editor_game_wrapper = function (editor, main, core) {
}
}
editor.indexs[0] = [0];
var startOffset = core.icons.tilesetStartOffset;
for (var i in core.tilesets) {
var imgName = core.tilesets[i];
var img = core.material.images.tilesets[imgName];
var width = Math.floor(img.width/32), height = Math.floor(img.height/32);
if(img.width%32 || img.height%32){
alert(imgName+'的长或宽不是32的整数倍, 请修改后刷新页面');
var width = Math.floor(img.width / 32), height = Math.floor(img.height / 32);
if (img.width % 32 || img.height % 32) {
alert(imgName + '的长或宽不是32的整数倍, 请修改后刷新页面');
}
if(img.width*img.height > 32*32*3000){
alert(imgName+'上的图块数量超过了3000请修改后刷新页面');
if (img.width * img.height > 32 * 32 * 3000) {
alert(imgName + '上的图块数量超过了3000请修改后刷新页面');
}
for (var id=startOffset; id<startOffset+width*height;id++) {
var x = (id-startOffset)%width, y = parseInt((id-startOffset)/width);
for (var id = startOffset; id < startOffset + width * height; id++) {
var x = (id - startOffset) % width, y = parseInt((id - startOffset) / width);
var indexBlock = getInfoById(id);
editor.ids.push({'idnum': id, 'id': indexBlock.event.id, 'images': imgName, "x": x, "y": y, isTile: true});
editor.ids.push({ 'idnum': id, 'id': indexBlock.event.id, 'images': imgName, "x": x, "y": y, isTile: true });
point++;
editor.indexs[id]=[point];
editor.indexs[id] = [point];
}
startOffset += core.icons.tilesetStartOffset;
}
}
editor_game.prototype.fetchMapFromCore = function(){
editor_game.prototype.fetchMapFromCore = function () {
var mapArray = core.maps.saveMap(core.status.floorId);
editor.map = mapArray.map(function (v) {
return v.map(function (v) {
var x = parseInt(v), y = editor.indexs[x];
if (y == null) {
printe("素材数字"+x+"未定义。是不是忘了注册或者接档时没有覆盖icons.js和maps.js");
printe("素材数字" + x + "未定义。是不是忘了注册或者接档时没有覆盖icons.js和maps.js");
y = [0];
}
return editor.ids[y[0]]
@ -99,17 +139,17 @@ editor_game_wrapper = function (editor, main, core) {
});
editor.currentFloorId = core.status.floorId;
editor.currentFloorData = core.floors[core.status.floorId];
for(var ii=0,name;name=['bgmap','fgmap'][ii];ii++){
for (var ii = 0, name; name = ['bgmap', 'fgmap'][ii]; ii++) {
var mapArray = editor.currentFloorData[name];
if(!mapArray || JSON.stringify(mapArray)==JSON.stringify([])){//未设置或空数组
if (!mapArray || JSON.stringify(mapArray) == JSON.stringify([])) {//未设置或空数组
//与editor.map同形的全0
mapArray=eval('['+Array(editor.map.length+1).join('['+Array(editor.map[0].length+1).join('0,')+'],')+']');
mapArray = eval('[' + Array(editor.map.length + 1).join('[' + Array(editor.map[0].length + 1).join('0,') + '],') + ']');
}
editor[name]=mapArray.map(function (v) {
editor[name] = mapArray.map(function (v) {
return v.map(function (v) {
var x = parseInt(v), y = editor.indexs[x];
if (y == null) {
printe("素材数字"+x+"未定义。是不是忘了注册或者接档时没有覆盖icons.js和maps.js");
printe("素材数字" + x + "未定义。是不是忘了注册或者接档时没有覆盖icons.js和maps.js");
y = [0];
}
return editor.ids[y[0]]
@ -118,7 +158,6 @@ editor_game_wrapper = function (editor, main, core) {
}
}
editor.constructor.prototype.game = new editor_game();
}
//editor_game_wrapper(editor);

View File

@ -12,31 +12,31 @@ editor_table_wrapper = function (editor) {
values.map(function (v) {
return editor.table.option(v)
}).join('')
return `<select>\n${content}</select>\n`
return /* html */`<select>\n${content}</select>\n`
}
editor_table.prototype.option = function (value) {
return `<option value='${JSON.stringify(value)}'>${JSON.stringify(value)}</option>\n`
return /* html */`<option value='${JSON.stringify(value)}'>${JSON.stringify(value)}</option>\n`
}
editor_table.prototype.text = function (value) {
return `<input type='text' spellcheck='false' value='${JSON.stringify(value)}'/>\n`
return /* html */`<input type='text' spellcheck='false' value='${JSON.stringify(value)}'/>\n`
}
editor_table.prototype.checkbox = function (value) {
return `<input type='checkbox' ${(value ? 'checked ' : '')}/>\n`
return /* html */`<input type='checkbox' ${(value ? 'checked ' : '')}/>\n`
}
editor_table.prototype.textarea = function (value, indent) {
return `<textarea spellcheck='false'>${JSON.stringify(value, null, indent || 0)}</textarea>\n`
return /* html */`<textarea spellcheck='false'>${JSON.stringify(value, null, indent || 0)}</textarea>\n`
}
editor_table.prototype.title = function () {
return `\n<tr><td>条目</td><td>注释</td><td>值</td></tr>\n`
return /* html */`\n<tr><td>条目</td><td>注释</td><td>值</td></tr>\n`
}
editor_table.prototype.gap = function (field) {
return `<tr><td>----</td><td>----</td><td>${field}</td></tr>\n`
return /* html */`<tr><td>----</td><td>----</td><td>${field}</td></tr>\n`
}
editor_table.prototype.tr = function (guid, field, shortField, commentHTMLescape, cobjstr, shortCommentHTMLescape, tdstr) {
return `<tr id="${guid}">
return /* html */`<tr id="${guid}">
<td title="${field}">${shortField}</td>
<td title="${commentHTMLescape}" cobj="${cobjstr}">${shortCommentHTMLescape}</td>
<td><div class="etableInputDiv">${tdstr}</div></td>

View File

@ -473,7 +473,7 @@ editor_unsorted_2_wrapper=function(editor_mode){
throw(err);
}
// Step 4: 自动注册
editor_file.registerAutotile(filename, function (err) {
editor.file.registerAutotile(filename, function (err) {
if (err) {
printe(err);
throw(err);

View File

@ -11,11 +11,11 @@
+ [ ] editor_multi 多行文本编辑器
+ [x] editor_table 处理表格的生成, 及其响应的事件, 从原editor\_mode中分离
+ [ ] editor_file 调用fs.js编辑文件, 把原editor\_file模块化
+ [ ] editor_game 处理来自core的数据, 导入为editor的数据, 从原editor中分离
+ [ ] editor_game 处理来自core的数据, 导入为editor的数据, 从原editor中分离. **只有此文件允许`\s(main|core)`形式的调用**(以及其初始化`editor_game_wrapper(editor, main, core);`)
+ [x] editor_util 生成guid等函数, 从editor分离
+ [ ] editor 执行初始化流程加组合各组件
+ [ ] 原editor_mode 移除
+ [ ] 原vm 移除
+ [x] 原vm 移除
+ [x] \*comment.js 表格注释与结构, 移至table/\*comment.js
## 对象结构
@ -46,19 +46,23 @@ editor: {
+ 插入公共事件的参数的转义处理, .g4中添加ObjectString, 要求其中的值可以JSON.parse, 生成的code中也是作为对象而不是字符串出现
+ 修改editor.multi中的转义处理
+ 修改editor.multi中的转义处理, 目前双击某些方块使用文本编辑的处理, 一部分在editor.blockly, 一部分在editor.multi, 比较混乱
+ 地图的编辑与其他(如全塔属性和楼层属性), 现在的文件操作的模式是完全不同的
楼层文件的储存与其他不同
+ editor.file在修改时不再返回obj和commentobj,只在查询时返回
+ [x] editor.file在修改时不再返回obj和commentobj,只在查询时返回
+ editor.file中的各个条目, 非常相似, 但是细节的不同处理非常麻烦. 是类似的代码复制后修改一部分, 尝试模块化
+ editor.file中的各个条目, 非常相似, 但是细节的不同处理非常麻烦. 是类似的代码复制后修改一部分, 尝试模块化(或者重写)
+ functions和plugins的借助JSON.stringify的replacer特殊处理
+ functions和plugins的借助JSON.stringify的replacer特殊处理, 与其他项的处理完全不同, 改成用统一的方法处理(为了统一,全部使用这种不直观的replacer的处理)
+ 怪物/物品/地图选点事件的处理, field中怪物id等明显与其他节地位不等, 处理起来很繁琐
+ 目前editor.map中储存的是info\<object\>, 准备改为和core一致只储存数字
+ editor.widthX特别不直观
## 功能改进
+ [ ] 大地图
@ -99,6 +103,10 @@ editor: {
+ [ ] 多帧素材只显示第一帧
+ [ ] `显示文章`以及`选项`等方块, 把`标题`和`图像`从字符串提取出填回相应的空
+ [ ] blockly中某些需要选点的填空, 增加按钮, 点击后从缩略图中点击位置
## 左侧页面模式
标题? 保存按钮? 添加按钮? 删除按钮?

View File

@ -32,7 +32,7 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"_leaf": true,
"_type": "textarea",
"_range": "editor.mode.checkUnique(thiseval)",
"_data": "在此存放所有可能使用的动画必须是animate格式在这里不写后缀名 \n动画必须放在animates目录下文件名不能使用中文不能带空格或特殊字符 \n \"jianji\", \"thunder\" \n 根据需求自行添加"
"_data": "在此存放所有可能使用的动画必须是animate格式在这里不写后缀名 \n动画必须放在animates目录下文件名不能使用中文不能带空格或特殊字符 \n \"jianji\", \"thunder\" 根据需求自行添加"
},
"bgms": {
"_leaf": true,
@ -46,6 +46,11 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"_range": "editor.mode.checkUnique(thiseval)",
"_data": "在此存放所有的SE和文件名一致 \n音频名不能使用中文不能带空格或特殊字符可以直接改名拼音就好"
},
"nameMap": {
"_leaf": true,
"_type": "textarea",
"_data": "文件名映射目前仅对images, animates, bgms, sounds有效。\n例如定义 {\"精灵石.mp3\":\"jinglingshi.mp3\"} 就可以使用\ncore.playBgm(\"精灵石.mp3\") 或对应的事件来播放该bgm。"
},
"startBackground": {
"_leaf": true,
"_type": "textarea",

View File

@ -523,8 +523,9 @@
<!-- <script src='_server/vendor/polyfill.min.js'></script> -->
<script src='_server/fs.js'></script>
<script src='_server/editor_util.js'></script>
<script src='_server/editor_file.js'></script>
<script src='_server/editor_game.js'></script>
<script src='_server/editor_file.js'></script>
<script src='_server/editor_file_unsorted.js'></script>
<script src='_server/editor_table.js'></script>
<script src='_server/editor_mode.js'></script>
<script src='_server/editor_unsorted_1.js'></script>

View File

@ -506,8 +506,9 @@
<!-- <script src='_server/vendor/polyfill.min.js'></script> -->
<script src='_server/fs.js'></script>
<script src='_server/editor_util.js'></script>
<script src='_server/editor_file.js'></script>
<script src='_server/editor_game.js'></script>
<script src='_server/editor_file.js'></script>
<script src='_server/editor_file_unsorted.js'></script>
<script src='_server/editor_table.js'></script>
<script src='_server/editor_mode.js'></script>
<script src='_server/editor_unsorted_1.js'></script>

View File

@ -71,7 +71,7 @@ actions.prototype._init = function () {
* 返回如果func返回true则不会再继续执行其他的交互函数否则会继续执行其他的交互函数
*/
actions.prototype.registerAction = function (action, name, func, priority) {
if (!name || !func || !(func instanceof Function))
if (!name || !func)
return;
priority = priority || 0;
if (!this.actions[action]) {
@ -99,8 +99,14 @@ actions.prototype.doRegisteredAction = function (action) {
var actions = this.actions[action];
if (!actions) return false;
for (var i = 0; i < actions.length; ++i) {
if (core.doFunc.apply(core, [actions[i].func, this].concat(Array.prototype.slice.call(arguments, 1))))
return true;
try {
if (core.doFunc.apply(core, [actions[i].func, this].concat(Array.prototype.slice.call(arguments, 1))))
return true;
}
catch (e) {
main.log(e);
main.log("ERROR in actions["+actions[i].name+"].");
}
}
return false;
}
@ -239,6 +245,7 @@ actions.prototype._sys_keyDown_lockControl = function (keyCode) {
case 'save':
case 'load':
case 'replayLoad':
case 'replayRemain':
this._keyDownSL(keyCode);
break;
case 'shop':
@ -340,6 +347,7 @@ actions.prototype._sys_keyUp_lockControl = function (keyCode, altKey) {
case 'save':
case 'load':
case 'replayLoad':
case 'replayRemain':
this._keyUpSL(keyCode);
break;
case 'keyBoard':
@ -606,6 +614,7 @@ actions.prototype._sys_onclick_lockControl = function (x, y) {
case 'save':
case 'load':
case 'replayLoad':
case 'replayRemain':
this._clickSL(x, y);
break;
case 'confirmBox':
@ -750,7 +759,7 @@ actions.prototype._sys_longClick_lockControl = function (x, y) {
}
}
// 长按SL快速翻页
if (["save","load","replayLoad"].indexOf(core.status.event.id) >= 0) {
if (["save","load","replayLoad","replayRemain"].indexOf(core.status.event.id) >= 0) {
if ([this.HSIZE-2, this.HSIZE-3, this.HSIZE+2, this.HSIZE+3].indexOf(x) >= 0 && y == this.LAST) {
this._clickSL(x, y);
return true;
@ -991,10 +1000,17 @@ actions.prototype._clickBook = function (x, y) {
// 怪物信息
var data = core.status.event.data;
if (data != null && y < this.LAST) {
var page = parseInt(data / this.HSIZE);
var index = this.HSIZE * page + parseInt(y / 2);
core.ui.drawBook(index);
core.ui.drawBookDetail(index);
var pageinfo = core.ui._drawBook_pageinfo();
var per_page = pageinfo.per_page, page = parseInt(data / per_page);
var u = this.LAST / per_page;
for (var i = 0; i < per_page; ++i) {
if (y >= u*i && y < u*(i+1)) {
var index = per_page * page + i;
core.ui.drawBook(index);
core.ui.drawBookDetail(index);
break;
}
}
return;
}
return;
@ -1027,7 +1043,7 @@ actions.prototype._keyUpBook = function (keycode) {
if (keycode == 13 || keycode == 32 || keycode == 67) {
var data = core.status.event.data;
if (data != null) {
this._clickBook(this.HSIZE, 2 * (data % this.HSIZE));
core.ui.drawBookDetail(data);
}
return;
}
@ -1644,6 +1660,7 @@ actions.prototype._clickSL = function (x, y) {
if (core.events.recoverEvents(core.status.event.interval))
return;
core.ui.closePanel();
delete core.status.tempRoute;
if (!core.isPlaying())
core.showStartAnimate(true);
return;
@ -1847,18 +1864,20 @@ actions.prototype._clickSwitchs = function (x, y) {
case 1:
return this._clickSwitchs_sound();
case 2:
return this._clickSwitchs_displayEnemyDamage();
return this._clickSwitchs_moveSpeed();
case 3:
return this._clickSwitchs_displayCritical();
return this._clickSwitchs_displayEnemyDamage();
case 4:
return this._clickSwitchs_displayExtraDamage();
return this._clickSwitchs_displayCritical();
case 5:
return this._clickSwitchs_localForage();
return this._clickSwitchs_displayExtraDamage();
case 6:
return this._clickSwitchs_clickMove();
return this._clickSwitchs_localForage();
case 7:
return this._clickSwitchs_ExtendKeyboard();
return this._clickSwitchs_clickMove();
case 8:
return this._clickSwitchs_ExtendKeyboard();
case 9:
core.status.event.selection = 0;
core.ui.drawSettings();
break;
@ -1877,6 +1896,16 @@ actions.prototype._clickSwitchs_sound = function () {
core.ui.drawSwitchs();
}
actions.prototype._clickSwitchs_moveSpeed = function () {
core.myprompt("请输入行走速度每走一步的时间单位毫秒默认100", core.values.moveSpeed, function (value) {
value = parseInt(value) || core.values.moveSpeed;
value = core.clamp(value, 10, 500);
core.values.moveSpeed = value;
core.setLocalStorage("moveSpeed", value);
core.ui.drawSwitchs();
});
}
actions.prototype._clickSwitchs_displayEnemyDamage = function () {
core.flags.displayEnemyDamage = !core.flags.displayEnemyDamage;
core.updateDamage();
@ -2006,12 +2035,10 @@ actions.prototype._clickSyncSave = function (x, y) {
case 4:
return this._clickSyncSave_replay();
case 5:
return this._clickSyncSave_download();
case 6:
core.status.event.selection = 0;
core.ui.drawStorageRemove();
break;
case 7:
case 6:
core.status.event.selection = 4;
core.ui.drawSettings();
break;
@ -2040,19 +2067,6 @@ actions.prototype._clickSyncSave_replay = function () {
}
}
actions.prototype._clickSyncSave_download = function () {
if (core.hasFlag('debug')) {
core.drawText("\t[系统提示]调试模式下无法下载录像");
return;
}
core.download(core.firstData.name + "_" + core.formatDate2() + ".h5route", JSON.stringify({
'name': core.firstData.name,
'hard': core.status.hard,
'seed': core.getFlag('__seed__'),
'route': core.encodeRoute(core.status.route)
}));
}
////// 同步存档界面时,放开某个键的操作 //////
actions.prototype._keyUpSyncSave = function (keycode) {
if (keycode == 27 || keycode == 88) {
@ -2239,9 +2253,10 @@ actions.prototype._clickReplay = function (x, y) {
switch (selection) {
case 0: return this._clickReplay_fromBeginning();
case 1: return this._clickReplay_fromLoad();
case 2: return core.chooseReplayFile();
case 3: return this._clickReplay_download();
case 4: return core.ui.closePanel();
case 2: return this._clickReplay_replayRemain();
case 3: return core.chooseReplayFile();
case 4: return this._clickReplay_download();
case 5: return core.ui.closePanel();
}
}
}
@ -2260,6 +2275,21 @@ actions.prototype._clickReplay_fromLoad = function () {
core.ui.drawSLPanel(10 * page + offset);
}
actions.prototype._clickReplay_replayRemain = function () {
core.closePanel();
core.drawText([
"\t[接续播放录像]该功能允许你播放\r[yellow]两个存档之间的录像\r常常用于\r[yellow]区域优化\r。\n" +
"例如,有若干个区,已经全部通关;之后重打一区并进行了优化,则可以对剩余区域直接播放录像而无需全部重打。",
"\t[步骤1]请选择一个存档。\n\r[yellow]该存档的坐标必须和当前勇士坐标完全相同。\r\n将尝试从此处开始回放。",
], function () {
core.status.event.id = 'replayRemain';
core.lockControl();
var saveIndex = core.saves.saveIndex;
var page = parseInt((saveIndex - 1) / 5), offset = saveIndex - 5 * page;
core.ui.drawSLPanel(10 * page + offset);
});
}
actions.prototype._clickReplay_download = function () {
if (core.hasFlag('debug')) return core.drawText("\t[系统提示]调试模式下无法下载录像");
core.download(core.firstData.name + "_" + core.formatDate2() + ".h5route", JSON.stringify({

View File

@ -1059,7 +1059,7 @@ control.prototype.startReplay = function (list) {
core.status.replay.pausing=false;
core.status.replay.speed=1.0;
core.status.replay.toReplay = core.clone(list);
core.status.replay.totalList = core.clone(list);
core.status.replay.totalList = core.status.route.concat(list);
core.status.replay.steps = 0;
core.status.replay.save = [];
core.updateStatusBar();
@ -1100,7 +1100,7 @@ control.prototype.speedUpReplay = function () {
else if (core.status.replay.speed==3) core.status.replay.speed=6;
else if (core.status.replay.speed==2.5) core.status.replay.speed=3;
else if (core.status.replay.speed==2) core.status.replay.speed=2.5;
else {
else if (core.status.replay.speed<2) {
core.status.replay.speed = parseInt(10*core.status.replay.speed + 2)/10;
}
core.drawTip("x"+core.status.replay.speed+"倍");
@ -1512,8 +1512,9 @@ control.prototype.checkAutosave = function () {
control.prototype.doSL = function (id, type) {
switch (type) {
case 'save': this._doSL_save(id); break;
case 'load': this._doSL_load(id); break;
case 'replayLoad': this._doSL_replayLoad(id); break;
case 'load': this._doSL_load(id, this._doSL_load_afterGet); break;
case 'replayLoad': this._doSL_load(id, this._doSL_replayLoad_afterGet); break;
case 'replayRemain': this._doSL_load(id, this._doSL_replayRemain_afterGet); break;
}
}
@ -1542,14 +1543,14 @@ control.prototype._doSL_save = function (id) {
return;
}
control.prototype._doSL_load = function (id) {
control.prototype._doSL_load = function (id, callback) {
if (id == 'autoSave' && core.saves.autosave.data != null) {
this._doSL_load_afterGet(id, core.clone(core.saves.autosave.data));
callback(id, core.clone(core.saves.autosave.data))
}
else {
core.getLocalForage(id=='autoSave'?id:"save"+id, null, function(data) {
if (id == 'autoSave') core.saves.autosave.data = core.clone(data);
core.control._doSL_load_afterGet(id, data);
callback(id, data);
}, function(err) {
main.log(err);
alert("无效的存档");
@ -1579,22 +1580,6 @@ control.prototype._doSL_load_afterGet = function (id, data) {
core.setLocalStorage('saveIndex', core.saves.saveIndex);
}
});
}
control.prototype._doSL_replayLoad = function (id) {
if (id == 'autoSave' && core.saves.autosave.data != null) {
this._doSL_replayLoad_afterGet(core.clone(core.saves.autosave.data));
}
else{
core.getLocalForage(id=='autoSave'?id:"save"+id, null, function(data) {
if (id == 'autoSave') core.saves.autosave.data = core.clone(data);
core.control._doSL_replayLoad_afterGet(id, data);
}, function(err) {
main.log(err);
alert("无效的存档");
})
}
}
control.prototype._doSL_replayLoad_afterGet = function (id, data) {
@ -1613,6 +1598,34 @@ control.prototype._doSL_replayLoad_afterGet = function (id, data) {
}
control.prototype._doSL_replayRemain_afterGet = function (id, data) {
if (!data) return core.drawTip("无效的存档");
var route = core.decodeRoute(data.route);
if (core.status.tempRoute) {
var remainRoute = core.subarray(route, core.status.tempRoute);
if (remainRoute == null)
return alert("无法接续播放录像!\n该存档必须是前一个选择的存档的后续内容。");
delete core.status.tempRoute;
core.ui.closePanel();
core.startReplay(remainRoute);
core.drawTip("接续播放录像");
return;
}
else if (data.floorId != core.status.floorId || data.hero.loc.x != core.getHeroLoc('x') || data.hero.loc.y != core.getHeroLoc('y'))
return alert("楼层或坐标不一致!");
core.status.tempRoute = route;
core.ui.closePanel();
core.drawText("\t[步骤2]请选择第二个存档。\n\r[yellow]该存档必须是前一个存档的后续。\r\n将尝试播放到此存档。", function () {
core.status.event.id = 'replayRemain';
core.lockControl();
var saveIndex = core.saves.saveIndex;
var page = parseInt((saveIndex - 1) / 5), offset = saveIndex - 5 * page;
core.ui.drawSLPanel(10 * page + offset);
});
}
////// 同步存档到服务器 //////
control.prototype.syncSave = function (type) {
core.ui.drawWaiting("正在同步,请稍后...");
@ -1856,8 +1869,8 @@ control.prototype.getStatus = function (name) {
////// 从status中获得属性如果不存在则从勇士属性中获取 //////
control.prototype.getStatusOrDefault = function (status, name) {
if (status && name in status)
return status[name];
return this.getStatus(name);
return Math.floor(status[name]);
return Math.floor(this.getStatus(name));
}
////// 获得勇士实际属性(增幅后的) //////
@ -1867,7 +1880,7 @@ control.prototype.getRealStatus = function (name) {
////// 从status中获得实际属性增幅后的如果不存在则从勇士属性中获取 //////
control.prototype.getRealStatusOrDefault = function (status, name) {
return this.getStatusOrDefault(status, name) * this.getBuff(name);
return Math.floor(this.getStatusOrDefault(status, name) * this.getBuff(name));
}
////// 设置某个属性的增幅值 //////
@ -1966,6 +1979,10 @@ control.prototype.debug = function() {
// ------ 天气色调BGM ------ //
control.prototype.getMappedName = function (name) {
return (main.nameMap || {})[name] || name;
}
////// 更改天气效果 //////
control.prototype.setWeather = function (type, level) {
// 非雨雪
@ -2088,6 +2105,7 @@ control.prototype.screenFlash = function (color, time, times, callback) {
////// 播放背景音乐 //////
control.prototype.playBgm = function (bgm, startTime) {
bgm = core.getMappedName(bgm);
if (main.mode!='play' || !core.material.bgms[bgm]) return;
// 如果不允许播放
if (!core.musicStatus.bgmStatus) {
@ -2114,8 +2132,6 @@ control.prototype.playBgm = function (bgm, startTime) {
}
control.prototype._playBgm_play = function (bgm, startTime) {
// 缓存BGM
core.loader.loadBgm(bgm);
// 如果当前正在播放且和本BGM相同直接忽略
if (core.musicStatus.playingBgm == bgm && !core.material.bgms[core.musicStatus.playingBgm].paused) {
return;
@ -2124,6 +2140,8 @@ control.prototype._playBgm_play = function (bgm, startTime) {
if (core.musicStatus.playingBgm) {
core.material.bgms[core.musicStatus.playingBgm].pause();
}
// 缓存BGM
core.loader.loadBgm(bgm);
// 播放当前BGM
core.material.bgms[bgm].volume = core.musicStatus.volume;
core.material.bgms[bgm].currentTime = startTime || 0;
@ -2152,7 +2170,7 @@ control.prototype.pauseBgm = function () {
control.prototype.resumeBgm = function () {
if (main.mode!='play')return;
try {
core.playBgm(core.musicStatus.playingBgm || core.musicStatus.lastBgm);
core.playBgm(core.musicStatus.playingBgm || core.musicStatus.lastBgm || main.startBgm);
}
catch (e) {
console.log("无法恢复BGM");
@ -2182,6 +2200,7 @@ control.prototype.triggerBgm = function () {
////// 播放音频 //////
control.prototype.playSound = function (sound) {
sound = core.getMappedName(sound);
if (main.mode!='play' || !core.musicStatus.soundStatus || !core.material.sounds[sound]) return;
try {
if (core.musicStatus.audioContext != null) {

View File

@ -252,6 +252,8 @@ core.prototype._init_sys_flags = function () {
core.flags.displayEnemyDamage = core.getLocalStorage('enemyDamage', core.flags.displayEnemyDamage);
core.flags.displayCritical = core.getLocalStorage('critical', core.flags.displayCritical);
core.flags.displayExtraDamage = core.getLocalStorage('extraDamage', core.flags.displayExtraDamage);
// 行走速度
core.values.moveSpeed = core.getLocalStorage('moveSpeed', core.values.moveSpeed);
}
core.prototype._init_platform = function () {

View File

@ -360,6 +360,14 @@ enemys.prototype._getCurrentEnemys_sort = function (enemys) {
}
enemys.prototype.hasEnemyLeft = function (enemyId, floorId) {
if (floorId == null) floorId = core.status.floorId;
if (floorId instanceof Array) {
for (var i = 0; i < floorId.length; ++i) {
if (core.hasEnemyLeft(enemyId, floorId[i]))
return true;
}
return false;
}
return core.getCurrentEnemys(floorId).filter(function (enemy) {
return enemyId == null || enemy.id == enemyId;
}).length > 0;

View File

@ -41,7 +41,7 @@ events.prototype.startGame = function (hard, seed, route, callback) {
events.prototype._startGame_start = function (hard, seed, route, callback) {
console.log('开始游戏');
core.resetGame(core.firstData.hero, hard, null, core.initStatus.maps);
core.resetGame(core.firstData.hero, hard, null, core.clone(core.initStatus.maps));
var nowLoc = core.clone(core.getHeroLoc());
core.setHeroLoc('x', -1);
core.setHeroLoc('y', -1);
@ -287,8 +287,12 @@ events.prototype.doSystemEvent = function (type, data, callback) {
////// 触发(x,y)点的事件 //////
events.prototype._trigger = function (x, y) {
// 如果已经死亡,或正处于某事件中,则忽略
if (core.status.gameOver || core.status.event.id) return;
if (core.status.gameOver) return;
if (core.status.event.id == 'action') {
core.insertAction({"type": "trigger", "loc": [x, y]}, x, y, null, true);
return;
}
if (core.status.event.id) return;
var block = core.getBlock(x, y);
if (block == null) return;
@ -711,7 +715,7 @@ events.prototype._sys_action = function (data, callback) {
var dir = core.reverseDirection();
var id = data.event.id, toId = (data.event.faceIds || {})[dir];
if (toId && id != toId) {
var number = core.icons.getNumberById(toId);
var number = core.getNumberById(toId);
if (number > 0)
core.setBlock(number, ex, ey);
}
@ -924,7 +928,7 @@ events.prototype._action_autoText = function (data, x, y, prefix) {
events.prototype._action_scrollText = function (data, x, y, prefix) {
if (this.__action_checkReplaying()) return;
this.__action_doAsyncFunc(data.async, core.ui.drawScrollText, data.text, data.lineHeight || 1.4, data.time || 5000);
this.__action_doAsyncFunc(data.async, core.drawScrollText, data.text, data.time || 5000, data.lineHeight || 1.4);
}
events.prototype._action_comment = function (data, x, y, prefix) {
@ -941,9 +945,10 @@ events.prototype._action_setText = function (data, x, y, prefix) {
core.status.textAttribute[t] = data[t];
}
if (t == 'background') {
var img = core.material.images.images[data[t]];
var name = core.getMappedName(data[t]);
var img = core.material.images.images[name];
if (img && img.width == 192 && img.height == 128) {
core.status.textAttribute[t] = data[t];
core.status.textAttribute[t] = name;
}
}
});
@ -1067,20 +1072,20 @@ events.prototype._action_changePos = function (data, x, y, prefix) {
events.prototype._action_showImage = function (data, x, y, prefix) {
if (core.isReplaying()) data.time = 0;
this.__action_doAsyncFunc(data.async || data.time == 0, this.showImage,
this.__action_doAsyncFunc(data.async || data.time == 0, core.showImage,
data.code, data.image, data.sloc, data.loc, data.opacity, data.time);
}
events.prototype._action_showTextImage = function (data, x, y, prefix) {
var loc = this.__action_getLoc(data.loc, 0, 0, prefix);
if (core.isReplaying()) data.time = 0;
this.__action_doAsyncFunc(data.async || data.time == 0, this.showImage,
this.__action_doAsyncFunc(data.async || data.time == 0, core.showImage,
data.code, core.ui.textImage(data.text), loc[0], loc[1], 100, 100, data.opacity, data.time);
}
events.prototype._action_hideImage = function (data, x, y, prefix) {
if (core.isReplaying()) data.time = 0;
this.__action_doAsyncFunc(data.async || data.time == 0, this.hideImage, data.code, data.time);
this.__action_doAsyncFunc(data.async || data.time == 0, core.hideImage, data.code, data.time);
}
events.prototype._action_showGif = function (data, x, y, prefix) {
@ -1091,7 +1096,7 @@ events.prototype._action_showGif = function (data, x, y, prefix) {
events.prototype._action_moveImage = function (data, x, y, prefix) {
if (this.__action_checkReplaying()) return;
this.__action_doAsyncFunc(data.async, this.moveImage, data.code, data.to, data.opacity, data.time);
this.__action_doAsyncFunc(data.async, core.moveImage, data.code, data.to, data.opacity, data.time);
}
events.prototype._action_setFg = function (data, x, y, prefix) {
@ -1250,7 +1255,7 @@ events.prototype._action_stopSound = function (data, x, y, prefix) {
events.prototype._action_setVolume = function (data, x, y, prefix) {
data.value = core.clamp(parseInt(data.value) / 100, 0, 1);
core.setFlag("__volume__", data.value);
this.__action_doAsyncFunc(data.async, this.setVolume, data.value, data.time || 0);
this.__action_doAsyncFunc(data.async, core.setVolume, data.value, data.time || 0);
}
events.prototype._action_setValue = function (data, x, y, prefix) {
@ -1487,7 +1492,7 @@ events.prototype._action_updateEnemys = function (data, x, y, prefix) {
}
events.prototype._action_vibrate = function (data, x, y, prefix) {
this.__action_doAsyncFunc(data.async, this.vibrate, data.time);
this.__action_doAsyncFunc(data.async, core.vibrate, data.time);
}
events.prototype._action_sleep = function (data, x, y, prefix) {
@ -1743,6 +1748,7 @@ events.prototype.hasAsync = function () {
////// 跟随 //////
events.prototype.follow = function (name) {
core.status.hero.followers = core.status.hero.followers || [];
name = core.getMappedName(name);
if (core.material.images.images[name]
&& core.material.images.images[name].width == 128) {
core.status.hero.followers.push({"name": name});
@ -1759,6 +1765,7 @@ events.prototype.unfollow = function (name) {
core.status.hero.followers = [];
}
else {
name = core.getMappedName(name);
for (var i = 0; i < core.status.hero.followers.length; i++) {
if (core.status.hero.followers[i].name == name) {
core.status.hero.followers.splice(i, 1);
@ -1883,7 +1890,10 @@ events.prototype.closeDoor = function (x, y, id, callback) {
////// 显示图片 //////
events.prototype.showImage = function (code, image, sloc, loc, opacityVal, time, callback) {
if (typeof image == 'string') image = core.material.images.images[image];
if (typeof image == 'string') {
image = core.getMappedName(image);
image = core.material.images.images[image];
}
if (!image) {
if (callback) callback();
return;
@ -1976,6 +1986,7 @@ events.prototype._moveImage_moving = function (name, moveInfo, callback) {
////// 绘制或取消一张gif图片 //////
events.prototype.showGif = function (name, x, y) {
name = core.getMappedName(name);
var image = core.material.images.images[name];
if (image) {
var gif = new Image();
@ -2226,6 +2237,7 @@ events.prototype.canUseQuickShop = function (shopId) {
////// 设置角色行走图 //////
events.prototype.setHeroIcon = function (name, noDraw) {
name = core.getMappedName(name);
var img = core.material.images.images[name];
if (!img || img.width != 128) return;
core.setFlag("heroIcon", name);

View File

@ -238,6 +238,7 @@ loader.prototype.loadOneSound = function (name) {
}
loader.prototype.loadBgm = function (name) {
name = core.getMappedName(name);
if (!core.material.bgms[name]) return;
// 如果没开启音乐,则不预加载
if (!core.musicStatus.bgmStatus) return;
@ -265,6 +266,7 @@ loader.prototype._preloadBgm = function (bgm) {
}
loader.prototype.freeBgm = function (name) {
name = core.getMappedName(name);
if (!core.material.bgms[name]) return;
// 从cachedBgms中删除
core.musicStatus.cachedBgms = core.musicStatus.cachedBgms.filter(function (t) {

View File

@ -784,13 +784,26 @@ maps.prototype._drawBgFgMap = function (floorId, ctx, name, onMap) {
core.status[name + "maps"] = {};
var arr = this._getBgFgMapArray(name, floorId, true);
var eventArr = null;
if (main.mode == 'editor' && name == 'fg' && onMap) {
eventArr = this.getMapArray(floorId);
}
for (var x = 0; x < width; x++) {
for (var y = 0; y < height; y++) {
var block = this.initBlock(x, y, arr[y][x], true);
block.name = name;
var blockInfo = this.getBlockInfo(block);
if (!blockInfo) continue;
// --- 前景虚化
var blur = false, alpha;
if (eventArr != null && eventArr[y][x] != 0) {
blur = true;
alpha = ctx.globalAlpha;
ctx.globalAlpha = 0.6;
}
this._drawMap_drawBlockInfo(ctx, block, blockInfo, arr, onMap);
if (blur) ctx.globalAlpha = alpha;
}
}
if (onMap)
@ -806,6 +819,7 @@ maps.prototype._drawFloorImages = function (floorId, ctx, name, images, currStat
images.forEach(function (t) {
if (typeof t == 'string') t = [0, 0, t];
var dx = parseInt(t[0]), dy = parseInt(t[1]), imageName = t[2], frame = core.clamp(parseInt(t[4]), 1, 8);
imageName = core.getMappedName(imageName);
var image = core.material.images.images[imageName];
if (redraw && frame == 1) return; // 不重绘
@ -1069,6 +1083,7 @@ maps.prototype._drawThumbnail_realDrawTempCanvas = function (floorId, blocks, op
// 缩略图:勇士
if (options.heroLoc) {
options.heroIcon = options.heroIcon || core.getFlag("heroIcon", "hero.png");
options.heroIcon = core.getMappedName(options.heroIcon);
var icon = core.material.icons.hero[options.heroLoc.direction];
var height = core.material.images.images[options.heroIcon].height / 4;
tempCanvas.drawImage(core.material.images.images[options.heroIcon], icon.stop * 32, icon.loc * height, 32, height,
@ -1844,6 +1859,7 @@ maps.prototype.drawBoxAnimate = function () {
////// 绘制动画 //////
maps.prototype.drawAnimate = function (name, x, y, callback) {
name = core.getMappedName(name);
// 正在播放录像:不显示动画
if (core.isReplaying()) {

View File

@ -226,6 +226,7 @@ ui.prototype.drawImage = function (name, image, x, y, w, h, x1, y1, w1, h1) {
var ctx = this.getContextByName(name);
if (!ctx) return;
if (typeof image == 'string') {
image = core.getMappedName(image);
image = core.material.images.images[image];
if (!image) return;
}
@ -374,8 +375,10 @@ ui.prototype._getTitleAndIcon = function (content) {
icon = 0;
height = core.material.icons.hero.height;
}
else if (/^[-\w.]+\.png$/.test(s4))
else if (s4.endsWith(".png")) {
s4 = core.getMappedName(s4);
image = core.material.images.images[s4];
}
else {
var blockInfo = core.getBlockInfo(s4);
if (blockInfo != null) {
@ -509,29 +512,42 @@ ui.prototype.drawBackground = function (left, top, right, bottom, posInfo) {
var xoffset = posInfo.xoffset || 0, yoffset = posInfo.yoffset || 0;
var background = core.status.textAttribute.background;
if (this._drawBackground_drawWindowSkin(background, left, top, right, bottom, posInfo.position, px, py))
return true;
if (typeof background == 'string') background = core.initStatus.textAttribute.background;
this._drawBackground_drawColor(background, left, top, right, bottom, posInfo.position, px, py, xoffset, yoffset);
return false;
}
ui.prototype._drawWindowSkin_getOpacity = function () {
return core.getFlag("__winskin_opacity__", 0.85);
}
ui.prototype._drawBackground_drawWindowSkin = function (background, left, top, right, bottom, position, px, py) {
if (typeof background == 'string' && core.material.images.images[background]) {
var image = core.material.images.images[background];
if (image.width==192 && image.height==128) {
core.setAlpha('ui', 0.85);
this.drawWindowSkin(image, 'ui', left, top, right - left, bottom - top, posInfo.position, px, py);
core.setAlpha('ui', this._drawWindowSkin_getOpacity());
this.drawWindowSkin(image, 'ui', left, top, right - left, bottom - top, position, px, py);
core.setAlpha('ui', 1);
return true;
}
background = core.initStatus.textAttribute.background;
}
return false;
}
ui.prototype._drawBackground_drawColor = function (background, left, top, right, bottom, position, px, py, xoffset, yoffset) {
var alpha = background[3];
core.setAlpha('ui', alpha);
core.setStrokeStyle('ui', core.status.globalAttribute.borderColor);
core.setFillStyle('ui', core.arrayToRGB(background));
core.setLineWidth('ui', 2);
// 绘制
var ctx = core.canvas.ui;
ctx.beginPath();
ctx.moveTo(left, top);
// 上边缘三角
if (posInfo.position == 'down' && px != null && py != null) {
if (position == 'down' && px != null && py != null) {
ctx.lineTo(px + xoffset, top);
ctx.lineTo(px + 16, top - yoffset);
ctx.lineTo(px + 32 - xoffset, top);
@ -539,7 +555,7 @@ ui.prototype.drawBackground = function (left, top, right, bottom, posInfo) {
ctx.lineTo(right, top);
ctx.lineTo(right, bottom);
// 下边缘三角
if (posInfo.position == 'up' && px != null && py != null) {
if (position == 'up' && px != null && py != null) {
ctx.lineTo(px + 32 - xoffset, bottom);
ctx.lineTo(px + 16, bottom + yoffset);
ctx.lineTo(px + xoffset, bottom);
@ -549,7 +565,6 @@ ui.prototype.drawBackground = function (left, top, right, bottom, posInfo) {
ctx.fill();
ctx.stroke();
core.setAlpha('ui', 1);
return false;
}
////// 计算有效文本框的宽度
@ -802,7 +817,7 @@ ui.prototype.drawTextBox = function(content, showAll) {
var pInfo = core.clone(posInfo);
pInfo.xoffset = hPos.xoffset; pInfo.yoffset = vPos.yoffset - 4;
var isWindowSkin = this.drawBackground(hPos.left, vPos.top, hPos.right, vPos.bottom, pInfo);
var alpha = isWindowSkin ? 0.85 : textAttribute.background[3];
var alpha = isWindowSkin ? this._drawWindowSkin_getOpacity() : textAttribute.background[3];
// Step 4: 绘制标题、头像、动画
var content_top = this._drawTextBox_drawTitleAndIcon(titleInfo, hPos, vPos, alpha);
@ -818,6 +833,7 @@ ui.prototype._drawTextBox_drawImages = function (content) {
return content.replace(/(\f|\\f)\[(.*?)]/g, function (text, sympol, str) {
var ss = str.split(",");
if (ss.length!=3 && ss.length!=5 && ss.length!=9) return "";
ss[0] = core.getMappedName(ss[0]);
var img = core.material.images.images[ss[0]];
if (!img) return "";
// 绘制
@ -1174,6 +1190,7 @@ ui.prototype.drawSwitchs = function() {
var choices = [
"背景音乐: "+(core.musicStatus.bgmStatus ? "[ON]" : "[OFF]"),
"背景音效: "+(core.musicStatus.soundStatus ? "[ON]" : "[OFF]"),
"行走速度: "+parseInt(core.values.moveSpeed),
"怪物显伤: "+(core.flags.displayEnemyDamage ? "[ON]" : "[OFF]"),
"临界显伤: "+(core.flags.displayCritical ? "[ON]" : "[OFF]"),
"领域显伤: "+(core.flags.displayExtraDamage ? "[ON]" : "[OFF]"),
@ -1210,7 +1227,7 @@ ui.prototype.drawQuickShop = function () {
ui.prototype.drawSyncSave = function () {
core.status.event.id = 'syncSave';
this.drawChoices(null, [
"同步存档到服务器", "从服务器加载存档", "存档至本地文件", "从本地文件读档", "回放当前录像", "下载当前录像", "清空本地存档", "返回主菜单"
"同步存档到服务器", "从服务器加载存档", "存档至本地文件", "从本地文件读档", "回放和下载录像", "清空本地存档", "返回主菜单"
]);
}
@ -1242,7 +1259,7 @@ ui.prototype.drawReplay = function () {
core.lockControl();
core.status.event.id = 'replay';
this.drawChoices(null, [
"从头回放录像", "从存档开始回放", "选择录像文件", "下载当前录像", "返回游戏"
"从头回放录像", "从存档开始回放", "接续播放剩余录像", "选择录像文件", "下载当前录像", "返回游戏"
]);
}
@ -1309,12 +1326,14 @@ ui.prototype.drawBook = function (index) {
index = core.clamp(index, 0, enemys.length - 1);
core.status.event.data = index;
var perpage = this.HSIZE, page = parseInt(index / perpage) + 1, totalPage = Math.ceil(enemys.length / perpage);
var pageinfo = this._drawBook_pageinfo();
var perpage = pageinfo.per_page, page = parseInt(index / perpage) + 1, totalPage = Math.ceil(enemys.length / perpage);
var start = (page - 1) * perpage;
enemys = enemys.slice(start, page * perpage);
for (var i = 0; i < enemys.length; i++)
this._drawBook_drawOne(floorId, i, enemys[i], index == start + i);
this._drawBook_drawOne(floorId, i, enemys[i], pageinfo, index == start + i);
core.drawBoxAnimate();
this.drawPagination(page, totalPage);
@ -1322,6 +1341,13 @@ ui.prototype.drawBook = function (index) {
core.fillText('ui', '返回游戏', this.PIXEL - 46, this.PIXEL - 13,'#DDDDDD', this._buildFont(15, true));
}
ui.prototype._drawBook_pageinfo = function () {
var per_page = this.HSIZE; // 每页个数
var padding_top = 12; // 距离顶端像素
var per_height = (this.PIXEL - 32 - padding_top) / per_page;
return { per_page: per_page, padding_top: padding_top, per_height: per_height };
}
ui.prototype._drawBook_drawBackground = function () {
core.setAlpha('ui', 1);
core.setFillStyle('ui', core.material.groundPattern);
@ -1332,24 +1358,24 @@ ui.prototype._drawBook_drawBackground = function () {
core.fillRect('ui', 0, 0, this.PIXEL, this.PIXEL);
}
ui.prototype._drawBook_drawOne = function (floorId, index, enemy, selected) {
// --- 区域规划:每个区域总高度为62宽度为 PIXEL
var top = 62 * index + 12; // 最上面margin是12px
ui.prototype._drawBook_drawOne = function (floorId, index, enemy, pageinfo, selected) {
// --- 区域规划:每个区域总高度默认为62宽度为 PIXEL
var top = pageinfo.per_height * index + pageinfo.padding_top; // 最上面margin默认是12px
// 横向规划:
// 22 + 42 = 64 是头像框
this._drawBook_drawBox(index, enemy, top);
this._drawBook_drawBox(index, enemy, top, pageinfo);
// 剩余 PIXEL - 64 的宽度,按照 10 : 9 : 8 : 8 的比例划分
var left = 64, total_width = this.PIXEL - left;
var name_width = total_width * 10 / 35;
this._drawBook_drawName(index, enemy, top, left, name_width);
this._drawBook_drawContent(index, enemy, top, left + name_width);
if (selected)
core.strokeRect('ui', 10, top + 1, this.PIXEL - 10 * 2, 62, '#FFD700');
core.strokeRect('ui', 10, top + 1, this.PIXEL - 10 * 2, pageinfo.per_height, '#FFD700');
}
ui.prototype._drawBook_drawBox = function (index, enemy, top) {
ui.prototype._drawBook_drawBox = function (index, enemy, top, pageinfo) {
// 横向22+42纵向10 + 42 + 10正好居中内部图像 32x32
var border_top = top + 10, border_left = 22;
var border_top = top + (pageinfo.per_height - 42) / 2, border_left = 22;
var img_top = border_top + 5, img_left = border_left + 5;
core.strokeRect('ui', 22, border_top, 42, 42, '#DDDDDD', 2);
var blockInfo = core.getBlockInfo(enemy.id);
@ -2011,19 +2037,19 @@ ui.prototype._drawEquipbox_getStatusChanged = function (info, equip, equipType)
ui.prototype._drawEquipbox_drawStatusChanged = function (info, y, equip, equipType) {
var compare = this._drawEquipbox_getStatusChanged(info, equip, equipType);
if (compare == null) return;
var drawOffset = 10;
var obj = { drawOffset: 10, y: y };
// --- 变化值...
core.setFont('ui', this._buildFont(14, true));
for (var name in compare) {
var img = core.statusBar.icons[name];
var text = core.getStatusName(name);
if (img && core.flags.iconInEquipbox) { // 绘制图标
core.drawImage('ui', img, 0, 0, 32, 32, drawOffset, y - 13, 16, 16);
drawOffset += 20;
core.drawImage('ui', img, 0, 0, 32, 32, obj.drawOffset, obj.y - 13, 16, 16);
obj.drawOffset += 20;
}
else { // 绘制文字
core.fillText('ui', text + " ", drawOffset, y, '#CCCCCC');
drawOffset += core.calWidth('ui', text + " ");
this._drawEquipbox_drawStatusChanged_draw(text + " ", '#CCCCCC', obj);
}
var nowValue = core.getStatus(name) * core.getBuff(name), newValue = (nowValue + compare[name]) * core.getBuff(name);
if (equip.equip.percentage) {
@ -2033,13 +2059,22 @@ ui.prototype._drawEquipbox_drawStatusChanged = function (info, y, equip, equipTy
}
nowValue = core.formatBigNumber(nowValue);
newValue = core.formatBigNumber(newValue);
core.fillText('ui', nowValue + "->", drawOffset, y, '#CCCCCC');
drawOffset += core.calWidth('ui', nowValue + "->");
core.fillText('ui', newValue, drawOffset, y, compare[name]>0?'#00FF00':'#FF0000');
drawOffset += core.calWidth('ui', newValue) + 8;
this._drawEquipbox_drawStatusChanged_draw(nowValue+"->", '#CCCCCC', obj);
this._drawEquipbox_drawStatusChanged_draw(newValue, compare[name]>0?'#00FF00':'#FF0000', obj);
obj.drawOffset += 8;
}
}
ui.prototype._drawEquipbox_drawStatusChanged_draw = function (text, color, obj) {
var len = core.calWidth('ui', text);
if (obj.drawOffset + len >= core.__PIXELS__) { // 换行
obj.y += 19;
obj.drawOffset = 10;
}
core.fillText('ui', text, obj.drawOffset, obj.y, color);
obj.drawOffset += len;
}
ui.prototype._drawEquipbox_drawEquiped = function (info, line) {
core.setTextAlign('ui', 'center');
var per_line = this.HSIZE - 3, width = Math.floor(this.PIXEL / (per_line + 0.25));
@ -2169,7 +2204,7 @@ ui.prototype._drawSLPanel_drawRecords = function (n) {
var page = core.status.event.data.page;
var offset = core.status.event.data.offset;
var u = Math.floor(this.PIXEL/6), size = Math.floor(this.PIXEL/3-20);
var name=core.status.event.id=='save'?"存档":core.status.event.id=='load'?"读档":core.status.event.id=='replayLoad'?"回放":"";
var name=core.status.event.id=='save'?"存档":core.status.event.id=='load'?"读档":"回放";
for (var i = 0; i < (n||6); i++){
var data = core.status.event.ui[i];

View File

@ -63,10 +63,10 @@ utils.prototype.replaceText = function (text, need, times) {
utils.prototype.calValue = function (value, prefix, need, times) {
if (!core.isset(value)) return null;
if (typeof value === 'string') {
value = value.replace(/status:([\w\d_]+)/g, "core.getStatus('$1')");
value = value.replace(/item:([\w\d_]+)/g, "core.itemCount('$1')");
value = value.replace(/flag:([\w\d_]+)/g, "core.getFlag('$1', 0)");
value = value.replace(/switch:([\w\d_]+)/g, "core.getFlag('" + (prefix || ":f@x@y") + "@$1', 0)");
value = value.replace(/status:([a-zA-Z0-9_]+)/g, "core.getStatus('$1')");
value = value.replace(/item:([a-zA-Z0-9_]+)/g, "core.itemCount('$1')");
value = value.replace(/flag:([a-zA-Z0-9_\u4E00-\u9FCC]+)/g, "core.getFlag('$1', 0)");
value = value.replace(/switch:([a-zA-Z0-9_]+)/g, "core.getFlag('" + (prefix || ":f@x@y") + "@$1', 0)");
return eval(value);
}
if (value instanceof Function) {
@ -282,8 +282,10 @@ utils.prototype.clone = function (data, filter, recursion) {
////// 裁剪图片 //////
utils.prototype.splitImage = function (image, width, height) {
if (typeof image == "string")
if (typeof image == "string") {
image = core.getMappedName(image);
image = core.material.images.images[image];
}
if (!image) return [];
width = width || 32;
height = height || width;

View File

@ -35,6 +35,10 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
"bomb.mp3",
"centerFly.mp3"
],
"nameMap": {
"背景图.jpg": "bg.jpg",
"背景音乐.mp3": "bgm.mp3"
},
"startBackground": "bg.jpg",
"startLogoStyle": "color: black",
"levelChoose": [
@ -63,7 +67,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
"statusLeftBackground": "url(project/images/ground.png) repeat",
"statusTopBackground": "url(project/images/ground.png) repeat",
"toolsBackground": "url(project/images/ground.png) repeat",
"borderColor": "white",
"borderColor": "#CCCCCC",
"statusBarColor": "white",
"hardLabelColor": "red",
"floorChangingBackground": "black",

View File

@ -9,7 +9,9 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
// 这一步会清空状态栏和全部画布内容,并删除所有动态创建的画布
core.clearStatus();
// 初始化status
core.status = core.clone(core.initStatus);
core.status = core.clone(core.initStatus, function (name) {
return name != 'hero' && name != 'maps';
});
core.status.played = true;
// 初始化人物,图标,统计信息
core.status.hero = core.clone(hero);
@ -22,7 +24,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
core.status.hard = hard || "";
// 初始化地图
core.status.floorId = floorId;
core.status.maps = core.clone(maps);
core.status.maps = maps;
// 初始化怪物和道具
core.material.enemys = core.enemys.getEnemys();
core.material.items = core.items.getItems();
@ -968,6 +970,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
core.events.setVolume(core.getFlag("__volume__", 1), 0);
// 加载勇士图标
var icon = core.getFlag("heroIcon", "hero.png");
icon = core.getMappedName(icon);
if (core.material.images.images[icon]) {
core.material.images.hero.src = core.material.images.images[icon].src;
core.material.icons.hero.height = core.material.images.images[icon].height / 4;
@ -978,7 +981,12 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
// TODO增加自己的一些读档处理
// 切换到对应的楼层
core.changeFloor(data.floorId, null, data.hero.loc, 0, callback, true);
core.changeFloor(data.floorId, null, data.hero.loc, 0, function () {
// TODO可以在这里设置读档后播放BGM
// if (core.getFlag("bgm", 0)==1) core.playBgm("bgm.mp3");
if (callback) callback();
}, true);
},
"updateStatusBar": function () {
// 更新状态栏