Merge remote-tracking branch 'refs/remotes/ckcz123/master'

This commit is contained in:
YouWei Zhao 2017-12-28 12:05:50 +08:00
commit 6dc7b50d2d
39 changed files with 1755 additions and 854 deletions

101
_server/fs.js Normal file
View File

@ -0,0 +1,101 @@
(function(){
fs = {};
var postsomething = function (data,_ip,callback) {
//callback:function(err, data)
//data:字符串
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
switch(xhr.readyState){
case 4 :
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304) {
if (Boolean(callback)){
if (xhr.responseText.slice(0,6)=='error:'){
callback(xhr.responseText,null);
} else {
callback(null,xhr.responseText);
}
}
//printf(xhr.responseText)
}else{
if (Boolean(callback))callback(xhr.status,null);
//printf('error:' + xhr.status+'<br>'+(xhr.responseText||''));
}
break;
}
}
xhr.open('post',_ip);
xhr.setRequestHeader('Content-Type','text/plain');
if(typeof(data)==typeof([][0]) || data==null)data=JSON.stringify({1:2});
xhr.send(data);
}
fs.readFile = function (filename,encoding,callback) {
if (typeof(filename)!=typeof(''))
throw 'Type Error in fs.readFile';
if (encoding=='utf-8'){
//读文本文件
//filename:支持"/"做分隔符
//callback:function(err, data)
//data:字符串
var data='';
data+='type=utf8&';
data+='name='+filename;
postsomething(data,'/readFile',callback);
return;
}
if (encoding=='base64'){
//读二进制文件
//filename:支持"/"做分隔符
//callback:function(err, data)
//data:base64字符串
var data='';
data+='type=base64&';
data+='name='+filename;
postsomething(data,'/readFile',callback);
return;
}
throw 'Type Error in fs.readFile';
}
fs.writeFile = function (filename,datastr,encoding,callback) {
if (typeof(filename)!=typeof('') || typeof(datastr)!=typeof(''))
throw 'Type Error in fs.writeFile';
if (encoding=='utf-8'){
//写文本文件
//filename:支持"/"做分隔符
//callback:function(err)
//datastr:字符串
var data='';
data+='type=utf8&';
data+='name='+filename;
data+='&value='+datastr;
postsomething(data,'/writeFile',callback);
return;
}
if (encoding=='base64'){
//写二进制文件
//filename:支持"/"做分隔符
//callback:function(err)
//datastr:base64字符串
var data='';
data+='type=base64&';
data+='name='+filename;
data+='&value='+datastr;
postsomething(data,'/writeFile',callback);
return;
}
throw 'Type Error in fs.writeFile';
}
fs.readdir = function (path, callback) {
//callback:function(err, data)
//path:支持"/"做分隔符,不以"/"结尾
//data:[filename1,filename2,..] filename是字符串,只包含文件不包含目录
if (typeof(path)!=typeof(''))
throw 'Type Error in fs.readdir';
var data='';
data+='name='+path;
postsomething(data,'/listFile',function(err, data){callback(err,JSON.parse(data))});
return;
}
})();

View File

