This commit is contained in:
ckcz123 2018-01-16 19:54:18 +08:00
parent bbf250047f
commit 9ebb6652c5
7 changed files with 158 additions and 43 deletions

View File

@ -142,10 +142,6 @@ floorId指定的是目标楼层的唯一标识符ID
可以指定time指定后切换动画时长为指定的数值。
楼梯和传送门默认可`"穿透"`。所谓穿透,就是当寻路穿过一个楼梯/传送门后不会触发楼层传送事件而是继续前进。通过系统Flag可以指定是否穿透你也可以对每个传送点单独设置该项。
![楼层转换穿透](./img/floorset.png)
## 背景音乐
本塔支持BGM和SE的播放。

View File

@ -766,6 +766,22 @@ core.prototype.keyUp = function(keyCode) {
if (!core.status.lockControl && core.status.heroStop)
core.ui.drawHelp();
break;
case 82: // R
if (!core.status.lockControl && core.status.heroStop) {
core.ui.drawConfirmBox("确定要回放录像吗?", function () {
core.ui.closePanel();
var hard=core.status.hard, route=core.clone(core.status.route);
core.resetStatus(core.firstData.hero, hard, core.firstData.floorId, null, core.initStatus.maps);
core.events.setInitData(hard);
core.changeFloor(core.status.floorId, null, core.firstData.hero.loc, null, function() {
core.setHeroMoveTriggerInterval();
core.replay(route);
});
}, function () {
core.ui.closePanel();
});
}
break;
case 37: // UP
break;
case 38: // DOWN
@ -1483,18 +1499,16 @@ core.prototype.moveAction = function (callback) {
}
}
////// 设置勇士的方向(转向) //////
core.prototype.turnHero = function(direction) {
if (core.isset(direction)) {
core.status.hero.loc.direction = direction;
}
else if (core.status.hero.loc.direction == 'up') core.status.hero.loc.direction = 'right';
////// 转向 //////
core.prototype.turnHero = function() {
if (core.status.hero.loc.direction == 'up') core.status.hero.loc.direction = 'right';
else if (core.status.hero.loc.direction == 'right') core.status.hero.loc.direction = 'down';
else if (core.status.hero.loc.direction == 'down') core.status.hero.loc.direction = 'left';
else if (core.status.hero.loc.direction == 'left') core.status.hero.loc.direction = 'up';
core.drawHero(core.status.hero.loc.direction, core.status.hero.loc.x, core.status.hero.loc.y, 'stop', 0, 0);
core.status.automaticRoutingTemp = {'destX': 0, 'destY': 0, 'moveStep': []};
core.canvas.ui.clearRect(0, 0, 416, 416);
core.status.route.push("turn");
}
////// 勇士能否前往某方向 //////
@ -1832,12 +1846,14 @@ core.prototype.trigger = function (x, y) {
if (core.isset(mapBlocks[b].event) && core.isset(mapBlocks[b].event.trigger)) {
var trigger = mapBlocks[b].event.trigger;
// 转换楼层能否穿透
/*
if (trigger=='changeFloor' && (core.status.autoHeroMove || core.status.autoStep<core.status.autoStepRoutes.length)) {
var canCross = core.flags.portalWithoutTrigger;
if (core.isset(mapBlocks[b].event.data) && core.isset(mapBlocks[b].event.data.portalWithoutTrigger))
canCross=mapBlocks[b].event.data.portalWithoutTrigger;
if (canCross) continue;
}
*/
core.material.events[trigger](mapBlocks[b], core, function (data) {
});
@ -3028,8 +3044,8 @@ core.prototype.removeItem = function (itemId) {
}
////// 使用某个物品 //////
core.prototype.useItem = function (itemId) {
core.items.useItem(itemId);
core.prototype.useItem = function (itemId, callback) {
core.items.useItem(itemId, callback);
return;
}
@ -3061,6 +3077,7 @@ core.prototype.getNextItem = function() {
if (block==null) return;
if (block.block.event.trigger=='getItem') {
core.getItem(block.block.event.id, 1, nextX, nextY);
core.status.route.push("getNext");
}
}
@ -3356,14 +3373,16 @@ core.prototype.debug = function() {
core.drawTip("作弊成功");
}
core.prototype.testReplay = function(list) {
core.status.replay.replaying=true;
core.status.replay.toReplay=core.clone(list);
core.replay();
}
////// 回放 //////
core.prototype.replay = function () {
core.prototype.replay = function (list) {
if (core.isset(list) && (list instanceof Array)) {
core.status.replay.replaying=true;
core.status.replay.toReplay = core.clone(list);
this.replay();
return;
}
if (!core.status.replay.replaying) return; // 没有回放
if (core.status.replay.pausing) return; // 暂停状态
if (core.status.replay.animate) return; // 正在某段动画中
@ -3376,24 +3395,83 @@ core.prototype.replay = function () {
var action=core.status.replay.toReplay.shift();
if (action=='up' || action=='down' || action=='left' || action=='right')
if (action=='up' || action=='down' || action=='left' || action=='right') {
core.moveHero(action, function () {
core.replay();
});
else if (action.indexOf("item:")==0) {
}
else if (action.indexOf("fly:")==0) {
}
else if (action.indexOf("shop:")==0) {
}
else { // 其他情况:回放失败
core.status.replay.replaying=false;
core.insertAction("录像出错,回放失败。");
return;
}
else if (action.indexOf("item:")==0) {
var itemId = action.substring(5);
if (core.canUseItem(itemId)) {
core.useItem(itemId, function () {
core.replay();
});
return;
}
}
else if (action.indexOf("fly:")==0) {
var floorId=action.substring(4);
var toIndex=core.status.hero.flyRange.indexOf(floorId);
var nowIndex=core.status.hero.flyRange.indexOf(core.status.floorId);
if (core.hasItem('fly') && toIndex>=0 && nowIndex>=0) {
var stair=toIndex<nowIndex?"upFloor":"downFloor";
core.status.route.push("fly:"+core.floorIds.indexOf(floorId));
core.changeFloor(floorId, stair, null, null, function () {
core.replay();
});
return;
}
}
else if (action.indexOf("shop:")==0) {
var sps=action.substring(5).split(":");
var shopId=sps[0], selections=sps[1].split("");
if (selections.length>0 && core.events.canUseQuickShop(shopId)==null) {
var shop=core.status.shops[shopId];
if (core.isset(shop) && shop.visited) { // 商店可用
var choices = shop.choices;
var topIndex = 6 - parseInt(choices.length / 2);
core.events.openShop(shopId, false);
var shopInterval = setInterval(function () {
if (selections.length==0) {
clearInterval(shopInterval);
core.events.clickShop(6, topIndex+choices.length);
core.replay();
return;
}
var selection = parseInt(selections.shift());
if (isNaN(core.status.event.selection=selection) || selection<0 || selection>=choices.length || !core.events.clickShop(6, topIndex+selection)) {
clearInterval(shopInterval);
core.status.replay.replaying=false;
core.drawTip("录像文件出错");
return;
}
}, 500);
return;
}
}
}
else if (action=='turn') {
core.turnHero();
core.replay();
return;
}
else if (action=='getNext') {
if (core.flags.enableGentleClick && core.getBlock(core.nextX(), core.nextY())!=null) {
var nextX = core.nextX(), nextY = core.nextY();
var block = core.getBlock(nextX, nextY);
if (block!=null && block.block.event.trigger=='getItem') {
core.getItem(block.block.event.id, 1, nextX, nextY);
core.status.route.push("getNext");
core.replay();
return;
}
}
}
core.status.replay.replaying=false;
core.insertAction("录像文件出错");
}
@ -3748,6 +3826,10 @@ core.prototype.encodeRoute = function (route) {
var sp=t.substring(5).split(":");
ans+="S"+shops.indexOf(sp[0])+":"+sp[1];
}
else if (t=='turn')
ans+='T';
else if (t=='getNext')
ans+='G';
}
});
if (cnt>0) {
@ -3788,6 +3870,8 @@ core.prototype.decodeRoute = function (route) {
case "F": ans.push("fly:"+core.floorIds[number]); break;
case "C": ans.push("choices:"+number); break;
case "S": ++index; ans.push("shop:"+shops[number]+":"+getNumber(true)); break;
case "T": ans.push("turn"); break;
case "G": ans.push("getNext"); break;
}
}
return ans;

View File

@ -166,7 +166,6 @@ data.prototype.init = function() {
"displayEnemyDamage": true, // 是否地图怪物显伤;用户可以手动在菜单栏中开关
"displayExtraDamage": false, // 是否地图高级显伤(领域、夹击等);用户可以手动在菜单栏中开关
"enableGentleClick": true, // 是否允许轻触(获得面前物品)
"portalWithoutTrigger": true, // 经过楼梯、传送门时是否能“穿透”。穿透的意思是,自动寻路得到的的路径中间经过了楼梯,行走时是否触发楼层转换事件
"potionWhileRouting": false, // 寻路算法是否经过血瓶如果该项为false则寻路算法会自动尽量绕过血瓶
}
}

View File

@ -293,7 +293,12 @@ events.prototype.doAction = function() {
this.doAction();
break;
case "openShop": // 打开一个全局商店
core.events.openShop(data.id);
if (core.status.replay.replaying) { // 正在播放录像简单将visited置为true
core.status.shops[data.id].visited=true;
this.doAction();
}
else
core.events.openShop(data.id);
break;
case "disableShop": // 禁用一个全局商店
core.events.disableQuickShop(data.id);
@ -374,6 +379,30 @@ events.prototype.doAction = function() {
this.doAction();
break;
case "choices": // 提供选项
if (core.status.replay.replaying) {
if (core.status.replay.toReplay.length==0) { // 回放完毕
core.status.replay.replaying=false;
core.drawTip("录像回放完毕");
}
else {
var action = core.status.replay.toReplay.shift(), index;
if (action.indexOf("choices:")==0 && ((index=parseInt(action.substring(8)))>=0) && index<data.choices.length) {
//core.status.route.push("choices:"+index);
//this.insertAction(data.choices[index].action);
//this.doAction();
core.status.event.selection=index;
setTimeout(function () {
core.status.route.push("choices:"+index);
core.events.insertAction(data.choices[index].action);
core.events.doAction();
}, 500)
}
else {
core.status.replay.replaying=false;
core.drawTip("录像文件出错");
}
}
}
core.ui.drawChoices(data.text, data.choices);
break;
case "win":
@ -488,7 +517,7 @@ events.prototype.disableQuickShop = function (shopId) {
}
////// 能否使用快捷商店 //////
events.prototype.canUseQuickShop = function(shopIndex) {
events.prototype.canUseQuickShop = function(shopId) {
if (core.isset(core.floors[core.status.floorId].canUseQuickShop) && !core.isset(core.floors[core.status.floorId].canUseQuickShop))
return '当前不能使用快捷商店。';
@ -952,7 +981,7 @@ events.prototype.clickShop = function(x,y) {
if (need > eval(use)) {
core.drawTip("你的"+use_text+"不足");
return;
return false;
}
core.status.event.data.actions.push(y-topIndex);
@ -981,7 +1010,9 @@ events.prototype.clickShop = function(x,y) {
core.ui.drawQuickShop();
else core.ui.closePanel();
}
else return false;
}
return true;
}
////// 商店界面时,按下某个键的操作 //////
@ -1023,7 +1054,7 @@ events.prototype.clickQuickShop = function(x, y) {
if (x >= 5 && x <= 7) {
var topIndex = 6 - parseInt(keys.length / 2);
if (y>=topIndex && y<topIndex+keys.length) {
var reason = core.events.canUseQuickShop(y-topIndex);
var reason = core.events.canUseQuickShop(keys[y - topIndex]);
if (core.isset(reason)) {
core.drawText(reason);
return;

View File

@ -50,7 +50,6 @@ main.floors.sample0 = {
"\t[老人,womanMagician]这些是路障、楼梯、传送门。",
"\t[老人,womanMagician]血网的伤害数值、中毒后每步伤害数值、衰弱时攻防下降的数值,都在 data.js 内定义。\n\n路障同样会尽量被自动寻路绕过。",
"\t[老人,womanMagician]楼梯和传送门需要在changeFloor中定义目标楼层和位置可参见样板里已有的的写法。",
"\t[老人,womanMagician]楼梯和传送门是否可“穿透”由data.js中的全局变量所决定你也可以单独设置。\n穿透的意思是自动寻路得到的路径中间经过了楼梯行走时是否触发楼层转换事件。\n例如下面的“下箭头”就是不能穿透的。",
{"type": "hide", "time": 500}
],
"2,8": [ // 守着第一批怪物的老人
@ -75,7 +74,6 @@ main.floors.sample0 = {
{"type": "hide", "time": 500}
]
},
},
"changeFloor": { // 楼层转换事件该事件不能和上面的events有冲突同位置点否则会被覆盖
"6,0": {"floorId": "sample1", "stair": "downFloor"}, // 目标点sample1层的下楼梯位置
@ -85,8 +83,8 @@ main.floors.sample0 = {
"2,12": {"floorId": "sample0", "loc": [2,12]},
"3,12": {"floorId": "sample0", "loc": [6,1], "direction": "up"}, // 切换楼层后勇士面对上方
"4,12": {"floorId": "sample0", "loc": [0,9], "direction": "left", "time": 1000}, // 切换楼层后勇士面对左边切换动画1000ms
"5,12": {"floorId": "sample0", "loc": [6,10], "portalWithoutTrigger": false}, // 不能穿透
"6,12": {"floorId": "sample0", "loc": [10,10], "direction": "left", "time": 1000, "portalWithoutTrigger": false},
"5,12": {"floorId": "sample0", "loc": [6,10], "time": 0}, // time=0表示无切换时间
"6,12": {"floorId": "sample0", "loc": [10,10], "direction": "left", "time": 1000},
},
"afterBattle": { // 战斗后可能触发的事件列表
"2,6": ["\t[ghostSkeleton]不可能,你怎么可能打败我!\n一个打败怪物触发的事件"]

View File

@ -143,8 +143,11 @@ items.prototype.getItemEffectTip = function(itemId) {
}
////// 使用道具 //////
items.prototype.useItem = function (itemId) {
if (!this.canUseItem(itemId)) return;
items.prototype.useItem = function (itemId, callback) {
if (!this.canUseItem(itemId)) {
if (core.isset(callback)) callback();
return;
}
var itemCls = core.material.items[itemId].cls;
if (itemId=='book') core.ui.drawBook(0);
@ -174,6 +177,7 @@ items.prototype.useItem = function (itemId) {
// 上楼器/下楼器
core.changeFloor(core.status.event.data.id, null, {'direction': core.status.hero.loc.direction, 'x': core.status.event.data.x, 'y': core.status.event.data.y}, null, function (){
core.drawTip(core.material.items[itemId].name + "使用成功");
core.replay();
});
}
if (itemId == 'poisonWine') core.setFlag('poison', false);
@ -204,6 +208,8 @@ items.prototype.useItem = function (itemId) {
core.status.hero.items[itemCls][itemId]--;
if (core.status.hero.items[itemCls][itemId]==0)
delete core.status.hero.items[itemCls][itemId];
if (core.isset(callback)) callback();
}
////// 当前能否使用道具 //////

View File

@ -3,6 +3,7 @@
=== 全局 ===
[↑][↓][←][→] 移动勇士
[CTRL] 跳过对话
[Z] 转向
[X] 打开/关闭怪物手册
[G] 打开/关闭楼层传送器
[A] 读取自动存档