Merge branch 'v2.0' of https://github.com/ckcz123/mota-js into v2.0

This commit is contained in:
ckcz123 2018-03-10 15:11:32 +08:00
commit 5f452a5363
36 changed files with 938 additions and 485 deletions

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MarkdownExportedFiles">
<htmlFiles />
<imageFiles />
<otherFiles />
</component>
</project>

View File

@ -59,38 +59,38 @@ editor.file.saveFloorFileAs
```
5个编辑模式有关的查询
```javascript
editor.file.editItem(editor,'redJewel',[],function(a){console.log(a)});
editor.file.editEnemy(editor,'redBat',[],function(a){console.log(a)});
editor.file.editLoc(editor,2,0,[],function(a){console.log(a)});
editor.file.editFloor(editor,[],function(a){console.log(a)});
editor.file.editTower(editor,[],function(a){console.log(a)});
editor.file.editItem('redJewel',[],function(a){console.log(a)});
editor.file.editEnemy('redBat',[],function(a){console.log(a)});
editor.file.editLoc(2,0,[],function(a){console.log(a)});
editor.file.editFloor([],function(a){console.log(a)});
editor.file.editTower([],function(a){console.log(a)});
```
5个编辑模式有关的编辑
```javascript
editor.info={images: "terrains", y: 9};
editor.file.changeIdAndIdnum(editor,'yellowWall2',16,editor.info,function(a){console.log(a)});
editor.file.editItem(editor,'book',[["change","['items']['name']","怪物手册的新名字"]],function(a){console.log(a)});
editor.file.editEnemy(editor,'redBat',[['change',"['atk']",20]],function(a){console.log(a)});
editor.file.editLoc(editor,2,6,[["change","['afterBattle']",null]],function(a){console.log(a)});
editor.file.editFloor(editor,[["change","['title']",'样板 33 层']],function(a){console.log(a)});
editor.file.editTower(editor,[["change","['values']['lavaDamage']",200]],function(a){console.log(a)});
editor.file.changeIdAndIdnum('yellowWall2',16,editor.info,function(a){console.log(a)});
editor.file.editItem('book',[["change","['items']['name']","怪物手册的新名字"]],function(a){console.log(a)});
editor.file.editEnemy('redBat',[['change',"['atk']",20]],function(a){console.log(a)});
editor.file.editLoc(2,6,[["change","['afterBattle']",null]],function(a){console.log(a)});
editor.file.editFloor([["change","['title']",'样板 33 层']],function(a){console.log(a)});
editor.file.editTower([["change","['values']['lavaDamage']",200]],function(a){console.log(a)});
```
### editor_mode.js
4个生成表格并绑定事件的函数
```javascript
editor_mode.loc();
editor_mode.emenyitem();
editor_mode.floor();
editor_mode.tower();
editor.mode.loc();
editor.mode.emenyitem();
editor.mode.floor();
editor.mode.tower();
```
切换模式
```javascript
editor_mode.onmode('');
editor_mode.onmode('loc');
editor_mode.onmode('emenyitem');
editor_mode.onmode('floor');
editor_mode.onmode('tower');
editor.mode.onmode('');
editor.mode.onmode('loc');
editor.mode.onmode('emenyitem');
editor.mode.onmode('floor');
editor.mode.onmode('tower');
```
在切换模式时,改动才会保存到文件,并且需要刷新页面使得`editor`能看到改动
@ -139,14 +139,11 @@ $textarea(evalstr)$end
# todo & 目前的bug
+ `event`,`after...`在地图上没有标记,可以在右下角加类似于无`id`的红问号类似的绿色星号小标记
+ 添加新图块只对地形好使,添加的新物品还是需要手动在`project/items.js`中加东西
+ 目前未做$range(evalstr:thiseval)$end的检查
+ [x] 添加新图块只对地形好使,添加的新物品还是需要手动在`project/items.js`中加东西
+ [x] 目前未做$range(evalstr:thiseval)$end的检查
+ 通过`core.values.redJewel`的方式设置物品加的数值,在全GUI下反而会不直观
+ `idnum`上限改到`999`,不需要在`.js`中手动设置`idnum`的话,根据数字范围来约定类型意义不大,而且`400`内随便输个数就发现已经被占了,体验极差
+ `editor.html`中独立换背景的功能不再需要,待移除
+ 全GUI下编辑要经常保存修改后F5
+ 目前的报错只是throw,如果不开F12注意不到有错误发生,修改没有生效
+ 有待美化,以及做成标签页式的模式切换
+ replay模式,这个功能对于魔塔网站以及贴吧活动很有意义
前三条我会尽快修复(添加)
+ [x] 目前的报错只是throw,如果不开F12注意不到有错误发生,修改没有生效
+ [x] 有待美化,以及做成标签页式的模式切换

100
_server/README.md Normal file
View File

@ -0,0 +1,100 @@
# editor
本目录下所有文件,以及`../editor.html`和`../启动服务.exe`([源码](http://github.com/ckcz123/mota-js-server/))是地图编辑器的所有组件.
`editor.js`,`editor_file.js`和`editor_mode.js`耦合较强,`editor_blockly.js`和`fs.js`基本可以独立使用.
## 各组件功能
### editor.js
暂略
### editor_file.js
提供了以下函数进行楼层`map`数组相关的操作
```javascript
editor.file.getFloorFileList
editor.file.loadFloorFile
editor.file.saveFloorFile
editor.file.saveFloorFileAs
```
编辑模式有关的查询
```javascript
editor.file.editItem('redJewel',[],function(a){console.log(a)});
editor.file.editEnemy('redBat',[],function(a){console.log(a)});
editor.file.editLoc(2,0,[],function(a){console.log(a)});
editor.file.editFloor([],function(a){console.log(a)});
editor.file.editTower([],function(a){console.log(a)});
editor.file.editFunctions([],function(a){console.log(a)});
```
编辑模式有关的编辑
```javascript
editor.info={images: "terrains", y: 9};
editor.file.changeIdAndIdnum('yellowWall2',16,editor.info,function(a){console.log(a)});
editor.file.editItem('book',[["change","['items']['name']","怪物手册的新名字"]],function(a){console.log(a)});
editor.file.editEnemy('redBat',[['change',"['atk']",20]],function(a){console.log(a)});
editor.file.editLoc(2,6,[["change","['afterBattle']",null]],function(a){console.log(a)});
editor.file.editFloor([["change","['title']",'样板 33 层']],function(a){console.log(a)});
editor.file.editTower([["change","['values']['lavaDamage']",200]],function(a){console.log(a)});
editor.file.editFunctions(["change","['events']['afterChangeLight']","function(x,y){console.log(x,y)}"],function(a){console.log(a)});
```
### editor_mode.js
5个生成表格并绑定事件的函数
```javascript
editor.mode.loc();
editor.mode.emenyitem();
editor.mode.floor();
editor.mode.tower();
editor.mode.functions();
```
切换模式
```javascript
editor.mode.onmode('');//清空
editor.mode.onmode('save');//保存
editor.mode.onmode('nextChange');//下次onmode时前端进行切换
editor.mode.onmode('loc');
editor.mode.onmode('emenyitem');
editor.mode.onmode('floor');
editor.mode.onmode('tower');
editor.mode.onmode('functions');
editor.mode.onmode('map');
editor.mode.onmode('appendpic');
```
在`onmode('save')`时,改动才会保存到文件,涉及到图片的改动需要刷新页面使得`editor`能看到
表格的`onchange`的实现中,获得当前模式的方式.不注意的话,修改`index.html`中页面的结构,会被坑
```javascript
var node = thisTr.parentNode;
while (!editor_mode._ids.hasOwnProperty(node.getAttribute('id'))) {
node = node.parentNode;
}
editor_mode.onmode(editor_mode._ids[node.getAttribute('id')]);
```
### editor_blockly.js
把选定`id_`的事件用blockly编辑
``` js
editor_blockly.import(id_);
```
把文本区域的代码转换成图块
``` js
editor_blockly.parse();
```
把当前图块对应的事件返回给调用blockly的`id_`
``` js
editor_blockly.confirm();
```
### 待调整
+ [x] 多行文本编辑器独立作为组件
+ [x] editor_multi.js
## z-index
目前主体部分使用了 0,75,100
暂定blockly使用 200 ,多行文本编辑器使用 300
完成后再调整

File diff suppressed because one or more lines are too long

View File

@ -140,7 +140,7 @@ changeFloor_m
/* changeFloor_m
tooltip : 楼梯, 传送门, 如果目标楼层有多个楼梯, 写upFloor或downFloor可能会导致到达的楼梯不确定, 这时候请使用loc方式来指定具体的点位置
helpUrl : https://ckcz123.github.io/mota-js/#/element?id=%e8%b7%af%e9%9a%9c%ef%bc%8c%e6%a5%bc%e6%a2%af%ef%bc%8c%e4%bc%a0%e9%80%81%e9%97%a8
default : ["MT1",null,0,0,null,500,null]
default : ["MT1",null,0,0,[['不变',''],['上','up'],['下','down'],['左','left'],['右','right']],500,null]
var loc = ', "loc": ['+Int_0+', '+Int_1+']';
if (Stair_List_0!=='loc')loc = ', "stair": "'+Stair_List_0+'"';
DirectionEx_List_0 = DirectionEx_List_0 && (', "direction": "'+DirectionEx_List_0+'"');
@ -470,7 +470,7 @@ changeFloor_s
/* changeFloor_s
tooltip : changeFloor: 楼层切换,动画时间可不填
helpUrl : https://ckcz123.github.io/mota-js/#/event?id=changefloor-%e6%a5%bc%e5%b1%82%e5%88%87%e6%8d%a2
default : ["MT1",0,0,null,500]
default : ["MT1",0,0,[['不变',''],['上','up'],['下','down'],['左','left'],['右','right']],500]
colour : this.dataColor
DirectionEx_List_0 = DirectionEx_List_0 && (', "direction": "'+DirectionEx_List_0+'"');
Int_2 = Int_2 ?(', "time": '+Int_2):'';
@ -485,7 +485,7 @@ changePos_0_s
/* changePos_0_s
tooltip : changePos: 当前位置切换
helpUrl : https://ckcz123.github.io/mota-js/#/event?id=changepos-%e5%bd%93%e5%89%8d%e4%bd%8d%e7%bd%ae%e5%88%87%e6%8d%a2%e5%8b%87%e5%a3%ab%e8%bd%ac%e5%90%91
default : [0,0,null]
default : [0,0,[['不变',''],['上','up'],['下','down'],['左','left'],['右','right']]]
colour : this.dataColor
DirectionEx_List_0 = DirectionEx_List_0 && (', "direction": "'+DirectionEx_List_0+'"');
var code = '{"type": "changePos", "loc": ['+Int_0+','+Int_1+']'+DirectionEx_List_0+'},\n';
@ -500,6 +500,7 @@ changePos_1_s
tooltip : changePos: 勇士转向
helpUrl : https://ckcz123.github.io/mota-js/#/event?id=changepos-%e5%bd%93%e5%89%8d%e4%bd%8d%e7%bd%ae%e5%88%87%e6%8d%a2%e5%8b%87%e5%a3%ab%e8%bd%ac%e5%90%91
colour : this.dataColor
default : [[['上','up'],['下','down'],['左','left'],['右','right']]]
var code = '{"type": "changePos", "direction": "'+Direction_List_0+'"},\n';
return code;
*/
@ -1037,23 +1038,23 @@ LineComment
;
/* Function_0
//converter.evisitor.recieveOrder='ORDER_NONE';
converter.evisitor.valueColor=330;
converter.evisitor.statementColor=70;
converter.evisitor.entryColor=250;
//this.evisitor.recieveOrder='ORDER_NONE';
this.evisitor.valueColor=330;
this.evisitor.statementColor=70;
this.evisitor.entryColor=250;
converter.evisitor.idstring_eColor=310;
converter.evisitor.subColor=190;
converter.evisitor.printColor=70;
converter.evisitor.dataColor=130;
converter.evisitor.eventColor=220;
converter.evisitor.soundColor=20;
this.evisitor.idstring_eColor=310;
this.evisitor.subColor=190;
this.evisitor.printColor=70;
this.evisitor.dataColor=130;
this.evisitor.eventColor=220;
this.evisitor.soundColor=20;
*/
/* Function_1
delete(converter.evisitor.expressionRules.negate_e.blockjs.inputsInline);
converter.evisitor.expressionRules.idString_1_e.blockjs.output='idString_e';
converter.evisitor.expressionRules.idString_2_e.blockjs.output='idString_e';
delete(this.block('negate_e').inputsInline);
this.block('idString_1_e').output='idString_e';
this.block('idString_2_e').output='idString_e';
*/
/* Functions
@ -1075,7 +1076,7 @@ ActionParser.prototype.parse = function (obj,type) {
if(!obj)obj={};
if(!this.isset(obj.loc))obj.loc=[0,0];
return MotaActionBlocks['changeFloor_m'].xmlText([
obj.floorId,obj.stair||'loc',obj.loc[0],obj.loc[1],this.Direction(obj.direction),obj.time||0,!this.isset(obj.portalWithoutTrigger)
obj.floorId,obj.stair||'loc',obj.loc[0],obj.loc[1],obj.direction,obj.time||0,!this.isset(obj.portalWithoutTrigger)
]);
case 'point':
@ -1215,15 +1216,15 @@ ActionParser.prototype.parseAction = function() {
break;
case "changeFloor": // 楼层转换
this.next = MotaActionBlocks['changeFloor_s'].xmlText([
data.floorId,data.loc[0],data.loc[1],this.Direction(data.direction),this.time||0,this.next]);
data.floorId,data.loc[0],data.loc[1],data.direction,this.time||0,this.next]);
break;
case "changePos": // 直接更换勇士位置, 不切换楼层
if(this.isset(data.loc)){
this.next = MotaActionBlocks['changePos_0_s'].xmlText([
data.loc[0],data.loc[1],this.Direction(data.direction),this.next]);
data.loc[0],data.loc[1],data.direction,this.next]);
} else {
this.next = MotaActionBlocks['changePos_1_s'].xmlText([
this.Direction(data.direction),this.next]);
data.direction,this.next]);
}
break;
case "animate": // 显示动画
@ -1390,18 +1391,6 @@ ActionParser.prototype.StepString = function(steplist) {
return StepString.join('');
}
ActionParser.prototype.Direction = function(Direction) {
var stepchar = {
'up': '上',
'down': '下',
'left': '左',
'right': '右'
}
Direction=stepchar[Direction];
if(!Direction)Direction='不变';
return Direction;
}
ActionParser.prototype.EvalString = function(EvalString) {
return EvalString.split('\b').join('\\b').split('\t').join('\\t').split('\n').join('\\n');
}
@ -1428,20 +1417,6 @@ MotaActionFunctions.IdString_pre = function(IdString){
return IdString;
}
MotaActionFunctions.DirectionEx_List_pre = function(DirectionEx_List){
var directionchar = {
'上': 'up',
'下': 'down',
'左': 'left',
'右': 'right'
}
Direction=directionchar[DirectionEx_List];
if(!Direction)Direction='';
return Direction;
}
MotaActionFunctions.Direction_List_pre = MotaActionFunctions.DirectionEx_List_pre
MotaActionFunctions.StepString_pre = function(StepString){
//StepString='上右3下2左上左2'
var route = StepString.replace(/上/g,'U').replace(/下/g,'D').replace(/左/g,'L').replace(/右/g,'R');

View File

@ -13,52 +13,42 @@
.leftTab > :first-child{margin-top:5px;}
.leftTab > :last-child{margin-bottom:5px;}
#left1 {
.leftTab {
left: 5px;
top: 650px;
top: 10px;
width: 435px;
}
#left2 {
left: 448px;
top: 650px;
width: 440px;
}
#left3 {
left: 900px;
top: 650px;
width: 440px;
}
#left4 {
left: 5px;
top: 1290px;
width: 435px;
}
#left5 {
left: 448px;
top: 1290px;
width: 440px;
}
#left6 {
left: 5px;
top: 1930px;
/* top: 1930px; */
top: 5px;
z-index: 200;
position: fixed;
background-color: rgb(245, 245, 245);
width: 1335px;
height: 780px;
}
#left6 #blocklyDiv {height: 480px; width: 940px;float:left;}
#left6 #codeArea {width: 99.5%; height: 15.4em;overflow:y;/* resize:none; */clear:both;}
#left6 #multiLineDiv {height: 440px; width: 375px;float:left;}
#left6 #multiLineDiv .CodeMirror {
#left7 {
/* height: 440px; width: 375px;float:left; */
left: 5px;
top: 5px;
z-index: 200;
position: fixed;
background-color: rgb(245, 245, 245);
width: 1335px;
height: 780px;
}
#left7 .CodeMirror {
/* border-top: 1px solid black;
border-bottom: 1px solid black; */
border: 1px solid #eee;
height: 438px;
width: 373px;
height: 700px;
width: 940px;
}
.etable table,
@ -106,25 +96,6 @@
overflow: visible;
}
.etable tr:not(:first-child) :last-child {
margin: 0;
padding: 0;
height: 100%;
width: 100%;
}
.etable tr:not(:first-child) input:last-child {
}
.etable tr:not(:first-child) select:last-child {
}
.etable tr:not(:first-child) textarea:last-child {
}
.etable tr:not(:first-child) > :last-child:hover {
border: 1px solid rgb(87, 198, 232);
box-shadow: 0px 0px 3px rgb(87, 198, 232);
@ -134,4 +105,45 @@
.etable tr:not(:first-child) > :nth-child(1):hover {
border: 1px solid rgb(87, 232, 198);
box-shadow: 0px 0px 3px rgb(87, 232, 198);
}
}
.etable tr:not(:first-child) > :last-child {
margin: 0;
padding: 0;
height: 100%;
width: 100%;
position: relative;
}
div.etableInputDiv {
position: absolute;
padding: 5px 0 0 5px;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
.etableInputDiv > * {
margin: 0;
padding: 0;
height: 100%;
width: 100%;
background-color: rgba(255, 255, 255, 0);
border: none;
}
.etableInputDiv input {
}
.etableInputDiv select {
}
.etableInputDiv textarea {
resize: none;
}
.etableInputDiv textarea:hover {
margin: -5px;
}

View File

@ -20,22 +20,28 @@ editor.prototype.init = function(callback){
if (Boolean(callback))callback();
});
}
var afterMainInit = 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}));
editor.main=main;
editor.core=core;
editor.fs=fs;
editor.file=editor_file;
editor.material.images=core.material.images;
editor.listen(); // 开始监听事件
var hard = 'Hard';
core.resetStatus(core.firstData.hero, hard, core.firstData.floorId, null, core.initStatus.maps);
//core.status.maps = core.clone(core.maps.initMaps(floorIds));
core.changeFloor(core.status.floorId, null, core.firstData.hero.loc, null, function() {
afterCoreReset();
editor_file = editor_file(editor, function() {
editor.file=editor_file;
editor_mode = editor_mode(editor);
editor.mode=editor_mode;
editor.material.images=core.material.images;
editor.listen(); // 开始监听事件
core.resetStatus(core.firstData.hero, null, core.firstData.floorId, null, core.initStatus.maps);
core.changeFloor(core.status.floorId, null, core.firstData.hero.loc, null, function() {
afterCoreReset();
}, true);
core.events.setInitData(null);
});
core.events.setInitData(hard);
}
setTimeout(afterMainInit, 500);
afterMainInit();
}
editor.prototype.reset = function(callback){
@ -151,6 +157,7 @@ editor.prototype.mapInit = function(){
editor.currentFloorData.afterBattle={};
editor.currentFloorData.afterGetItem={};
editor.currentFloorData.afterOpenDoor={};
editor.currentFloorData.cannotMove={};
}
editor.prototype.drawMapBg = function(img){
var bgc = bg.getContext('2d');
@ -308,6 +315,13 @@ editor.prototype.changeFloor = function(floorId,callback) {
});
}
editor.prototype.guid = function() {
return 'id_'+'xxxxxxxx_xxxx_4xxx_yxxx_xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
return v.toString(16);
});
}
editor.prototype.listen = function() {
var uc = eui.getContext('2d');
@ -351,7 +365,7 @@ editor.prototype.listen = function() {
if(!selectBox.isSelected) {
var loc = eToLoc(e);
var pos = locToPos(loc);
editor_mode.onmode('');//为了强制触发doAction
editor_mode.onmode('nextChange');
editor_mode.onmode('loc');
editor_mode.loc();
tip.whichShow = 1;
@ -509,7 +523,7 @@ editor.prototype.listen = function() {
}
}
tip.infos = JSON.parse(JSON.stringify(editor.info));
editor_mode.onmode('');//为了强制触发doAction
editor_mode.onmode('nextChange');
editor_mode.onmode('emenyitem');
editor_mode.emenyitem();
}

View File

@ -239,10 +239,10 @@ editor_blockly.runOne = function (){
//var printf = function(){};
var grammerFile = input_;
converter = new Converter().init();
converter.generBlocks(grammerFile,[]);
converter.generBlocks(grammerFile);
//printf(converter.blocks);
converter.renderGrammerName();
converter.generToolbox();
//converter.generToolbox();
converter.generMainFile();
//printf(converter.mainFile.join(''));
console.log(converter);
@ -302,7 +302,7 @@ editor_blockly.id='';
editor_blockly.import = function(id_){
var thisTr = document.getElementById(id_);
if(!thisTr)return;
if(!thisTr)return false;
var input = thisTr.children[2].children[0].children[0];
var field = thisTr.children[0].getAttribute('title');
var type = {
@ -312,22 +312,30 @@ editor_blockly.import = function(id_){
"['afterGetItem']":'afterGetItem',
"['afterOpenDoor']":'afterOpenDoor',
"['firstData']['shops']":'shop',
//"['firstData']['shops']":'shop',
"--shop--未完成数组的处理":'shop',
"['firstArrive']":'firstArrive',
"['firstData']['startText']":'firstArrive',
"--point--未完成数据转移":'point',
}[field];
if(!type)return;
if(!type)return false;
editor_blockly.id=id_;
document.getElementById('codeArea').value = input.value;
document.getElementById('entryType').value = type;
editor_blockly.parse();
editor_blockly.show();
return true;
}
editor_blockly.show = function(){}
editor_blockly.show = function(){document.getElementById('left6').style='';}
editor_blockly.hide = function(){document.getElementById('left6').style='z-index:-1;opacity: 0;';}
editor_blockly.cancel = function(){
editor_blockly.id='';
editor_blockly.hide();
}
editor_blockly.confirm = function (){
if(!editor_blockly.id){
@ -339,6 +347,7 @@ editor_blockly.confirm = function (){
editor_blockly.id='';
var input = thisTr.children[2].children[0].children[0];
input.value = value;
editor_blockly.hide();
input.onchange();
}
if(document.getElementById('codeArea').value===''){
@ -350,29 +359,6 @@ editor_blockly.confirm = function (){
setvalue(JSON.stringify(obj));
}
var codeEditor = CodeMirror.fromTextArea(document.getElementById("multiLineCode"), {
lineNumbers: true,
matchBrackets: true,
lineWrapping: true,
continueComments: "Enter",
extraKeys: {"Ctrl-Q": "toggleComment"}
});
var multiLineArgs=[null,null,null];
editor_blockly.multiLineEdit = function(value,b,f,callback){
document.getElementById("multiLineDiv").style.display='';
codeEditor.setValue(value.split('\\n').join('\n')||'');
multiLineArgs[0]=b;
multiLineArgs[1]=f;
multiLineArgs[2]=callback;
}
editor_blockly.multiLineDone = function(){
document.getElementById("multiLineDiv").style.display='none';
if(!multiLineArgs[0] || !multiLineArgs[1] || !multiLineArgs[2])return;
var newvalue = codeEditor.getValue()||'';
multiLineArgs[2](newvalue,multiLineArgs[0],multiLineArgs[1])
}
editor_blockly.doubleClickBlock = function (blockId){
var b=editor_blockly.workspace.getBlockById(blockId);
console.log(b);
@ -387,7 +373,7 @@ editor_blockly.doubleClickBlock = function (blockId){
if(f){
var value = b.getFieldValue(f);
//多行编辑
editor_blockly.multiLineEdit(value,b,f,function(newvalue,b,f){
editor_multi.multiLineEdit(value,b,f,function(newvalue,b,f){
if(textStringDict[b.type]!=='RawEvalString_0'){}
b.setFieldValue(newvalue.split('\n').join('\\n'),f);
});

View File

@ -1,34 +1,33 @@
(function(){
editor_file = function(editor, callback){
editor_file = {};
(function(){
var script = document.createElement('script');
if (window.location.href.indexOf('_server')!==-1)
script.src = '../project/comment.js';
else
script.src = 'project/comment.js';
document.body.appendChild(script);
script.onload = function () {
editor_file.comment=comment_c456ea59_6018_45ef_8bcc_211a24c627dc;
delete(comment_c456ea59_6018_45ef_8bcc_211a24c627dc);
}
})();
(function(){
var script = document.createElement('script');
if (window.location.href.indexOf('_server')!==-1)
script.src = '../project/data.comment.js';
else
script.src = 'project/data.comment.js';
document.body.appendChild(script);
script.onload = function () {
editor_file.dataComment=data_comment_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d;
delete(data_comment_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d);
}
})();
var editor_file = {};
editor_file.getFloorFileList = function(editor,callback){
var commentjs={
'comment':'comment',
'data.comment':'dataComment',
'functions.comment':'functionsComment',
}
for(var key in commentjs){
(function(key){
var value = commentjs[key];
var script = document.createElement('script');
if (window.location.href.indexOf('_server')!==-1)
script.src = '../project/'+key+'.js';
else
script.src = 'project/'+key+'.js';
document.body.appendChild(script);
script.onload = function () {
editor_file[value]=eval(key.replace('.','_')+'_c456ea59_6018_45ef_8bcc_211a24c627dc');
var loaded = Boolean(callback);
for(var key_ in commentjs){loaded = loaded && editor_file[commentjs[key_]]}
if (loaded)callback();
}
})(key);
}
editor_file.getFloorFileList = function(callback){
if (!isset(callback)) {printe('未设置callback');throw('未设置callback')};
/* var fs = editor.fs;
fs.readdir('project/floors',function(err, data){
@ -37,7 +36,7 @@
callback([editor.core.floorIds,null]);
}
//callback([Array<String>,err:String])
editor_file.loadFloorFile = function(editor,filename,callback){
editor_file.loadFloorFile = function(filename,callback){
//filename不含'/'不含'.js'
if (!isset(callback)) {printe('未设置callback');throw('未设置callback')};
/* var fs = editor.fs;
@ -63,7 +62,7 @@
editor.currentFloorData = editor.core.floors[editor.currentFloorId];
}
//callback(err:String)
editor_file.saveFloorFile = function(editor,callback){
editor_file.saveFloorFile = function(callback){
if (!isset(callback)) {printe('未设置callback');throw('未设置callback')};
/* if (!isset(editor.currentFloorId) || !isset(editor.currentFloorData)) {
callback('未选中文件或无数据');
@ -80,12 +79,12 @@
}
datastr=datastr.concat(['\n}']);
datastr=datastr.join('');
fs.writeFile(filename,datastr,'utf-8',function(err, data){
fs.writeFile(filename,encode(datastr),'base64',function(err, data){
callback(err);
});
}
//callback(err:String)
editor_file.saveFloorFileAs = function(editor,saveAsFilename,callback){
editor_file.saveFloorFileAs = function(saveAsFilename,callback){
//saveAsFilename不含'/'不含'.js'
if (!isset(callback)) {printe('未设置callback');throw('未设置callback')};
if (!isset(editor.currentFloorData)) {
@ -95,13 +94,13 @@
editor.currentFloorData=JSON.parse(JSON.stringify(editor.currentFloorData));
editor.currentFloorData.floorId=saveAsFilename;
editor.currentFloorId=saveAsFilename;
editor_file.saveFloorFile(editor,callback);
editor_file.saveFloorFile(callback);
}
//callback(err:String)
////////////////////////////////////////////////////////////////////
editor_file.changeIdAndIdnum = function(editor,id,idnum,info,callback){
editor_file.changeIdAndIdnum = function(id,idnum,info,callback){
if (!isset(callback)) {printe('未设置callback');throw('未设置callback')};
//检查maps中是否有重复的idnum或id
var change = -1;
@ -159,7 +158,7 @@
callback(null);
}
//callback(err:String)
editor_file.editItem = function(editor,id,actionList,callback){
editor_file.editItem = function(id,actionList,callback){
/*actionList:[
["change","['items']['name']","红宝石的新名字"],
["add","['items']['新的和name同级的属性']",123],
@ -208,7 +207,7 @@
//只有items.cls是items的才有itemEffect和itemEffectTip,keys和constants和tools只有items
}
//callback([obj,commentObj,err:String])
editor_file.editEnemy = function(editor,id,actionList,callback){
editor_file.editEnemy = function(id,actionList,callback){
/*actionList:[
["change","['name']","初级巫师的新名字"],
["add","['新的和name同级的属性']",123],
@ -256,7 +255,7 @@
////////////////////////////////////////////////////////////////////
editor_file.editLoc = function(editor,x,y,actionList,callback){
editor_file.editLoc = function(x,y,actionList,callback){
/*actionList:[
["change","['events']",["\t[老人,magician]领域、夹击。\n请注意领域怪需要设置value为伤害数值可参见样板中初级巫师的写法。"]],
["change","['afterBattle']",null],
@ -304,7 +303,7 @@
////////////////////////////////////////////////////////////////////
editor_file.editFloor = function(editor,actionList,callback){
editor_file.editFloor = function(actionList,callback){
/*actionList:[
["change","['title']",'样板 3 层'],
["change","['color']",null],
@ -348,7 +347,7 @@
////////////////////////////////////////////////////////////////////
editor_file.editTower = function(editor,actionList,callback){
editor_file.editTower = function(actionList,callback){
/*actionList:[
["change","['firstData']['version']",'Ver 1.0.1 (Beta)'],
["change","['values']['lavaDamage']",200],
@ -390,6 +389,52 @@
}
//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.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(){...}"],
]
[]时只查询不修改
*/
if (!isset(callback)) {printe('未设置callback');throw('未设置callback')};
if (isset(actionList) && actionList.length > 0){
saveSetting('functions',actionList,function (err) {
callback([
(function(){
var locObj=JSON.parse(fjson);
buildlocobj(locObj);
return locObj;
})(),
editor_file.functionsComment,
err]);
});
} else {
callback([
(function(){
var locObj=JSON.parse(fjson);
buildlocobj(locObj);
return locObj;
})(),
editor_file.functionsComment,
null]);
}
}
//callback([obj,commentObj,err:String])
////////////////////////////////////////////////////////////////////
var isset = function (val) {
@ -416,6 +461,12 @@
}
return formatArrStr;
}
var encode = function (str) {
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function(match, p1) {
return String.fromCharCode(parseInt(p1, 16))
}))
}
var saveSetting = function(file,actionList,callback) {
console.log(file);
@ -431,7 +482,7 @@
});
var datastr='icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1 = \n';
datastr+=JSON.stringify(icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1,null,4);
fs.writeFile('project/icons.js',datastr,'utf-8',function(err, data){
fs.writeFile('project/icons.js',encode(datastr),'base64',function(err, data){
callback(err);
});
return;
@ -443,7 +494,7 @@
});
var datastr='maps_90f36752_8815_4be8_b32b_d7fad1d0542e = \n';
datastr+=JSON.stringify(maps_90f36752_8815_4be8_b32b_d7fad1d0542e,null,4);
fs.writeFile('project/maps.js',datastr,'utf-8',function(err, data){
fs.writeFile('project/maps.js',encode(datastr),'base64',function(err, data){
callback(err);
});
return;
@ -455,7 +506,7 @@
});
var datastr='items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = \n';
datastr+=JSON.stringify(items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a,null,4);
fs.writeFile('project/items.js',datastr,'utf-8',function(err, data){
fs.writeFile('project/items.js',encode(datastr),'base64',function(err, data){
callback(err);
});
return;
@ -467,7 +518,7 @@
});
var datastr='enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80 = \n';
datastr+=JSON.stringify(enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80,null,4);
fs.writeFile('project/enemys.js',datastr,'utf-8',function(err, data){
fs.writeFile('project/enemys.js',encode(datastr),'base64',function(err, data){
callback(err);
});
return;
@ -479,7 +530,23 @@
});
var datastr='data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = \n';
datastr+=JSON.stringify(data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d,null,4);
fs.writeFile('project/data.js',datastr,'utf-8',function(err, data){
fs.writeFile('project/data.js',encode(datastr),'base64',function(err, data){
callback(err);
});
return;
}
if (file=='functions') {
actionList.forEach(function (value) {
if (value[0]!='change')return;
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='functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = \n';
datastr+=fraw;
fs.writeFile('project/functions.js',encode(datastr),'base64',function(err, data){
callback(err);
});
return;
@ -489,7 +556,7 @@
if (value[0]!='change')return;
eval("editor.currentFloorData"+value[1]+'='+JSON.stringify(value[2]));
});
editor_file.saveFloorFile(editor,callback);
editor_file.saveFloorFile(callback);
return;
}
callback('出错了,要设置的文件名不识别');
@ -523,5 +590,6 @@
// ]
*/
})();
return editor_file;
}
//editor_file = editor_file(editor);

View File

@ -11,31 +11,32 @@
pout.innerHTML='waiting\nwaiting waiting';
var editor={};
editor.fs=fs;
editor_file = editor_file(editor);
editor.file=editor_file;
//代码复制到 http://127.0.0.1:1055/drawMapGUI.html 的console中进行测试
/* editor.file.loadFloorFile(editor,'sample0',function(err){console.log(err);
editor.file.saveFloorFileAs(editor,'aaa',function(err){console.log(err)});
/* editor.file.loadFloorFile('sample0',function(err){console.log(err);
editor.file.saveFloorFileAs('aaa',function(err){console.log(err)});
}); */
//查询
/*
editor_file.editItem(editor,'redJewel',[],function(a){console.log(a)});
editor_file.editEnemy(editor,'redBat',[],function(a){console.log(a)});
editor_file.editLoc(editor,2,6,[],function(a){console.log(a)});
editor_file.editFloor(editor,[],function(a){console.log(a)});
editor.file.editTower(editor,[],function(a){console.log(a)});
editor.file.editItem('redJewel',[],function(a){console.log(a)});
editor.file.editEnemy('redBat',[],function(a){console.log(a)});
editor.file.editLoc(2,6,[],function(a){console.log(a)});
editor.file.editFloor([],function(a){console.log(a)});
editor.file.editTower([],function(a){console.log(a)});
*/
//编辑
/*
editor.info={images: "terrains", y: 9};
editor.file.changeIdAndIdnum(editor,'yellowWall2',16,editor.info,function(a){console.log(a)});
editor_file.editItem(editor,'book',[["change","['items']['name']","怪物手册的新名字"]],function(a){console.log(a)});
editor_file.editEnemy(editor,'redBat',[['change',"['atk']",20]],function(a){console.log(a)});
editor_file.editLoc(editor,2,6,[["change","['afterBattle']",null]],function(a){console.log(a)});
editor_file.editFloor(editor,[["change","['title']",'样板 33 层']],function(a){console.log(a)});
editor.file.editTower(editor,[["change","['values']['lavaDamage']",200]],function(a){console.log(a)});
editor.file.changeIdAndIdnum('yellowWall2',16,editor.info,function(a){console.log(a)});
editor.file.editItem('book',[["change","['items']['name']","怪物手册的新名字"]],function(a){console.log(a)});
editor.file.editEnemy('redBat',[['change',"['atk']",20]],function(a){console.log(a)});
editor.file.editLoc(2,6,[["change","['afterBattle']",null]],function(a){console.log(a)});
editor.file.editFloor([["change","['title']",'样板 33 层']],function(a){console.log(a)});
editor.file.editTower([["change","['values']['lavaDamage']",200]],function(a){console.log(a)});
*/
pout.innerHTML='succeed\nsucceed succeed';

View File

@ -1,9 +1,16 @@
editor_mode = function(editor){
var core = editor.core;
function editor_mode(){
this.ids={
'loc':'left2',
'emenyitem':'left3',
'floor':'left4',
'tower':'left5'
'tower':'left5',
'functions':'left8',
'map':'left',
'appendpic':'left1',
}
this._ids={}
this.dom={}
@ -12,8 +19,11 @@ function editor_mode(){
this.info={};
this.appendPic={};
}
editor_mode.prototype.init = function(callback){
if (Boolean(callback))callback();
}
editor_mode.prototype.init_dom_ids = function(callback){
Object.keys(editor_mode.ids).forEach(function(v){
editor_mode.dom[v]=document.getElementById(editor_mode.ids[v]);
@ -28,11 +38,25 @@ editor_mode.prototype.init = function(callback){
editor_mode.prototype.objToTable = function(obj,commentObj){
var outstr=["\n<tr><td>条目</td><td>注释</td><td>值</td></tr>\n"];
var guids=[];
var checkIsLeaf = function(obj,commentObj,field){
var thiseval = eval('obj'+field);
if (thiseval == null || thiseval == undefined)return true;//null,undefined
if (typeof(thiseval) == typeof(''))return true;//字符串
if (Object.keys(thiseval).length == 0)return true;//数字,true,false,空数组,空对象
try {
var comment = eval('commentObj'+field);
if( comment.indexOf('$leaf') != -1){
evalstr = comment.split('$leaf')[1].split('$end')[0];
if(eval(evalstr) === true)return true;
}
} catch (error) {}
return false;
}
//深度优先遍历
var recursionParse = function(tfield) {
for(var ii in eval("obj"+tfield)){
var field = tfield+"['"+ii+"']";
var isleaf = editor_mode.checkIsLeaf(obj,commentObj,field);
var isleaf = checkIsLeaf(obj,commentObj,field);
if (isleaf) {
var leafnode = editor_mode.objToTr(obj,commentObj,field);
outstr.push(leafnode[0]);
@ -44,6 +68,13 @@ editor_mode.prototype.objToTable = function(obj,commentObj){
}
}
recursionParse("");
var checkRange = function(comment,thiseval){
if( comment.indexOf('$range') !== -1){
var evalstr = comment.split('$range')[1].split('$end')[0];
return eval(evalstr);
}
return true;
}
var listen = function(guids) {
guids.forEach(function(guid){
// tr>td[title=field]
@ -59,38 +90,25 @@ editor_mode.prototype.objToTable = function(obj,commentObj){
node = node.parentNode;
}
editor_mode.onmode(editor_mode._ids[node.getAttribute('id')]);
editor_mode.addAction(['change',field,JSON.parse(input.value)]);
//尚未完成,不完善,目前还没做$range的检查
/*临时*/editor_mode.onmode('');/*临时*/
//临时改为立刻写入文件,删去此句的时,切换模式才会真正写入
//现阶段这样会更实用,20180218
var thiseval = JSON.parse(input.value);
if(checkRange(comment,thiseval)){
editor_mode.addAction(['change',field,thiseval]);
} else {
printe('输入的值不合要求,请鼠标放置在注释上查看说明');
}
}
input.ondblclick = function(){
editor_blockly.import(guid);
if(!editor_blockly.import(guid))
if(!editor_multi.import(guid)){}
}
});
}
return {"HTML":outstr.join(''),"guids":guids,"listen":listen};
}
editor_mode.prototype.checkIsLeaf = function(obj,commentObj,field){
var thiseval = eval('obj'+field);
if (thiseval == null || thiseval == undefined)return true;//null,undefined
if (typeof(thiseval) == typeof(''))return true;//字符串
if (Object.keys(thiseval).length == 0)return true;//数字,true,false,空数组,空对象
try {
var comment = eval('commentObj'+field);
if( comment.indexOf('$leaf') != -1){
evalstr = comment.split('$leaf')[1].split('$end')[0];
if(eval(evalstr) === true)return true;
}
} catch (error) {}
return false;
}
editor_mode.prototype.objToTr = function(obj,commentObj,field){
var guid = editor_mode.guid();
var guid = editor.guid();
var thiseval = eval('obj'+field);
var comment = '';
try {
@ -108,7 +126,7 @@ editor_mode.prototype.objToTr = function(obj,commentObj,field){
var outstr=['<tr id="',guid,'"><td title="',field,'">',shortField,'</td>',
'<td title="',commentHTMLescape,'">',shortCommentHTMLescape,'</td>',
'<td><div>',editor_mode.objToTd(thiseval,comment),'</div></td></tr>\n',
'<td><div class="etableInputDiv">',editor_mode.objToTd(thiseval,comment),'</div></td></tr>\n',
];
return [outstr.join(''),guid];
}
@ -131,39 +149,37 @@ editor_mode.prototype.objToTd = function(thiseval,comment){
}
}
editor_mode.prototype.guid = function() {
return 'id_'+'xxxxxxxx_xxxx_4xxx_yxxx_xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
return v.toString(16);
});
}
editor_mode.prototype.addAction = function(action){
editor_mode.actionList.push(action);
}
editor_mode.prototype.doActionList = function(mode,actionList){
if (actionList.length==0)return;
printf('修改中...');
switch (mode) {
case 'loc':
editor_file.editLoc(editor,editor_mode.pos.x,editor_mode.pos.y,actionList,function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')});
editor.file.editLoc(editor_mode.pos.x,editor_mode.pos.y,actionList,function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')});
break;
case 'emenyitem':
if (editor_mode.info.images=='enemys'){
editor_file.editEnemy(editor,editor_mode.info.id,actionList,function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')});
editor.file.editEnemy(editor_mode.info.id,actionList,function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')});
} else if (editor_mode.info.images=='items'){
editor_file.editItem(editor,editor_mode.info.id,actionList,function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')});
editor.file.editItem(editor_mode.info.id,actionList,function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')});
}
break;
case 'floor':
editor_file.editFloor(editor,actionList,function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')});
editor.file.editFloor(actionList,function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')});
break;
case 'tower':
editor.file.editTower(editor,actionList,function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')});
editor.file.editTower(actionList,function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')});
break;
case 'functions':
editor.file.editFunctions(actionList,function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')});
break;
default:
break;
@ -173,12 +189,28 @@ editor_mode.prototype.doActionList = function(mode,actionList){
editor_mode.prototype.onmode = function (mode) {
if (editor_mode.mode!=mode) {
console.log('change mode into : '+mode);
editor_mode.doActionList(editor_mode.mode,editor_mode.actionList);
if(mode==='save')editor_mode.doActionList(editor_mode.mode,editor_mode.actionList);
if(editor_mode.mode==='nextChange' && mode)editor_mode.showMode(mode);
editor_mode.mode=mode;
editor_mode.actionList=[];
}
}
editor_mode.prototype.showMode = function (mode) {
for(var name in this.dom){
editor_mode.dom[name].style='z-index:-1;opacity: 0;';
}
editor_mode.dom[mode].style='';
if(editor_mode[mode])editor_mode[mode]();
document.getElementById('editModeSelect').value=mode;
var tips = [
'涉及图片的更改需要F5刷新浏览器来生效',
'文本域可以通过双击,在文本编辑器或事件编辑器中编辑',
'事件编辑器中的显示文本和自定义脚本的方块也可以双击',
];
if(!selectBox.isSelected)printf('tips: '+tips[~~(tips.length*Math.random())]);
}
editor_mode.prototype.loc = function(callback){
//editor.pos={x: 0, y: 0};
if (!core.isset(editor.pos))return;
@ -186,7 +218,7 @@ editor_mode.prototype.loc = function(callback){
document.getElementById('pos_a6771a78_a099_417c_828f_0a24851ebfce').innerText=editor_mode.pos.x+','+editor_mode.pos.y;
var objs=[];
editor_file.editLoc(editor,editor_mode.pos.x,editor_mode.pos.y,[],function(objs_){objs=objs_;console.log(objs_)});
editor.file.editLoc(editor_mode.pos.x,editor_mode.pos.y,[],function(objs_){objs=objs_;console.log(objs_)});
//只查询不修改时,内部实现不是异步的,所以可以这么写
var tableinfo=editor_mode.objToTable(objs[0],objs[1]);
document.getElementById('table_3d846fc4_7644_44d1_aa04_433d266a73df').innerHTML=tableinfo.HTML;
@ -198,7 +230,8 @@ editor_mode.prototype.loc = function(callback){
editor_mode.prototype.emenyitem = function(callback){
//editor.info=editor.ids[editor.indexs[201]];
if (!core.isset(editor.info))return;
editor_mode.info=editor.info;//避免editor.info被清空导致无法获得是物品还是怪物
if(Object.keys(editor.info).length!==0)editor_mode.info=editor.info;//避免editor.info被清空导致无法获得是物品还是怪物
if (!core.isset(editor_mode.info.id)){
document.getElementById('table_a3f03d4c_55b8_4ef6_b362_b345783acd72').innerHTML='';
@ -209,9 +242,9 @@ editor_mode.prototype.emenyitem = function(callback){
var objs=[];
if (editor_mode.info.images=='enemys'){
editor_file.editEnemy(editor,editor_mode.info.id,[],function(objs_){objs=objs_;console.log(objs_)});
editor.file.editEnemy(editor_mode.info.id,[],function(objs_){objs=objs_;console.log(objs_)});
} else if (editor_mode.info.images=='items'){
editor_file.editItem(editor,editor_mode.info.id,[],function(objs_){objs=objs_;console.log(objs_)});
editor.file.editItem(editor_mode.info.id,[],function(objs_){objs=objs_;console.log(objs_)});
} else {
document.getElementById('table_a3f03d4c_55b8_4ef6_b362_b345783acd72').innerHTML='';
return;
@ -226,7 +259,7 @@ editor_mode.prototype.emenyitem = function(callback){
editor_mode.prototype.floor = function(callback){
var objs=[];
editor_file.editFloor(editor,[],function(objs_){objs=objs_;console.log(objs_)});
editor.file.editFloor([],function(objs_){objs=objs_;console.log(objs_)});
//只查询不修改时,内部实现不是异步的,所以可以这么写
var tableinfo=editor_mode.objToTable(objs[0],objs[1]);
document.getElementById('table_4a3b1b09_b2fb_4bdf_b9ab_9f4cdac14c74').innerHTML=tableinfo.HTML;
@ -236,7 +269,7 @@ editor_mode.prototype.floor = function(callback){
editor_mode.prototype.tower = function(callback){
var objs=[];
editor.file.editTower(editor,[],function(objs_){objs=objs_;console.log(objs_)});
editor.file.editTower([],function(objs_){objs=objs_;console.log(objs_)});
//只查询不修改时,内部实现不是异步的,所以可以这么写
var tableinfo=editor_mode.objToTable(objs[0],objs[1]);
document.getElementById('table_b6a03e4c_5968_4633_ac40_0dfdd2c9cde5').innerHTML=tableinfo.HTML;
@ -244,24 +277,36 @@ editor_mode.prototype.tower = function(callback){
if (Boolean(callback))callback();
}
editor_mode.prototype.functions = function(callback){
var objs=[];
editor.file.editFunctions([],function(objs_){objs=objs_;console.log(objs_)});
//只查询不修改时,内部实现不是异步的,所以可以这么写
var tableinfo=editor_mode.objToTable(objs[0],objs[1]);
document.getElementById('table_e260a2be_5690_476a_b04e_dacddede78b3').innerHTML=tableinfo.HTML;
tableinfo.listen(tableinfo.guids);
if (Boolean(callback))callback();
}
/////////////////////////////////////////////////////////////////////////////
editor_mode.prototype.listen = function(callback){
var newIdIdnum = document.getElementById('newIdIdnum');
newIdIdnum.children[0].onchange = newIdIdnum.children[1].onchange = function(){
newIdIdnum.children[2].onclick = function(){
if (newIdIdnum.children[0].value && newIdIdnum.children[1].value){
var id = newIdIdnum.children[0].value;
var idnum = parseInt(newIdIdnum.children[1].value);
editor_file.changeIdAndIdnum(editor,id,idnum,editor_mode.info,function(err){
editor.file.changeIdAndIdnum(id,idnum,editor_mode.info,function(err){
if(err){printe(err);throw(err)}
printe('添加id的idnum成功,请F5刷新编辑器');
});
} else {
printe('请输入id和idnum');
}
}
var selectFloor = document.getElementById('selectFloor');
editor_file.getFloorFileList(editor,function(floors){
editor.file.getFloorFileList(function(floors){
var outstr=[];
floors[0].forEach(function(floor){
outstr.push(["<option value='",floor,"'>",floor,'</option>\n'].join(''));
@ -277,7 +322,7 @@ editor_mode.prototype.listen = function(callback){
var saveFloor = document.getElementById('saveFloor');
saveFloor.onclick = function(){
editor_mode.onmode('');
editor_file.saveFloorFile(editor,function(err){if(err){printe(err);throw(err)}});
editor.file.saveFloorFile(function(err){if(err){printe(err);throw(err)}});
}
var saveFloorAs = document.getElementById('saveFloorAs');
@ -285,10 +330,10 @@ editor_mode.prototype.listen = function(callback){
saveFloorAs.onclick = function(){
if (!saveAsName.value)return;
editor_mode.onmode('');
editor_file.saveFloorFileAs(editor,saveAsName.value,function(err){
editor.file.saveFloorFileAs(saveAsName.value,function(err){
if(err){printe(err);throw(err)}
core.floorIds.push(saveAsName.value);
editor.file.editTower(editor,[['change',"['main']['floorIds']",core.floorIds]],function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])}});
editor.file.editTower([['change',"['main']['floorIds']",core.floorIds]],function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])}});
});
}
@ -429,12 +474,22 @@ editor_mode.prototype.listen = function(callback){
var imgbase64 = sprite.toDataURL().split(',')[1];
fs.writeFile('./project/images/'+editor_mode.appendPic.imageName+'.png',imgbase64,'base64',function(err,data){
if(err){printe(err);throw(err)}
printe('追加素材成功,请刷新编辑器');
printe('追加素材成功,请F5刷新编辑器');
});
}
var editModeSelect = document.getElementById('editModeSelect');
editModeSelect.onchange = function(){
editor_mode.onmode('nextChange');
editor_mode.onmode(editModeSelect.value);
}
if (Boolean(callback))callback();
}
editor_mode = new editor_mode();
editor_mode.init();
var editor_mode = new editor_mode();
editor_mode.init_dom_ids();
return editor_mode;
}
//editor_mode = editor_mode(editor);

87
_server/editor_multi.js Normal file
View File

@ -0,0 +1,87 @@
editor_multi = function(){
var editor_multi = {};
var codeEditor = CodeMirror.fromTextArea(document.getElementById("multiLineCode"), {
lineNumbers: true,
matchBrackets: true,
lineWrapping: true,
continueComments: "Enter",
extraKeys: {"Ctrl-Q": "toggleComment"}
});
editor_multi.id='';
editor_multi.isString=false;
editor_multi.show = function(){document.getElementById('left7').style='';}
editor_multi.hide = function(){document.getElementById('left7').style='z-index:-1;opacity: 0;';}
editor_multi.import = function(id_){
var thisTr = document.getElementById(id_);
if(!thisTr)return false;
var input = thisTr.children[2].children[0].children[0];
var field = thisTr.children[0].getAttribute('title');
if(!input.type || input.type!=='textarea')return false;
editor_multi.id=id_;
editor_multi.isString=false;
if(input.value.slice(0,1)==='"'){
editor_multi.isString=true;
codeEditor.setValue(JSON.parse(input.value)||'');
} else {
codeEditor.setValue(input.value||'');
}
editor_multi.show();
return true;
}
editor_multi.cancel = function(){
editor_multi.hide();
editor_multi.id='';
multiLineArgs=[null,null,null];
}
editor_multi.confirm = function (){
if(!editor_multi.id){
editor_multi.id='';
return;
}
if(editor_multi.id==='callFromBlockly'){
editor_multi.id='';
editor_multi.multiLineDone();
return;
}
var setvalue = function(value){
var thisTr = document.getElementById(editor_multi.id);
editor_multi.id='';
var input = thisTr.children[2].children[0].children[0];
if(editor_multi.isString){
input.value = JSON.stringify(value);
} else {
input.value = value;
}
editor_multi.hide();
input.onchange();
}
setvalue(codeEditor.getValue()||'');
}
var multiLineArgs=[null,null,null];
editor_multi.multiLineEdit = function(value,b,f,callback){
editor_multi.id='callFromBlockly';
codeEditor.setValue(value.split('\\n').join('\n')||'');
multiLineArgs[0]=b;
multiLineArgs[1]=f;
multiLineArgs[2]=callback;
editor_multi.show();
}
editor_multi.multiLineDone = function(){
editor_multi.hide();
if(!multiLineArgs[0] || !multiLineArgs[1] || !multiLineArgs[2])return;
var newvalue = codeEditor.getValue()||'';
multiLineArgs[2](newvalue,multiLineArgs[0],multiLineArgs[1])
}
return editor_multi;
}
//editor_multi=editor_multi();

View File

@ -1,8 +1,21 @@
// vue 相关处理
document.body.onmousedown = function(e){
selectBox.isSelected = false;
editor_mode.onmode('');
console.log(e);
var eid=[];
e.path.forEach(function(node){
if(!node.getAttribute)return;
var id_ = node.getAttribute('id');
if (id_){
if(['left','left1','left2','left3','left4','left5','left8'].indexOf(id_)!==-1)eid.push('edit');
eid.push(id_);
}
});
console.log(eid);
if(eid.indexOf('edit')===-1){
if(eid.indexOf('tip')===-1)selectBox.isSelected = false;
}
//editor.mode.onmode('');
editor.info = {};
}
iconLib.onmousedown = function(e){
@ -185,13 +198,21 @@ var clear = new Vue({
}
})
printf = function(str_,type) {
selectBox.isSelected = false;
if(!type){
tip.msgs[11]=String(str_);
tip.whichShow=12;
} else {
tip.msgs[10]=String(str_);
tip.whichShow=11;
} else {
tip.whichShow=12;
}
setTimeout(function(){
if(!type){
tip.msgs[11]=String(str_);
tip.whichShow=12;
} else {
tip.msgs[10]=String(str_);
tip.whichShow=11;
}
},1);
}
printe = function(str_){printf(str_,'error')}
var tip = new Vue({

View File

@ -8,7 +8,7 @@
</head>
<body>
<div class="main">
<div id="left">
<div id="left" style="z-index:-1;opacity: 0;"><!-- map -->
<div id="arrEditor">
<table class="col" id='arrColMark'></table>
<table class="row" id='arrRowMark'></table>
@ -23,6 +23,10 @@
<input class='btn' type="button" value="saveAs" id='saveFloorAs'/>
<input class='btn' type="button" value="复制地图" v-on:click="copyMap"/>
</div>
<div style="position: absolute;right: 10px;bottom:70px;">
<input class='btn' id='clear' type="button" value="清除地图" v-on:click="clearMap"/>
<input class='btn' type="button" value="导出地图" id="exportM" v-on:click="exportMap"/>
</div>
</div>
<div id="objDataEditor">
@ -32,7 +36,7 @@
</div>
</div>
<div id="left1" class='leftTab'><div ><!-- appendpic -->
<div id="left1" class='leftTab' style="z-index:-1;opacity: 0;"><div ><!-- appendpic -->
<h3>追加素材</h3>
<p>
<input id="selectFileBtn" type="button" value="导入文件到画板"/>
@ -52,8 +56,8 @@
</div>
</div>
</div></div>
<div id="left2" class='leftTab'><div><!-- loc -->
<h3>地图选点</h3>
<div id="left2" class='leftTab' style="z-index:-1;opacity: 0;"><div><!-- loc -->
<h3>地图选点&nbsp;&nbsp;<button onclick="editor.mode.onmode('save')">save</button></h3>
<p id='pos_a6771a78_a099_417c_828f_0a24851ebfce'>0,0</p>
<div class='etable'>
<table>
@ -63,11 +67,12 @@
</table>
</div>
</div></div>
<div id="left3" class='leftTab'><div><!-- emenyitem -->
<h3>图块属性</h3>
<div id="left3" class='leftTab' style="z-index:-1;opacity: 0;"><div><!-- emenyitem -->
<h3>图块属性&nbsp;&nbsp;<button onclick="editor.mode.onmode('save')">save</button></h3>
<div id='newIdIdnum'><!-- id and idnum -->
<input placeholder="输入新id"/>
<input placeholder="输入新idnum"/>
<button>save</button>
</div>
<div><!-- enemy and item -->
<div class='etable'>
@ -79,8 +84,8 @@
</div>
</div>
</div></div>
<div id="left4" class='leftTab'><div><!-- floor -->
<h3>楼层属性</h3>
<div id="left4" class='leftTab' style="z-index:-1;opacity: 0;"><div><!-- floor -->
<h3>楼层属性&nbsp;&nbsp;<button onclick="editor.mode.onmode('save')">save</button></h3>
<div class='etable'>
<table>
<tbody id='table_4a3b1b09_b2fb_4bdf_b9ab_9f4cdac14c74'>
@ -89,8 +94,8 @@
</table>
</div>
</div></div>
<div id="left5" class='leftTab'><div><!-- tower -->
<h3>全塔属性</h3>
<div id="left5" class='leftTab' style="z-index:-1;opacity: 0;"><div><!-- tower -->
<h3>全塔属性&nbsp;&nbsp;<button onclick="editor.mode.onmode('save')">save</button></h3>
<div class='etable'>
<table>
<tbody id='table_b6a03e4c_5968_4633_ac40_0dfdd2c9cde5'>
@ -99,7 +104,7 @@
</table>
</div>
</div></div>
<div id="left6" class='leftTab'><div><!-- eventsEditor -->
<div id="left6" class='leftTab' style="z-index:-1;opacity: 0;"><div><!-- eventsEditor -->
<h3>事件编辑器 &nbsp;&nbsp;
<button onclick="editor_blockly.showXML()">Show XML</button>
<button onclick="editor_blockly.runCode()">console.log(obj=code)</button>
@ -115,6 +120,7 @@
</select>
<button onclick="editor_blockly.parse()">parse</button>
<button onclick="editor_blockly.confirm()">confirm</button>
<button onclick="editor_blockly.cancel()">cancel</button>
<xml id="toolbox" style="display:none">
<category name="entry"></category>
<category name="statement"></category>
@ -124,13 +130,24 @@
</h3>
<div>
<div id="blocklyDiv"></div>
<div id="multiLineDiv" style="display:none">
<textarea id="multiLineCode" name="multiLineCode"></textarea>
<button onclick="editor_blockly.multiLineDone()">done</button>
</div>
<textarea id="codeArea" spellcheck="false"></textarea>
</div>
</div></div>
<div id="left7" style="z-index:-1;opacity: 0;"><div><!-- 多行文本编辑器 -->
<button onclick="editor_multi.confirm()">confirm</button>
<button onclick="editor_multi.cancel()">cancel</button>
<textarea id="multiLineCode" name="multiLineCode"></textarea>
</div></div>
<div id="left8" class='leftTab' style="z-index:-1;opacity: 0;"><div><!-- functions -->
<h3>脚本编辑&nbsp;&nbsp;<button onclick="editor.mode.onmode('save')">save</button></h3>
<div class='etable'>
<table>
<tbody id='table_e260a2be_5690_476a_b04e_dacddede78b3'>
<tr><td>条目</td><td>注释</td><td></td></tr>
</tbody>
</table>
</div>
</div></div>
<div id="mid">
<table class="col" id='mapColMark'></table>
<table class="row" id='mapRowMark'></table>
@ -155,10 +172,19 @@
<p v-if="whichShow" v-bind:class="[ (whichShow%2) ? 'warnText' : 'successText']">{{ mapMsg }}</p>
</div>
</div>
<input class='btn' id='clear' type="button" value="清除地图" v-on:click="clearMap"/>
<input class='btn' type="button" value="导出地图" id="exportM" v-on:click="exportMap"/>
<div id="bgSelect" v-cloak>
<select id="editModeSelect">
<option value="map">地图编辑</option>
<option value="loc">地图选点</option>
<option value="emenyitem">图块属性</option>
<option value="floor">楼层属性</option>
<option value="tower">全塔属性</option>
<option value="functions">脚本编辑</option>
<option value="appendpic">追加素材</option>
</select>
<!-- -->
<div id="bgSelect" v-cloak style="display:none">
<span>当前地板: </span>
<select v-model="selectedBg">
<option disabled value="">请选择地板</option>
@ -171,6 +197,7 @@
<input class='btn' type="button" value="确定" v-on:click="updatebg"/>
</div>
</div>
<!-- -->
</div>
</div>
<div id="right">
@ -321,22 +348,29 @@ function hasOwnProp (obj, key) {
</script>
<script src='_server/editor.js'></script>
<script>
main.init('editor');
editor.init(function(){
editor.pos={x: 0, y: 0};
editor_mode.loc();
editor.info=editor.ids[editor.indexs[201]];
editor_mode.emenyitem();
editor_mode.floor();
editor_mode.tower();
editor_mode.listen();
editor_blockly=editor_blockly();
main.init('editor', function() {
editor.init(function(){
editor.pos={x: 0, y: 0};
editor.mode.loc();
editor.info=editor.ids[editor.indexs[201]];
editor.mode.emenyitem();
editor.mode.floor();
editor.mode.tower();
editor.mode.functions();
editor.mode.showMode('loc');
editor.mode.listen();
editor_multi=editor_multi();
editor_blockly=editor_blockly();
});
});
//main.listen();
</script>
<!-- hightlight textarea -->
<script src='_server/editor_multi.js'></script>
<!-- blockly -->
<script src="_server/blockly/Converter.bundle.min.js"></script>
<script src="_server/blockly/blockly_compressed.js"></script>

View File

@ -128,6 +128,10 @@ actions.prototype.keyDown = function(keyCode) {
this.keyDownLocalSaveSelect(keyCode);
return;
}
if (core.status.event.id=='storageRemove') {
this.keyDownStorageRemove(keyCode);
return;
}
if (core.status.event.id=='cursor') {
this.keyDownCursor(keyCode);
return;
@ -181,8 +185,8 @@ actions.prototype.keyDown = function(keyCode) {
}
////// 根据放开键的code来执行一系列操作 //////
actions.prototype.keyUp = function(keyCode) {
if (core.isset(core.status.replay)&&core.status.replay.replaying) return;
actions.prototype.keyUp = function(keyCode, fromReplay) {
if (!fromReplay&&core.isset(core.status.replay)&&core.status.replay.replaying) return;
if (core.status.lockControl) {
core.status.holdingKeys = [];
@ -255,7 +259,10 @@ actions.prototype.keyUp = function(keyCode) {
this.keyUpLocalSaveSelect(keyCode);
return;
}
if (core.status.event.id=='storageRemove') {
this.keyUpStorageRemove(keyCode);
return;
}
if (core.status.event.id=='cursor') {
this.keyUpCursor(keyCode);
return;
@ -324,7 +331,7 @@ actions.prototype.keyUp = function(keyCode) {
core.events.setInitData(hard);
core.changeFloor(core.status.floorId, null, core.firstData.hero.loc, null, function() {
core.startReplay(route);
});
}, true);
}, function () {
core.ui.closePanel();
});
@ -649,6 +656,10 @@ actions.prototype.onclick = function (x, y, stepPostfix) {
this.clickLocalSaveSelect(x,y);
return;
}
if (core.status.event.id=='storageRemove') {
this.clickStorageRemove(x,y);
return;
}
if (core.status.event.id == 'cursor') {
this.clickCursor(x,y);
@ -1353,8 +1364,10 @@ actions.prototype.clickSwitchs = function (x,y) {
core.musicStatus.bgmStatus = !core.musicStatus.bgmStatus;
if (core.musicStatus.bgmStatus)
core.resumeBgm();
else
else {
core.pauseBgm();
core.musicStatus.playingBgm = null;
}
core.setLocalStorage('bgmStatus', core.musicStatus.bgmStatus);
core.ui.drawSwitchs();
break;
@ -1626,14 +1639,8 @@ actions.prototype.clickSyncSave = function (x,y) {
}));
break;
case 5:
core.status.event.selection=1;
core.ui.drawConfirmBox("你确定要清空所有存档吗?", function() {
localStorage.clear();
core.drawText("\t[操作成功]你的所有存档已被清空。");
}, function() {
core.status.event.selection=5;
core.ui.drawSyncSave();
})
core.status.event.selection=0;
core.ui.drawStorageRemove();
break;
case 6:
core.status.event.selection=3;
@ -1791,6 +1798,61 @@ actions.prototype.keyUpLocalSaveSelect = function (keycode) {
}
}
////// 存档删除界面时的点击操作 //////
actions.prototype.clickStorageRemove = function (x, y) {
if (x<5 || x>7) return;
var choices = core.status.event.ui.choices;
var topIndex = 6 - parseInt((choices.length - 1) / 2);
if (y>=topIndex && y<topIndex+choices.length) {
var selection = y - topIndex;
switch (selection) {
case 0:
localStorage.clear();
core.drawText("\t[操作成功]你的所有存档已被清空。");
break;
case 1:
for (var i=1;i<=150;i++) {
core.removeLocalStorage("save"+i);
}
core.drawText("\t[操作成功]当前塔的存档已被清空。");
core.removeLocalStorage("autoSave");
break;
case 2:
core.status.event.selection=5;
core.ui.drawSyncSave();
break;
}
}
}
////// 存档删除界面时,按下某个键的操作 //////
actions.prototype.keyDownStorageRemove = function (keycode) {
if (keycode==38) {
core.status.event.selection--;
core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices);
}
if (keycode==40) {
core.status.event.selection++;
core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices);
}
}
////// 存档删除界面时,放开某个键的操作 //////
actions.prototype.keyUpStorageRemove = function (keycode) {
if (keycode==27 || keycode==88) {
core.status.event.selection=5;
core.ui.drawSyncSave();
return;
}
var choices = core.status.event.ui.choices;
if (keycode==13 || keycode==32 || keycode==67) {
var topIndex = 6 - parseInt((choices.length - 1) / 2);
this.clickStorageRemove(6, topIndex+core.status.event.selection);
}
}
////// “虚拟键盘”界面时的点击操作 //////
actions.prototype.clickKeyBoard = function (x, y) {
if (y==3 && x>=1 && x<=11) {

View File

@ -280,7 +280,7 @@ control.prototype.startGame = function (hard, callback) {
core.changeFloor(core.status.floorId, null, core.firstData.hero.loc, null, function() {
if (core.isset(callback)) callback();
});
}, true);
setTimeout(function () {
// Upload
@ -300,6 +300,8 @@ control.prototype.startGame = function (hard, callback) {
////// 重新开始游戏;此函数将回到标题页面 //////
control.prototype.restart = function() {
this.showStartAnimate();
if (core.bgms.length>0)
core.playBgm(core.bgms[0]);
}
@ -1483,7 +1485,7 @@ control.prototype.replay = function () {
core.events.openShop(shopId, false);
var shopInterval = setInterval(function () {
if (!core.events.clickShop(6, topIndex+core.status.event.selection)) {
if (!core.actions.clickShop(6, topIndex+core.status.event.selection)) {
clearInterval(shopInterval);
core.stopReplay();
core.drawTip("录像文件出错");
@ -1491,7 +1493,7 @@ control.prototype.replay = function () {
}
if (selections.length==0) {
clearInterval(shopInterval);
core.events.clickShop(6, topIndex+choices.length);
core.actions.clickShop(6, topIndex+choices.length);
core.replay();
return;
}
@ -1533,6 +1535,11 @@ control.prototype.replay = function () {
return;
}
}
else if (action.indexOf('key:')==0) {
core.actions.keyUp(parseInt(action.substring(4)), true);
core.replay();
return;
}
core.stopReplay();
core.insertAction("录像文件出错");
@ -1707,7 +1714,7 @@ control.prototype.doSL = function (id, type) {
core.events.setInitData(data.hard);
core.changeFloor(core.status.floorId, null, core.firstData.hero.loc, null, function() {
core.startReplay(core.decodeRoute(data.route));
});
}, true);
}
return;
}
@ -1880,7 +1887,7 @@ control.prototype.loadData = function (data, callback) {
core.changeFloor(data.floorId, null, data.hero.loc, 0, function() {
if (core.isset(callback)) callback();
});
}, true);
}
////// 设置勇士属性 //////
@ -1994,7 +2001,11 @@ control.prototype.resumeBgm = function () {
}
else {
if (core.bgms.length>0) {
core.playBgm(core.bgms[0]);
if (core.isset(core.floors[core.status.floorId].bgm)) {
core.playBgm(core.floors[core.status.floorId].bgm);
}
else
core.playBgm(core.bgms[0]);
core.musicStatus.isPlaying = true;
}
}

View File

@ -151,7 +151,7 @@ function core() {
/////////// 系统事件相关 ///////////
////// 初始化 //////
core.prototype.init = function (coreData) {
core.prototype.init = function (coreData, callback) {
for (var key in coreData) {
core[key] = coreData[key];
}
@ -281,6 +281,9 @@ core.prototype.init = function (coreData) {
core.material.icons.hero.height = core.material.images.hero.height/4;
core.setRequestAnimationFrame();
core.showStartAnimate();
if (core.isset(callback)) callback();
});
}
@ -536,8 +539,8 @@ core.prototype.trigger = function (x, y) {
}
////// 楼层切换 //////
core.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback) {
core.events.changeFloor(floorId, stair, heroLoc, time, callback);
core.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback, fromLoad) {
core.events.changeFloor(floorId, stair, heroLoc, time, callback, fromLoad);
}
////// 清除地图 //////

View File

@ -59,6 +59,7 @@ enemys.prototype.getSpecialText = function (enemyId) {
if (this.hasSpecial(special, 20)) text.push("无敌");
if (this.hasSpecial(special, 21)) text.push("退化");
if (this.hasSpecial(special, 22)) text.push("固伤");
if (this.hasSpecial(special, 23)) text.push("重生");
return text;
}
@ -99,9 +100,10 @@ enemys.prototype.getSpecialHint = function (enemy, special) {
case 20: return "无敌:勇士无法打败怪物,除非拥有十字架";
case 21: return "退化:战斗后勇士永久下降"+(enemy.atkValue||0)+"点攻击和"+(enemy.defValue||0)+"点防御";
case 22: return "固伤:战斗前,怪物对勇士造成"+(enemy.damage||0)+"点固定伤害,无视勇士魔防。";
case 23: return "重生:怪物被击败后,角色转换楼层则怪物将再次出现";
default: break;
}
return ""
return "";
}
////// 获得某个怪物的伤害 //////
@ -168,6 +170,10 @@ enemys.prototype.getDefDamage = function (monsterId) {
enemys.prototype.calDamage = function (monster, hero_hp, hero_atk, hero_def, hero_mdef) {
var mon_hp = monster.hp, mon_atk = monster.atk, mon_def = monster.def, mon_special = monster.special;
hero_hp=Math.max(0, hero_hp);
hero_atk=Math.max(0, hero_atk);
hero_def=Math.max(0, hero_def);
hero_mdef=Math.max(0, hero_mdef);
if (this.hasSpecial(mon_special, 20) && !core.hasItem("cross")) // 如果是无敌属性,且勇士未持有十字架
return 999999999; // 返回无限大

View File

@ -1,9 +1,10 @@
function events() {
this.init();
}
var eventdata = functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a.events;
////// 初始化 //////
events.prototype.init = function () {
this.eventdata = functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a.events;
this.events = {
'battle': function (data, core, callback) {
//core.autosave(true);
@ -101,16 +102,19 @@ events.prototype.startGame = function (hard) {
}
////// 不同难度分别设置初始属性 //////
events.prototype.setInitData = eventdata.setInitData
// function (hard)
events.prototype.setInitData = function (hard) {
return this.eventdata.setInitData(hard);
}
////// 游戏获胜事件 //////
events.prototype.win = eventdata.win
// function(reason)
events.prototype.win = function (reason) {
return this.eventdata.win(reason);
}
////// 游戏失败事件 //////
events.prototype.lose = eventdata.lose
// function(reason)
events.prototype.lose = function (reason) {
return this.eventdata.lose(reason);
}
////// 游戏结束 //////
events.prototype.gameOver = function (ending, fromReplay) {
@ -188,8 +192,9 @@ events.prototype.gameOver = function (ending, fromReplay) {
}
////// 转换楼层结束的事件 //////
events.prototype.afterChangeFloor = eventdata.afterChangeFloor
// function (floorId)
events.prototype.afterChangeFloor = function (floorId) {
return this.eventdata.afterChangeFloor(floorId);
}
////// 开始执行一系列自定义事件 //////
events.prototype.doEvents = function (list, x, y, callback) {
@ -219,9 +224,10 @@ events.prototype.doAction = function() {
// 事件处理完毕
if (core.status.event.data.list.length==0) {
if (core.isset(core.status.event.data.callback))
core.status.event.data.callback();
var callback = core.status.event.data.callback;
core.ui.closePanel();
if (core.isset(callback))
callback();
core.replay();
return;
}
@ -796,7 +802,7 @@ events.prototype.trigger = function (x, y) {
}
////// 楼层切换 //////
events.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback) {
events.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback, fromLoad) {
var displayAnimate=!(time==0) && !core.status.replay.replaying;
@ -874,6 +880,16 @@ events.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback
}
else core.setWeather();
// 检查重生
if (!core.isset(fromLoad)) {
core.status.maps[floorId].blocks.forEach(function(block) {
if (core.isset(block.enable) && !block.enable && core.isset(block.event) && block.event.cls=='enemys'
&& core.enemys.hasSpecial(core.material.enemys[block.event.id].special, 23)) {
block.enable = true;
}
})
}
core.drawMap(floorId, function () {
setTimeout(function() {
if (core.isset(heroLoc.direction))
@ -1027,16 +1043,19 @@ events.prototype.useItem = function(itemId) {
}
////// 加点事件 //////
events.prototype.addPoint = eventdata.addPoint
// function (enemy)
events.prototype.addPoint = function (enemy) {
return this.eventdata.addPoint(enemy);
}
////// 战斗结束后触发的事件 //////
events.prototype.afterBattle = eventdata.afterBattle
// function(enemyId,x,y,callback)
events.prototype.afterBattle = function (enemyId,x,y,callback) {
return this.eventdata.afterBattle(enemyId,x,y,callback);
}
////// 开一个门后触发的事件 //////
events.prototype.afterOpenDoor = eventdata.afterOpenDoor
// function(doorId,x,y,callback)
events.prototype.afterOpenDoor = function (doorId,x,y,callback) {
return this.eventdata.afterOpenDoor(doorId,x,y,callback);
}
////// 经过一个路障 //////
events.prototype.passNet = function (data) {
@ -1087,8 +1106,9 @@ events.prototype.changeLight = function(x, y) {
}
////// 改变亮灯之后,可以触发的事件 //////
events.prototype.afterChangeLight = eventdata.afterChangeLight
// function(x,y)
events.prototype.afterChangeLight = function (x,y) {
return this.eventdata.afterChangeLight(x,y);
}
////// 滑冰 //////
events.prototype.ski = function (direction) {
@ -1165,21 +1185,23 @@ events.prototype.pushBox = function (data) {
}
////// 推箱子后的事件 //////
events.prototype.afterPushBox = eventdata.afterPushBox
// function ()
events.prototype.afterPushBox = function () {
return this.eventdata.afterPushBox();
}
////// 使用炸弹/圣锤后的事件 //////
events.prototype.afterUseBomb = eventdata.afterUseBomb
// function ()
events.prototype.afterUseBomb = function () {
return this.eventdata.afterUseBomb();
}
////// 即将存档前可以执行的操作 //////
events.prototype.beforeSaveData = eventdata.beforeSaveData
// function(data)
events.prototype.beforeSaveData = function (data) {
return this.eventdata.beforeSaveData(data);
}
////// 读档事件后,载入事件前,可以执行的操作 //////
events.prototype.afterLoadData = eventdata.afterLoadData
// function(data)
events.prototype.afterLoadData = function (data) {
return this.eventdata.afterLoadData(data);
}
delete(eventdata);

View File

@ -41,6 +41,7 @@ items.prototype.getItemEffect = function(itemId, itemNum) {
var itemCls = core.material.items[itemId].cls;
// 消耗品
if (itemCls === 'items') {
var ratio = parseInt(core.floors[core.status.floorId].item_ratio) || 1;
if (itemId in this.itemEffect)eval(this.itemEffect[itemId]);
}
else {
@ -50,6 +51,7 @@ items.prototype.getItemEffect = function(itemId, itemNum) {
////// “即捡即用类”道具的文字提示 //////
items.prototype.getItemEffectTip = function(itemId) {
var ratio = parseInt(core.floors[core.status.floorId].item_ratio) || 1;
if (itemId in this.itemEffectTip && (!this.items[itemId].isEquipment || !core.flags.equipment)) {
return eval(this.itemEffectTip[itemId]);
}

View File

@ -721,20 +721,26 @@ maps.prototype.removeBlock = function (x, y, floorId) {
////// 根据block的索引删除该块 //////
maps.prototype.removeBlockById = function (index, floorId) {
var blocks = core.status.maps[floorId].blocks;
var x=blocks[index].x, y=blocks[index].y;
var blocks = core.status.maps[floorId].blocks, block = blocks[index];
var x=block.x, y=block.y;
// 检查该点是否存在事件
var event = core.floors[floorId].events[x+","+y];
if (!core.isset(event))
event = core.floors[floorId].changeFloor[x+","+y];
// 检查是否存在重生
var isReborn = false;
if (core.isset(block.event) && block.event.cls=='enemys'
&& core.enemys.hasSpecial(core.material.enemys[block.event.id].special, 23))
isReborn = true;
// 不存在事件,直接删除
if (!core.isset(event)) {
if (!isReborn && !core.isset(event)) {
blocks.splice(index,1);
return;
}
blocks[index].enable = false;
block.enable = false;
}
////// 一次性删除多个block //////

View File

@ -6,10 +6,10 @@
function ui() {
this.init();
}
var uidata = functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a.ui;
// 初始化UI
ui.prototype.init = function () {
this.uidata = functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a.ui;
}
////////////////// 地图设置
@ -1068,6 +1068,14 @@ ui.prototype.drawLocalSaveSelect = function () {
]);
}
////// 绘制存档删除页面 //////
ui.prototype.drawStorageRemove = function () {
core.status.event.id = 'storageRemove';
this.drawChoices(null, [
"清空全部塔的存档", "只清空当前塔的存档", "返回上级菜单"
]);
}
////// 绘制分页 //////
ui.prototype.drawPagination = function (page, totalPage) {
@ -1626,7 +1634,9 @@ ui.prototype.drawKeyBoard = function () {
}
////// 绘制“关于”界面 //////
ui.prototype.drawAbout = uidata.drawAbout
ui.prototype.drawAbout = function () {
return this.uidata.drawAbout();
}
////// 绘制帮助页面 //////
ui.prototype.drawHelp = function () {
@ -1657,4 +1667,3 @@ ui.prototype.drawHelp = function () {
]);
}
delete(uidata)

View File

@ -158,8 +158,6 @@ utils.prototype.encodeRoute = function (route) {
var ans="";
var lastMove = "", cnt=0;
var items=Object.keys(core.material.items).sort();
var shops=Object.keys(core.initStatus.shops).sort();
route.forEach(function (t) {
if (t=='up' || t=='down' || t=='left' || t=='right') {
if (t!=lastMove && cnt>0) {
@ -177,15 +175,13 @@ utils.prototype.encodeRoute = function (route) {
cnt=0;
}
if (t.indexOf('item:')==0)
ans+="I"+items.indexOf(t.substring(5));
ans+="I"+t.substring(5)+":";
else if (t.indexOf('fly:')==0)
ans+="F"+core.floorIds.indexOf(t.substring(4));
ans+="F"+t.substring(4)+":";
else if (t.indexOf('choices:')==0)
ans+="C"+t.substring(8);
else if (t.indexOf('shop:')==0) {
var sp=t.substring(5).split(":");
ans+="S"+shops.indexOf(sp[0])+":"+sp[1];
}
else if (t.indexOf('shop:')==0)
ans+="S"+t.substring(5);
else if (t=='turn')
ans+='T';
else if (t=='getNext')
@ -194,9 +190,10 @@ utils.prototype.encodeRoute = function (route) {
ans+="P"+t.substring(6);
else if (t=='no')
ans+='N';
else if (t.indexOf('move:')==0) {
else if (t.indexOf('move:')==0)
ans+="M"+t.substring(5);
}
else if (t=='key:')
ans+='K'+t.substring(4);
}
});
if (cnt>0) {
@ -221,27 +218,33 @@ utils.prototype.decodeRoute = function (route) {
if (num.length==0) num="1";
return core.isset(noparse)?num:parseInt(num);
}
var getString = function () {
var str="";
while (index<route.length && /\w/.test(route.charAt(index))) {
str+=route.charAt(index++);
}
return str;
}
var items=Object.keys(core.material.items).sort();
var shops=Object.keys(core.initStatus.shops).sort();
while (index<route.length) {
var c=route.charAt(index++);
var number=getNumber();
var nxt=(c=='I'||c=='F'||c=='S')?getString():getNumber();
switch (c) {
case "U": for (var i=0;i<number;i++) ans.push("up"); break;
case "D": for (var i=0;i<number;i++) ans.push("down"); break;
case "L": for (var i=0;i<number;i++) ans.push("left"); break;
case "R": for (var i=0;i<number;i++) ans.push("right"); break;
case "I": ans.push("item:"+items[number]); break;
case "F": ans.push("fly:"+core.floorIds[number]); break;
case "C": ans.push("choices:"+number); break;
case "S": ++index; ans.push("shop:"+shops[number]+":"+getNumber(true)); break;
case "U": for (var i=0;i<nxt;i++) ans.push("up"); break;
case "D": for (var i=0;i<nxt;i++) ans.push("down"); break;
case "L": for (var i=0;i<nxt;i++) ans.push("left"); break;
case "R": for (var i=0;i<nxt;i++) ans.push("right"); break;
case "I": ++index; ans.push("item:"+nxt); break;
case "F": ++index; ans.push("fly:"+nxt); break;
case "C": ans.push("choices:"+nxt); break;
case "S": ++index; ans.push("shop:"+nxt+":"+getNumber(true)); break;
case "T": ans.push("turn"); break;
case "G": ans.push("getNext"); break;
case "P": ans.push("input:"+number); break;
case "P": ans.push("input:"+nxt); break;
case "N": ans.push("no"); break;
case "M": ++index; ans.push("move:"+number+":"+getNumber()); break;
case "M": ++index; ans.push("move:"+nxt+":"+getNumber()); break;
case "K": ans.push("key:"+nxt); break;
}
}
return ans;

14
main.js
View File

@ -106,11 +106,10 @@ function main() {
'hard': document.getElementById("hard")
}
this.floors = {}
this.instance = {};
this.canvas = {};
}
main.prototype.init = function (mode) {
main.prototype.init = function (mode, callback) {
for (var i = 0; i < main.dom.gameCanvas.length; i++) {
main.canvas[main.dom.gameCanvas[i].id] = main.dom.gameCanvas[i].getContext('2d');
}
@ -156,7 +155,7 @@ main.prototype.init = function (mode) {
"animates", "bgms", "sounds", "floorIds", "floors"].forEach(function (t) {
coreData[t] = main[t];
})
main.core.init(coreData);
main.core.init(coreData, callback);
main.core.resize(main.dom.body.clientWidth, main.dom.body.clientHeight);
});
});
@ -213,7 +212,6 @@ main.prototype.loadMod = function (modName, callback) {
script.src = 'libs/' + modName + (this.useCompress?".min":"") + '.js?v=' + this.version;
main.dom.body.appendChild(script);
script.onload = function () {
main[name] = main.instance[name];
callback(name);
}
}
@ -444,8 +442,9 @@ main.dom.replayGame.onclick = function () {
return;
}
if (core.isset(obj.version) && obj.version!=core.firstData.version) {
alert("游戏版本不一致!");
return;
// alert("游戏版本不一致!");
if (!confirm("游戏版本不一致!\n你仍然想播放录像吗"))
return;
}
if (!core.isset(obj.route) || !core.isset(obj.hard)) {
alert("无效的录像!");
@ -456,9 +455,8 @@ main.dom.replayGame.onclick = function () {
core.resetStatus(core.firstData.hero, obj.hard, core.firstData.floorId, null, core.initStatus.maps);
core.events.setInitData(obj.hard);
core.changeFloor(core.status.floorId, null, core.firstData.hero.loc, null, function() {
//core.setHeroMoveTriggerInterval();
core.startReplay(core.decodeRoute(obj.route));
});
}, true);
}, function () {
})

View File

@ -37,11 +37,13 @@ comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
"name": "显示在状态栏中的层数 ",
"canFlyTo": "该楼能否被楼传器飞到(不能的话在该楼也不允许使用楼传器) \n$select({\"values\":[true,false]})$end",
"canUseQuickShop": "该层是否允许使用快捷商店 \n$select({\"values\":[true,false]})$end",
"defaultGround": "默认地面的图块IDterrains中 ",
"defaultGround": "默认地面的图块IDterrains中 \n$select({\"values\":Object.keys(editor.core.icons.icons.terrains)})$end",
"png": "背景图你可以选择一张png图片来作为背景素材。详细用法请参见文档“自定义素材”中的说明。 \n$leaf(true)$end",
"color": "该层的默认画面色调。本项可不写代表无色调如果写需要是一个RGBA数组。 \n$leaf(true)$end",
"weather": "该层的默认天气。本项可忽略表示晴天,如果写则第一项为\"rain\"或\"snow\"代表雨雪第二项为1-10之间的数代表强度。 \n$leaf(true)$end",
"bgm": "到达该层后默认播放的BGM。本项可忽略。 ",
//"map": "地图数据需要是13x13建议使用地图生成器来生成 ",
"item_ratio": "每一层的宝石/血瓶效果,即获得宝石和血瓶时框内\"ratio\"的值。$range((thiseval==~~thiseval && thiseval>0)||thiseval==null)$end",
"firstArrive": "第一次到该楼层触发的事件 \n$leaf(true)$end",
},
'loc' : {

View File

@ -1,4 +1,4 @@
data_comment_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
{
"main": {
"useCompress": " 是否使用压缩文件 \n 当你即将发布你的塔时请使用“JS代码压缩工具”将所有js代码进行压缩然后将这里的useCompress改为true。 \n 请注意只有useCompress是false时才会读取floors目录下的文件为true时会直接读取libs目录下的floors.min.js文件。 \n 如果要进行剧本的修改请务必将其改成false。 \n$select({\"values\":[false]})$end",
@ -27,11 +27,11 @@ data_comment_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
"money": " 初始金币 ",
"experience": " 初始经验 ",
"items": {
"keys": {
"keys": " 初始道具个数 \n$leaf(true)$end"/* {
"yellowKey": " 初始道具个数 ",
"blueKey": "",
"redKey": ""
},
} */,
"constants": "\n$leaf(true)$end",
"tools": "\n$leaf(true)$end"
},
@ -41,11 +41,11 @@ data_comment_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
"x": "",
"y": ""
},
"flags": {
"flags": " 游戏过程中的变量或flags \n$leaf(true)$end"/* {
"poison": " 游戏过程中的变量或flags \n 毒 ",
"weak": " 衰 ",
"curse": " 咒 "
},
} */,
"steps": " 行走步数统计 ",
},
"startText": " 游戏开始前剧情。如果无剧情直接留一个空数组即可。 \n$leaf(true)$end",
@ -102,7 +102,7 @@ data_comment_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
]
}
},*/
"levelUp": [
"levelUp": " 经验升级所需要的数值,是一个数组 \n 第一项为初始等级可以简单留空也可以写name \n 每一个里面可以含有三个参数 need, name, effect \n need为所需要的经验数值是一个正整数。请确保need所需的依次递增 \n name为该等级的名称也可以省略代表使用系统默认值本项将显示在状态栏中 \n effect为本次升级所执行的操作可由若干项组成由分号分开 \n 其中每一项写法和上面的商店完全相同同样必须是X+=Y的形式Y是一个表达式同样可以使用status:xxx或item:xxx代表勇士的某项数值/道具个数 \n$leaf(true)$end"/* [
" 经验升级所需要的数值,是一个数组 \n 第一项为初始等级可以简单留空也可以写name \n 每一个里面可以含有三个参数 need, name, effect \n need为所需要的经验数值是一个正整数。请确保need所需的依次递增 \n name为该等级的名称也可以省略代表使用系统默认值本项将显示在状态栏中 \n effect为本次升级所执行的操作可由若干项组成由分号分开 \n 其中每一项写法和上面的商店完全相同同样必须是X+=Y的形式Y是一个表达式同样可以使用status:xxx或item:xxx代表勇士的某项数值/道具个数 \n$leaf(true)$end",
{
"need": "",
@ -113,7 +113,7 @@ data_comment_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
"need": "",
"effect": " effect也允许写一个function代表本次升级将会执行的操作 \n 依次往下写需要的数值即可 "
}
]
] */
},
"values": {
"HPMAX": " 各种数值;一些数值可以在这里设置\n /****** 角色相关 ******/ \n HP上限-1则无上限 ",

View File

@ -134,12 +134,12 @@ data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
{"need": 20, "name": "第二级", "effect": "status:hp+=2*(status:atk+status:def);status:atk+=10;status:def+=10"}, // 先将生命提升攻防和的2倍再将攻击+10防御+10
{"need": 40, "effect": `function () {
{"need": 40, "effect": function () {
core.drawText("恭喜升级!");
core.status.hero.hp *= 2;
core.status.hero.atk += 100;
core.status.hero.def += 100;
}`}, // effect也允许写一个function代表本次升级将会执行的操作
}}, // effect也允许写一个function代表本次升级将会执行的操作
// 依次往下写需要的数值即可
]
@ -218,7 +218,7 @@ data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
"showBattleAnimateConfirm": true, // 是否在游戏开始时提供“是否开启战斗动画”的选项
"battleAnimate": true, // 是否默认显示战斗动画;用户可以手动在菜单栏中开关
"displayEnemyDamage": true, // 是否地图怪物显伤;用户可以手动在菜单栏中开关
"displayExtraDamage": false, // 是否地图高级显伤(领域、夹击等);用户可以手动在菜单栏中开关
"displayExtraDamage": true, // 是否地图高级显伤(领域、夹击等);用户可以手动在菜单栏中开关
"enableGentleClick": true, // 是否允许轻触(获得面前物品)
"potionWhileRouting": false, // 寻路算法是否经过血瓶如果该项为false则寻路算法会自动尽量绕过血瓶
"enableViewMaps": true, // 是否支持在菜单栏中查看所有楼层的地图

View File

@ -23,7 +23,7 @@ enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80 =
'yellowGuard': {'name': '初级卫兵', 'hp': 100, 'atk': 120, 'def': 0, 'money': 10, 'experience': 0, 'special': 0},
'blueGuard': {'name': '中级卫兵', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 0, 'special': 0},
'redGuard': {'name': '高级卫兵', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 0, 'special': 0},
'swordsman': {'name': '双手剑士', 'hp': 100, 'atk': 120, 'def': 0, 'money': 6, 'experience': 0, 'special': 5},
'swordsman': {'name': '双手剑士', 'hp': 100, 'atk': 120, 'def': 0, 'money': 6, 'experience': 0, 'special': [5,23]},
'soldier': {'name': '冥战士', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 0, 'special': 0},
'yellowKnight': {'name': '金骑士', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 0, 'special': 0},
'redKnight': {'name': '红骑士', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 0, 'special': 0},

View File

@ -13,6 +13,7 @@ main.floors.MT0 =
// "color": [0,0,0,0.3], // 该层的默认画面色调。本项可不写代表无色调如果写需要是一个RGBA数组。
// "weather": ["snow",5], // 该层的默认天气。本项可忽略表示晴天,如果写则第一项为"rain"或"snow"代表雨雪第二项为1-10之间的数代表强度。
// "bgm": "bgm.mp3", // 到达该层后默认播放的BGM。本项可忽略。
"item_ratio": 1, // 该层的宝石/血瓶倍率
"map": [ // 地图数据需要是13x13建议使用地图生成器来生成
],

View File

@ -13,6 +13,7 @@ main.floors.sample0 =
// "color": [0,0,0,0.3] // 该层的默认画面色调。本项可不写代表无色调如果写需要是一个RGBA数组。
// "weather": ["snow",5], // 该层的默认天气。本项可忽略表示晴天,如果写则第一项为"rain"或"snow"代表雨雪第二项为1-10之间的数代表强度。
"bgm": "bgm.mp3", // 到达该层后默认播放的BGM。本项可忽略。
"item_ratio": 2, // 该层的宝石/血瓶倍率
"map": [ // 地图数据需要是13x13建议使用地图生成器来生成
[0, 0, 220, 0, 0, 20, 87, 3, 65, 64, 44, 43, 42],
[0, 246, 0, 246, 0, 20, 0, 3, 58, 59, 60, 61, 41],

View File

@ -13,6 +13,7 @@ main.floors.sample1 =
// "color": [0,0,0,0.3] // 该层的默认画面色调。本项可不写代表无色调如果写需要是一个RGBA数组。
"weather": ["snow",6], // 该层的默认天气。本项可忽略表示晴天,如果写则第一项为"rain"或"snow"代表雨雪第二项为1-10之间的数代表强度。
// "bgm": "bgm.mp3", // 到达该层后默认播放的BGM。本项可忽略。
"item_ratio": 1, // 该层的宝石/血瓶倍率
"map": [ // 地图数据需要是13x13建议使用地图生成器来生成
[7, 131, 8, 152, 9, 130, 10, 152, 166, 165, 132, 165, 166],
[0, 0, 0, 0, 0, 0, 0, 152, 165, 164, 0, 162, 165],

View File

@ -13,6 +13,7 @@ main.floors.sample2 =
"color": [255,0,0,0.3], // 该层的默认画面色调。本项可不写代表无色调如果写需要是一个RGBA数组。
"weather": ["rain",10], // 该层的默认天气。本项可忽略表示晴天,如果写则第一项为"rain"或"snow"代表雨雪第二项为1-10之间的数代表强度。
"bgm": "qianjin.mid", // 到达该层后默认播放的BGM。本项可忽略。
"item_ratio": 1, // 该层的宝石/血瓶倍率
"map": [ // 地图数据需要是13x13建议使用地图生成器来生成
[5, 5, 5, 5, 5, 5, 87, 5, 5, 5, 5, 5, 5],
[5, 4, 4, 4, 4, 1, 0, 1, 4, 4, 4, 4, 5],

View File

@ -1,46 +0,0 @@
main.floors.test =
{
"floorId": "test", // 这里需要改楼层名请和文件名及下面的floorId保持完全一致
// 楼层唯一标识符仅能由字母、数字、下划线组成,且不能由数字开头
// 推荐用法第20层就用MT20第38层就用MT38地下6层就用MT_6用下划线代替负号隐藏3层用MT3hh表示隐藏等等
// 楼层唯一标识符,需要和名字完全一致
"title": "test", // 楼层中文名
"name": "", // 显示在状态栏中的层数
"canFlyTo": true, // 该楼能否被楼传器飞到(不能的话在该楼也不允许使用楼传器)
"canUseQuickShop": true, // 该层是否允许使用快捷商店
"defaultGround": "ground", // 默认地面的图块IDterrains中
"map": [ // 地图数据需要是13x13建议使用地图生成器来生成
[201,201,201,201,201,201,201,201,201,201,201,201,201],
[201,201,201,201,201,201,201,201,201,201,201,201,201],
[201,201,201,201,201,201,201,201,201,201,201,201,201],
[201,201,201,201,201,201,201,201,201,201,201,201,201],
[201,201,201,201,201,201,201,201,201,201,201,201,201],
[201,201,201,201,201,201,201,201,201,201,201,201,201],
[201,201,201,201,201,201,201,201,201,201,201,201,201],
[201,201,201,201,201,201,201,201,201,201,201,201,201],
[201,201,201,201,201,201,201,201,201,201,201,201,201],
[201,201,201,201,201,201,201,201,201,201,201,201,201],
[201,201,201,201,201,201,201,201,201,201,201,201,201],
[201,201,201,201,201,201, 45,201,201,201,201,201,201],
[201,201,201,201,201,201, 0,201,201,201,201,201,201]
],
"firstArrive": [ // 第一次到该楼层触发的事件
],
"events": { // 该楼的所有可能事件列表
},
"changeFloor": { // 楼层转换事件该事件不能和上面的events有冲突同位置点否则会被覆盖
},
"afterBattle": { // 战斗后可能触发的事件列表
},
"afterGetItem": { // 获得道具后可能触发的事件列表
},
"afterOpenDoor": { // 开完门后可能触发的事件列表
}
}

View File

@ -1,4 +1,4 @@
functions_comment_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
{
"events" : {
"setInitData" : "不同难度分别设置初始属性",

View File

@ -3,6 +3,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
"events":{
////// 不同难度分别设置初始属性 //////
"setInitData":function (hard) {
// 不同难度分别设置初始属性
if (hard=='Easy') { // 简单难度
core.setFlag('hard', 1); // 可以用flag:hard来获得当前难度
// 可以在此设置一些初始福利,比如设置初始生命值可以调用:
@ -19,10 +20,11 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
if (hard=='Hell') { // 噩梦难度
core.setFlag('hard', 4); // 可以用flag:hard来获得当前难度
}
this.afterLoadData();
core.events.afterLoadData();
},
////// 游戏获胜事件 //////
"win" : function(reason) {
// 游戏获胜事件
core.ui.closePanel();
var replaying = core.status.replay.replaying;
core.stopReplay();
@ -38,6 +40,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
},
////// 游戏失败事件 //////
"lose" : function(reason) {
// 游戏失败事件
core.ui.closePanel();
var replaying = core.status.replay.replaying;
core.stopReplay();
@ -51,10 +54,11 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
},
////// 转换楼层结束的事件 //////
"afterChangeFloor" : function (floorId) {
// 转换楼层结束的事件
if (core.isset(core.status.event.id)) return; // 当前存在事件
if (!core.hasFlag("visited_"+floorId)) {
this.doEvents(core.floors[floorId].firstArrive, null, null, function () {
core.events.doEvents(core.floors[floorId].firstArrive, null, null, function () {
//core.autosave();
});
core.setFlag("visited_"+floorId, true);
@ -66,6 +70,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
},
////// 加点事件 //////
"addPoint" : function (enemy) {
// 加点事件
var point = enemy.point;
if (!core.isset(point) || point<=0) return [];
@ -88,6 +93,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
},
////// 战斗结束后触发的事件 //////
"afterBattle" : function(enemyId,x,y,callback) {
// 战斗结束后触发的事件
var enemy = core.material.enemys[enemyId];
@ -174,7 +180,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
// 如果事件不为空,将其插入
if (todo.length>0) {
this.insertAction(todo,x,y);
core.events.insertAction(todo,x,y);
}
// 如果已有事件正在处理中
@ -189,6 +195,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
},
////// 开一个门后触发的事件 //////
"afterOpenDoor" : function(doorId,x,y,callback) {
// 开一个门后触发的事件
var todo = [];
if (core.isset(x) && core.isset(y)) {
@ -199,7 +206,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
}
if (todo.length>0) {
this.insertAction(todo,x,y);
core.events.insertAction(todo,x,y);
}
if (core.status.event.id == null) {
@ -212,10 +219,12 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
},
////// 改变亮灯之后,可以触发的事件 //////
"afterChangeLight" : function(x,y) {
// 改变亮灯之后,可以触发的事件
},
////// 推箱子后的事件 //////
"afterPushBox" : function () {
// 推箱子后的事件
var noBoxLeft = function () {
// 地图上是否还存在未推到的箱子如果不存在则返回true存在则返回false
@ -239,6 +248,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
},
////// 使用炸弹/圣锤后的事件 //////
"afterUseBomb" : function () {
// 使用炸弹/圣锤后的事件
// 这是一个使用炸弹也能开门的例子
/*
@ -254,10 +264,12 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
},
////// 即将存档前可以执行的操作 //////
"beforeSaveData" : function(data) {
// 即将存档前可以执行的操作
},
////// 读档事件后,载入事件前,可以执行的操作 //////
"afterLoadData" : function(data) {
// 读档事件后,载入事件前,可以执行的操作
}
@ -266,6 +278,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
"ui":{
////// 绘制“关于”界面 //////
"drawAbout" : function() {
// 绘制“关于”界面
if (!core.isPlaying()) {
core.status.event = {'id': null, 'data': null};

View File

@ -62,16 +62,16 @@ items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"itemEffect" : {
"redJewel":"core.status.hero.atk += core.values.redJewel",
"blueJewel":"core.status.hero.def += core.values.blueJewel",
"greenJewel":"core.status.hero.mdef += core.values.greenJewel",
"redJewel":"core.status.hero.atk += core.values.redJewel * ratio",
"blueJewel":"core.status.hero.def += core.values.blueJewel * ratio",
"greenJewel":"core.status.hero.mdef += core.values.greenJewel * ratio",
"yellowJewel":"core.status.hero.hp+=1000;core.status.hero.atk+=6;core.status.hero.def+=6;core.status.hero.mdef+=10;",
// 黄宝石属性:需自己定义
"redPotion":"core.status.hero.hp += core.values.redPotion",
"bluePotion":"core.status.hero.hp += core.values.bluePotion",
"yellowPotion":"core.status.hero.hp += core.values.yellowPotion",
"greenPotion":"core.status.hero.hp += core.values.greenPotion",
"redPotion":"core.status.hero.hp += core.values.redPotion * ratio",
"bluePotion":"core.status.hero.hp += core.values.bluePotion * ratio",
"yellowPotion":"core.status.hero.hp += core.values.yellowPotion * ratio",
"greenPotion":"core.status.hero.hp += core.values.greenPotion * ratio",
"sword1":"core.status.hero.atk += core.values.sword1",
"sword2":"core.status.hero.atk += core.values.sword2",
"sword3":"core.status.hero.atk += core.values.sword3",
@ -91,14 +91,14 @@ items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"itemEffectTip" : {
"redJewel":"',攻击+'+core.values.redJewel",
"blueJewel":"',防御+'+core.values.blueJewel",
"greenJewel":"',魔防+'+core.values.greenJewel",
"redJewel":"',攻击+'+core.values.redJewel * ratio",
"blueJewel":"',防御+'+core.values.blueJewel * ratio",
"greenJewel":"',魔防+'+core.values.greenJewel * ratio",
"yellowJewel":"',全属性提升'",
"redPotion":"',生命+'+core.values.redPotion",
"bluePotion":"',生命+'+core.values.bluePotion",
"yellowPotion":"',生命+'+core.values.yellowPotion",
"greenPotion":"',生命+'+core.values.greenPotion",
"redPotion":"',生命+'+core.values.redPotion * ratio",
"bluePotion":"',生命+'+core.values.bluePotion * ratio",
"yellowPotion":"',生命+'+core.values.yellowPotion * ratio",
"greenPotion":"',生命+'+core.values.greenPotion * ratio",
"sword1":"',攻击+'+core.values.sword1",
"sword2":"',攻击+'+core.values.sword2",
"sword3":"',攻击+'+core.values.sword3",