@ -2,109 +2,7 @@
<html>
<head><meta charset="utf-8"></head>
<body>
<script>
(function(){
fs = {};
var postsomething = function (data,_ip,callback) {
//callback:function(err, data)
//data:字符串
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
switch(xhr.readyState){
case 4 :
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304) {
if (Boolean(callback)){
if (xhr.responseText.slice(0,6)=='error:'){
callback(xhr.responseText,null);
} else {
callback(null,xhr.responseText);
}
}
//printf(xhr.responseText)
}else{
if (Boolean(callback))callback(xhr.status,null);
//printf('error:' + xhr.status+'<br>'+(xhr.responseText||''));
}
break;
}
}
xhr.open('post',_ip);
xhr.setRequestHeader('Content-Type','text/plain');
if(typeof(data)==typeof([][0]) || data==null)data=JSON.stringify({1:2});
xhr.send(data);
}
fs.readFile = function (filename,encoding,callback) {
if (typeof(filename)!=typeof(''))
throw 'Type Error in fs.readFile';
if (encoding=='utf-8'){
//读文本文件
//filename:支持"/"做分隔符
//callback:function(err, data)
//data:字符串
var data='';
data+='type=utf8&';
data+='name='+filename;
postsomething(data,'/readFile',callback);
return;
}
if (encoding=='base64'){
//读二进制文件
//filename:支持"/"做分隔符
//callback:function(err, data)
//data:base64字符串
var data='';
data+='type=base64&';
data+='name='+filename;
postsomething(data,'/readFile',callback);
return;
}
throw 'Type Error in fs.readFile';
}
fs.writeFile = function (filename,datastr,encoding,callback) {
if (typeof(filename)!=typeof('') || typeof(datastr)!=typeof(''))
throw 'Type Error in fs.writeFile';
if (encoding=='utf-8'){
//写文本文件
//filename:支持"/"做分隔符
//callback:function(err)
//datastr:字符串
var data='';
data+='type=utf8&';
data+='name='+filename;
data+='&value='+datastr;
postsomething(data,'/writeFile',callback);
return;
}
if (encoding=='base64'){
//写二进制文件
//filename:支持"/"做分隔符
//callback:function(err)
//datastr:base64字符串
var data='';
data+='type=base64&';
data+='name='+filename;
data+='&value='+datastr;
postsomething(data,'/writeFile',callback);
return;
}
throw 'Type Error in fs.writeFile';
}
fs.readdir = function (path, callback) {
//callback:function(err, data)
//path:支持"/"做分隔符,不以"/"结尾
//data:[filename1,filename2,..] filename是字符串,只包含文件不包含目录
if (typeof(path)!=typeof(''))
throw 'Type Error in fs.readdir';
var data='';
data+='name='+path;
postsomething(data,'/listFile',function(err, data){callback(err,JSON.parse(data))});
return;
}
})();
</script>
<script src="./fs.js"></script>
<script>
fs.writeFile('_test.txt','123中a文bc','utf-8',function(e,d){console.log(e);console.log(d);})
setTimeout(function() {

View File

@ -4,7 +4,7 @@
## 事件的机制
本塔所有的事件都是依靠触发`trigger`完成的。例如,勇士碰到一个门可以触发一个事件`openDoor`,勇士碰到怪物可以触发一个事件`battle`,勇士碰到一个(上面定义的)楼层传送点可以触发一个事件`changeFloor`,勇士穿过路障可以触发一个事件`passNet`包括勇士到达一个指定的`checkBlock`也可以触发一个检查领域、夹击的事件。上面说的这些事件都是系统本身自带的即类似于RMXP中的公共事件。
本塔所有的事件都是依靠触发`trigger`完成的。例如,勇士碰到一个门可以触发一个事件`openDoor`,勇士碰到怪物可以触发一个事件`battle`,勇士碰到一个(上面定义的)楼层传送点可以触发一个事件`changeFloor`,勇士穿过路障可以触发一个事件`passNet`等等。上面说的这些事件都是系统本身自带的即类似于RMXP中的公共事件。
上述这些默认的事件已经存在处理机制,不需要我们操心。我们真正所需要关心的,其实只是一个自定义的事件。
@ -829,7 +829,7 @@ core.insertAction(list) //往当前事件列表中插入一系列事件。使用
请注意,快捷商店默认是不可被使用的。直到至少调用一次自定义事件中的 `{"type": "openShop"}` 打开商店后,才能真正在快捷栏中被使用。
``` java
``` js
"1,0": [ // 金币商店
// 打开商店前,你也可以添加自己的剧情
// 例如通过if来事件来判断是不是第一次访问商店是的则显示一段文字类似宿命的华音那样

View File

@ -348,44 +348,9 @@
</div>
<script>main={'instance':{}}</script>
<script src='libs/icons.js'></script>
<script src='libs/maps.js'></script>
<script src='_server/vendor/vue.min.js'></script>
<!-- <script src="https://unpkg.com/vue"></script> -->
<script>
main.instance.icons.init();//不知道为什么,需要手动init,明明maps是正常的
icons=main.instance.icons.getIcons();
var ids = [], indexs = []
ids.push({'idnum':0,'id':'ground','images':'terrains','y':0});
var point = 0
for(var i=0; i<400; i++){
var indexBlock = main.instance.maps.getBlock(0,0,i);
indexs[i] = [];
if('event' in indexBlock){
var id = indexBlock.event.id;
var indexId = indexBlock.id;
if(id=='autotile'){
ids.push({'idnum':indexId,'id':'autotile','images':'autotile','y':0});
point++;
indexs[i].push(point);
continue;
}
var allCls = Object.keys(icons);
for(var j=0; j<allCls.length; j++){
if(id in icons[allCls[j]] ){
ids.push({'idnum':indexId,'id':id,'images':allCls[j],'y':icons[allCls[j]][id]});
point++;
indexs[i].push(point);
}
}
}
}
// 生成定位编号
// 生成定位编号
(function(){
var colNum = ' ';
for(var i=0; i<13; i++){
var tpl = '<td>'+i+'<div class="colBlock" style="left:'+(i*32+1)+'px;"></div></td>';
@ -400,11 +365,111 @@
}
arrRowMark.innerHTML = rowNum;
mapRowMark.innerHTML = rowNum;
})();
</script>
<!-- =========================================================== -->
<script src='_server/vendor/vue.min.js'></script>
<!-- <script src="https://unpkg.com/vue"></script> -->
<script src='_server/fs.js'></script>
<script>
(function(){
printf = function(str,weak) {
var prefix='<span class="result">',postfix='</span>';
if (weak){prefix='<span class="weakresult">';}
if (typeof(str)==="undefined")str='';
printOut.innerHTML=prefix+String(str)+postfix;
}
//所有全局量
__all__=['Vue','fs','printf','editor','main','core','fullX','fullY'];
__id__=['printOut','arrRowMark','mapRowMark','data','bg','dataSelection'];
__Vue__=['exportM','editArea','editTip','clear','tip','selectBox'];
var main={'instance':{}};
var core={};
function editor() {
this.version = "0.1";
}
editor.prototype.init = function() {
var loadedNum=0;
var tmp_callback = function () {
loadedNum++;
if (loadedNum==2)
editor.drawInitData(function(){
editor.listen();
});
}
editor.loadMod(function(){
editor.afterLoadMod(function(){
tmp_callback();
});
});
editor.loadImage(function(){
editor.importGrass(function(){
editor.afterImportGrass(function(){
tmp_callback();
});
});
});
}
editor.prototype.loadMod = function (callback) {
main={'instance':{}};
var loadedNum=0;
['libs/icons.js','libs/maps.js'].forEach( function (value,ii,aa) {
var script = document.createElement('script');
script.src = value + '?' + editor.version;
document.body.appendChild(script);
script.onload = function () {
loadedNum++;
if (loadedNum==aa.length)
callback();
}
})
}//main 加载['libs/icons.js','libs/maps.js']
editor.prototype.afterLoadMod = function (callback) {
main.instance.icons.init();
var icons=main.instance.icons.getIcons();
editor.ids = [];
editor.indexs = [];
editor.ids.push({'idnum':0,'id':'ground','images':'terrains','y':0});
var point = 0
for(var i=0; i<400; i++){
var indexBlock = main.instance.maps.getBlock(0,0,i);
editor.indexs[i] = [];
if('event' in indexBlock){
var id = indexBlock.event.id;
var indexId = indexBlock.id;
if(id=='autotile'){
editor.ids.push({'idnum':indexId,'id':'autotile','images':'autotile','y':0});
point++;
editor.indexs[i].push(point);
continue;
}
var allCls = Object.keys(icons);
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]});
point++;
editor.indexs[i].push(point);
}
}
}
}
callback();
}//editor.ids,editor.indexs
editor.prototype.loadImage = function (callback) {
core={};
core.material={};
core.material.images = {};
@ -432,26 +497,30 @@
imgName = imgName[0];
core.material.images[imgName] = image;
loadedImageNum++;
if (loadedImageNum == core.images.length) {importGrass();}
if (loadedImageNum == core.images.length) {callback();}
});
}
})();
//context.drawImage(img,sx,sy,swidth,sheight,x,y,width,height)
</script>
}//core 加载['terrains','animates', 'enemys', 'items', 'npcs']
<script type="text/javascript">
//预处理草的源图片
importGrass=function(){
autotile = new Image();
editor.prototype.importGrass = function (callback) {
var autotile = new Image();
autotile.src = "images/autotile.png"
autotile.src = "images/autotile.png";
if (autotile.complete) {
editor.autotile = autotile;
callback();
return;
}
autotile.onload = function () {
console.log("loaded")
drawInitData();
editor.autotile = autotile;
callback();
};
function drawAutotile(canvas, x, y, size, autotile, index) {
}// 加载 'autotile'
editor.prototype.afterImportGrass = function (callback) {
var drawAutotile = function (canvas, x, y, size, autotile, index) {
switch (index) {
case 0:
canvas.drawImage(autotile, 0, 0, 32, 32, x, y, size, size);
@ -529,36 +598,34 @@ importGrass=function(){
//根据状态画图
var cxt = eventLayer.getContext("2d");
grass = function (ii, x, y) {
var grass = function (ii, x, y) {
cxt.clearRect(x * 32, y * 32, 32, 32);
// cxt.putImageData(grassImageData[ii], x * 32, y * 32);
drawAutotile(cxt, x * 32, y * 32, 32, autotile, ii);
drawAutotile(cxt, x * 32, y * 32, 32, editor.autotile, ii);
}
//function clearGrass() { cxt.clearRect(0, 0, 416, 416); }
fullX = 12;
fullY = 12;
map = [];//-2表示边界,0表示空地,其他对象对应实体
map[fullX + 1 + fullY * (fullX + 1)] = -2;
for(var ii=0;ii<fullX + 1 + fullY * (fullX + 1);ii++)map[ii]=0;
m = function (x, y) {
if (x < 0 || x > fullX || y < 0 || y > fullY) return fullX + 1 + fullY * (fullX + 1);
return x + y * (fullX + 1);
}
isGrass = function (xx, yy) {
var mapxy=map[m(xx,yy)];
var isGrass = function (xx, yy) {
var mapxy=editor.map[editor.m(xx,yy)];
if (typeof(mapxy) == typeof(-1) || typeof(mapxy) == typeof([][0]))return 0;
if (mapxy.images=='autotile')return 1;
return 0;
}
updateMap = function () {
fullX = 12;
fullY = 12;
editor.map = [];//-2表示边界,0表示空地,其他对象对应实体
editor.map[fullX + 1 + fullY * (fullX + 1)] = -2;
for(var ii=0;ii<fullX + 1 + fullY * (fullX + 1);ii++)editor.map[ii]=0;
editor.m = function (x, y) {
if (x < 0 || x > fullX || y < 0 || y > fullY) return fullX + 1 + fullY * (fullX + 1);
return x + y * (fullX + 1);
}
editor.updateMap = function (error) {
//clearGrass();
// console.log(map)
// console.log(editor.map)
for (var xx = 0; xx <= fullX; xx++) {
for (var yy = 0; yy <= fullY; yy++) {
if (!isGrass(xx, yy)) continue;
@ -571,6 +638,7 @@ importGrass=function(){
for (var xx = 0; xx < fullX; xx++) {
for (var yy = 0; yy < fullY; yy++) {
if (isGrass(xx, yy) + isGrass(xx + 1, yy) + isGrass(xx + 1, yy + 1) + isGrass(xx, yy + 1) != 3) continue;
var autotile = editor.autotile;
if (!isGrass(xx, yy)) {
// cxt.clearRect(xx * 32 + 32, yy * 32 + 32, 16, 16);
// cxt.putImageData(grassImageData[16], xx * 32 + 32, yy * 32 + 32);
@ -596,81 +664,81 @@ importGrass=function(){
for (var xx = 0; xx <= fullX; xx++) {
for (var yy = 0; yy <= fullY; yy++) {
if (isGrass(xx, yy)) continue;
var mapxy=map[m(xx,yy)];
var mapxy=editor.map[editor.m(xx,yy)];
if (typeof(mapxy) == typeof(-1)){
if(mapxy == 0) cxt.clearRect(xx*32, yy*32, 32, 32);
continue;
}
else if(typeof(mapxy) == typeof([][0])) {//未定义块画红块
cxt.fillStyle = 'red';
cxt.fillRect(xx*32, yy*32, 32, 32);
continue;
}
//context.drawImage(img,sx,sy,swidth,sheight,x,y,width,height)
cxt.clearRect(xx*32, yy*32, 32, 32);
cxt.drawImage(core.material.images[mapxy.images], 0, mapxy.y*32, 32, 32, xx*32, yy*32, 32, 32);
if(typeof(mapxy) != typeof({}) || !('idnum' in mapxy) ) {//未定义块画红块
if (error=='clearError'){
editor.map[editor.m(xx,yy)]=0;
cxt.clearRect(xx*32, yy*32, 32, 32);
continue;
}
if (error=='showError'){
cxt.fillStyle = 'rgba(255,0,0,0.8)';
var tmpNum =6;
cxt.fillRect(xx*32+tmpNum, yy*32+tmpNum, 32-tmpNum*2, 32-tmpNum*2);
}
}
}
}
}
}
</script>
<script>
//画背景以及拖拽相关的支持
callback();
}//fullX,fullY,editor.map,editor.m,editor.updateMap
printf = function(str,weak) {
var prefix='<span class="result">',postfix='</span>';
if (weak){prefix='<span class="weakresult">';}
if (typeof(str)==="undefined")str='';
printOut.innerHTML=prefix+String(str)+postfix;
editor.prototype.drawInitData = function (callback) {
var ratio=1;
var images=core.material.images;
var maxHeight=700;
var sumWidth=0;
editor.widthsX={};
for(var ii=0;ii<core.images.length;ii++){
var img=core.images[ii];
editor.widthsX[img]=[img,sumWidth/32,(sumWidth+images[img].width)/32];
sumWidth+=images[img].width;
maxHeight=Math.max(maxHeight,images[img].height);
}
editor.widthsX['autotile']=['autotile',sumWidth/32,(sumWidth+3*32)/32];
sumWidth+=3*32;
var fullWidth=~~(sumWidth*ratio);
var fullHeight=~~(maxHeight*ratio);
drawInitData = function(){
var ratio=1;
var images=core.material.images;
maxHeight=700;
sumWidth=0;
widthsX={};
for(var ii=0;ii<core.images.length;ii++){
var img=core.images[ii];
widthsX[img]=[img,sumWidth/32,(sumWidth+images[img].width)/32];
sumWidth+=images[img].width;
maxHeight=Math.max(maxHeight,images[img].height);
if (fullWidth > data.width) data.style.width = (data.width = fullWidth)/ratio + 'px';
data.style.height = (data.height = fullHeight)/ratio + 'px';
var dc = data.getContext('2d');
var bgc = bg.getContext('2d');
//var colorA = ["#f8f8f8", "#cccccc"];
//var colorIndex = 1;
//在data内画一个13*13的灰白相间的格子
for (var ii = 0; ii < 13; ii++)
for (var jj = 0; jj < 13; jj++) {
//dc.fillStyle = colorA[colorIndex];
//colorIndex = 1 - colorIndex;
//dc.fillRect(ii * 32, jj * 32, 32, 32);
bgc.drawImage(core.material.images['terrains'], 0, 0, 32, 32, ii*32, jj*32, 32, 32);
}
widthsX['autotile']=['autotile',sumWidth/32,(sumWidth+3*32)/32];
sumWidth+=3*32;
var fullWidth=~~(sumWidth*ratio);
var fullHeight=~~(maxHeight*ratio);
var nowx=0;
for(var ii=0;ii<core.images.length;ii++){
var img=core.images[ii];
dc.drawImage(images[img], nowx, 0)
nowx+=images[img].width;
}
dc.drawImage(editor.autotile, nowx, 0)
// data.style.width = (data.width = fullWidth)/ratio + 'px';
data.style.height = (data.height = fullHeight)/ratio + 'px';
callback();
}//editor.widthsX
var dc = data.getContext('2d');
var bgc = bg.getContext('2d');
//var colorA = ["#f8f8f8", "#cccccc"];
//var colorIndex = 1;
//在data内画一个13*13的灰白相间的格子
for (var ii = 0; ii < 13; ii++)
for (var jj = 0; jj < 13; jj++) {
//dc.fillStyle = colorA[colorIndex];
//colorIndex = 1 - colorIndex;
//dc.fillRect(ii * 32, jj * 32, 32, 32);
bgc.drawImage(core.material.images['terrains'], 0, 0, 32, 32, ii*32, jj*32, 32, 32);
}
var nowx=0;
for(var ii=0;ii<core.images.length;ii++){
var img=core.images[ii];
dc.drawImage(images[img], nowx, 0)
nowx+=images[img].width;
}
dc.drawImage(autotile, nowx, 0)
};
editor.prototype.listen = function() {
(function () {
var uc = ui.getContext('2d');
function fillPos(pos) {
@ -679,16 +747,16 @@ importGrass=function(){
}//在格子内画一个随机色块
function eToLoc(e) {
var loc = {
editor.loc = {
'x': document.documentElement.scrollLeft+e.clientX - mid.offsetLeft-mapEdit.offsetLeft,
'y': document.documentElement.scrollTop+e.clientY - mid.offsetTop-mapEdit.offsetTop,
'size': 32
};
return loc; }//返回可用的组件内坐标
return editor.loc; }//返回可用的组件内坐标
function locToPos(loc) {
pos = { 'x': ~~(loc.x / loc.size), 'y': ~~(loc.y / loc.size) }
return pos;
editor.pos = { 'x': ~~(loc.x / loc.size), 'y': ~~(loc.y / loc.size) }
return editor.pos;
}
var holdingPath = 0;
@ -718,7 +786,7 @@ importGrass=function(){
e.stopPropagation();
uc.clearRect(0, 0, 416, 416);
var loc = eToLoc(e);
pos = locToPos(loc)
var pos = locToPos(loc)
stepPostfix = [];
stepPostfix.push(pos);
fillPos(pos);
@ -744,7 +812,7 @@ importGrass=function(){
max = directionDistance[i];
}
}
pos = [{ 'x': 0, 'y': 1 }, { 'x': -1, 'y': 0 }, { 'x': 0, 'y': -1 }, { 'x': 1, 'y': 0 }, false][index]
var pos = [{ 'x': 0, 'y': 1 }, { 'x': -1, 'y': 0 }, { 'x': 0, 'y': -1 }, { 'x': 1, 'y': 0 }, false][index]
if (pos) {
pos.x += pos0.x;
pos.y += pos0.y;
@ -762,16 +830,16 @@ importGrass=function(){
e.stopPropagation();
var loc = eToLoc(e);
if (stepPostfix.length) {
preMapData = JSON.parse(JSON.stringify(map));
preMapData = JSON.parse(JSON.stringify(editor.map));
currDrawData.pos = JSON.parse(JSON.stringify(stepPostfix));
currDrawData.info = JSON.parse(JSON.stringify(info));
currDrawData.info = JSON.parse(JSON.stringify(editor.info));
reDo = null;
// console.log(stepPostfix);
for (var ii = 0; ii < stepPostfix.length; ii++)
map[m(stepPostfix[ii].x, stepPostfix[ii].y)] = info;
map[fullX + 1 + fullY * (fullX + 1)] = -2;
// console.log(map);
updateMap();
editor.map[editor.m(stepPostfix[ii].x, stepPostfix[ii].y)] = editor.info;
editor.map[fullX + 1 + fullY * (fullX + 1)] = -2;
// console.log(editor.map);
editor.updateMap();
holdingPath = 0;
stepPostfix = [];
uc.clearRect(0, 0, 416, 416);
@ -790,38 +858,39 @@ importGrass=function(){
e.preventDefault();
//Ctrl+z 撤销上一步undo
if(e.keyCode == 90 && e.ctrlKey && preMapData && currDrawData.pos.length){
map = JSON.parse(JSON.stringify(preMapData));
updateMap();
editor.map = JSON.parse(JSON.stringify(preMapData));
editor.updateMap();
reDo = JSON.parse(JSON.stringify(currDrawData));
currDrawData = {pos: [],info: {}};
preMapData = null;
}
//Ctrl+y 重做一步redo
if(e.keyCode == 89 && e.ctrlKey && reDo && reDo.pos.length){
preMapData = JSON.parse(JSON.stringify(map));
preMapData = JSON.parse(JSON.stringify(editor.map));
for(var j=0; j<reDo.pos.length;j++)
map[m(reDo.pos[j].x, reDo.pos[j].y)] = JSON.parse(JSON.stringify(reDo.info));
editor.map[editor.m(reDo.pos[j].x, reDo.pos[j].y)] = JSON.parse(JSON.stringify(reDo.info));
map[fullX + 1 + fullY * (fullX + 1)] = -2;
updateMap();
editor.map[fullX + 1 + fullY * (fullX + 1)] = -2;
editor.updateMap();
currDrawData = JSON.parse(JSON.stringify(reDo));
reDo = null;
}
}
// info=ids[indexs[20][0]];//autotile
// info=editor.ids[editor.indexs[20][0]];//autotile
data.onmousedown = function (e) {
e.stopPropagation();
var loc = {
'x': document.documentElement.scrollLeft + e.clientX - right.offsetLeft-iconLib.offsetLeft,
'y': document.documentElement.scrollTop + e.clientY + iconLib.scrollTop - right.offsetTop-iconLib.offsetTop,
'x': document.documentElement.scrollLeft + e.clientX + (iconLib.scrollLeft||0) - right.offsetLeft-iconLib.offsetLeft,
'y': document.documentElement.scrollTop + e.clientY + (iconLib.scrollTop||0) - right.offsetTop-iconLib.offsetTop,
'size': 32
};
pos = locToPos(loc);
for (var spriter in widthsX){
if(pos.x>=widthsX[spriter][1] && pos.x<widthsX[spriter][2]){
pos.x=widthsX[spriter][1];
pos.images=widthsX[spriter][0];
editor.loc =loc;
var pos = locToPos(loc);
for (var spriter in editor.widthsX){
if(pos.x>=editor.widthsX[spriter][1] && pos.x<editor.widthsX[spriter][2]){
pos.x=editor.widthsX[spriter][1];
pos.images=editor.widthsX[spriter][0];
if(pos.images=='autotile'){
pos.y=0;
}else if((pos.y+1)*32>core.material.images[pos.images].height)
@ -831,87 +900,39 @@ importGrass=function(){
// console.log(pos,core.material.images[pos.images].height)
dataSelection.style.left = pos.x*32 +'px';
dataSelection.style.top = pos.y*32 +'px';
info={'images':pos.images,'y':pos.y};
for (var ii=0;ii<ids.length;ii++){
if(pos.images==ids[ii].images && pos.y==ids[ii].y)
info = ids[ii];
editor.info={'images':pos.images,'y':pos.y};
for (var ii=0;ii<editor.ids.length;ii++){
if(pos.images==editor.ids[ii].images && pos.y==editor.ids[ii].y)
editor.info = editor.ids[ii];
}
tip.infos = JSON.parse(JSON.stringify(info));
tip.infos = JSON.parse(JSON.stringify(editor.info));
}
}
}
})();
}//绑定事件
/*
editor.updateMap
现在可以通过editor.updateMap('clearError')把所有错误id置零并绘图
以及editor.updateMap('showError')显示所有错误
editor.loc
editor.pos
editor.info
始终是最后一次点击的结果
注意editor.info可能因为点击其他地方而被清空
*/
var editor = new editor();
editor.init();
</script>
<script type="text/javascript">
//var timecheck=0;
postsomething = function (data,callback) {
//if(timecheck!==0)return;
//timecheck=1;
setTimeout(function(){timecheck=0},5000);
var xhr = function(){
if (window.XMLHttpRequest) {
return new XMLHttpRequest();
}else{
return new ActiveObject('Micrsorf.XMLHttp');
}
}();
xhr.onreadystatechange = function(){
switch(xhr.readyState){
case 0 :
printf('waiting... ','weak');
break;
case 1 :
printf('waiting ...','weak');
break;
case 2 :
printf('waiting... ','weak');
break;
case 3 :
printf('waiting ...','weak');
break;
case 4 :
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304) {
printf(xhr.responseText);
if (Boolean(callback))callback(xhr.responseText);
}else{
printf('error:' + xhr.status+'<br>'+(xhr.responseText||''),'weak');
}
//timecheck=0;
break;
}
}
xhr.open('post','http://127.0.0.1');
xhr.setRequestHeader('Content-Type','text/plain');
if(typeof(data)==typeof([][0]) || data==null)data=JSON.stringify({1:2});
xhr.send(data);
}
function readUTF8file(filename,callback){
data={};
data.name='readUTF8file';
data.func='open';
data.args=[String(filename)];
postsomething(JSON.stringify(data),callback);
}
function writeUTF8file(filename,filestr,callback){
data={};
data.name='writeUTF8file';
data.func='open';
data.args=[String(filename),String(filestr)];
postsomething(JSON.stringify(data),callback);
}
</script>
<script type="text/javascript">
//Vue
//var listenByVue = function() {
document.body.onmousedown = function(e){
selectBox.isSelected = false;
info = {};
editor.info = {};
}
iconLib.onmousedown = function(e){
e.stopPropagation();
@ -921,24 +942,28 @@ importGrass=function(){
methods: {
exportMap: function(){
setTimeout(function(){editor.updateMap();},5000);
if(editArea.error) {
tip.whichShow = 3;
editor.updateMap('showError');
return;
}
var filestr='';
for (var yy = 0; yy < 13; yy++){
filestr+='['
for (var xx = 0; xx < 13; xx++) {
var mapxy=map[m(xx,yy)];
var mapxy=editor.map[editor.m(xx,yy)];
if(typeof(mapxy)==typeof({})){
if ('idnum' in mapxy)mapxy=mapxy.idnum;
else {
// mapxy='!!?';
tip.whichShow = 3;
editor.updateMap('showError');
return;
}
}else if(typeof(mapxy)=='undefined'){
tip.whichShow = 3;
editor.updateMap('showError');
return;
}
mapxy=String(mapxy);
@ -997,17 +1022,17 @@ importGrass=function(){
for(var i=0; i<mapArray.length; i++){
var num = parseInt(mapArray[i]);
if(num == 0 )
map[i] = 0;
editor.map[i] = 0;
else if(num >= 400){
that.error = 3;
map[i] = undefined;
}else if(indexs[num][0] == undefined){
editor.map[i] = undefined;
}else if(editor.indexs[num][0] == undefined){
that.error = 2;
map[i] = undefined;
}else map[i] = ids[[indexs[num][0]]];
editor.map[i] = undefined;
}else editor.map[i] = editor.ids[[editor.indexs[num][0]]];
}
updateMap();
editor.updateMap();
},
formatArr: function(){
@ -1072,8 +1097,8 @@ importGrass=function(){
methods: {
clearMap: function(){
map[fullX + 1 + fullY * (fullX + 1)] = -2;
for(var ii=0;ii<fullX + 1 + fullY * (fullX + 1);ii++)map[ii]=0;
editor.map[fullX + 1 + fullY * (fullX + 1)] = -2;
for(var ii=0;ii<fullX + 1 + fullY * (fullX + 1);ii++)editor.map[ii]=0;
ec = eventLayer.getContext('2d');
ec.clearRect(0, 0, 416, 416);
clearTimeout(editArea.formatTimer);
@ -1088,7 +1113,7 @@ importGrass=function(){
var tip = new Vue({
el: '#tip',
data: {
infos: ids[indexs[20][0]],
infos: {idnum: 20, id: "autotile", images: "autotile", y: 0},//editor.ids[editor.indexs[20][0]],
hasId: true,
isSelectedBlock: false,
geneMapSuccess: false,
@ -1150,6 +1175,11 @@ importGrass=function(){
}
}
})
//}
//listenByVue()
</script>
</body>
</html>

BIN
images/autotile1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
images/autotile2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

BIN
images/autotile3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

BIN
images/lv.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 27 KiB

BIN
images/up.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 863 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

View File

@ -47,10 +47,14 @@
<p id='floorNameLabel'></p>
</div>
<div id='statusBar' class="clearfix">
<div class="status">
<div class="status" id="floorCol">
<img src='images/floor.png' id="img-floor">
<p class='statusLabel' id='floor'></p>
</div>
<div class="status" id="lvCol">
<img src='images/lv.png' id="img-lv">
<p class='statusLabel' id='lv'></p>
</div>
<div class="status">
<img src='images/hp.png' id="img-hp">
<p class='statusLabel' id='hp'></p>
@ -67,7 +71,7 @@
<img src='images/mdef.png' id="img-mdef">
<p class='statusLabel' id='mdef'></p>
</div>
<div class="status">
<div class="status" id="moneyCol">
<img src='images/money.png' id="img-money">
<p class='statusLabel' id='money'></p>
</div>
@ -75,12 +79,16 @@
<img src='images/experience.png' id="img-experience">
<p class='statusLabel' id='experience'></p>
</div>
<div class="status" id="upCol">
<img src='images/up.png' id="img-up">
<p class='statusLabel' id='up'></p>
</div>
<div class="status">
<span class='statusLabel' id='yellowKey' style="color:#FFCCAA"></span>
<span class='statusLabel' id='blueKey' style="color:#AAAADD"></span>
<span class='statusLabel' id='redKey' style="color:#FF8888"></span>
</div>
<div class="status">
<div class="status" id="debuffCol">
<span class='statusLabel' id='poison' style="color: #AFFCA8;"></span>
<span class='statusLabel' id='weak' style="color: #FECCD0;"></span>
<span class='statusLabel' id='curse' style="color: #C2F4E7;"></span>
@ -96,10 +104,11 @@
<img src="images/settings.png" class="tools" id='img-settings'>
<p class="statusLabel tools" id="hard"></p>
</div>
<div id="curtain"></div>
<canvas class='gameCanvas' id='bg' width='416' height='416'></canvas>
<canvas class='gameCanvas' id='event' width='416' height='416'></canvas>
<canvas class='gameCanvas' id='hero' width='416' height='416'></canvas>
<canvas class='gameCanvas' id='fg' width='416' height='416'></canvas>
<canvas class='gameCanvas' id='hero' width='416' height='416'></canvas>
<canvas class='gameCanvas' id='ui' width='416' height='416'></canvas>
<canvas class='gameCanvas' id='data' width='416' height='416'>此浏览器不支持HTML5</canvas>
</div>

File diff suppressed because it is too large Load Diff

View File

@ -10,12 +10,13 @@ data.prototype.init = function() {
"floorId": "sample0", // 初始楼层ID
"hero": { // 勇士初始数据
"name": "阳光", // 勇士名;可以改成喜欢的
'lv': 1, // 初始等级,该项必须为正整数
"hp": 1000, // 初始生命值
"atk": 100, // 初始攻击
"def": 100, // 初始防御
"mdef": 100, // 初始魔防
"money": 100, // 初始金币
"experience": 1000, // 初始经验
"experience": 0, // 初始经验
"items": { // 初始道具个数
"keys": {
"yellowKey": 0,
@ -57,10 +58,11 @@ data.prototype.init = function() {
{"text": "防御+4", "effect": "status:def+=4"},
{"text": "魔防+10", "effect": "status:mdef+=10"}
// effect只能对status和item进行操作不能修改flag值。
// 中间只能用+=符号(也就是只能增加某个属性或道具)
// 必须是X+=Y的形式其中Y可以是一个表达式以status:xxx或item:xxx为参数
// 其他effect样例
// "item:yellowKey+=1" 黄钥匙+1
// "item:pickaxe+=3" 破墙镐+3
// "status:hp+=2*(status:atk+status:def)" 将生命提升攻防和的数值的两倍
]
},
"expShop1": { // 商店唯一ID
@ -73,13 +75,33 @@ data.prototype.init = function() {
"choices": [
// 在choices中写need可以针对每个选项都有不同的需求。
// 这里的need同样可以以times作为参数比如 "need": "100+20*times"
{"text": "等级+1", "need": "100", "effect": "status:hp+=1000;status:atk+=7;status:def+=7"},
{"text": "等级+1", "need": "100", "effect": "status:lv+=1;status:hp+=1000;status:atk+=7;status:def+=7"},
// 多个effect直接以分号分开即可。如上面的意思是生命+1000攻击+7防御+7。
{"text": "攻击+5", "need": "30", "effect": "status:atk+=5"},
{"text": "防御+5", "need": "30", "effect": "status:def+=5"},
]
}
},
},
"levelUp": [ // 经验升级所需要的数值,是一个数组
{}, // 第一项为初始等级可以简单留空也可以写name
// 每一个里面可以含有三个参数 name, need, effect
// need为所需要的经验数值是一个正整数。请确保need所需的依次递增
// name为该等级的名称也可以省略代表使用系统默认值本项将显示在状态栏中
// effect为本次升级所执行的操作可由若干项组成由分号分开
// 其中每一项写法和上面的商店完全相同同样必须是X+=Y的形式Y是一个表达式同样可以使用status:xxx或item:xxx代表勇士的某项数值/道具个数
{"need": 20, "name": "第二级", "effect": "status:hp+=2*(status:atk+status:def);status:atk+=10;status:def+=10"}, // 先将生命提升攻防和的2倍再将攻击+10防御+10
// effect也允许写一个function代表本次升级将会执行的操作
{"need": 40, "effect": function () {
core.drawText("恭喜升级!");
core.status.hero.hp *= 2;
core.status.hero.atk += 100;
core.status.hero.def += 100;
}},
// 依次往下写需要的数值即可
]
}
// 各种数值;一些数值可以在这里设置
this.values = {
@ -118,9 +140,15 @@ data.prototype.init = function() {
// 系统FLAG在游戏运行中中请不要修改它。
this.flags = {
/****** 角色状态相关 ******/
"enableMDef": true, // 是否涉及勇士的魔防值如果此项为false则状态栏不会显示勇士的魔防值
"enableExperience": true, // 是否涉及经验值如果此项为false则状态栏和怪物手册均将不会显示经验值
"enableNegativeDamage": true, // 是否支持负伤害(回血)
"enableFloor": false, // 是否在状态栏显示当前楼层
"enableLv": true, // 是否在状态栏显示当前等级
"enableMDef": true, // 是否在状态栏及战斗界面显示魔防(护盾)
"enableMoney": true, // 是否在状态栏、怪物手册及战斗界面显示金币
"enableExperience": true, // 是否在状态栏、怪物手册及战斗界面显示经验
"enableLevelUp": false, // 是否允许等级提升进阶如果上面enableExperience为false则此项恒视为false
"enableDebuff": true, // 是否涉及毒衰咒如果此项为false则不会在状态栏中显示毒衰咒的debuff
////// 上述的几个开关将直接影响状态栏的显示效果 //////
/****** 道具相关 ******/
"flyNearStair": true, // 是否需要在楼梯边使用传送器
"pickaxeFourDirections": true, // 使用破墙镐是否四个方向都破坏如果false则只破坏面前的墙壁
@ -128,6 +156,8 @@ data.prototype.init = function() {
"bigKeyIsBox": false, // 如果此项为true则视为钥匙盒红黄蓝钥匙+1若为false则视为大黄门钥匙
/****** 系统相关 ******/
"startDirectly": false, // 点击“开始游戏”后是否立刻开始游戏而不显示难度选择界面
"canOpenBattleAnimate": true, // 是否允许用户开启战斗过程如果此项为false则下面两项均强制视为false
"showBattleAnimateConfirm": true, // 是否在游戏开始时提供“是否开启战斗动画”的选项
"battleAnimate": true, // 是否默认显示战斗动画;用户可以手动在菜单栏中开关
"displayEnemyDamage": true, // 是否地图怪物显伤;用户可以手动在菜单栏中开关
"displayExtraDamage": false, // 是否地图高级显伤(领域、夹击等);用户可以手动在菜单栏中开关

View File

@ -5,7 +5,7 @@ function enemys() {
enemys.prototype.init = function () {
// 怪物属性初始化定义:
this.enemys = {
'greenSlime': {'name': '绿头怪', 'hp': 100, 'atk': 120, 'def': 0, 'money': 1, 'experience': 0, 'special': 0},
'greenSlime': {'name': '绿头怪', 'hp': 100, 'atk': 120, 'def': 0, 'money': 1, 'experience': 1, 'special': 0},
'redSlime': {'name': '红头怪', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 0, 'special': 0},
'blackSlime': {'name': '青头怪', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 0, 'special': 0},
'slimelord': {'name': '怪王', 'hp': 100, 'atk': 120, 'def': 0, 'money': 10, 'experience': 0, 'special': 9},
@ -76,7 +76,7 @@ enemys.prototype.getEnemys = function (enemyId) {
}
enemys.prototype.hasSpecial = function (special, test) {
return special!=0 && (special%100 == test || this.hasSpecial(parseInt(special/100), test));
return (special instanceof Array)?special.indexOf(test)>=0:(special!=0&&(special%100==test||this.hasSpecial(parseInt(special/100), test)));
}
enemys.prototype.getSpecialText = function (enemyId) {
@ -131,7 +131,7 @@ enemys.prototype.getCritical = function (monsterId) {
if (this.hasSpecial(monster.special, 3) || this.hasSpecial(monster.special, 10)) return "???";
var last = this.calDamage(core.status.hero.atk, core.status.hero.def, core.status.hero.mdef,
monster.hp, monster.atk, monster.def, monster.special);
if (last == 0) return 0;
if (last <= 0) return 0;
for (var i = core.status.hero.atk + 1; i <= monster.hp + monster.def; i++) {
var damage = this.calDamage(i, core.status.hero.def, core.status.hero.mdef,
@ -147,9 +147,8 @@ enemys.prototype.getCritical = function (monsterId) {
enemys.prototype.getCriticalDamage = function (monsterId) {
var c = this.getCritical(monsterId);
if (c == '???') return '???';
if (c == 0) return 0;
if (c <= 0) return 0;
var monster = core.material.enemys[monsterId];
// if (c<=0) return 0;
var last = this.calDamage(core.status.hero.atk, core.status.hero.def, core.status.hero.mdef,
monster.hp, monster.atk, monster.def, monster.special);
if (last == 999999999) return '???';
@ -202,11 +201,7 @@ enemys.prototype.calDamage = function (hero_atk, hero_def, hero_mdef, mon_hp, mo
var ans = damage + turn * per_damage + (turn + 1) * counterDamage;
ans -= hero_mdef;
// 魔防回血
// return ans;
// 魔防不回血
return ans <= 0 ? 0 : ans;
return core.flags.enableNegativeDamage?ans:Math.max(0, ans);
}
// 获得当前楼层的怪物列表

View File

@ -20,12 +20,11 @@ events.prototype.init = function () {
callback();
},
'changeFloor': function (data, core, callback) {
var heroLoc = null;
if (core.isset(data.event.data.loc)) {
var heroLoc = {};
if (core.isset(data.event.data.loc))
heroLoc = {'x': data.event.data.loc[0], 'y': data.event.data.loc[1]};
if (core.isset(data.event.data.direction))
heroLoc.direction = data.event.data.direction;
}
if (core.isset(data.event.data.direction))
heroLoc.direction = data.event.data.direction;
core.changeFloor(data.event.data.floorId, data.event.data.stair,
heroLoc, data.event.data.time, callback);
},
@ -66,22 +65,43 @@ events.prototype.startGame = function (hard) {
core.hideStartAnimate(function() {
core.drawText(core.clone(core.firstData.startText), function() {
core.startGame(hard);
if (hard=='Easy') { // 简单难度
core.setFlag('hard', 1); // 可以用flag:hard来获得当前难度
// 可以在此设置一些初始福利,比如设置初始生命值可以调用:
// core.setStatus("hp", 10000);
if (core.flags.showBattleAnimateConfirm) { // 是否提供“开启战斗动画”的选择项
core.status.event.selection = core.flags.battleAnimate ? 0 : 1;
core.ui.drawConfirmBox("你想开启战斗动画吗?\n之后可以在菜单栏中开启或关闭。\n强烈建议新手开启此项", function () {
core.flags.battleAnimate = true;
core.setLocalStorage('battleAnimate', true);
core.startGame(hard);
core.events.setInitData(hard);
}, function () {
core.flags.battleAnimate = false;
core.setLocalStorage('battleAnimate', false);
core.startGame(hard);
core.events.setInitData(hard);
});
}
if (hard=='Normal') { // 普通难度
core.setFlag('hard', 2); // 可以用flag:hard来获得当前难度
}
if (hard=='Hard') { // 困难难度
core.setFlag('hard', 3); // 可以用flag:hard来获得当前难度
else {
core.startGame(hard);
core.events.setInitData(hard);
}
});
})
}
////// 简单难度设置初始福利 //////
events.prototype.setInitData = function (hard) {
if (hard=='Easy') { // 简单难度
core.setFlag('hard', 1); // 可以用flag:hard来获得当前难度
// 可以在此设置一些初始福利,比如设置初始生命值可以调用:
// core.setStatus("hp", 10000);
}
if (hard=='Normal') { // 普通难度
core.setFlag('hard', 2); // 可以用flag:hard来获得当前难度
}
if (hard=='Hard') { // 困难难度
core.setFlag('hard', 3); // 可以用flag:hard来获得当前难度
}
}
////// 游戏结束事件 //////
events.prototype.win = function(reason) {
// 获胜
@ -166,6 +186,7 @@ events.prototype.doAction = function() {
case "tip":
core.drawTip(core.replaceText(data.text));
core.events.doAction();
break;
case "show": // 显示
if (core.isset(data.time) && data.time>0 && (!core.isset(data.floorId) || data.floorId==core.status.floorId)) {
core.animateBlock(data.loc[0],data.loc[1],'show', data.time, function () {
@ -308,7 +329,6 @@ events.prototype.doAction = function() {
core.status.hero.hp=0;
core.updateStatusBar();
core.events.lose('damage');
}
else {
core.updateStatusBar();
@ -361,7 +381,7 @@ events.prototype.doAction = function() {
break;
default:
core.status.event.data.type='text';
core.ui.drawTextBox("\t[警告,]出错啦!\n"+data.type+" 事件不被支持...");
core.ui.drawTextBox("\t[警告]出错啦!\n"+data.type+" 事件不被支持...");
}
return;
}
@ -383,9 +403,14 @@ events.prototype.openShop = function(shopId, needVisited) {
}
shop.visited = true;
var selection = core.status.event.selection;
core.ui.closePanel();
core.lockControl();
core.status.event = {'id': 'shop', 'data': {'id': shopId, 'shop': shop}};
// core.status.event = {'id': 'shop', 'data': {'id': shopId, 'shop': shop}};
core.status.event.id = 'shop';
core.status.event.data = {'id': shopId, 'shop': shop};
core.status.event.selection = selection;
// 拼词
var content = "\t["+shop.name+","+shop.icon+"]";
var times = shop.times, need=eval(shop.need);
@ -402,9 +427,9 @@ events.prototype.openShop = function(shopId, needVisited) {
var text = choice.text;
if (core.isset(choice.need))
text += ""+eval(choice.need)+use+""
choices.push({"text": text});
choices.push(text);
}
choices.push({"text": "离开"});
choices.push("离开");
core.ui.drawChoices(content, choices);
}
@ -462,6 +487,7 @@ events.prototype.useItem = function(itemId) {
var fillstyle = 'rgba(255,0,0,0.5)';
if (core.canUseItem('centerFly')) fillstyle = 'rgba(0,255,0,0.5)';
core.fillRect('ui',(12-core.getHeroLoc('x'))*32,(12-core.getHeroLoc('y'))*32,32,32,fillstyle);
core.drawTip("请确认当前中心对称飞行器的位置");
return;
}
@ -602,6 +628,46 @@ events.prototype.afterLoadData = function(data) {
/*********** 界面上的点击事件 ***************/
/******************************************/
events.prototype.keyDownCtrl = function () {
if (core.status.event.id=='text') {
core.drawText();
return;
}
if (core.status.event.id=='action' && core.status.event.data.type=='text') {
this.doAction();
return;
}
}
events.prototype.keyUpConfirmBox = function (keycode) {
if (keycode==37) {
core.status.event.selection=0;
core.ui.drawConfirmBox(core.status.event.ui, core.status.event.data.yes, core.status.event.data.no);
}
if (keycode==39) {
core.status.event.selection=1;
core.ui.drawConfirmBox(core.status.event.ui, core.status.event.data.yes, core.status.event.data.no);
}
if (keycode==13 || keycode==32 || keycode==67) {
if (core.status.event.selection==0 && core.isset(core.status.event.data.yes)) {
core.status.event.selection=null;
core.status.event.data.yes();
}
if (core.status.event.selection==1 && core.isset(core.status.event.data.no)) {
core.status.event.selection=null;
core.status.event.data.no();
}
}
}
events.prototype.clickConfirmBox = function (x,y) {
if ((x == 4 || x == 5) && y == 7 && core.isset(core.status.event.data.yes))
core.status.event.data.yes();
if ((x == 7 || x == 8) && y == 7 && core.isset(core.status.event.data.no))
core.status.event.data.no();
}
// 正在处理事件时的点击操作...
events.prototype.clickAction = function (x,y) {
@ -625,6 +691,42 @@ events.prototype.clickAction = function (x,y) {
}
}
events.prototype.keyDownAction = function (keycode) {
if (core.status.event.data.type=='choices') {
var data = core.status.event.data.current;
var choices = data.choices;
if (choices.length>0) {
if (keycode==38) {
core.status.event.selection--;
if (core.status.event.selection<0) core.status.event.selection=0;
core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices);
}
if (keycode==40) {
core.status.event.selection++;
if (core.status.event.selection>=choices.length) core.status.event.selection=choices.length-1;
core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices);
}
}
}
}
events.prototype.keyUpAction = function (keycode) {
if (core.status.event.data.type=='text' && (keycode==13 || keycode==32 || keycode==67)) {
this.doAction();
return;
}
if (core.status.event.data.type=='choices') {
var data = core.status.event.data.current;
var choices = data.choices;
if (choices.length>0) {
if (keycode==13 || keycode==32 || keycode==67) {
this.insertAction(choices[core.status.event.selection].action);
this.doAction();
}
}
}
}
// 怪物手册
events.prototype.clickBook = function(x,y) {
// 上一页
@ -642,6 +744,19 @@ events.prototype.clickBook = function(x,y) {
return;
}
events.prototype.keyDownBook = function (keycode) {
if (keycode==37 || keycode==38) core.ui.drawEnemyBook(core.status.event.data - 1);
else if (keycode==39 || keycode==40) core.ui.drawEnemyBook(core.status.event.data + 1);
return;
}
events.prototype.keyUpBook = function (keycode) {
if (keycode==27 || keycode==88) {
core.ui.closePanel(true);
return;
}
}
// 飞行器
events.prototype.clickFly = function(x,y) {
if ((x==10 || x==11) && y==9) core.ui.drawFly(core.status.event.data-1);
@ -657,6 +772,20 @@ events.prototype.clickFly = function(x,y) {
return;
}
events.prototype.keyDownFly = function (keycode) {
if (keycode==37 || keycode==38) core.ui.drawFly(core.status.event.data+1);
else if (keycode==39 || keycode==40) core.ui.drawFly(core.status.event.data-1);
return;
}
events.prototype.keyUpFly = function (keycode) {
if (keycode==71 || keycode==27 || keycode==88)
core.ui.closePanel();
if (keycode==13 || keycode==32 || keycode==67)
this.clickFly(5,5);
return;
}
// 商店
events.prototype.clickShop = function(x,y) {
var shop = core.status.event.data.shop;
@ -687,12 +816,7 @@ events.prototype.clickShop = function(x,y) {
// 更新属性
choice.effect.split(";").forEach(function (t) {
if (t.indexOf("status:")==0) {
eval(t.replace("status:", "core.status.hero."));
}
else if (t.indexOf("item:")==0) {
eval(t.replace("item:", "core.getItem('").replace("+=", "', ")+")");
}
core.doEffect(t);
});
core.updateStatusBar();
shop.times++;
@ -709,14 +833,47 @@ events.prototype.clickShop = function(x,y) {
}
}
events.prototype.keyDownShop = function (keycode) {
var shop = core.status.event.data.shop;
var choices = shop.choices;
if (keycode==38) {
core.status.event.selection--;
if (core.status.event.selection<0) core.status.event.selection=0;
core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices);
}
if (keycode==40) {
core.status.event.selection++;
if (core.status.event.selection>choices.length) core.status.event.selection=choices.length;
core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices);
}
}
events.prototype.keyUpShop = function (keycode) {
if (keycode==27 || keycode==88) {
if (core.status.event.data.fromList) {
core.status.boxAnimateObjs = [];
core.setBoxAnimate();
core.ui.drawQuickShop();
}
else
core.ui.closePanel();
return;
}
var shop = core.status.event.data.shop;
var choices = shop.choices;
if (keycode==13 || keycode==32 || keycode==67) {
var topIndex = 6 - parseInt(choices.length / 2);
this.clickShop(6, topIndex+core.status.event.selection);
}
return;
}
// 快捷商店
events.prototype.clickQuickShop = function(x, y) {
var shopList = core.status.shops, keys = Object.keys(shopList);
if (x >= 5 && x <= 7) {
var shopList = core.status.shops, keys = Object.keys(shopList);
var topIndex = 6 - parseInt((keys.length + 1) / 2);
var exitIndex = 6 + parseInt((keys.length + 1) / 2);
if (y >= topIndex && y - topIndex < keys.length) {
var topIndex = 6 - parseInt(keys.length / 2);
if (y>=topIndex && y<topIndex+keys.length) {
var reason = core.events.canUseQuickShop(y-topIndex);
if (core.isset(reason)) {
core.drawText(reason);
@ -726,42 +883,146 @@ events.prototype.clickQuickShop = function(x, y) {
if (core.status.event.id=='shop')
core.status.event.data.fromList = true;
}
if (y == exitIndex) {
// 离开
else if (y==topIndex+keys.length)
core.ui.closePanel();
}
}
}
events.prototype.keyDownQuickShop = function (keycode) {
var shopList = core.status.shops, keys = Object.keys(shopList);
if (keycode==38) {
core.status.event.selection--;
if (core.status.event.selection<0) core.status.event.selection=0;
core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices);
}
if (keycode==40) {
core.status.event.selection++;
if (core.status.event.selection>keys.length) core.status.event.selection=keys.length;
core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices);
}
}
events.prototype.keyUpQuickShop = function (keycode) {
if (keycode==27 || keycode==75 || keycode==88) {
core.ui.closePanel();
return;
}
var shopList = core.status.shops, keys = Object.keys(shopList);
if (keycode==13 || keycode==32 || keycode==67) {
var topIndex = 6 - parseInt(keys.length / 2);
this.clickQuickShop(6, topIndex+core.status.event.selection);
}
return;
}
// 工具栏
events.prototype.clickToolbox = function(x,y) {
// 返回
if (x>=10 && x<=12 && y==12) {
core.ui.closePanel(false);
return;
}
var items = null;
if (y>=4 && y<=7 && x!=12)
items = Object.keys(core.status.hero.items.tools).sort();
if (y>=9 && y<=12 && x!=12)
items = Object.keys(core.status.hero.items.constants).sort();
if (items==null) return;
var index=0;
if (y==4||y==5||y==9||y==10) index=parseInt(x/2);
else index=6+parseInt(x/2);
if (y>=9) index+=100;
this.clickToolboxIndex(index);
}
if (index>=items.length) return;
itemId=items[index];
events.prototype.clickToolboxIndex = function(index) {
var items = null;
var ii=index;
if (ii<100)
items = Object.keys(core.status.hero.items.tools).sort();
else {
ii-=100;
items = Object.keys(core.status.hero.items.constants).sort();
}
if (items==null) return;
if (ii>=items.length) return;
var itemId=items[ii];
if (itemId==core.status.event.data) {
core.events.useItem(itemId);
}
else {
core.ui.drawToolbox(itemId);
core.ui.drawToolbox(index);
}
}
events.prototype.keyDownToolbox = function (keycode) {
if (!core.isset(core.status.event.data)) return;
var tools = Object.keys(core.status.hero.items.tools).sort();
var constants = Object.keys(core.status.hero.items.constants).sort();
var index=core.status.event.selection;
if (keycode==37) { // left
if ((index>0 && index<100) || index>100) {
this.clickToolboxIndex(index-1);
return;
}
if (index==100 && tools.length>0) {
this.clickToolboxIndex(tools.length-1);
return;
}
}
if (keycode==38) { // up
if ((index>5 && index<100) || index>105) {
this.clickToolboxIndex(index-6);
return;
}
if (index>=100 && index<=105) {
if (tools.length>6) {
this.clickToolboxIndex(Math.min(tools.length-1, index-100+6));
}
else if (tools.length>0) {
this.clickToolboxIndex(Math.min(tools.length-1, index-100));
}
return;
}
}
if (keycode==39) { // right
if ((index<tools.length-1) || (index>=100 && index<constants.length+100)) {
this.clickToolboxIndex(index+1);
return;
}
if (index==tools.length-1 && constants.length>0) {
this.clickToolboxIndex(100);
return;
}
}
if (keycode==40) { // down
if (index<=5) {
if (tools.length>6) {
this.clickToolboxIndex(Math.min(tools.length-1, index+6));
}
else if (constants.length>0) {
this.clickToolboxIndex(100+Math.min(constants.length-1, index));
}
return;
}
if (index>5 && index<100 && constants.length>0) {
this.clickToolboxIndex(100+Math.min(constants.length-1, index-6));
return;
}
if (index>=100 && index<=105 && constants.length>6) {
this.clickToolboxIndex(Math.min(100+constants.length-1, index+6));
return;
}
}
}
events.prototype.keyUpToolbox = function (keycode) {
if (keycode==84 || keycode==27 || keycode==88) {
core.ui.closePanel();
return;
}
if (!core.isset(core.status.event.data)) return;
if (keycode==13 || keycode==32 || keycode==67) {
this.clickToolboxIndex(core.status.event.selection);
return;
}
}
@ -769,11 +1030,11 @@ events.prototype.clickToolbox = function(x,y) {
events.prototype.clickSL = function(x,y) {
// 上一页
if ((x == 3 || x == 4) && y == 12) {
core.ui.drawSLPanel(core.status.event.data - 1);
core.ui.drawSLPanel(core.status.event.data - 6);
}
// 下一页
if ((x == 8 || x == 9) && y == 12) {
core.ui.drawSLPanel(core.status.event.data + 1);
core.ui.drawSLPanel(core.status.event.data + 6);
}
// 返回
if (x>=10 && x<=12 && y==12) {
@ -784,7 +1045,8 @@ events.prototype.clickSL = function(x,y) {
return;
}
var index=6*core.status.event.data+1;
var page=parseInt((core.status.event.data-1)/6);
var index=6*page+1;
if (y>=1 && y<=4) {
if (x>=1 && x<=3) core.doSL(index, core.status.event.id);
if (x>=5 && x<=7) core.doSL(index+1, core.status.event.id);
@ -797,78 +1059,274 @@ events.prototype.clickSL = function(x,y) {
}
}
events.prototype.clickSwitchs = function (x,y) {
if (x<5 || x>7) return;
if (y==4) {
if (core.musicStatus.isIOS) {
core.drawTip("iOS设备不支持播放音乐");
return;
}
core.changeSoundStatus();
core.ui.drawSwitchs();
events.prototype.keyDownSL = function(keycode) {
if (keycode==37) { // left
core.ui.drawSLPanel(core.status.event.data - 1);
return;
}
if (y==5) {
core.flags.battleAnimate=!core.flags.battleAnimate;
core.ui.drawSwitchs();
if (keycode==38) { // up
core.ui.drawSLPanel(core.status.event.data - 3);
return;
}
if (y==6) {
core.flags.displayEnemyDamage=!core.flags.displayEnemyDamage;
core.updateFg();
core.ui.drawSwitchs();
if (keycode==39) { // right
core.ui.drawSLPanel(core.status.event.data + 1);
return;
}
if (y==7) {
core.flags.displayExtraDamage=!core.flags.displayExtraDamage;
core.updateFg();
core.ui.drawSwitchs();
if (keycode==40) { // down
core.ui.drawSLPanel(core.status.event.data + 3);
return;
}
if (y==8) {
core.ui.drawSettings(false);
if (keycode==33) { // PAGEUP
core.ui.drawSLPanel(core.status.event.data - 6);
return;
}
if (keycode==34) { // PAGEDOWN
core.ui.drawSLPanel(core.status.event.data + 6);
return;
}
}
events.prototype.keyUpSL = function (keycode) {
if (keycode==27 || keycode==88 || (core.status.event.id == 'save' && keycode==83) || (core.status.event.id == 'load' && keycode==68)) {
core.ui.closePanel();
if (!core.isPlaying()) {
core.showStartAnimate();
}
return;
}
if (keycode==13 || keycode==32 || keycode==67) {
core.doSL(core.status.event.data, core.status.event.id);
return;
}
}
events.prototype.clickSwitchs = function (x,y) {
if (x<5 || x>7) return;
var choices = [
"背景音乐", "战斗动画", "怪物显伤", "领域显伤", "返回主菜单"
];
var topIndex = 6 - parseInt((choices.length - 1) / 2);
if (y>=topIndex && y<topIndex+choices.length) {
var selection = y-topIndex;
switch (selection) {
case 0:
if (core.musicStatus.isIOS) {
core.drawTip("iOS设备不支持播放音乐");
return;
}
core.changeSoundStatus();
core.ui.drawSwitchs();
break;
case 1:
if (!core.flags.canOpenBattleAnimate) {
core.drawTip("本塔不能开启战斗动画!");
}
else {
core.flags.battleAnimate=!core.flags.battleAnimate;
core.setLocalStorage('battleAnimate', core.flags.battleAnimate);
core.ui.drawSwitchs();
}
break;
case 2:
core.flags.displayEnemyDamage=!core.flags.displayEnemyDamage;
core.updateFg();
core.setLocalStorage('enemyDamage', core.flags.displayEnemyDamage);
core.ui.drawSwitchs();
break;
case 3:
core.flags.displayExtraDamage=!core.flags.displayExtraDamage;
core.updateFg();
core.setLocalStorage('extraDamage', core.flags.displayExtraDamage);
core.ui.drawSwitchs();
break;
case 4:
core.status.event.selection=0;
core.ui.drawSettings(false);
break;
}
}
}
events.prototype.keyDownSwitchs = function (keycode) {
var choices = [
"背景音乐", "战斗动画", "怪物显伤", "领域显伤", "返回主菜单"
];
if (keycode==38) {
core.status.event.selection--;
if (core.status.event.selection<0) core.status.event.selection=0;
core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices);
}
if (keycode==40) {
core.status.event.selection++;
if (core.status.event.selection>=choices.length) core.status.event.selection=choices.length-1;
core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices);
}
}
events.prototype.keyUpSwitchs = function (keycode) {
if (keycode==27 || keycode==88) {
core.status.event.selection=0;
core.ui.drawSettings(false);
return;
}
var choices = [
"背景音乐", "战斗动画", "怪物显伤", "领域显伤", "返回主菜单"
];
if (keycode==13 || keycode==32 || keycode==67) {
var topIndex = 6 - parseInt((choices.length - 1) / 2);
this.clickSwitchs(6, topIndex+core.status.event.selection);
}
}
// 菜单栏
events.prototype.clickSettings = function (x,y) {
if (x<5 || x>7) return;
if (y == 3) {
core.ui.drawSwitchs();
var choices = [
"系统设置", "快捷商店", "同步存档", "重新开始", "操作帮助", "关于本塔", "返回游戏"
];
var topIndex = 6 - parseInt((choices.length - 1) / 2);
if (y>=topIndex && y<topIndex+choices.length) {
var selection = y-topIndex;
switch (selection) {
case 0:
core.status.event.selection=0;
core.ui.drawSwitchs();
break;
case 1:
core.status.event.selection=0;
core.ui.drawQuickShop();
break;
case 2:
core.status.event.selection=0;
core.ui.drawSyncSave();
break;
case 3:
core.status.event.selection=1;
core.ui.drawConfirmBox("你确定要重新开始吗?", function () {
core.ui.closePanel();
core.restart();
}, function () {
core.status.event.selection=3;
core.ui.drawSettings(false);
});
break;
case 4:
core.ui.drawHelp();
break;
case 5:
core.ui.drawAbout();
break;
case 6:
core.ui.closePanel();
break;
}
}
if (y==4) {
/*
core.flags.battleAnimate=!core.flags.battleAnimate;
core.setLocalStorage('battleAnimate', core.flags.battleAnimate);
core.ui.drawSettings(false);
*/
this.decreaseHard();
}
if (y == 5) core.ui.drawQuickShop();
// if (y == 5) this.decreaseHard();
if (y == 6) {
core.ui.drawSyncSave();
}
/*
if (y == 6) {
core.ui.drawConfirmBox("你确定要清空所有本地存档吗?", function() {
localStorage.clear();
core.drawText("\t[操作成功]你的本地所有存档已被清空。");
}, function() {
core.ui.drawSettings(false);
})
}
*/
if (y == 7) {
core.ui.drawConfirmBox("你确定要重新开始吗?", function () {
core.ui.closePanel();
core.restart();
}, function () {
core.ui.drawSettings(false);
});
}
if (y==8) {
core.ui.drawAbout();
// core.debug();
}
if (y == 9) core.ui.closePanel();
return;
}
events.prototype.keyDownSettings = function (keycode) {
var choices = [
"系统设置", "快捷商店", "同步存档", "重新开始", "操作帮助", "关于本塔", "返回游戏"
];
if (keycode==38) {
core.status.event.selection--;
if (core.status.event.selection<0) core.status.event.selection=0;
core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices);
}
if (keycode==40) {
core.status.event.selection++;
if (core.status.event.selection>=choices.length) core.status.event.selection=choices.length-1;
core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices);
}
}
events.prototype.keyUpSettings = function (keycode) {
if (keycode==27 || keycode==88) {
core.ui.closePanel();
return;
}
var choices = [
"系统设置", "快捷商店", "同步存档", "重新开始", "操作帮助", "关于本塔", "返回游戏"
];
if (keycode==13 || keycode==32 || keycode==67) {
var topIndex = 6 - parseInt((choices.length - 1) / 2);
this.clickSettings(6, topIndex+core.status.event.selection);
}
}
events.prototype.clickSyncSave = function (x,y) {
if (x<5 || x>7) return;
var choices = [
"同步存档到服务器", "从服务器加载存档", "清空本地存档", "返回主菜单"
];
var topIndex = 6 - parseInt((choices.length - 1) / 2);
if (y>=topIndex && y<topIndex+choices.length) {
var selection = y-topIndex;
switch (selection) {
case 0:
core.syncSave("save");
break;
case 1:
core.syncSave("load");
break;
case 2:
core.status.event.selection=1;
core.ui.drawConfirmBox("你确定要清空所有本地存档吗?", function() {
localStorage.clear();
core.drawText("\t[操作成功]你的本地所有存档已被清空。");
}, function() {
core.status.event.selection=2;
core.ui.drawSyncSave(false);
})
break;
case 3:
core.status.event.selection=2;
core.ui.drawSettings(false);
break;
}
}
return;
}
events.prototype.keyDownSyncSave = function (keycode) {
var choices = [
"同步存档到服务器", "从服务器加载存档", "清空本地存档", "返回主菜单"
];
if (keycode==38) {
core.status.event.selection--;
if (core.status.event.selection<0) core.status.event.selection=0;
core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices);
}
if (keycode==40) {
core.status.event.selection++;
if (core.status.event.selection>=choices.length) core.status.event.selection=choices.length-1;
core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices);
}
}
events.prototype.keyUpSyncSave = function (keycode) {
if (keycode==27 || keycode==88) {
core.status.event.selection=2;
core.ui.drawSettings(false);
return;
}
var choices = [
"同步存档到服务器", "从服务器加载存档", "清空本地存档", "返回主菜单"
];
if (keycode==13 || keycode==32 || keycode==67) {
var topIndex = 6 - parseInt((choices.length - 1) / 2);
this.clickSyncSave(6, topIndex+core.status.event.selection);
}
}
events.prototype.clickAbout = function () {
if (core.isPlaying())
core.ui.closePanel(false);
else
core.showStartAnimate();
}
/*********** 点击事件 END ***************/

View File

@ -4,9 +4,10 @@
main.floors.MT0 = {
"floorId": "MT0", // 楼层唯一标识符,需要和名字完全一致
"title": "主塔 0 层", // 楼层中文名
"name": 0, // 显示在状态栏中的层数
"name": "0", // 显示在状态栏中的层数
"canFlyTo": true, // 该楼能否被楼传器飞到(不能的话在该楼也不允许使用楼传器)
"canUseQuickShop": true, // 该层是否允许使用快捷商店
"defaultGround": "ground", // 默认地面的图块IDterrains中
"map": [ // 地图数据需要是13x13建议使用地图生成器来生成
],

View File

@ -4,9 +4,10 @@
main.floors.sample0 = {
"floorId": "sample0", // 楼层唯一标识符,需要和名字完全一致
"title": "样板 0 层", // 楼层中文名
"name": 0, // 显示在状态栏中的层数
"name": "0", // 显示在状态栏中的层数
"canFlyTo": true, // 该楼能否被楼传器飞到(不能的话在该楼也不允许使用楼传器)
"canUseQuickShop": true, // 该层是否允许使用快捷商店
"defaultGround": "ground", // 默认地面的图块IDterrains中
"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

@ -4,23 +4,24 @@
main.floors.sample1 = {
"floorId": "sample1", // 楼层唯一标识符,需要和名字完全一致
"title": "样板 1 层", // 楼层中文名
"name": 1, // 显示在状态栏中的层数
"name": "1", // 显示在状态栏中的层数
"canFlyTo": true, // 该楼能否被楼传器飞到(不能的话在该楼也不允许使用楼传器)
"canUseQuickShop": true, // 该层是否允许使用快捷商店
"defaultGround": "grass", // 默认地面的图块IDterrains中
"map": [ // 地图数据需要是13x13建议使用地图生成器来生成
[7, 131, 8, 2, 9, 130, 10, 2, 166, 165, 132, 165, 166],
[0, 0, 0, 0, 0, 0, 0, 2, 165, 164, 0, 162, 165],
[2, 2, 2, 2, 121, 2, 2, 2, 0, 0, 229, 0, 0],
[43, 33, 44, 1, 0, 0, 0, 2, 165, 161, 0, 163, 165],
[21, 22, 21, 1, 0, 0, 0, 2, 166, 165, 0, 165, 166],
[1, 245, 1, 1, 0, 87, 0, 2, 2, 2, 85, 2, 2],
[0, 246, 0, 1, 0, 0, 0, 2, 2, 221, 0, 221, 2],
[246, 0, 246, 1, 0, 0, 0, 121, 85, 0, 0, 0, 2],
[1, 246, 1, 1, 0, 2, 2, 2, 2, 2, 2, 2, 2],
[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],
[152, 152, 152, 152, 121, 152, 152, 152, 0, 0, 229, 0, 0],
[43, 33, 44, 151, 0, 0, 0, 152, 165, 161, 0, 163, 165],
[21, 22, 21, 151, 0, 0, 0, 152, 166, 165, 0, 165, 166],
[151, 245, 151, 151, 0, 87, 0, 152, 152, 152, 85, 153, 153],
[0, 246, 0, 151, 0, 0, 0, 152, 152, 221, 0, 221, 153],
[246, 0, 246, 151, 0, 0, 0, 121, 85, 0, 0, 0, 153],
[151, 246, 151, 151, 0, 153, 153, 153, 153, 153, 153, 153, 153],
[0, 0, 0, 0, 0, 0, 0, 164, 0, 0, 163, 0, 0],
[1, 1, 1, 1, 0, 3, 0, 0, 0, 162, 0, 161, 0],
[1, 0, 123, 1, 0, 3, 124, 0, 121, 0, 122, 0, 126],
[1, 0, 0, 1, 88, 3, 86, 0, 0, 0, 0, 0, 0],
[1, 1, 1, 1, 0, 20, 0, 0, 0, 162, 0, 161, 0],
[1, 0, 123, 1, 0, 20, 124, 0, 121, 0, 122, 0, 126],
[1, 0, 0, 1, 88, 20, 86, 0, 0, 0, 0, 0, 0],
],
"firstArrive": [ // 第一次到该楼层触发的事件
@ -272,7 +273,7 @@ main.floors.sample1 = {
},
"changeFloor": { // 楼层转换事件该事件不能和上面的events有冲突同位置点否则会被覆盖
"4,12": {"floorId": "sample0", "loc": [6,0]}, // 由于楼下有多个上楼梯,所以需指定位置而不是简单地写"stair": "upFloor"
"5,5": {"floorId": "sample2", "stair": "downFloor"}
"5,5": {"floorId": "sample2", "stair": "downFloor", "direction": "up"}
},
"afterBattle": { // 战斗后可能触发的事件列表
"9,6": [ // 初级卫兵1

View File

@ -4,9 +4,10 @@
main.floors.sample2 = {
"floorId": "sample2", // 楼层唯一标识符,需要和名字完全一致
"title": "主塔 40 层", // 楼层中文名
"name": 40, // 显示在状态栏中的层数
"name": "40", // 显示在状态栏中的层数
"canFlyTo": false, // 该楼能否被楼传器飞到(不能的话在该楼也不允许使用楼传器)
"canUseQuickShop": true, // 该层是否允许使用快捷商店
"defaultGround": "snowGround", // 默认地面的图块IDterrains中
"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],

45
libs/floors/test.js Normal file
View File

@ -0,0 +1,45 @@
// 这里需要改楼层名请和文件名及下面的floorId保持完全一致
// 楼层唯一标识符仅能由字母、数字、下划线组成,且不能由数字开头
// 推荐用法第20层就用MT20第38层就用MT38地下6层就用MT_6用下划线代替负号隐藏3层用MT3hh表示隐藏等等
main.floors.test = {
"floorId": "test", // 楼层唯一标识符,需要和名字完全一致
"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

@ -12,30 +12,46 @@ icons.prototype.init = function () {
},
'terrains': {
'ground': 0,
'yellowWall': 1,
'whiteWall': 2,
'blueWall': 3,
'star': 4,
'lava': 5,
'ice': 6,
'downFloor': 7,
'upFloor': 8,
'yellowDoor': 9,
'blueDoor': 10,
'redDoor': 11,
'greenDoor': 12,
'specialDoor': 13,
'steelDoor': 14,
'blueShop-left': 15,
'blueShop-right': 16,
'pinkShop-left': 17,
'pinkShop-right': 18,
'arrowUp': 19,
'arrowDown': 20,
'arrowLeft': 21,
'arrowRight': 22,
'light': 23,
'darkLight': 24
'grass': 1,
'grass2': 2,
'snowGround': 3,
'ground2': 4,
'ground3': 5,
'ground4': 6,
'sand': 7,
'ground5': 8,
'yellowWall2': 9,
'whiteWall2': 10,
'blueWall2': 11,
'blockWall': 12,
'grayWall': 13,
'white': 14,
'ground6': 15,
'soil': 16,
'yellowWall': 17,
'whiteWall': 18,
'blueWall': 19,
'star': 20,
'lava': 21,
'ice': 22,
'downFloor': 23,
'upFloor': 24,
'yellowDoor': 25,
'blueDoor': 26,
'redDoor': 27,
'greenDoor': 28,
'specialDoor': 29,
'steelDoor': 30,
'blueShop-left': 31,
'blueShop-right': 32,
'pinkShop-left': 33,
'pinkShop-right': 34,
'arrowUp': 35,
'arrowDown': 36,
'arrowLeft': 37,
'arrowRight': 38,
'light': 39,
'darkLight': 40
},
'animates': {
'star': 0,
@ -193,6 +209,12 @@ icons.prototype.init = function () {
'moneyPocket': 46,
'shoes': 47,
'hammer': 48
},
'autotile': { // 所有的Autotile列表后面的index简单取0即可
'autotile': 0,
'autotile1': 0,
'autotile2': 0,
'autotile3': 0,
}
}
}

View File

@ -34,7 +34,7 @@ maps.prototype.loadFloor = function (floorId, map) {
}
}
}
this.addEvent(block,j,i,floor.events[j+","+i])
this.addEvent(block,j,i,floor.events[j+","+i],floor.defaultGround || "ground")
this.addChangeFloor(block,j,i,floor.changeFloor[j+","+i]);
if (core.isset(block.event)) blocks.push(block);
}
@ -61,6 +61,8 @@ maps.prototype.getBlock = function (x, y, id) {
var tmp = {'x': x, 'y': y, 'id': id};
if (enable!=null) tmp.enable = enable;
////////////////////////// 地形部分 //////////////////////////
// 0-20 地形
if (id == 1) tmp.event = {'cls': 'terrains', 'id': 'yellowWall'}; // 黄墙
if (id == 2) tmp.event = {'cls': 'terrains', 'id': 'whiteWall'}; // 白墙
@ -77,9 +79,18 @@ maps.prototype.getBlock = function (x, y, id) {
if (id == 13) tmp.event = {'cls': 'animates', 'id': 'weakNet', 'noPass': false, 'trigger': 'passNet'}; // 衰网
if (id == 14) tmp.event = {'cls': 'animates', 'id': 'curseNet', 'noPass': false, 'trigger': 'passNet'}; // 咒网
if (id == 15) tmp.event = {'cls': 'animates', 'id': 'water', 'noPass': true}; // 水
// 在这里添加更多地形
// 如果空地不足可以从180以后开始继续放只要不和现有的数字冲突即可
// autotile: 20
// Autotile
if (id == 20) tmp.event = {'cls': 'autotile', 'id': 'autotile', 'noPass': true}; // autotile
// 更多的autotile从151到160只要不和现有的数字冲突即可
if (id == 151) tmp.event = {'cls': 'autotile', 'id': 'autotile1', 'noPass': true};
if (id == 152) tmp.event = {'cls': 'autotile', 'id': 'autotile2', 'noPass': true};
if (id == 153) tmp.event = {'cls': 'autotile', 'id': 'autotile3', 'noPass': true};
////////////////////////// 物品部分 //////////////////////////
// 21-80 物品
if (id == 21) tmp.event = {'cls': 'items', 'id': 'yellowKey'}; // 黄钥匙
@ -128,6 +139,9 @@ maps.prototype.getBlock = function (x, y, id) {
if (id == 64) tmp.event = {'cls': 'items', 'id': 'shoes'} // 绿鞋
if (id == 65) tmp.event = {'cls': 'items', 'id': 'hammer'} // 圣锤
////////////////////////// 门、楼梯、传送点部分 //////////////////////////
// 81-100 门
if (id == 81) tmp.event = {'cls': 'terrains', 'id': 'yellowDoor', 'trigger': 'openDoor'}; // 黄门
if (id == 82) tmp.event = {'cls': 'terrains', 'id': 'blueDoor', 'trigger': 'openDoor'}; // 蓝门
@ -145,6 +159,8 @@ maps.prototype.getBlock = function (x, y, id) {
if (id == 94) tmp.event = {'cls': 'animates', 'id': 'rightPortal', 'noPass': false}; // 右箭头
////////////////////////// NPC部分 //////////////////////////
// 121-150 NPC
if (id == 121) tmp.event = {'cls': 'npcs', 'id': 'man'};
if (id == 122) tmp.event = {'cls': 'npcs', 'id': 'woman'};
@ -159,6 +175,8 @@ maps.prototype.getBlock = function (x, y, id) {
if (id == 131) tmp.event = {'cls': 'npcs', 'id': 'blueShop'};
if (id == 132) tmp.event = {'cls': 'npcs', 'id': 'princess'};
////////////////////////// 其他部分 //////////////////////////
// 161-200 其他(单向箭头、灯、箱子等等)
if (id == 161) tmp.event = {'cls': 'terrains', 'id': 'arrowUp', 'noPass': false}; // 单向上箭头
if (id == 162) tmp.event = {'cls': 'terrains', 'id': 'arrowDown', 'noPass': false}; // 单向下箭头
@ -167,6 +185,9 @@ maps.prototype.getBlock = function (x, y, id) {
if (id == 165) tmp.event = {'cls': 'terrains', 'id': 'light', 'trigger': 'changeLight', 'noPass': false}; // 灯
if (id == 166) tmp.event = {'cls': 'terrains', 'id': 'darkLight', 'noPass': true}; // 暗灯
////////////////////////// 怪物部分 //////////////////////////
// 201-300 怪物
if (id == 201) tmp.event = {'cls': 'enemys', 'id': 'greenSlime'};
if (id == 202) tmp.event = {'cls': 'enemys', 'id': 'redSlime'};
@ -229,13 +250,16 @@ maps.prototype.getBlock = function (x, y, id) {
if (id == 259) tmp.event = {'cls': 'enemys', 'id': 'darkFairy'};
if (id == 260) tmp.event = {'cls': 'enemys', 'id': 'greenKnight'};
////////////////////////// 待定... //////////////////////////
// 目前ID暂时不要超过400
return tmp;
}
maps.prototype.addEvent = function (block, x, y, event) {
maps.prototype.addEvent = function (block, x, y, event, ground) {
if (!core.isset(event)) return;
if (!core.isset(block.event)) { // 本身是空地?
block.event = {'cls': 'terrains', 'id': 'ground', 'noPass': false};
block.event = {'cls': 'terrains', 'id': ground, 'noPass': false};
}
// event是字符串或数组
if (typeof event == "string") {
@ -267,9 +291,9 @@ maps.prototype.addEvent = function (block, x, y, event) {
}
}
maps.prototype.addChangeFloor = function (block, x, y, event) {
maps.prototype.addChangeFloor = function (block, x, y, event, ground) {
if (!core.isset(event)) return;
this.addEvent(block, x, y, {"trigger": "changeFloor", "data": event});
this.addEvent(block, x, y, {"trigger": "changeFloor", "data": event}, ground);
}
maps.prototype.initMaps = function (floorIds) {

View File

@ -26,6 +26,8 @@ ui.prototype.closePanel = function (clearData) {
core.unLockControl();
core.status.event.data = null;
core.status.event.id = null;
core.status.event.selection = null;
core.status.event.ui = null;
}
@ -144,6 +146,8 @@ ui.prototype.drawChoices = function(content, choices) {
core.setAlpha('ui', 1);
core.setFillStyle('ui', background);
core.status.event.ui = {"text": content, "choices": choices};
// Step 1: 计算长宽高
var length = choices.length;
var left=85, width = 416-2*left; // 宽度
@ -258,10 +262,15 @@ ui.prototype.drawChoices = function(content, choices) {
// 选项
core.canvas.ui.textAlign = "center";
for (var i = 0; i < choices.length; i++) {
core.fillText('ui', core.replaceText(choices[i].text), 208, choice_top + 32 * i, "#FFFFFF", "bold 17px Verdana");
core.fillText('ui', core.replaceText(choices[i].text || choices[i]), 208, choice_top + 32 * i, "#FFFFFF", "bold 17px Verdana");
}
if (choices.length>0) {
if (!core.isset(core.status.event.selection)) core.status.event.selection=0;
var len = core.canvas.ui.measureText(core.replaceText(choices[core.status.event.selection].text || choices[core.status.event.selection])).width;
core.strokeRect('ui', 208-len/2-5, choice_top + 32 * core.status.event.selection - 20, len+10, 28, "#FFD700", 2);
}
return;
}
/**
@ -271,8 +280,13 @@ ui.prototype.drawChoices = function(content, choices) {
* @param noCallback
*/
ui.prototype.drawConfirmBox = function (text, yesCallback, noCallback) {
core.lockControl();
core.status.event.id = 'confirmBox';
core.status.event.data = {'yes': yesCallback, 'no': noCallback};
core.status.event.ui = text;
if (!core.isset(core.status.event.selection)) core.status.event.selection=1;
var background = core.canvas.ui.createPattern(core.material.ground, "repeat");
core.clearMap('ui', 0, 0, 416, 416);
@ -291,8 +305,10 @@ ui.prototype.drawConfirmBox = function (text, yesCallback, noCallback) {
var top = 140 - (lines-1)*30;
var right = 416 - 2 * left, bottom = 416 - 140 - top;
core.fillRect('ui', left, top, right, bottom, background);
core.strokeRect('ui', left - 1, top - 1, right + 1, bottom + 1, '#FFFFFF', 2);
if (core.isPlaying())
core.fillRect('ui', left, top, right, bottom, background);
if (core.isPlaying())
core.strokeRect('ui', left - 1, top - 1, right + 1, bottom + 1, '#FFFFFF', 2);
core.canvas.ui.textAlign = "center";
for (var i in contents) {
core.fillText('ui', contents[i], 208, top + 50 + i*30, "#FFFFFF");
@ -300,6 +316,15 @@ ui.prototype.drawConfirmBox = function (text, yesCallback, noCallback) {
core.fillText('ui', "确定", 208 - 38, top + bottom - 35, "#FFFFFF", "bold 17px Verdana");
core.fillText('ui', "取消", 208 + 38, top + bottom - 35);
var len=core.canvas.ui.measureText("确定").width;
if (core.status.event.selection==0) {
core.strokeRect('ui', 208-38-len/2-5, top+bottom-35-20, len+10, 28, "#FFD700", 2);
}
if (core.status.event.selection==1) {
core.strokeRect('ui', 208+38-len/2-5, top+bottom-35-20, len+10, 28, "#FFD700", 2);
}
}
////// 绘制开关界面 //////
@ -308,22 +333,15 @@ ui.prototype.drawSwitchs = function() {
core.status.event.id = 'switchs';
var background = core.canvas.ui.createPattern(core.material.ground, "repeat");
core.clearMap('ui', 0, 0, 416, 416);
core.setAlpha('ui', 1);
core.setFillStyle('ui', background);
var left = 97, top = 64 + 32, right = 416 - 2 * left, bottom = 416 - 2 * top;
core.fillRect('ui', left, top, right, bottom, background);
core.strokeRect('ui', left - 1, top - 1, right + 1, bottom + 1, '#FFFFFF', 2);
var choices = [
"背景音乐:"+(core.musicStatus.soundStatus ? "[ON]" : "[OFF]"),
"战斗动画: " + (core.flags.battleAnimate ? "[ON]" : "[OFF]"),
"怪物显伤: " + (core.flags.displayEnemyDamage ? "[ON]" : "[OFF]"),
"领域显伤: " + (core.flags.displayExtraDamage ? "[ON]" : "[OFF]"),
"返回主菜单"
];
this.drawChoices(null, choices);
core.canvas.ui.textAlign = "center";
core.fillText('ui', "背景音乐: " + (core.musicStatus.soundStatus ? "[ON]" : "[OFF]"), 208, top + 56, "#FFFFFF", "bold 17px Verdana");
// core.fillText('ui', "背景音效" + (core.musicStatus.soundStatus ? "[ON]" : "[OFF]"), 208, top + 88, "#FFFFFF", "bold 17px Verdana")
core.fillText('ui', "战斗动画: " + (core.flags.battleAnimate ? "[ON]" : "[OFF]"), 208, top + 88, "#FFFFFF", "bold 17px Verdana")
core.fillText('ui', "怪物显伤: " + (core.flags.displayEnemyDamage ? "[ON]" : "[OFF]"), 208, top + 120, "#FFFFFF", "bold 17px Verdana")
core.fillText('ui', "领域显伤: " + (core.flags.displayExtraDamage ? "[ON]" : "[OFF]"), 208, top + 152, "#FFFFFF", "bold 17px Verdana")
core.fillText('ui', "返回上级菜单", 208, top + 184, "#FFFFFF", "bold 17px Verdana");
}
/**
@ -334,57 +352,28 @@ ui.prototype.drawSettings = function (need) {
if (!core.checkStatus('settings', need))
return;
var background = core.canvas.ui.createPattern(core.material.ground, "repeat");
core.clearMap('ui', 0, 0, 416, 416);
core.setAlpha('ui', 1);
core.setFillStyle('ui', background);
var left = 97, top = 64, right = 416 - 2 * left, bottom = 416 - 2 * top;
core.fillRect('ui', left, top, right, bottom, background);
core.strokeRect('ui', left - 1, top - 1, right + 1, bottom + 1, '#FFFFFF', 2);
core.canvas.ui.textAlign = "center";
core.fillText('ui', "系统设置", 208, top + 56, "#FFFFFF", "bold 17px Verdana");
core.fillText('ui', "降低难度", 208, top + 88, "#FFFFFF", "bold 17px Verdana")
core.fillText('ui', "快捷商店", 208, top + 120, "#FFFFFF", "bold 17px Verdana");
core.fillText('ui', "同步存档", 208, top + 152, "#FFFFFF", "bold 17px Verdana");
// core.fillText('ui', "清空存档", 208, top + 152, "#FFFFFF", "bold 17px Verdana");
core.fillText('ui', "重新开始", 208, top + 184, "#FFFFFF", "bold 17px Verdana");
core.fillText('ui', "关于本塔", 208, top + 216, "#FFFFFF", "bold 17px Verdana");
core.fillText('ui', "返回游戏", 208, top + 248, "#FFFFFF", "bold 17px Verdana");
this.drawChoices(null, [
"系统设置", "快捷商店", "同步存档", "重新开始", "操作帮助", "关于本塔", "返回游戏"
]);
}
/**
* 绘制选择商店窗口
* @param need
*/
ui.prototype.drawQuickShop = function (need) {
if (core.isset(need) && !core.checkStatus('selectShop', need))
return;
core.status.event.id = 'selectShop';
var background = core.canvas.ui.createPattern(core.material.ground, "repeat");
core.clearMap('ui', 0, 0, 416, 416);
core.setAlpha('ui', 1);
core.setFillStyle('ui', background);
var shopList = core.status.shops, keys = Object.keys(shopList);
var len = keys.length + 1;
if (len % 2 == 0) len++;
var left = 97, top = 208 - 32 - 16 * len, right = 416 - 2 * left, bottom = 416 - 2 * top;
core.fillRect('ui', left, top, right, bottom, background);
core.strokeRect('ui', left - 1, top - 1, right + 1, bottom + 1, '#FFFFFF', 2);
core.canvas.ui.textAlign = "center";
for (var i = 0; i < keys.length; i++) {
core.fillText('ui', shopList[keys[i]].textInList, 208, top + 56 + 32 * i, "#FFFFFF", "bold 17px Verdana");
var choices = [];
for (var i=0;i<keys.length;i++) {
choices.push(shopList[keys[i]].textInList);
}
core.fillText('ui', "返回游戏", 208, top + bottom - 40, "#FFFFFF", "bold 17px Verdana");
choices.push("返回游戏");
this.drawChoices(null, choices);
}
ui.prototype.drawBattleAnimate = function(monsterId, callback) {
// UI层
@ -441,7 +430,10 @@ ui.prototype.drawBattleAnimate = function(monsterId, callback) {
var left=10, right=416-2*left;
var lines = core.flags.enableExperience?5:4;
// var lines = core.flags.enableExperience?5:4;
var lines = 3;
if (core.flags.enableMDef || core.flags.enableMoney || core.flags.enableExperience) lines=4;
if (core.flags.enableMoney && core.flags.enableExperience) lines=5;
var lineHeight = 60;
var height = lineHeight * lines + 50;
@ -454,6 +446,8 @@ ui.prototype.drawBattleAnimate = function(monsterId, callback) {
core.setAlpha('ui', 1);
core.strokeRect('ui', left - 1, top - 1, right + 1, bottom + 1, '#FFFFFF', 2);
core.clearMap('data',0,0,416,416);
clearInterval(core.interval.tipAnimate);
core.setAlpha('data', 1);
core.setOpacity('data', 1);
core.status.boxAnimateObjs = [];
@ -524,7 +518,7 @@ ui.prototype.drawBattleAnimate = function(monsterId, callback) {
if (core.flags.enableMDef) {
textTop += lineHeight;
core.canvas.ui.textAlign='left';
core.fillText('ui', "魔防", left_start, textTop, '#DDDDDD', '16px Verdana');
core.fillText('ui', "护盾", left_start, textTop, '#DDDDDD', '16px Verdana');
core.drawLine('ui', left_start, textTop + 8, left_end, textTop + 8, '#FFFFFF', 2);
core.canvas.data.textAlign='right';
core.fillText('data', hero_mdef, left_end, textTop+26, '#DDDDDD', 'bold 16px Verdana');
@ -552,12 +546,14 @@ ui.prototype.drawBattleAnimate = function(monsterId, callback) {
core.canvas.ui.textAlign='left';
core.fillText('ui', mon_def, right_start, textTop+26, '#DDDDDD', 'bold 16px Verdana');
textTop += lineHeight;
core.canvas.ui.textAlign='right';
core.fillText('ui', "金币", right_end, textTop, '#DDDDDD', '16px Verdana');
core.drawLine('ui', right_start, textTop + 8, right_end, textTop + 8, '#FFFFFF', 2);
core.canvas.ui.textAlign='left';
core.fillText('ui', mon_money, right_start, textTop+26, '#DDDDDD', 'bold 16px Verdana');
if (core.flags.enableMoney) {
textTop += lineHeight;
core.canvas.ui.textAlign = 'right';
core.fillText('ui', "金币", right_end, textTop, '#DDDDDD', '16px Verdana');
core.drawLine('ui', right_start, textTop + 8, right_end, textTop + 8, '#FFFFFF', 2);
core.canvas.ui.textAlign = 'left';
core.fillText('ui', mon_money, right_start, textTop + 26, '#DDDDDD', 'bold 16px Verdana');
}
if (core.flags.enableExperience) {
textTop += lineHeight;
@ -573,12 +569,6 @@ ui.prototype.drawBattleAnimate = function(monsterId, callback) {
core.canvas.ui.textAlign='right';
core.fillText("ui", "S", right_start-8, 208+15, "#FFFFFF", "italic bold 40px Verdana");
/*
core.drawLine('data', left + right - margin - boxWidth + 6, top+margin+boxWidth-6,
left+right-margin-6, top+margin+6, '#FF0000', 4);
core.drawLine('data', left + margin + 6, top+margin+heroHeight+(boxWidth-32)-6,
left+margin+boxWidth-6, top+margin+6, '#FF0000', 4);
*/
var battleInterval = setInterval(function() {
core.playSound("attack", "ogg");
@ -603,8 +593,7 @@ ui.prototype.drawBattleAnimate = function(monsterId, callback) {
// 反击
if (core.enemys.hasSpecial(mon_special, 8)) {
var counterDamage = parseInt(core.values.counterAttack * hero_atk);
hero_mdef -= counterDamage;
hero_mdef -= parseInt(core.values.counterAttack * hero_atk);
if (hero_mdef<0) {
hero_hp+=hero_mdef;
@ -702,20 +691,11 @@ ui.prototype.drawWaiting = function(text) {
ui.prototype.drawSyncSave = function () {
core.status.event.id = 'syncSave';
var background = core.canvas.ui.createPattern(core.material.ground, "repeat");
core.clearMap('ui', 0, 0, 416, 416);
core.setAlpha('ui', 1);
core.setFillStyle('ui', background);
var left = 97, top = 208 - 32 - 16 * 3, right = 416 - 2 * left, bottom = 416 - 2 * top + 32;
core.fillRect('ui', left, top, right, bottom, background);
core.strokeRect('ui', left - 1, top - 1, right + 1, bottom + 1, '#FFFFFF', 2);
this.drawChoices(null, [
"同步存档到服务器", "从服务器加载存档", "清空本地存档", "返回主菜单"
]);
core.canvas.ui.textAlign = "center";
core.fillText('ui', "同步存档到服务器", 208, top + 56, "#FFFFFF", "bold 17px Verdana");
core.fillText('ui', "从服务器加载存档", 208, top + 56 + 32, "#FFFFFF", "bold 17px Verdana");
core.fillText('ui', "清空本地存档", 208, top + 56 + 64, "#FFFFFF", "bold 17px Verdana");
core.fillText('ui', "返回游戏", 208, top + bottom - 40);
}
/**
@ -816,25 +796,34 @@ ui.prototype.drawEnemyBook = function (page) {
core.fillText('ui', enemy.atk, 285, 62 * i + 32, '#DDDDDD', 'bold 13px Verdana');
core.fillText('ui', '防御', 335, 62 * i + 32, '#DDDDDD', '13px Verdana');
core.fillText('ui', enemy.def, 365, 62 * i + 32, '#DDDDDD', 'bold 13px Verdana');
core.fillText('ui', '金币', 165, 62 * i + 50, '#DDDDDD', '13px Verdana');
core.fillText('ui', enemy.money, 195, 62 * i + 50, '#DDDDDD', 'bold 13px Verdana');
var damage_offset = 326;
var expOffset = 165;
if (core.flags.enableMoney) {
core.fillText('ui', '金币', 165, 62 * i + 50, '#DDDDDD', '13px Verdana');
core.fillText('ui', enemy.money, 195, 62 * i + 50, '#DDDDDD', 'bold 13px Verdana');
expOffset = 255;
}
if (core.flags.enableExperience) {
core.canvas.ui.textAlign = "left";
core.fillText('ui', '经验', 255, 62 * i + 50, '#DDDDDD', '13px Verdana');
core.fillText('ui', enemy.experience, 285, 62 * i + 50, '#DDDDDD', 'bold 13px Verdana');
damage_offset = 361;
core.fillText('ui', '经验', expOffset, 62 * i + 50, '#DDDDDD', '13px Verdana');
core.fillText('ui', enemy.experience, expOffset + 30, 62 * i + 50, '#DDDDDD', 'bold 13px Verdana');
}
var damageOffet = 281;
if (core.flags.enableMoney && core.flags.enableExperience)
damageOffet = 361;
else if (core.flags.enableMoney || core.flags.enableExperience)
damageOffet = 326;
core.canvas.ui.textAlign = "center";
var damage = enemy.damage;
var color = '#FFFF00';
if (damage >= core.status.hero.hp) color = '#FF0000';
if (damage == 0) color = '#00FF00';
if (damage <= 0) color = '#00FF00';
if (damage >= 999999999) damage = '无法战斗';
var length = core.canvas.ui.measureText(damage).width;
core.fillText('ui', damage, damage_offset, 62 * i + 50, color, 'bold 13px Verdana');
core.fillText('ui', damage, damageOffet, 62 * i + 50, color, 'bold 13px Verdana');
core.canvas.ui.textAlign = "left";
@ -876,17 +865,29 @@ ui.prototype.drawFly = function(page) {
if (page>0)
core.fillText('ui', '▼', 356, 247+64, '#FFFFFF', "17px Verdana");
core.strokeRect('ui', 20, 100, 273, 273, '#FFFFFF', 2);
this.drawThumbnail('ui', core.status.maps[floorId].blocks, 20, 100, 273);
this.drawThumbnail(floorId, 'ui', core.status.maps[floorId].blocks, 20, 100, 273);
}
/**
* 绘制工具栏
* @param selectId
*/
ui.prototype.drawToolbox = function(selectId) {
ui.prototype.drawToolbox = function(index) {
if (!core.hasItem(selectId))
selectId=null;
var tools = Object.keys(core.status.hero.items.tools).sort();
var constants = Object.keys(core.status.hero.items.constants).sort();
if (!core.isset(index)) {
if (tools.length>0) index=0;
else if (constants.length>0) index=100;
else index=0;
}
core.status.event.selection=index;
var selectId;
if (index<100)
selectId = tools[index];
else
selectId = constants[index-100];
if (!core.hasItem(selectId)) selectId=null;
core.status.event.data=selectId;
core.clearMap('ui', 0, 0, 416, 416);
@ -937,7 +938,7 @@ ui.prototype.drawToolbox = function(selectId) {
core.canvas.ui.textAlign = 'right';
var images = core.material.images.items;
// 消耗道具
var tools = Object.keys(core.status.hero.items.tools).sort();
for (var i=0;i<tools.length;i++) {
var tool=tools[i];
var icon=core.material.icons.items[tool];
@ -959,7 +960,7 @@ ui.prototype.drawToolbox = function(selectId) {
}
// 永久道具
var constants = Object.keys(core.status.hero.items.constants).sort();
for (var i=0;i<constants.length;i++) {
var constant=constants[i];
var icon=core.material.icons.items[constant];
@ -981,16 +982,18 @@ ui.prototype.drawToolbox = function(selectId) {
core.fillText('ui', '返回游戏', 370, 403,'#DDDDDD', 'bold 15px Verdana');
}
/**
* 绘制存档读档
* @param page
*/
ui.prototype.drawSLPanel = function(page) {
if (page<0) page=0;
if (page>=30) page=29;
core.status.event.data = page;
core.status.savePage = page;
ui.prototype.drawSLPanel = function(index) {
if (!core.isset(index)) index=1;
if (index<=0) index=1;
if (index>180) index=180;
core.status.event.data=index;
var page=parseInt((index-1)/6);
// core.status.event.data = page;
// core.status.savePage = page;
core.clearMap('ui', 0, 0, 416, 416);
core.setAlpha('ui', 0.85);
@ -1007,9 +1010,9 @@ ui.prototype.drawSLPanel = function(page) {
if (i<3) {
core.fillText('ui', name+id, (2*i+1)*u, 35, '#FFFFFF', "bold 17px Verdana");
core.strokeRect('ui', (2*i+1)*u-size/2, 50, size, size, '#FFFFFF', 2);
core.strokeRect('ui', (2*i+1)*u-size/2, 50, size, size, id==index?'#FFD700':'#FFFFFF', id==index?6:2);
if (core.isset(data) && core.isset(data.floorId)) {
this.drawThumbnail('ui', core.maps.load(data.maps, data.floorId).blocks, (2*i+1)*u-size/2, 50, size, data.hero.loc);
this.drawThumbnail(data.floorId, 'ui', core.maps.load(data.maps, data.floorId).blocks, (2*i+1)*u-size/2, 50, size, data.hero.loc);
core.fillText('ui', core.formatDate(new Date(data.time)), (2*i+1)*u, 65+size, '#FFFFFF', '10px Verdana');
}
else {
@ -1019,9 +1022,9 @@ ui.prototype.drawSLPanel = function(page) {
}
else {
core.fillText('ui', name+id, (2*i-5)*u, 230, '#FFFFFF', "bold 17px Verdana");
core.strokeRect('ui', (2*i-5)*u-size/2, 245, size, size, '#FFFFFF', 2);
core.strokeRect('ui', (2*i-5)*u-size/2, 245, size, size, id==index?'#FFD700':'#FFFFFF', id==index?6:2);
if (core.isset(data) && core.isset(data.floorId)) {
this.drawThumbnail('ui', core.maps.load(data.maps, data.floorId).blocks, (2*i-5)*u-size/2, 245, size, data.hero.loc);
this.drawThumbnail(data.floorId, 'ui', core.maps.load(data.maps, data.floorId).blocks, (2*i-5)*u-size/2, 245, size, data.hero.loc);
core.fillText('ui', core.formatDate(new Date(data.time)), (2*i-5)*u, 260+size, '#FFFFFF', '10px Verdana');
}
else {
@ -1031,16 +1034,16 @@ ui.prototype.drawSLPanel = function(page) {
}
}
this.drawPagination(page+1, 30);
}
ui.prototype.drawThumbnail = function(canvas, blocks, x, y, size, heroLoc) {
ui.prototype.drawThumbnail = function(floorId, canvas, blocks, x, y, size, heroLoc) {
core.clearMap(canvas, x, y, size, size);
var groundId = core.floors[floorId].defaultGround || "ground";
var blockIcon = core.material.icons.terrains[groundId];
var blockImage = core.material.images.terrains;
var persize = size/13;
for (var i=0;i<13;i++) {
for (var j=0;j<13;j++) {
var blockIcon = core.material.icons.terrains.ground;
var blockImage = core.material.images.terrains;
core.canvas[canvas].drawImage(blockImage, 0, blockIcon * 32, 32, 32, x + i * persize, y + j * persize, persize, persize);
}
}
@ -1050,7 +1053,7 @@ ui.prototype.drawThumbnail = function(canvas, blocks, x, y, size, heroLoc) {
if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable)) {
if (block.event.cls == 'autotile') {
// core.drawAutotile();
autotileMaps[13*block.x + block.y] = true;
autotileMaps[13*block.x + block.y] = block.event.id;
continue;
}
else {
@ -1060,7 +1063,7 @@ ui.prototype.drawThumbnail = function(canvas, blocks, x, y, size, heroLoc) {
}
}
}
core.drawAutotile('ui', autotileMaps, x, y, persize);
core.drawAutotile(floorId, 'ui', autotileMaps, x, y, persize);
if (core.isset(heroLoc)) {
var heroIcon = core.material.icons.hero[heroLoc.direction];
@ -1108,4 +1111,28 @@ ui.prototype.drawAbout = function() {
core.fillText('ui', '打Dota的喵', text_start+len, top+272);
core.fillText('ui', 'HTML5魔塔交流群539113091', text_start, top+304);
*/
}
ui.prototype.drawHelp = function () {
core.drawText([
"\t[键盘快捷键列表]"+
"[CTRL] 跳过对话\n" +
"[X] 打开/关闭怪物手册\n" +
"[G] 打开/关闭楼层传送器\n" +
"[S/D] 打开/关闭存/读档页面\n" +
"[K] 打开/关闭快捷商店选择列表\n" +
"[T] 打开/关闭工具栏\n" +
"[ESC] 打开/关闭系统菜单\n" +
"[H] 打开帮助页面\n"+
"[SPACE] 轻按(仅在轻按开关打开时有效)\n" +
"[1] 快捷使用破墙镐\n" +
"[2] 快捷使用炸弹/圣锤\n" +
"[3] 快捷使用中心对称飞行器",
"\t[鼠标操作]"+
"点状态栏中图标: 进行对应的操作\n"+
"点任意块: 寻路并移动\n"+
"点任意块并拖动: 指定寻路路线\n"+
"单击勇士: 转向\n"+
"双击勇士: 轻按(仅在轻按开关打开时有效)"
]);
}

27
main.js
View File

@ -20,6 +20,7 @@ function main() {
'toolBar': document.getElementById('toolBar'),
'tools': document.getElementsByClassName('tools'),
'gameCanvas': document.getElementsByClassName('gameCanvas'),
'curtain': document.getElementById('curtain'),
'startButtons': document.getElementById('startButtons'),
'playGame': document.getElementById('playGame'),
'loadGame': document.getElementById('loadGame'),
@ -30,17 +31,21 @@ function main() {
'hardLevel': document.getElementById('hardLevel'),
'data': document.getElementById('data'),
'statusLabels': document.getElementsByClassName('statusLabel'),
'floorCol': document.getElementById('floorCol'),
'lvCol': document.getElementById('lvCol'),
'mdefCol': document.getElementById('mdefCol'),
'moneyCol': document.getElementById('moneyCol'),
'expCol': document.getElementById('expCol'),
'upCol': document.getElementById('upCol'),
'debuffCol': document.getElementById('debuffCol'),
'hard': document.getElementById('hard'),
};
// console.log('加载游戏容器和开始界面dom对象完成 如下');
// console.log(this.dom);
this.loadList = [
'items', 'icons', 'maps', 'enemys', 'events', 'data', 'ui', 'core'
];
// console.log('加载js文件列表加载完成' + this.loadList);
this.images = [
'animates', 'enemys', 'hero', 'items', 'npcs', 'terrains', "autotile"
'animates', 'enemys', 'hero', 'items', 'npcs', 'terrains'
// Autotile 动态添加
];
this.sounds = {
'mp3': ['bgm-loop', 'floor'],
@ -49,12 +54,14 @@ function main() {
this.statusBar = {
'image': {
'floor': document.getElementById('img-floor'),
'lv': document.getElementById('img-lv'),
'hp': document.getElementById("img-hp"),
'atk': document.getElementById("img-atk"),
'def': document.getElementById("img-def"),
'mdef': document.getElementById("img-mdef"),
'money': document.getElementById("img-money"),
'experience': document.getElementById("img-experience"),
'up': document.getElementById("img-up"),
'book': document.getElementById("img-book"),
'fly': document.getElementById("img-fly"),
'toolbox': document.getElementById("img-toolbox"),
@ -64,12 +71,14 @@ function main() {
'settings': document.getElementById("img-settings")
},
'floor': document.getElementById('floor'),
'lv': document.getElementById('lv'),
'hp': document.getElementById('hp'),
'atk': document.getElementById('atk'),
'def': document.getElementById("def"),
'mdef': document.getElementById('mdef'),
'money': document.getElementById("money"),
'experience': document.getElementById("experience"),
'up': document.getElementById('up'),
'yellowKey': document.getElementById("yellowKey"),
'blueKey': document.getElementById("blueKey"),
'redKey': document.getElementById("redKey"),
@ -78,6 +87,8 @@ function main() {
'curse': document.getElementById('curse'),
'hard': document.getElementById("hard")
}
//------------------------ 用户修改内容 ------------------------//
this.version = "0.1"; // 游戏版本号如果更改了游戏内容建议修改此version以免造成缓存问题。
this.useCompress = false; // 是否使用压缩文件
@ -86,8 +97,10 @@ function main() {
// 如果要进行剧本的修改请务必将其改成false。
this.floorIds = [ // 在这里按顺序放所有的楼层;其顺序直接影响到楼层传送器的顺序和上楼器/下楼器的顺序
"sample0", "sample1", "sample2"
"sample0", "sample1", "sample2", "test"
]
//------------------------ 用户修改内容 END ------------------------//
this.floors = {}
this.instance = {};
this.canvas = {};
@ -193,14 +206,14 @@ window.onresize = function () {
main.dom.body.onkeydown = function(e) {
try {
if (main.core.isPlaying())
if (main.core.isPlaying() || main.core.status.lockControl)
main.core.onkeyDown(e);
} catch (ee) {}
}
main.dom.body.onkeyup = function(e) {
try {
if (main.core.isPlaying())
if (main.core.isPlaying() || main.core.status.lockControl)
main.core.onkeyUp(e);
} catch (ee) {}
}

View File

@ -21,7 +21,7 @@
position: fixed;
top: 10px;
left: 10px;
z-index: 12;
z-index: 13;
}
#startPanel {
@ -32,7 +32,7 @@
left: 0;
background-color: #fff;
overflow: hidden;
z-index: 8;
z-index: 9;
}
#startTop {
@ -42,7 +42,7 @@
top: 0;
left: 0;
background-color: #000;
z-index: 11;
z-index: 12;
}
#startTopProgressBar {
@ -52,7 +52,7 @@
position: absolute;
top: 5%;
background-color: #fff;
z-index: 12;
z-index: 13;
}
#startTopProgress {
@ -67,7 +67,7 @@
position: absolute;
top: 8%;
left: 5%;
z-index: 12;
z-index: 13;
}
#startBackground {
@ -77,12 +77,12 @@
height: 100%;
width: auto;
transform:translate(-50%,-50%);
z-index: 9;
z-index: 10;
}
#startLogo {
position: absolute;
z-index: 9;
z-index: 10;
left: 0;
right: 0;
margin-left: auto;
@ -95,7 +95,7 @@
#startTitle {
position: absolute;
z-index: 10;
z-index: 11;
}
#startButtonGroup {
@ -106,7 +106,7 @@
background-color: #000;
opacity: 0.85;
display: none;
z-index: 9;
z-index: 10;
bottom: 0;
margin-bottom: 7%;
}
@ -142,7 +142,7 @@
display: none;
color: #fff;
background-color: #000;
z-index: 7;
z-index: 8;
}
#logoLabel {
@ -170,7 +170,7 @@
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
background: url(images/ground.png) round;
z-index: 6;
z-index: 7;
display: none;
}
#statusBar .status{
@ -180,8 +180,9 @@
}
.status img{
vertical-align: middle;
width: 1.6em;
height: 1.6em;
width: auto;
height: 100%;
max-height: 1.6em;
}
#statusBar span{
color: white;
@ -198,7 +199,7 @@
#toolBar {
position: absolute;
background: url(images/ground.png) round;
z-index: 5;
z-index: 6;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
@ -232,6 +233,13 @@ span#poison, span#weak, span#curse {
-webkit-box-sizing: border-box;
}
#curtain {
z-index: 5;
position: absolute;
opacity: 0;
background: #000000;
}
#bg {
z-index: 1;
}
@ -240,20 +248,20 @@ span#poison, span#weak, span#curse {
z-index: 2;
}
#hero {
#fg {
z-index: 3;
}
#fg {
#hero {
z-index: 4;
}
#ui {
z-index: 5;
z-index: 6;
}
#data {
z-index: 6;
z-index: 7;
}
.clearfix:before,

Binary file not shown.

Binary file not shown.

49
快捷键说明.txt Normal file
View File

@ -0,0 +1,49 @@
快捷键说明:
=== 全局 ===
[↑][↓][←][→] 移动勇士
[CTRL] 跳过对话
[X] 打开/关闭怪物手册
[G] 打开/关闭楼层传送器
[S] 打开/关闭存档页面
[D] 打开/关闭读档页面
[K] 打开/关闭快捷商店选择列表
[T] 打开/关闭工具栏
[ESC] 打开/关闭系统菜单
[H] 打开帮助页面
[SPACE] 轻按(仅在轻按开关打开时有效)
[1] 快捷使用破墙镐
[2] 快捷使用炸弹/圣锤(先检测有没有炸弹,没有再检测圣锤)
[3] 快捷使用中心对称飞行器
=== 文本显示界面 ===
[SPACE]/[ENTER] 继续
=== 选项列表 ===
[↑][↓] 移动当前选择项
[ESC] 返回
[SPACE]/[ENTER] 确认该选项
=== 怪物手册页面 ===
[↑][↓][←][→] 翻页
[ESC]/[X] 关闭怪物手册
=== 楼传器页面 ===
[↑][↓][←][→] 更改楼层
[SPACE]/[ENTER] 确认传送
[ESC]/[G] 关闭楼传器
=== 道具栏页面 ===
[↑][↓][←][→] 更改当前道具
[SPACE]/[ENTER] 确认使用道具
[ESC]/[T] 关闭道具栏
=== 存读档页面 ===
[↑][↓][←][→] 更改当前存读档位置
[PAGEUP][PAGEDOWN] 存读档翻页
[SPACE]/[ENTER] 确认存读档
[ESC]/[S]/[D] 关闭存读档界面
=== 正在使用中心对称飞行器时 ===
[3]/[SPACE]/[ENTER] 确认飞行
其他键 取消飞行

11
更新说明.txt Normal file
View File

@ -0,0 +1,11 @@
全键盘操作 √
进阶 √
Ctrl快速跳过对话 √
增加负伤 √
支持不同层使用不同的地面素材 √
支持多个Autotile同时存在 √
直接内嵌了诸多默认的terrains素材 √
自动定位到上次存/读档位置 √
设置储存 √
修改setFg的实现方法 √
大范围领域伤害