Merge remote-tracking branch 'refs/remotes/origin/blockly-mousewheel' into refactoring-editor
This commit is contained in:
commit
6b7f9837b6
@ -38,10 +38,12 @@ HTML5 canvas制作的魔塔样板,支持全平台游戏!
|
||||
│ ├─ /sounds/ # 音效目录
|
||||
│ ├─ data.js # 全局变量信息
|
||||
│ ├─ enemys.js # 怪物属性数据
|
||||
│ ├─ events.js # 公共事件
|
||||
│ ├─ functions.js # 可能会被修改的脚本代码
|
||||
│ ├─ icons.js # 素材和ID的对应关系定义
|
||||
│ ├─ items.js # 道具的定义,获得道具的效果
|
||||
│ └─ maps.js # 地图和数字的对应关系
|
||||
│ ├─ maps.js # 地图和数字的对应关系
|
||||
│ └─ plugins.js # 自定义插件
|
||||
├── /常用工具/ # 一些常用工具,可以辅助造塔;具体可参见下面的【相关工具】
|
||||
├── editor.html # 可视化地图编辑工具
|
||||
├── editor-mobile.html # 可视化地图编辑工具(手机版)
|
||||
|
||||
@ -901,6 +901,30 @@ needKey是可选的,如果设置为true则需要钥匙才能打开此门。如
|
||||
|
||||
!> needKey仅对当前楼层开门有效!跨楼层的门仍然不需要钥匙即可打开,如有需求请自行判定。
|
||||
|
||||
### closeDoor:关门
|
||||
|
||||
从V2.6开始提供了关门事件`{"type": "closeDoor"}`,拥有关门动画和对应的音效。
|
||||
|
||||
``` js
|
||||
"x,y": [ // 实际执行的事件列表
|
||||
{"type": "closeDoor", "id": "yellowDoor", "loc": [3,6]}, // 给(3,6)点关上黄门
|
||||
{"type": "closeDoor", "id": "specialDoor"}, // 不写loc则视为当前点
|
||||
]
|
||||
```
|
||||
|
||||
id为你要关门的ID,需要是一个合法的门,系统默认只支持如下几种:
|
||||
|
||||
```
|
||||
yellowDoor, blueDoor, redDoor, greenDoor, specialDoor, steelDoor,
|
||||
yellowWall, blueWall, whiteWall
|
||||
```
|
||||
|
||||
如果需要自己添加门,请参考[新增门和对应的钥匙](personalization#新增门和对应的钥匙)。
|
||||
|
||||
loc可选,为要关的位置,不填默认为当前点。
|
||||
|
||||
关门事件需要保证该点是空地,否则将无视此事件。
|
||||
|
||||
### changeFloor:楼层切换
|
||||
|
||||
在事件中也可以对楼层进行切换。一个比较典型的例子就是TSW中,勇士在三楼的陷阱被扔到了二楼,就是一个楼层切换事件。
|
||||
|
||||
@ -256,6 +256,7 @@ action
|
||||
| waitAsync_s
|
||||
| battle_s
|
||||
| openDoor_s
|
||||
| closeDoor_s
|
||||
| changeFloor_s
|
||||
| changePos_0_s
|
||||
| changePos_1_s
|
||||
@ -961,6 +962,23 @@ var code = '{"type": "openDoor"'+floorstr+IdString_0+Bool_0+'},\n';
|
||||
return code;
|
||||
*/;
|
||||
|
||||
closeDoor_s
|
||||
: '关门' 'x' PosString? ',' 'y' PosString? 'ID' IdString Newline
|
||||
|
||||
|
||||
/* closeDoor_s
|
||||
tooltip : closeDoor: 关门事件,需要该点本身无事件
|
||||
helpUrl : https://h5mota.com/games/template/docs/#/event?id=opendoor%EF%BC%9A%E5%BC%80%E9%97%A8
|
||||
default : ["","","yellowDoor"]
|
||||
colour : this.dataColor
|
||||
var floorstr = '';
|
||||
if (PosString_0 && PosString_1) {
|
||||
floorstr = ', "loc": ['+PosString_0+','+PosString_1+']';
|
||||
}
|
||||
var code = '{"type": "closeDoor", "id": "'+IdString_0+'"'+floorstr+'},\n';
|
||||
return code;
|
||||
*/;
|
||||
|
||||
changeFloor_s
|
||||
: '楼层切换' IdString? 'x' PosString? ',' 'y' PosString? '朝向' DirectionEx_List '动画时间' Int? Newline
|
||||
|
||||
@ -2338,6 +2356,11 @@ ActionParser.prototype.parseAction = function() {
|
||||
this.next = MotaActionBlocks['openDoor_s'].xmlText([
|
||||
data.loc[0],data.loc[1],data.floorId||'',data.needKey||false,this.next]);
|
||||
break;
|
||||
case "closeDoor": // 关一个门,需要该点无事件
|
||||
data.loc=data.loc||['','']
|
||||
this.next = MotaActionBlocks['closeDoor_s'].xmlText([
|
||||
data.loc[0],data.loc[1],data.id,this.next]);
|
||||
break;
|
||||
case "useItem": // 使用道具
|
||||
this.next = MotaActionBlocks['useItem_s'].xmlText([
|
||||
data.id,this.next]);
|
||||
@ -721,7 +721,7 @@ editor.prototype.listen = function () {
|
||||
mouseOutCheck = 2;
|
||||
setTimeout(clear1);
|
||||
e.stopPropagation();
|
||||
uc.clearRect(0, 0, core.__SIZE__, core.__SIZE__);
|
||||
uc.clearRect(0, 0, core.__PIXELS__, core.__PIXELS__);
|
||||
var loc = eToLoc(e);
|
||||
var pos = locToPos(loc,true);
|
||||
stepPostfix = [];
|
||||
|
||||
@ -93,6 +93,7 @@ editor_blockly = function () {
|
||||
MotaActionBlocks['changePos_1_s'].xmlText(),
|
||||
MotaActionBlocks['battle_s'].xmlText(),
|
||||
MotaActionBlocks['openDoor_s'].xmlText(),
|
||||
MotaActionBlocks['closeDoor_s'].xmlText(),
|
||||
MotaActionBlocks['useItem_s'].xmlText(),
|
||||
MotaActionBlocks['openShop_s'].xmlText(),
|
||||
MotaActionBlocks['setBlock_s'].xmlText(),
|
||||
@ -312,7 +313,8 @@ document.getElementById('blocklyDiv').onmousewheel = function(e){
|
||||
//console.log(e);
|
||||
e.preventDefault();
|
||||
var hvScroll = e.shiftKey?'hScroll':'vScroll';
|
||||
workspace.scrollbar[hvScroll].handlePosition_+=( ((e.deltaY||0)+(e.detail||0)) >0?20:-20);
|
||||
var mousewheelOffsetValue=20/380*workspace.scrollbar[hvScroll].handleLength_*3;
|
||||
workspace.scrollbar[hvScroll].handlePosition_+=( ((e.deltaY||0)+(e.detail||0)) >0?mousewheelOffsetValue:-mousewheelOffsetValue);
|
||||
workspace.scrollbar[hvScroll].onScroll_();
|
||||
workspace.setScale(workspace.scale);
|
||||
}
|
||||
@ -442,13 +444,13 @@ function omitedcheckUpdateFunction(event) {
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState != 4) return;
|
||||
if (xhr.status != 200) {
|
||||
alert("无法在file://下加载");
|
||||
alert("图块描述文件加载失败, 请在'启动服务.exe'中打开编辑器");
|
||||
return;
|
||||
}
|
||||
input_ = xhr.responseText;
|
||||
editor_blockly.runOne();
|
||||
}
|
||||
xhr.open('GET', '_server/blockly/MotaAction.g4', true);
|
||||
xhr.open('GET', '_server/MotaAction.g4', true);
|
||||
xhr.send(null);
|
||||
|
||||
codeAreaHL = CodeMirror.fromTextArea(document.getElementById("codeArea"), {
|
||||
|
||||
@ -13,14 +13,21 @@ var events_comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
|
||||
"_type": "event",
|
||||
"_range": "thiseval instanceof Array",
|
||||
"_event": "commonEvent",
|
||||
"_data": "打败怪物后进行加点"
|
||||
"_data": "打败怪物后加点"
|
||||
},
|
||||
"毒衰咒处理": {
|
||||
"_leaf": true,
|
||||
"_type": "event",
|
||||
"_range": "thiseval instanceof Array",
|
||||
"_event": "commonEvent",
|
||||
"_data": "对毒衰咒效果进行的处理"
|
||||
"_data": "毒衰咒效果处理"
|
||||
},
|
||||
"滑冰事件": {
|
||||
"_leaf": true,
|
||||
"_type": "event",
|
||||
"_range": "thiseval instanceof Array",
|
||||
"_event": "commonEvent",
|
||||
"_data": "滑冰事件"
|
||||
},
|
||||
}
|
||||
if (obj[key]) return obj[key];
|
||||
|
||||
@ -42,6 +42,12 @@ var functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
|
||||
"_lint": true,
|
||||
"_data": "切换楼层后"
|
||||
},
|
||||
"flyTo": {
|
||||
"_leaf": true,
|
||||
"_type": "textarea",
|
||||
"_lint": true,
|
||||
"_data": "楼层飞行"
|
||||
},
|
||||
"beforeBattle": {
|
||||
"_leaf": true,
|
||||
"_type": "textarea",
|
||||
@ -147,12 +153,6 @@ var functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
|
||||
"_lint": true,
|
||||
"_data": "读档操作"
|
||||
},
|
||||
"flyTo": {
|
||||
"_leaf": true,
|
||||
"_type": "textarea",
|
||||
"_lint": true,
|
||||
"_data": "楼层飞行"
|
||||
},
|
||||
"updateStatusBar": {
|
||||
"_leaf": true,
|
||||
"_type": "textarea",
|
||||
@ -176,6 +176,12 @@ var functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
|
||||
"_type": "textarea",
|
||||
"_lint": true,
|
||||
"_data": "瞬间移动处理"
|
||||
},
|
||||
"parallelDo": {
|
||||
"_leaf": true,
|
||||
"_type": "textarea",
|
||||
"_lint": true,
|
||||
"_data": "并行事件处理"
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -201,23 +207,6 @@ var functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
|
||||
"_data": "绘制关于界面"
|
||||
}
|
||||
}
|
||||
},
|
||||
"plugins": {
|
||||
"_type": "object",
|
||||
"_data": {
|
||||
"parallelDo": {
|
||||
"_leaf": true,
|
||||
"_type": "textarea",
|
||||
"_lint": true,
|
||||
"_data": "并行事件处理"
|
||||
},
|
||||
"plugin": {
|
||||
"_leaf": true,
|
||||
"_type": "textarea",
|
||||
"_lint": true,
|
||||
"_data": "自定义插件编写"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3,17 +3,17 @@ var plugins_comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
|
||||
"_type": "object",
|
||||
"_data": function (key) {
|
||||
var obj = {
|
||||
"test": {
|
||||
"init": {
|
||||
"_leaf": true,
|
||||
"_type": "textarea",
|
||||
"_range": "typeof(thiseval)=='string'",
|
||||
"_data": "插件函数执行测试, 这个函数在导入后被直接执行(因此不允许删除)"
|
||||
"_data": "自定义插件"
|
||||
},
|
||||
"drawLight": {
|
||||
"_leaf": true,
|
||||
"_type": "textarea",
|
||||
"_range": "typeof(thiseval)=='string' || thiseval==null",
|
||||
"_data": "绘制灯光/漆黑层效果"
|
||||
"_data": "绘制灯光效果"
|
||||
},
|
||||
}
|
||||
if (obj[key]) return obj[key];
|
||||
|
||||
@ -503,7 +503,7 @@
|
||||
<canvas class='gameCanvas' id='data' width='416' height='416'>此浏览器不支持HTML5</canvas>
|
||||
</div>
|
||||
</div>
|
||||
<div id='inputBackground'>
|
||||
<div id='inputBackground' style='display: none'>
|
||||
<div id='inputDialog'>
|
||||
<p id="inputMessage">请输入文字...</p>
|
||||
<input id='inputBox' type="text"/>
|
||||
|
||||
@ -486,7 +486,7 @@
|
||||
<canvas class='gameCanvas' id='data' width='416' height='416'>此浏览器不支持HTML5</canvas>
|
||||
</div>
|
||||
</div>
|
||||
<div id='inputBackground'>
|
||||
<div id='inputBackground' style='display: none'>
|
||||
<div id='inputDialog'>
|
||||
<p id="inputMessage">请输入文字...</p>
|
||||
<input id='inputBox' type="text"/>
|
||||
|
||||
599
libs/actions.js
599
libs/actions.js
@ -94,7 +94,7 @@ actions.prototype.doRegisteredAction = function (action) {
|
||||
var actions = this.actions[action];
|
||||
if (!actions) return false;
|
||||
for (var i = 0; i < actions.length; ++i) {
|
||||
if (core.doFunc.apply(this, [actions[i].func].concat(Array.prototype.slice.call(arguments, 1))))
|
||||
if (core.doFunc.apply(core, [actions[i].func, this].concat(Array.prototype.slice.call(arguments, 1))))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -109,7 +109,7 @@ actions.prototype.checkReplaying = function () {
|
||||
|
||||
////// 检查是否在录像播放中,如果是,则停止交互
|
||||
actions.prototype._sys_checkReplay = function () {
|
||||
if (this.checkReplaying()) return true;
|
||||
if (core.actions.checkReplaying()) return true;
|
||||
}
|
||||
|
||||
////// 按下某个键时 //////
|
||||
@ -127,10 +127,10 @@ actions.prototype._sys_onkeyDown = function (e) {
|
||||
}
|
||||
}
|
||||
core.status.holdingKeys.push(e.keyCode);
|
||||
this.pressKey(e.keyCode);
|
||||
core.actions.pressKey(e.keyCode);
|
||||
} else {
|
||||
if (e.keyCode == 17) core.status.ctrlDown = true;
|
||||
this.keyDown(e.keyCode);
|
||||
core.actions.keyDown(e.keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
@ -140,7 +140,7 @@ actions.prototype.onkeyUp = function (e) {
|
||||
}
|
||||
|
||||
actions.prototype._sys_onkeyUp_replay = function (e) {
|
||||
if (this.checkReplaying()) {
|
||||
if (core.actions.checkReplaying()) {
|
||||
if (e.keyCode == 27) // ESCAPE
|
||||
core.stopReplay();
|
||||
else if (e.keyCode == 90) // Z
|
||||
@ -179,10 +179,10 @@ actions.prototype._sys_onkeyUp = function (e) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.keyUp(e.keyCode, e.altKey);
|
||||
core.actions.keyUp(e.keyCode, e.altKey);
|
||||
} else {
|
||||
if (e.keyCode == 17) core.status.ctrlDown = false;
|
||||
this.keyUp(e.keyCode, e.altKey);
|
||||
core.actions.keyUp(e.keyCode, e.altKey);
|
||||
}
|
||||
}
|
||||
|
||||
@ -209,32 +209,32 @@ actions.prototype._sys_keyDown_lockControl = function (keyCode) {
|
||||
if (!core.status.lockControl) return false;
|
||||
// Ctrl跳过对话
|
||||
if (keyCode == 17) {
|
||||
this.keyDownCtrl();
|
||||
core.actions.keyDownCtrl();
|
||||
return true;
|
||||
}
|
||||
switch (core.status.event.id) {
|
||||
case 'action':
|
||||
this._keyDownAction(keyCode);
|
||||
core.actions._keyDownAction(keyCode);
|
||||
break;
|
||||
case 'book':
|
||||
this._keyDownBook(keyCode);
|
||||
core.actions._keyDownBook(keyCode);
|
||||
break;
|
||||
case 'fly':
|
||||
this._keyDownFly(keyCode);
|
||||
core.actions._keyDownFly(keyCode);
|
||||
break;
|
||||
case 'viewMaps':
|
||||
this._keyDownViewMaps(keyCode);
|
||||
core.actions._keyDownViewMaps(keyCode);
|
||||
break;
|
||||
case 'equipbox':
|
||||
this._keyDownEquipbox(keyCode);
|
||||
core.actions._keyDownEquipbox(keyCode);
|
||||
break;
|
||||
case 'toolbox':
|
||||
this._keyDownToolbox(keyCode);
|
||||
core.actions._keyDownToolbox(keyCode);
|
||||
break;
|
||||
case 'save':
|
||||
case 'load':
|
||||
case 'replayLoad':
|
||||
this._keyDownSL(keyCode);
|
||||
core.actions._keyDownSL(keyCode);
|
||||
break;
|
||||
case 'shop':
|
||||
case 'selectShop':
|
||||
@ -246,10 +246,10 @@ actions.prototype._sys_keyDown_lockControl = function (keyCode) {
|
||||
case 'storageRemove':
|
||||
case 'replay':
|
||||
case 'gameInfo':
|
||||
this._keyDownChoices(keyCode);
|
||||
core.actions._keyDownChoices(keyCode);
|
||||
break;
|
||||
case 'cursor':
|
||||
this._keyDownCursor(keyCode);
|
||||
core.actions._keyDownCursor(keyCode);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
@ -282,7 +282,7 @@ actions.prototype.keyUp = function (keyCode, altKey, fromReplay) {
|
||||
}
|
||||
|
||||
actions.prototype._sys_keyUp_replay = function (keyCode, altKey, fromReplay) {
|
||||
if (!fromReplay && this.checkReplaying()) return true;
|
||||
if (!fromReplay && core.actions.checkReplaying()) return true;
|
||||
}
|
||||
|
||||
actions.prototype._sys_keyUp_lockControl = function (keyCode, altKey) {
|
||||
@ -298,10 +298,10 @@ actions.prototype._sys_keyUp_lockControl = function (keyCode, altKey) {
|
||||
ok() && core.drawText();
|
||||
break;
|
||||
case 'confirmBox':
|
||||
this._keyUpConfirmBox(keyCode);
|
||||
core.actions._keyUpConfirmBox(keyCode);
|
||||
break;
|
||||
case 'action':
|
||||
this._keyUpAction(keyCode);
|
||||
core.actions._keyUpAction(keyCode);
|
||||
break;
|
||||
case 'about':
|
||||
ok() && core.ui.closePanel();
|
||||
@ -310,69 +310,69 @@ actions.prototype._sys_keyUp_lockControl = function (keyCode, altKey) {
|
||||
ok() && core.ui.closePanel();
|
||||
break;
|
||||
case 'book':
|
||||
this._keyUpBook(keyCode);
|
||||
core.actions._keyUpBook(keyCode);
|
||||
break;
|
||||
case 'book-detail':
|
||||
ok() && this._clickBookDetail();
|
||||
ok() && core.actions._clickBookDetail();
|
||||
break;
|
||||
case 'fly':
|
||||
this._keyUpFly(keyCode);
|
||||
break;
|
||||
case 'viewMaps':
|
||||
this._keyUpViewMaps(keyCode);
|
||||
core.actions._keyUpViewMaps(keyCode);
|
||||
break;
|
||||
case 'shop':
|
||||
this._keyUpShop(keyCode);
|
||||
core.actions._keyUpShop(keyCode);
|
||||
break;
|
||||
case 'selectShop':
|
||||
this._keyUpQuickShop(keyCode);
|
||||
core.actions._keyUpQuickShop(keyCode);
|
||||
break;
|
||||
case 'toolbox':
|
||||
this._keyUpToolbox(keyCode);
|
||||
core.actions._keyUpToolbox(keyCode);
|
||||
break;
|
||||
case 'equipbox':
|
||||
this._keyUpEquipbox(keyCode, altKey);
|
||||
core.actions._keyUpEquipbox(keyCode, altKey);
|
||||
break;
|
||||
case 'save':
|
||||
case 'load':
|
||||
case 'replayLoad':
|
||||
this._keyUpSL(keyCode);
|
||||
core.actions._keyUpSL(keyCode);
|
||||
break;
|
||||
case 'keyBoard':
|
||||
ok() && core.ui.closePanel();
|
||||
break;
|
||||
case 'switchs':
|
||||
this._keyUpSwitchs(keyCode);
|
||||
core.actions._keyUpSwitchs(keyCode);
|
||||
break;
|
||||
case 'settings':
|
||||
this._keyUpSettings(keyCode);
|
||||
core.actions._keyUpSettings(keyCode);
|
||||
break;
|
||||
case 'syncSave':
|
||||
this._keyUpSyncSave(keyCode);
|
||||
core.actions._keyUpSyncSave(keyCode);
|
||||
break;
|
||||
case 'syncSelect':
|
||||
this._keyUpSyncSelect(keyCode);
|
||||
core.actions._keyUpSyncSelect(keyCode);
|
||||
break;
|
||||
case 'localSaveSelect':
|
||||
this._keyUpLocalSaveSelect(keyCode);
|
||||
core.actions._keyUpLocalSaveSelect(keyCode);
|
||||
break;
|
||||
case 'storageRemove':
|
||||
this._keyUpStorageRemove(keyCode);
|
||||
core.actions._keyUpStorageRemove(keyCode);
|
||||
break;
|
||||
case 'cursor':
|
||||
this._keyUpCursor(keyCode);
|
||||
core.actions._keyUpCursor(keyCode);
|
||||
break;
|
||||
case 'replay':
|
||||
this._keyUpReplay(keyCode);
|
||||
core.actions._keyUpReplay(keyCode);
|
||||
break;
|
||||
case 'gameInfo':
|
||||
this._keyUpGameInfo(keyCode);
|
||||
core.actions._keyUpGameInfo(keyCode);
|
||||
break;
|
||||
case 'centerFly':
|
||||
this._keyUpCenterFly(keyCode);
|
||||
core.actions._keyUpCenterFly(keyCode);
|
||||
break;
|
||||
case 'paint':
|
||||
this._keyUpPaint(keyCode);
|
||||
core.actions._keyUpPaint(keyCode);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
@ -399,7 +399,7 @@ actions.prototype.ondown = function (loc) {
|
||||
actions.prototype._sys_ondown_paint = function (x, y, px, py) {
|
||||
// 画板
|
||||
if (core.status.played && (core.status.event || {}).id == 'paint') {
|
||||
this._ondownPaint(px, py);
|
||||
core.actions._ondownPaint(px, py);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -418,7 +418,7 @@ actions.prototype._sys_ondown_lockControl = function (x, y, px, py) {
|
||||
core.doAction();
|
||||
}
|
||||
else {
|
||||
this.onclick(x, y, []);
|
||||
core.actions.onclick(x, y, []);
|
||||
}
|
||||
|
||||
// --- 长按判定
|
||||
@ -456,7 +456,7 @@ actions.prototype.onmove = function (loc) {
|
||||
actions.prototype._sys_onmove_paint = function (x, y, px, py) {
|
||||
// 画板
|
||||
if (core.status.played && (core.status.event || {}).id == 'paint') {
|
||||
this._onmovePaint(px, py);
|
||||
core.actions._onmovePaint(px, py);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -492,7 +492,7 @@ actions.prototype.onup = function () {
|
||||
actions.prototype._sys_onup_paint = function () {
|
||||
// 画板
|
||||
if (core.status.played && (core.status.event || {}).id == 'paint') {
|
||||
this._onupPaint();
|
||||
core.actions._onupPaint();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -525,11 +525,11 @@ actions.prototype._sys_onup = function () {
|
||||
|
||||
// 长按
|
||||
if (!core.status.lockControl && stepPostfix.length == 0 && core.status.downTime != null && new Date() - core.status.downTime >= 1000) {
|
||||
this.longClick(posx, posy);
|
||||
core.actions.longClick(posx, posy);
|
||||
}
|
||||
else {
|
||||
//posx,posy是寻路的目标点,stepPostfix是后续的移动
|
||||
this.onclick(posx, posy, stepPostfix);
|
||||
core.actions.onclick(posx, posy, stepPostfix);
|
||||
}
|
||||
core.status.downTime = null;
|
||||
return true;
|
||||
@ -567,75 +567,75 @@ actions.prototype._sys_onclick_lockControl = function (x, y) {
|
||||
if (!core.status.lockControl) return false;
|
||||
switch (core.status.event.id) {
|
||||
case 'centerFly':
|
||||
this._clickCenterFly(x, y);
|
||||
core.actions._clickCenterFly(x, y);
|
||||
break;
|
||||
case 'book':
|
||||
this._clickBook(x, y);
|
||||
core.actions._clickBook(x, y);
|
||||
break;
|
||||
case 'book-detail':
|
||||
this._clickBookDetail(x, y);
|
||||
core.actions._clickBookDetail(x, y);
|
||||
break;
|
||||
case 'fly':
|
||||
this._clickFly(x, y);
|
||||
core.actions._clickFly(x, y);
|
||||
break;
|
||||
case 'viewMaps':
|
||||
this._clickViewMaps(x, y);
|
||||
core.actions._clickViewMaps(x, y);
|
||||
break;
|
||||
case 'switchs':
|
||||
this._clickSwitchs(x, y);
|
||||
core.actions._clickSwitchs(x, y);
|
||||
break;
|
||||
case 'settings':
|
||||
this._clickSettings(x, y);
|
||||
core.actions._clickSettings(x, y);
|
||||
break;
|
||||
case 'shop':
|
||||
this._clickShop(x, y);
|
||||
core.actions._clickShop(x, y);
|
||||
break;
|
||||
case 'selectShop':
|
||||
this._clickQuickShop(x, y);
|
||||
core.actions._clickQuickShop(x, y);
|
||||
break;
|
||||
case 'equipbox':
|
||||
this._clickEquipbox(x, y);
|
||||
core.actions._clickEquipbox(x, y);
|
||||
break;
|
||||
case 'toolbox':
|
||||
this._clickToolbox(x, y);
|
||||
core.actions._clickToolbox(x, y);
|
||||
break;
|
||||
case 'save':
|
||||
case 'load':
|
||||
case 'replayLoad':
|
||||
this._clickSL(x, y);
|
||||
core.actions._clickSL(x, y);
|
||||
break;
|
||||
case 'confirmBox':
|
||||
this._clickConfirmBox(x, y);
|
||||
core.actions._clickConfirmBox(x, y);
|
||||
break;
|
||||
case 'keyBoard':
|
||||
this._clickKeyBoard(x, y);
|
||||
core.actions._clickKeyBoard(x, y);
|
||||
break;
|
||||
case 'action':
|
||||
this._clickAction(x, y);
|
||||
core.actions._clickAction(x, y);
|
||||
break;
|
||||
case 'text':
|
||||
core.drawText();
|
||||
break;
|
||||
case 'syncSave':
|
||||
this._clickSyncSave(x, y);
|
||||
core.actions._clickSyncSave(x, y);
|
||||
break;
|
||||
case 'syncSelect':
|
||||
this._clickSyncSelect(x, y);
|
||||
core.actions._clickSyncSelect(x, y);
|
||||
break;
|
||||
case 'localSaveSelect':
|
||||
this._clickLocalSaveSelect(x, y);
|
||||
core.actions._clickLocalSaveSelect(x, y);
|
||||
break;
|
||||
case 'storageRemove':
|
||||
this._clickStorageRemove(x, y);
|
||||
core.actions._clickStorageRemove(x, y);
|
||||
break;
|
||||
case 'cursor':
|
||||
this._clickCursor(x, y);
|
||||
core.actions._clickCursor(x, y);
|
||||
break;
|
||||
case 'replay':
|
||||
this._clickReplay(x, y);
|
||||
core.actions._clickReplay(x, y);
|
||||
break;
|
||||
case 'gameInfo':
|
||||
this._clickGameInfo(x, y);
|
||||
core.actions._clickGameInfo(x, y);
|
||||
break;
|
||||
case 'about':
|
||||
case 'help':
|
||||
@ -668,8 +668,8 @@ actions.prototype._sys_onmousewheel = function (direct) {
|
||||
|
||||
// 楼层飞行器
|
||||
if (core.status.lockControl && core.status.event.id == 'fly') {
|
||||
if (direct == 1) core.ui.drawFly(this._getNextFlyFloor(1));
|
||||
if (direct == -1) core.ui.drawFly(this._getNextFlyFloor(-1));
|
||||
if (direct == 1) core.ui.drawFly(core.actions._getNextFlyFloor(1));
|
||||
if (direct == -1) core.ui.drawFly(core.actions._getNextFlyFloor(-1));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -689,8 +689,8 @@ actions.prototype._sys_onmousewheel = function (direct) {
|
||||
|
||||
// 浏览地图
|
||||
if (core.status.lockControl && core.status.event.id == 'viewMaps') {
|
||||
if (direct == 1) this._clickViewMaps(6, 3);
|
||||
if (direct == -1) this._clickViewMaps(6, 9);
|
||||
if (direct == 1) core.actions._clickViewMaps(6, 3);
|
||||
if (direct == -1) core.actions._clickViewMaps(6, 9);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -740,7 +740,7 @@ actions.prototype._sys_longClick_lockControl = function (x, y) {
|
||||
// 长按楼传器的箭头可以快速翻页
|
||||
if (core.status.event.id == 'fly') {
|
||||
if ((x == 10 || x == 11) && (y == 5 || y == 9)) {
|
||||
this._clickFly(x, y);
|
||||
core.actions._clickFly(x, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -774,12 +774,12 @@ actions.prototype._sys_longClick = function (x, y, fromEvent) {
|
||||
actions.prototype._selectChoices = function (length, keycode, callback) {
|
||||
var topIndex = 6 - parseInt((length - 1) / 2);
|
||||
if (keycode == 13 || keycode == 32 || keycode == 67) {
|
||||
callback(6, topIndex + core.status.event.selection);
|
||||
callback.apply(this, [6, topIndex + core.status.event.selection]);
|
||||
}
|
||||
if (keycode >= 49 && keycode <= 57) {
|
||||
var index = keycode - 49;
|
||||
if (index < length) {
|
||||
callback(6, topIndex + index);
|
||||
callback.apply(this, [6, topIndex + index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1754,53 +1754,24 @@ actions.prototype._clickSwitchs = function (x, y) {
|
||||
var topIndex = 6 - parseInt((choices.length - 1) / 2);
|
||||
if (y >= topIndex && y < topIndex + choices.length) {
|
||||
var selection = y - topIndex;
|
||||
core.status.event.selection = selection;
|
||||
switch (selection) {
|
||||
case 0:
|
||||
core.triggerBgm();
|
||||
core.ui.drawSwitchs();
|
||||
break;
|
||||
return this._clickSwitchs_bgm();
|
||||
case 1:
|
||||
core.musicStatus.soundStatus = !core.musicStatus.soundStatus;
|
||||
core.setLocalStorage('soundStatus', core.musicStatus.soundStatus);
|
||||
core.ui.drawSwitchs();
|
||||
break;
|
||||
return this._clickSwitchs_sound();
|
||||
case 2:
|
||||
core.flags.displayEnemyDamage = !core.flags.displayEnemyDamage;
|
||||
core.updateDamage();
|
||||
core.setLocalStorage('enemyDamage', core.flags.displayEnemyDamage);
|
||||
core.ui.drawSwitchs();
|
||||
break;
|
||||
return this._clickSwitchs_displayEnemyDamage();
|
||||
case 3:
|
||||
core.flags.displayCritical = !core.flags.displayCritical;
|
||||
core.updateDamage();
|
||||
core.setLocalStorage('critical', core.flags.displayCritical);
|
||||
core.ui.drawSwitchs();
|
||||
break;
|
||||
return this._clickSwitchs_displayCritical();
|
||||
case 4:
|
||||
core.flags.displayExtraDamage = !core.flags.displayExtraDamage;
|
||||
core.updateDamage();
|
||||
core.setLocalStorage('extraDamage', core.flags.displayExtraDamage);
|
||||
core.ui.drawSwitchs();
|
||||
break;
|
||||
return this._clickSwitchs_displayExtraDamage();
|
||||
case 5:
|
||||
core.platform.useLocalForage = !core.platform.useLocalForage;
|
||||
core.setLocalStorage('useLocalForage', core.platform.useLocalForage);
|
||||
core.control.getSaveIndexes(function (indexes) {
|
||||
core.saves.ids = indexes;
|
||||
});
|
||||
core.ui.drawSwitchs();
|
||||
break;
|
||||
return this._clickSwitchs_localForage();
|
||||
case 6:
|
||||
if (core.hasFlag('__noClickMove__')) core.removeFlag('__noClickMove__');
|
||||
else core.setFlag('__noClickMove__', true);
|
||||
core.ui.drawSwitchs();
|
||||
break;
|
||||
return this._clickSwitchs_clickMove();
|
||||
case 7:
|
||||
core.platform.extendKeyboard = !core.platform.extendKeyboard;
|
||||
core.setLocalStorage('extendKeyboard', core.platform.extendKeyboard);
|
||||
core.updateStatusBar();
|
||||
core.ui.drawSwitchs();
|
||||
break;
|
||||
return this._clickSwitchs_ExtendKeyboard();
|
||||
case 8:
|
||||
core.status.event.selection = 0;
|
||||
core.ui.drawSettings();
|
||||
@ -1809,6 +1780,60 @@ actions.prototype._clickSwitchs = function (x, y) {
|
||||
}
|
||||
}
|
||||
|
||||
actions.prototype._clickSwitchs_bgm = function () {
|
||||
core.triggerBgm();
|
||||
core.ui.drawSwitchs();
|
||||
}
|
||||
|
||||
actions.prototype._clickSwitchs_sound = function () {
|
||||
core.musicStatus.soundStatus = !core.musicStatus.soundStatus;
|
||||
core.setLocalStorage('soundStatus', core.musicStatus.soundStatus);
|
||||
core.ui.drawSwitchs();
|
||||
}
|
||||
|
||||
actions.prototype._clickSwitchs_displayEnemyDamage = function () {
|
||||
core.flags.displayEnemyDamage = !core.flags.displayEnemyDamage;
|
||||
core.updateDamage();
|
||||
core.setLocalStorage('enemyDamage', core.flags.displayEnemyDamage);
|
||||
core.ui.drawSwitchs();
|
||||
}
|
||||
|
||||
actions.prototype._clickSwitchs_displayCritical = function () {
|
||||
core.flags.displayCritical = !core.flags.displayCritical;
|
||||
core.updateDamage();
|
||||
core.setLocalStorage('critical', core.flags.displayCritical);
|
||||
core.ui.drawSwitchs();
|
||||
}
|
||||
|
||||
actions.prototype._clickSwitchs_displayExtraDamage = function () {
|
||||
core.flags.displayExtraDamage = !core.flags.displayExtraDamage;
|
||||
core.updateDamage();
|
||||
core.setLocalStorage('extraDamage', core.flags.displayExtraDamage);
|
||||
core.ui.drawSwitchs();
|
||||
}
|
||||
|
||||
actions.prototype._clickSwitchs_localForage = function () {
|
||||
core.platform.useLocalForage = !core.platform.useLocalForage;
|
||||
core.setLocalStorage('useLocalForage', core.platform.useLocalForage);
|
||||
core.control.getSaveIndexes(function (indexes) {
|
||||
core.saves.ids = indexes;
|
||||
});
|
||||
core.ui.drawSwitchs();
|
||||
}
|
||||
|
||||
actions.prototype._clickSwitchs_clickMove = function () {
|
||||
if (core.hasFlag('__noClickMove__')) core.removeFlag('__noClickMove__');
|
||||
else core.setFlag('__noClickMove__', true);
|
||||
core.ui.drawSwitchs();
|
||||
}
|
||||
|
||||
actions.prototype._clickSwitchs_ExtendKeyboard = function () {
|
||||
core.platform.extendKeyboard = !core.platform.extendKeyboard;
|
||||
core.setLocalStorage('extendKeyboard', core.platform.extendKeyboard);
|
||||
core.updateStatusBar();
|
||||
core.ui.drawSwitchs();
|
||||
}
|
||||
|
||||
////// 系统设置界面时,放开某个键的操作 //////
|
||||
actions.prototype._keyUpSwitchs = function (keycode) {
|
||||
if (keycode == 27 || keycode == 88) {
|
||||
@ -1826,7 +1851,7 @@ actions.prototype._clickSettings = function (x, y) {
|
||||
var topIndex = 6 - parseInt((choices.length - 1) / 2);
|
||||
if (y >= topIndex && y < topIndex + choices.length) {
|
||||
var selection = y - topIndex;
|
||||
|
||||
core.status.event.selection = selection;
|
||||
switch (selection) {
|
||||
case 0:
|
||||
core.status.event.selection = 0;
|
||||
@ -1836,11 +1861,11 @@ actions.prototype._clickSettings = function (x, y) {
|
||||
core.ui.drawKeyBoard();
|
||||
break;
|
||||
case 2:
|
||||
core.clearLastEvent();
|
||||
core.clearSelector();
|
||||
core.ui.drawMaps();
|
||||
break;
|
||||
case 3:
|
||||
core.clearLastEvent();
|
||||
core.clearSelector();
|
||||
core.ui.drawPaint();
|
||||
break;
|
||||
case 4:
|
||||
@ -1852,15 +1877,7 @@ actions.prototype._clickSettings = function (x, y) {
|
||||
core.ui.drawGameInfo();
|
||||
break;
|
||||
case 6:
|
||||
core.status.event.selection = 1;
|
||||
core.ui.drawConfirmBox("你确定要返回标题页面吗?", function () {
|
||||
core.ui.closePanel();
|
||||
core.restart();
|
||||
}, function () {
|
||||
core.status.event.selection = 3;
|
||||
core.ui.drawSettings();
|
||||
});
|
||||
break;
|
||||
return core.confirmRestart(true);
|
||||
case 7:
|
||||
core.ui.closePanel();
|
||||
break;
|
||||
@ -1885,9 +1902,9 @@ actions.prototype._clickSyncSave = function (x, y) {
|
||||
var topIndex = 6 - parseInt((choices.length - 1) / 2);
|
||||
if (y >= topIndex && y < topIndex + choices.length) {
|
||||
var selection = y - topIndex;
|
||||
core.status.event.selection = selection;
|
||||
switch (selection) {
|
||||
case 0:
|
||||
// core.syncSave("save");
|
||||
core.status.event.selection = 0;
|
||||
core.ui.drawSyncSelect();
|
||||
break;
|
||||
@ -1899,65 +1916,11 @@ actions.prototype._clickSyncSave = function (x, y) {
|
||||
core.ui.drawLocalSaveSelect();
|
||||
break;
|
||||
case 3:
|
||||
core.readFile(function (obj) {
|
||||
if (obj.name != core.firstData.name) {
|
||||
alert("存档和游戏不一致!");
|
||||
return;
|
||||
}
|
||||
if (obj.version != core.firstData.version) {
|
||||
alert("游戏版本不一致!");
|
||||
return;
|
||||
}
|
||||
if (!obj.data) {
|
||||
alert("无效的存档!");
|
||||
return;
|
||||
}
|
||||
var data = obj.data;
|
||||
|
||||
if (data instanceof Array) {
|
||||
core.ui.drawConfirmBox("所有本地存档都将被覆盖,确认?", function () {
|
||||
for (var i = 1; i <= 5 * (main.savePages || 30); i++) {
|
||||
if (i <= data.length) {
|
||||
core.setLocalForage("save" + i, data[i - 1]);
|
||||
}
|
||||
else {
|
||||
if (core.saves.ids[i])
|
||||
core.removeLocalForage("save" + i);
|
||||
}
|
||||
}
|
||||
core.ui.closePanel();
|
||||
core.drawText("读取成功!\n你的本地所有存档均已被覆盖。");
|
||||
}, function () {
|
||||
core.status.event.selection = 0;
|
||||
core.ui.drawSyncSave();
|
||||
})
|
||||
}
|
||||
else {
|
||||
// core.setLocalStorage("save"+core.saves.saveIndex, data);
|
||||
core.setLocalForage("save" + core.saves.saveIndex, data, function () {
|
||||
core.drawText("同步成功!\n单存档已覆盖至存档" + core.saves.saveIndex);
|
||||
})
|
||||
}
|
||||
}, function () {
|
||||
|
||||
});
|
||||
break;
|
||||
return this._clickSyncSave_readFile();
|
||||
case 4:
|
||||
core.status.event.selection = 0;
|
||||
core.ui.drawReplay();
|
||||
break;
|
||||
return this._clickSyncSave_replay();
|
||||
case 5:
|
||||
if (core.hasFlag('debug')) {
|
||||
core.drawText("\t[系统提示]调试模式下无法下载录像");
|
||||
break;
|
||||
}
|
||||
core.download(core.firstData.name + "_" + core.formatDate2(new Date()) + ".h5route", JSON.stringify({
|
||||
'name': core.firstData.name,
|
||||
'hard': core.status.hard,
|
||||
'seed': core.getFlag('__seed__'),
|
||||
'route': core.encodeRoute(core.status.route)
|
||||
}));
|
||||
break;
|
||||
return this._clickSyncSave_download();
|
||||
case 6:
|
||||
core.status.event.selection = 0;
|
||||
core.ui.drawStorageRemove();
|
||||
@ -1972,6 +1935,38 @@ actions.prototype._clickSyncSave = function (x, y) {
|
||||
return;
|
||||
}
|
||||
|
||||
actions.prototype._clickSyncSave_readFile = function () {
|
||||
core.readFile(function (obj) {
|
||||
if (obj.name != core.firstData.name) return alert("存档和游戏不一致!");
|
||||
if (obj.version != core.firstData.version) return alert("游戏版本不一致!");
|
||||
if (!obj.data) return alert("无效的存档!");
|
||||
core.control._syncLoad_write(obj.data);
|
||||
});
|
||||
}
|
||||
|
||||
actions.prototype._clickSyncSave_replay = function () {
|
||||
if (core.hasFlag('debug')) {
|
||||
core.drawText("\t[系统提示]调试模式下无法回放录像");
|
||||
}
|
||||
else {
|
||||
core.status.event.selection = 0;
|
||||
core.ui.drawReplay();
|
||||
}
|
||||
}
|
||||
|
||||
actions.prototype._clickSyncSave_download = function () {
|
||||
if (core.hasFlag('debug')) {
|
||||
core.drawText("\t[系统提示]调试模式下无法下载录像");
|
||||
return;
|
||||
}
|
||||
core.download(core.firstData.name + "_" + core.formatDate2() + ".h5route", JSON.stringify({
|
||||
'name': core.firstData.name,
|
||||
'hard': core.status.hard,
|
||||
'seed': core.getFlag('__seed__'),
|
||||
'route': core.encodeRoute(core.status.route)
|
||||
}));
|
||||
}
|
||||
|
||||
////// 同步存档界面时,放开某个键的操作 //////
|
||||
actions.prototype._keyUpSyncSave = function (keycode) {
|
||||
if (keycode == 27 || keycode == 88) {
|
||||
@ -1990,6 +1985,7 @@ actions.prototype._clickSyncSelect = function (x, y) {
|
||||
var topIndex = 6 - parseInt((choices.length - 1) / 2);
|
||||
if (y >= topIndex && y < topIndex + choices.length) {
|
||||
var selection = y - topIndex;
|
||||
core.status.event.selection = selection;
|
||||
switch (selection) {
|
||||
case 0:
|
||||
core.syncSave('all');
|
||||
@ -2024,6 +2020,7 @@ actions.prototype._clickLocalSaveSelect = function (x, y) {
|
||||
|
||||
if (y >= topIndex && y < topIndex + choices.length) {
|
||||
var selection = y - topIndex;
|
||||
core.status.event.selection = selection;
|
||||
if (selection < 2) {
|
||||
core.control.getSaves(selection == 0 ? null : core.saves.saveIndex, function (saves) {
|
||||
if (saves) {
|
||||
@ -2036,10 +2033,10 @@ actions.prototype._clickLocalSaveSelect = function (x, y) {
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
core.status.event.selection = 2;
|
||||
core.ui.drawSyncSave();
|
||||
core.status.event.selection = 2;
|
||||
core.ui.drawSyncSave();
|
||||
}
|
||||
}
|
||||
|
||||
////// 存档下载界面时,放开某个键的操作 //////
|
||||
@ -2061,57 +2058,12 @@ actions.prototype._clickStorageRemove = function (x, y) {
|
||||
|
||||
if (y >= topIndex && y < topIndex + choices.length) {
|
||||
var selection = y - topIndex;
|
||||
core.status.event.selection = selection;
|
||||
switch (selection) {
|
||||
case 0:
|
||||
core.myconfirm("你确定要清除【全部塔】的所有本地存档?\n此行为不可逆!!!", function () {
|
||||
if (core.platform.useLocalForage) {
|
||||
core.ui.drawWaiting("正在清空,请稍后...");
|
||||
localforage.clear(function () {
|
||||
core.ui.closePanel();
|
||||
core.drawText("\t[操作成功]你的所有存档已被清空。");
|
||||
core.saves.saveIndex = 1;
|
||||
core.removeLocalStorage('saveIndex');
|
||||
});
|
||||
}
|
||||
else {
|
||||
localStorage.clear();
|
||||
core.drawText("\t[操作成功]你的所有存档已被清空。");
|
||||
core.saves.saveIndex = 1;
|
||||
core.removeLocalStorage('saveIndex');
|
||||
}
|
||||
});
|
||||
break;
|
||||
return this._clickStorageRemove_all();
|
||||
case 1:
|
||||
core.myconfirm("你确定要清除本塔的所有本地存档?\n此行为不可逆!!!", function () {
|
||||
if (core.platform.useLocalForage) {
|
||||
core.ui.drawWaiting("正在清空,请稍后...");
|
||||
Object.keys(core.saves.ids).forEach(function (v) {
|
||||
if (v != 0)
|
||||
core.removeLocalForage("save" + v);
|
||||
});
|
||||
core.removeLocalForage("autoSave", function () {
|
||||
core.saves.autosave.data = null;
|
||||
core.saves.autosave.updated = false;
|
||||
core.ui.closePanel();
|
||||
core.drawText("\t[操作成功]当前塔的存档已被清空。");
|
||||
core.saves.saveIndex = 1;
|
||||
core.removeLocalStorage('saveIndex');
|
||||
});
|
||||
}
|
||||
else {
|
||||
Object.keys(core.saves.ids).forEach(function (v) {
|
||||
if (v != 0)
|
||||
core.removeLocalStorage("save" + v);
|
||||
});
|
||||
core.removeLocalStorage("autoSave");
|
||||
core.saves.autosave.data = null;
|
||||
core.saves.autosave.updated = false;
|
||||
core.drawText("\t[操作成功]当前塔的存档已被清空。");
|
||||
core.saves.saveIndex = 1;
|
||||
core.removeLocalStorage('saveIndex');
|
||||
}
|
||||
break;
|
||||
});
|
||||
return this._clickStorageRemove_current();
|
||||
case 2:
|
||||
core.status.event.selection = 6;
|
||||
core.ui.drawSyncSave();
|
||||
@ -2120,6 +2072,54 @@ actions.prototype._clickStorageRemove = function (x, y) {
|
||||
}
|
||||
}
|
||||
|
||||
actions.prototype._clickStorageRemove_all = function () {
|
||||
core.myconfirm("你确定要清除【全部塔】的所有本地存档?\n此行为不可逆!!!", function () {
|
||||
var done = function () {
|
||||
core.saves.autosave.data = null;
|
||||
core.saves.autosave.updated = false;
|
||||
core.ui.closePanel();
|
||||
core.drawText("\t[操作成功]你的所有存档已被清空。");
|
||||
core.saves.saveIndex = 1;
|
||||
core.removeLocalStorage('saveIndex');
|
||||
};
|
||||
if (core.platform.useLocalForage) {
|
||||
core.ui.drawWaiting("正在清空,请稍后...");
|
||||
localforage.clear(done);
|
||||
}
|
||||
else {
|
||||
localStorage.clear();
|
||||
done();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
actions.prototype._clickStorageRemove_current = function () {
|
||||
core.myconfirm("你确定要清除本塔的所有本地存档?\n此行为不可逆!!!", function () {
|
||||
var done = function () {
|
||||
core.saves.autosave.data = null;
|
||||
core.saves.autosave.updated = false;
|
||||
core.ui.closePanel();
|
||||
core.drawText("\t[操作成功]当前塔的存档已被清空。");
|
||||
core.saves.saveIndex = 1;
|
||||
core.removeLocalStorage('saveIndex');
|
||||
}
|
||||
if (core.platform.useLocalForage) {
|
||||
core.ui.drawWaiting("正在清空,请稍后...");
|
||||
Object.keys(core.saves.ids).forEach(function (v) {
|
||||
core.removeLocalForage("save" + v);
|
||||
});
|
||||
core.removeLocalForage("autoSave", done);
|
||||
}
|
||||
else {
|
||||
Object.keys(core.saves.ids).forEach(function (v) {
|
||||
core.removeLocalStorage("save" + v);
|
||||
});
|
||||
core.removeLocalStorage("autoSave");
|
||||
done();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
////// 存档删除界面时,放开某个键的操作 //////
|
||||
actions.prototype._keyUpStorageRemove = function (keycode) {
|
||||
if (keycode == 27 || keycode == 88) {
|
||||
@ -2139,44 +2139,42 @@ actions.prototype._clickReplay = function (x, y) {
|
||||
|
||||
if (y >= topIndex && y < topIndex + choices.length) {
|
||||
var selection = y - topIndex;
|
||||
core.status.event.selection = selection;
|
||||
switch (selection) {
|
||||
case 0: {
|
||||
core.ui.closePanel();
|
||||
core.startGame(core.status.hard, core.getFlag('__seed__'), core.clone(core.status.route));
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
core.status.event.id = 'replayLoad';
|
||||
core.status.event.selection = null;
|
||||
core.ui.clearLastEvent();
|
||||
var saveIndex = core.saves.saveIndex;
|
||||
var page = parseInt((saveIndex - 1) / 5), offset = saveIndex - 5 * page;
|
||||
core.ui.drawSLPanel(10 * page + offset);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
core.chooseReplayFile();
|
||||
break;
|
||||
case 3:
|
||||
if (core.hasFlag('debug')) {
|
||||
core.drawText("\t[系统提示]调试模式下无法下载录像");
|
||||
break;
|
||||
}
|
||||
core.download(core.firstData.name + "_" + core.formatDate2(new Date()) + ".h5route", JSON.stringify({
|
||||
'name': core.firstData.name,
|
||||
'hard': core.status.hard,
|
||||
'seed': core.getFlag('__seed__'),
|
||||
'route': core.encodeRoute(core.status.route)
|
||||
}));
|
||||
break;
|
||||
break;
|
||||
case 4:
|
||||
core.ui.closePanel();
|
||||
break;
|
||||
case 0: return this._clickReplay_fromBeginning();
|
||||
case 1: return this._clickReplay_fromLoad();
|
||||
case 2: return core.chooseReplayFile();
|
||||
case 3: return this._clickReplay_download();
|
||||
case 4: return core.ui.closePanel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
actions.prototype._clickReplay_fromBeginning = function () {
|
||||
core.ui.closePanel();
|
||||
core.startGame(core.status.hard, core.getFlag('__seed__'), core.clone(core.status.route));
|
||||
}
|
||||
|
||||
actions.prototype._clickReplay_fromLoad = function () {
|
||||
core.status.event.id = 'replayLoad';
|
||||
core.status.event.selection = null;
|
||||
core.ui.clearSelector();
|
||||
var saveIndex = core.saves.saveIndex;
|
||||
var page = parseInt((saveIndex - 1) / 5), offset = saveIndex - 5 * page;
|
||||
core.ui.drawSLPanel(10 * page + offset);
|
||||
}
|
||||
|
||||
actions.prototype._clickReplay_download = function () {
|
||||
if (core.hasFlag('debug')) return core.drawText("\t[系统提示]调试模式下无法下载录像");
|
||||
core.download(core.firstData.name + "_" + core.formatDate2() + ".h5route", JSON.stringify({
|
||||
'name': core.firstData.name,
|
||||
'hard': core.status.hard,
|
||||
'seed': core.getFlag('__seed__'),
|
||||
'route': core.encodeRoute(core.status.route)
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
////// 回放选择界面时,放开某个键的操作 //////
|
||||
actions.prototype._keyUpReplay = function (keycode) {
|
||||
if (keycode == 27 || keycode == 88) {
|
||||
@ -2195,41 +2193,14 @@ actions.prototype._clickGameInfo = function (x, y) {
|
||||
|
||||
if (y >= topIndex && y < topIndex + choices.length) {
|
||||
var selection = y - topIndex;
|
||||
core.status.event.selection = selection;
|
||||
switch (selection) {
|
||||
case 0:
|
||||
core.ui.drawStatistics();
|
||||
break;
|
||||
case 1:
|
||||
if (core.platform.isPC)
|
||||
window.open("editor.html", "_blank");
|
||||
else {
|
||||
core.myconfirm("即将离开本塔,跳转至本塔工程页面,确认?", function () {
|
||||
window.location.href = "editor-mobile.html";
|
||||
});
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (core.platform.isPC) {
|
||||
window.open("/score.php?name=" + core.firstData.name + "&num=10", "_blank");
|
||||
}
|
||||
else {
|
||||
core.myconfirm("即将离开本塔,跳转至本塔评论页面,确认?", function () {
|
||||
window.location.href = "/score.php?name=" + core.firstData.name + "&num=10";
|
||||
});
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
core.ui.drawHelp();
|
||||
break;
|
||||
case 4:
|
||||
core.ui.drawAbout();
|
||||
break;
|
||||
case 5:
|
||||
if (core.platform.isPC)
|
||||
window.open(core.firstData.name + ".zip");
|
||||
else
|
||||
window.location.href = core.firstData.name + ".zip";
|
||||
break;
|
||||
case 0: return core.ui.drawStatistics();
|
||||
case 1: return this._clickGameInfo_openProject();
|
||||
case 2: return this._clickGameInfo_openComments();
|
||||
case 3: return core.ui.drawHelp();
|
||||
case 4: return core.ui.drawAbout();
|
||||
case 5: return this._clickGameInfo_download();
|
||||
case 6:
|
||||
core.status.event.selection = 5;
|
||||
core.ui.drawSettings();
|
||||
@ -2238,6 +2209,34 @@ actions.prototype._clickGameInfo = function (x, y) {
|
||||
}
|
||||
}
|
||||
|
||||
actions.prototype._clickGameInfo_openProject = function () {
|
||||
if (core.platform.isPC)
|
||||
window.open("editor.html", "_blank");
|
||||
else {
|
||||
core.myconfirm("即将离开本塔,跳转至本塔工程页面,确认?", function () {
|
||||
window.location.href = "editor-mobile.html";
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
actions.prototype._clickGameInfo_openComments = function () {
|
||||
if (core.platform.isPC) {
|
||||
window.open("/score.php?name=" + core.firstData.name + "&num=10", "_blank");
|
||||
}
|
||||
else {
|
||||
core.myconfirm("即将离开本塔,跳转至本塔评论页面,确认?", function () {
|
||||
window.location.href = "/score.php?name=" + core.firstData.name + "&num=10";
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
actions.prototype._clickGameInfo_download = function () {
|
||||
if (core.platform.isPC)
|
||||
window.open(core.firstData.name + ".zip");
|
||||
else
|
||||
window.location.href = core.firstData.name + ".zip";
|
||||
}
|
||||
|
||||
////// 游戏信息界面时,放开某个键的操作 //////
|
||||
actions.prototype._keyUpGameInfo = function (keycode) {
|
||||
if (keycode == 27 || keycode == 88) {
|
||||
|
||||
@ -69,7 +69,7 @@ control.prototype._setRequestAnimationFrame = function () {
|
||||
if (b.func) {
|
||||
try {
|
||||
if (core.isPlaying() || !b.needPlaying)
|
||||
core.doFunc(b.func, timestamp);
|
||||
core.doFunc(b.func, core.control, timestamp);
|
||||
}
|
||||
catch (e) {
|
||||
main.log(e);
|
||||
@ -297,7 +297,7 @@ control.prototype._animationFrame_weather_fog = function () {
|
||||
}
|
||||
|
||||
control.prototype._animationFrame_parallelDo = function (timestamp) {
|
||||
functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a.plugins.parallelDo(timestamp);
|
||||
core.control.controldata.parallelDo(timestamp);
|
||||
}
|
||||
|
||||
control.prototype._animationFrame_checkConsoleOpened = function (timestamp) {
|
||||
@ -357,6 +357,24 @@ control.prototype.restart = function() {
|
||||
core.playBgm(main.startBgm);
|
||||
}
|
||||
|
||||
////// 询问是否需要重新开始 //////
|
||||
control.prototype.confirmRestart = function (fromSettings) {
|
||||
core.status.event.selection = 1;
|
||||
core.ui.drawConfirmBox("你确定要返回标题页面吗?", function () {
|
||||
core.ui.closePanel();
|
||||
core.restart();
|
||||
}, function () {
|
||||
if (fromSettings) {
|
||||
core.status.event.selection = 3;
|
||||
core.ui.drawSettings();
|
||||
}
|
||||
else {
|
||||
core.ui.closePanel();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
////// 清除游戏状态和数据 //////
|
||||
control.prototype.clearStatus = function() {
|
||||
// 停止各个Timeout和Interval
|
||||
@ -607,8 +625,6 @@ control.prototype.moveAction = function (callback) {
|
||||
}
|
||||
|
||||
control.prototype._moveAction_noPass = function (canMove, callback) {
|
||||
if (core.status.event.id!='ski')
|
||||
core.status.route.push(core.getHeroLoc('direction'));
|
||||
core.status.automaticRoute.moveStepBeforeStop = [];
|
||||
core.status.automaticRoute.lastDirection = core.getHeroLoc('direction');
|
||||
if (canMove) core.events._trigger(core.nextX(), core.nextY());
|
||||
@ -625,8 +641,6 @@ control.prototype._moveAction_moving = function (callback) {
|
||||
core.setHeroMoveInterval(function () {
|
||||
var direction = core.getHeroLoc('direction');
|
||||
core.control._moveAction_popAutomaticRoute();
|
||||
if (core.status.event.id!='ski')
|
||||
core.status.route.push(direction);
|
||||
|
||||
// 无事件的道具(如血瓶)需要优先于阻激夹域判定
|
||||
var nowx = core.getHeroLoc('x'), nowy = core.getHeroLoc('y');
|
||||
@ -639,10 +653,17 @@ control.prototype._moveAction_moving = function (callback) {
|
||||
}
|
||||
// 执行该点的阻激夹域事件
|
||||
core.checkBlock();
|
||||
|
||||
// 执行该点事件
|
||||
if (!hasTrigger)
|
||||
core.events._trigger(nowx, nowy);
|
||||
core.updateStatusBar();
|
||||
|
||||
// 检查该点是否是滑冰
|
||||
if (core.getBgFgNumber('bg') == 167) {
|
||||
core.insertAction("滑冰事件", null, null, null, true);
|
||||
}
|
||||
|
||||
if (callback) callback();
|
||||
});
|
||||
}
|
||||
@ -1239,7 +1260,7 @@ control.prototype.unregisterReplayAction = function (name) {
|
||||
control.prototype._doReplayAction = function (action) {
|
||||
for (var i in this.replayActions) {
|
||||
try {
|
||||
if (core.doFunc(this.replayActions[i].func, action)) return true;
|
||||
if (core.doFunc(this.replayActions[i].func, this, action)) return true;
|
||||
} catch (e) {
|
||||
main.log(e);
|
||||
main.log("ERROR in replayActions["+this.replayActions[i].name+"]:已自动注销该项。");
|
||||
@ -1411,7 +1432,7 @@ control.prototype._replayAction_shop = function (action) {
|
||||
}
|
||||
|
||||
control.prototype._replayAction_turn = function (action) {
|
||||
if (action != 'turn' || action.indexOf('turn:') != 0) return false;
|
||||
if (action != 'turn' && action.indexOf('turn:') != 0) return false;
|
||||
if (action == 'turn') core.turnHero();
|
||||
else core.turnHero(action.substring(5));
|
||||
setTimeout(core.replay);
|
||||
@ -1558,7 +1579,7 @@ control.prototype._doSL_replayLoad = function (id) {
|
||||
else{
|
||||
core.getLocalForage(id=='autoSave'?id:"save"+id, null, function(data) {
|
||||
if (id == 'autoSave') core.saves.autosave.data = core.clone(data);
|
||||
core.control._doSL_replayLoad_afterGet(data);
|
||||
core.control._doSL_replayLoad_afterGet(id, data);
|
||||
}, function(err) {
|
||||
main.log(err);
|
||||
alert("无效的存档");
|
||||
@ -1946,10 +1967,10 @@ control.prototype.setFg = function(color, time, callback) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._setFg_animate(core.status.curtainColor, color, callback);
|
||||
this._setFg_animate(core.status.curtainColor, color, time, callback);
|
||||
}
|
||||
|
||||
control.prototype._setFg_animate = function (nowColor, color, callback) {
|
||||
control.prototype._setFg_animate = function (nowColor, color, time, callback) {
|
||||
var per_time = 10, step = parseInt(time / per_time);
|
||||
var animate = setInterval(function() {
|
||||
nowColor = [
|
||||
@ -1962,7 +1983,7 @@ control.prototype._setFg_animate = function (nowColor, color, callback) {
|
||||
core.fillRect('curtain', 0, 0, core.__PIXELS__, core.__PIXELS__, core.arrayToRGBA(nowColor));
|
||||
step--;
|
||||
if (step <= 0) {
|
||||
delete core.animate.asyncId[animate];
|
||||
delete core.animateFrame.asyncId[animate];
|
||||
clearInterval(animate);
|
||||
core.status.curtainColor = color;
|
||||
if (core.isset(callback)) callback();
|
||||
@ -2375,7 +2396,7 @@ control.prototype.unregisterResize = function (name) {
|
||||
control.prototype._doResize = function (obj) {
|
||||
for (var i in this.resizes) {
|
||||
try {
|
||||
if (core.doFunc(this.resizes[i].func, obj)) return true;
|
||||
if (core.doFunc(this.resizes[i].func, this, obj)) return true;
|
||||
} catch (e) {
|
||||
main.log(e);
|
||||
main.log("ERROR in resizes["+this.resizes[i].name+"]:已自动注销该项。");
|
||||
|
||||
41
libs/core.js
41
libs/core.js
@ -20,7 +20,7 @@ function core() {
|
||||
'events': {}
|
||||
}
|
||||
this.timeout = {
|
||||
'getItemTipTimeout': null,
|
||||
'tipTimeout': null,
|
||||
'turnHeroTimeout': null,
|
||||
'onDownTimeout': null,
|
||||
'sleepTimeout': null,
|
||||
@ -194,7 +194,6 @@ function core() {
|
||||
},
|
||||
'curtainColor': null,
|
||||
'openingDoor': null,
|
||||
'isSkiing': false,
|
||||
|
||||
// 动画
|
||||
'globalAnimateObjs': [],
|
||||
@ -242,8 +241,6 @@ core.prototype._init_flags = function () {
|
||||
document.getElementById("startLogo").innerHTML = core.firstData.title;
|
||||
(core.firstData.shops||[]).forEach(function (t) { core.initStatus.shops[t.id] = t; });
|
||||
core.maps._setFloorSize();
|
||||
// 初始化地图
|
||||
core.initStatus.maps = core.maps.initMaps(core.floorIds);
|
||||
// 初始化怪物、道具等
|
||||
core.material.enemys = core.enemys.getEnemys();
|
||||
core.material.items = core.items.getItems();
|
||||
@ -337,17 +334,32 @@ core.prototype._init_others = function () {
|
||||
}
|
||||
|
||||
core.prototype._afterLoadResources = function (callback) {
|
||||
// 初始化地图
|
||||
core.initStatus.maps = core.maps.initMaps(core.floorIds);
|
||||
core.control._setRequestAnimationFrame();
|
||||
|
||||
core.plugin = new function () {};
|
||||
core.plugin.__init__ = functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a.plugins.plugin;
|
||||
core.plugin.__init__();
|
||||
core._forwardFunc("plugin");
|
||||
|
||||
core._initPlugins();
|
||||
core.showStartAnimate();
|
||||
if (callback) callback();
|
||||
}
|
||||
|
||||
core.prototype._initPlugins = function () {
|
||||
core.plugin = new function () {};
|
||||
|
||||
for (var name in plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1) {
|
||||
if (plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1[name] instanceof Function) {
|
||||
try {
|
||||
plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1[name].apply(core.plugin);
|
||||
}
|
||||
catch (e) {
|
||||
main.log(e);
|
||||
main.log("无法初始化插件"+name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
core._forwardFunc("plugin");
|
||||
}
|
||||
|
||||
core.prototype._forwardFuncs = function () {
|
||||
for (var i = 0; i < main.loadList.length; ++i) {
|
||||
var name = main.loadList[i];
|
||||
@ -376,9 +388,12 @@ core.prototype._forwardFunc = function (name, funcname) {
|
||||
eval("core." + funcname + " = function (" + parameters + ") {\n\treturn core." + name + "." + funcname + "(" + parameters + ");\n}");
|
||||
}
|
||||
|
||||
core.prototype.doFunc = function (func) {
|
||||
if (typeof func == 'string') func = core.plugin[func];
|
||||
return func.apply(this, Array.prototype.slice.call(arguments, 1));
|
||||
core.prototype.doFunc = function (func, _this) {
|
||||
if (typeof func == 'string') {
|
||||
func = core.plugin[func];
|
||||
_this = core.plugin;
|
||||
}
|
||||
return func.apply(_this, Array.prototype.slice.call(arguments, 2));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
105
libs/events.js
105
libs/events.js
@ -247,7 +247,7 @@ events.prototype.unregisterSystemEvent = function (type) {
|
||||
events.prototype.doSystemEvent = function (type, data, callback) {
|
||||
if (this.systemEvents[type]) {
|
||||
try {
|
||||
return core.doFunc(this.systemEvents[type], data, data, callback);
|
||||
return core.doFunc(this.systemEvents[type], this, data, data, callback);
|
||||
}
|
||||
catch (e) {
|
||||
main.log(e);
|
||||
@ -264,14 +264,12 @@ events.prototype._trigger = function (x, y) {
|
||||
// 如果已经死亡,或正处于某事件中,则忽略
|
||||
if (core.status.gameOver || core.status.event.id) return;
|
||||
|
||||
core.status.isSkiing = false;
|
||||
var block = core.getBlock(x, y);
|
||||
if (block == null) return;
|
||||
block = block.block;
|
||||
if (block.event.trigger) {
|
||||
var noPass = block.event.noPass, trigger = block.event.trigger;
|
||||
if (noPass) core.clearAutomaticRouteNode(x, y);
|
||||
if (trigger == 'ski') core.status.isSkiing = true;
|
||||
|
||||
// 转换楼层能否穿透
|
||||
if (trigger == 'changeFloor' && !noPass && this._trigger_ignoreChangeFloor(block))
|
||||
@ -346,10 +344,15 @@ events.prototype._sys_openDoor = function (data, callback) {
|
||||
events.prototype.openDoor = function (id, x, y, needKey, callback) {
|
||||
id = id || core.getBlockId(x, y);
|
||||
core.saveAndStopAutomaticRoute();
|
||||
if (!this._openDoor_check(id, x, y, needKey)) return false;
|
||||
if (!this._openDoor_check(id, x, y, needKey)) {
|
||||
core.waitHeroToStop(function () {
|
||||
core.unLockControl();
|
||||
if (callback) callback();
|
||||
});
|
||||
return;
|
||||
}
|
||||
core.playSound("door.mp3");
|
||||
this._openDoor_animate(id, x, y, callback);
|
||||
return true;
|
||||
}
|
||||
|
||||
events.prototype._openDoor_check = function (id, x, y, needKey) {
|
||||
@ -663,29 +666,7 @@ events.prototype.afterChangeLight = function (x, y) {
|
||||
}
|
||||
|
||||
events.prototype._sys_ski = function (data, callback) {
|
||||
this.ski();
|
||||
if (callback) callback();
|
||||
}
|
||||
|
||||
////// 滑冰 //////
|
||||
events.prototype.ski = function (direction) {
|
||||
if (!direction)
|
||||
direction = core.status.automaticRoute.lastDirection || core.getHeroLoc('direction');
|
||||
if (core.status.event.id != 'ski') {
|
||||
core.waitHeroToStop(function () {
|
||||
core.status.event.id = 'ski';
|
||||
core.events.ski(direction);
|
||||
});
|
||||
}
|
||||
else {
|
||||
core.moveHero(direction, function () {
|
||||
if (core.status.event.id == 'ski' && !core.status.isSkiing) {
|
||||
core.status.event.id = null;
|
||||
core.unLockControl();
|
||||
core.replay();
|
||||
}
|
||||
})
|
||||
}
|
||||
core.insertAction(["V2.6后,请将滑冰放在背景层!"], data.x, data.y, callback);
|
||||
}
|
||||
|
||||
events.prototype._sys_action = function (data, callback) {
|
||||
@ -722,7 +703,7 @@ events.prototype.doEvent = function (data, x, y, prefix) {
|
||||
var type = data.type;
|
||||
if (this.actions[type]) {
|
||||
try {
|
||||
return core.doFunc(this.actions[type], data, x, y, prefix);
|
||||
return core.doFunc(this.actions[type], this, data, x, y, prefix);
|
||||
}
|
||||
catch (e) {
|
||||
main.log(e);
|
||||
@ -755,7 +736,8 @@ events.prototype.setEvents = function (list, x, y, callback) {
|
||||
if (x != null) data.x = x;
|
||||
if (y != null) data.y = y;
|
||||
if (callback) data.callback = callback;
|
||||
core.status.event = {id: 'action', data: data};
|
||||
core.status.event.id = 'action';
|
||||
core.status.event.data = data;
|
||||
}
|
||||
|
||||
////// 执行当前自定义事件列表中的下一个事件 //////
|
||||
@ -764,12 +746,12 @@ events.prototype.doAction = function () {
|
||||
core.status.boxAnimateObjs = [];
|
||||
clearInterval(core.status.event.interval);
|
||||
core.status.event.interval = null;
|
||||
core.clearLastEvent();
|
||||
core.clearSelector();
|
||||
// 判定是否执行完毕
|
||||
if (this._doAction_finishEvents()) return;
|
||||
// 当前点坐标和前缀
|
||||
var x = core.status.event.data.x, y = core.status.event.data.y;
|
||||
var prefix = [core.status.floorId || "f", x != null ? x : "x", y != null ? y : "y"].join("@");
|
||||
var prefix = [core.status.floorId || ":f", x != null ? x : "x", y != null ? y : "y"].join("@");
|
||||
var current = core.status.event.data.list[0];
|
||||
if (this._popEvents(current, prefix)) return;
|
||||
// 当前要执行的事件
|
||||
@ -809,7 +791,7 @@ events.prototype._popEvents = function (current, prefix) {
|
||||
}
|
||||
|
||||
////// 往当前事件列表之前添加一个或多个事件 //////
|
||||
events.prototype.insertAction = function (action, x, y, callback) {
|
||||
events.prototype.insertAction = function (action, x, y, callback, addToLast) {
|
||||
if (core.hasFlag("__statistics__")) return;
|
||||
if (core.status.gameOver) return;
|
||||
|
||||
@ -822,7 +804,10 @@ events.prototype.insertAction = function (action, x, y, callback) {
|
||||
this.doEvents(action, x, y, callback);
|
||||
}
|
||||
else {
|
||||
core.unshift(core.status.event.data.list[0].todo, action);
|
||||
if (addToLast)
|
||||
core.push(core.status.event.data.list[0].todo, action)
|
||||
else
|
||||
core.unshift(core.status.event.data.list[0].todo, action);
|
||||
this.setEvents(null, x, y, callback);
|
||||
}
|
||||
}
|
||||
@ -1104,12 +1089,10 @@ events.prototype._action_openDoor = function (data, x, y, prefix) {
|
||||
var loc = this.__action_getLoc(data.loc, x, y, prefix);
|
||||
var floorId = data.floorId || core.status.floorId;
|
||||
if (floorId == core.status.floorId) {
|
||||
var _callback = function () {
|
||||
core.openDoor(null, loc[0], loc[1], data.needKey, function () {
|
||||
core.lockControl();
|
||||
core.doAction();
|
||||
}
|
||||
if (!core.openDoor(null, loc[0], loc[1], data.needKey, _callback))
|
||||
_callback();
|
||||
});
|
||||
}
|
||||
else {
|
||||
core.removeBlock(loc[0], loc[1], floorId);
|
||||
@ -1117,6 +1100,11 @@ events.prototype._action_openDoor = function (data, x, y, prefix) {
|
||||
}
|
||||
}
|
||||
|
||||
events.prototype._action_closeDoor = function (data, x, y, prefix) {
|
||||
var loc = this.__action_getLoc(data.loc, x, y, prefix);
|
||||
core.closeDoor(loc[0], loc[1], data.id, core.doAction);
|
||||
}
|
||||
|
||||
events.prototype._action_useItem = function (data, x, y, prefix) {
|
||||
// 考虑到可能覆盖楼传事件的问题,这里不对fly进行检查。
|
||||
if (data.id != 'book' && core.canUseItem(data.id)) {
|
||||
@ -1153,13 +1141,14 @@ events.prototype._action_trigger = function (data, x, y, prefix) {
|
||||
if (block != null && block.block.event.trigger) {
|
||||
block = block.block;
|
||||
this.setEvents([], block.x, block.y);
|
||||
var _callback = function () {
|
||||
core.lockControl();
|
||||
core.doAction();
|
||||
}
|
||||
if (block.event.trigger == 'action')
|
||||
this.setEvents(block.event.data);
|
||||
else {
|
||||
core.doSystemEvent(block.event.trigger, block, function () {
|
||||
core.lockControl();
|
||||
core.doAction();
|
||||
});
|
||||
core.doSystemEvent(block.event.trigger, block, _callback);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1593,7 +1582,7 @@ events.prototype.useFly = function (fromUserAction) {
|
||||
}
|
||||
|
||||
events.prototype.flyTo = function (toId, callback) {
|
||||
return this.controldata.flyTo(toId, callback);
|
||||
return this.eventdata.flyTo(toId, callback);
|
||||
}
|
||||
|
||||
////// 点击装备栏时的打开操作 //////
|
||||
@ -1722,7 +1711,7 @@ events.prototype.setValue = function (name, value, prefix, add) {
|
||||
this._setValue_setStatus(name, value);
|
||||
this._setValue_setItem(name, value);
|
||||
this._setValue_setFlag(name, value);
|
||||
this._setValue_setSwitch(name, value);
|
||||
this._setValue_setSwitch(name, value, prefix);
|
||||
core.updateStatusBar();
|
||||
}
|
||||
|
||||
@ -1750,7 +1739,7 @@ events.prototype._setValue_setFlag = function (name, value) {
|
||||
|
||||
events.prototype._setValue_setSwitch = function (name, value, prefix) {
|
||||
if (name.indexOf("switch:") !== 0) return;
|
||||
core.setFlag((prefix || "f@x@y") + "@" + data.name.substring(7), value);
|
||||
core.setFlag((prefix || ":f@x@y") + "@" + name.substring(7), value);
|
||||
}
|
||||
|
||||
////// 数值增减 //////
|
||||
@ -1799,6 +1788,32 @@ events.prototype.setGlobalFlag = function (name, value) {
|
||||
core.resize();
|
||||
}
|
||||
|
||||
events.prototype.closeDoor = function (x, y, id, callback) {
|
||||
id = id || "";
|
||||
if (!(id.endsWith("Door") || id.endsWith("Wall"))
|
||||
|| !core.material.icons.animates[id] || core.getBlock(x, y) != null) {
|
||||
if (callback) callback();
|
||||
return;
|
||||
}
|
||||
// 关门动画
|
||||
core.playSound('door.mp3');
|
||||
var door = core.material.icons.animates[id];
|
||||
var speed = id.endsWith("Door") ? 30 : 70, state = 0;
|
||||
var animate = window.setInterval(function () {
|
||||
state++;
|
||||
if (state == 4) {
|
||||
clearInterval(animate);
|
||||
delete core.animateFrame.asyncId[animate];
|
||||
core.setBlock(core.getNumberById(id), x, y);
|
||||
if (callback) callback();
|
||||
return;
|
||||
}
|
||||
core.clearMap('event', 32 * x, 32 * y, 32, 32);
|
||||
core.drawImage('event', core.material.images.animates, 32 * (4-state), 32 * door, 32, 32, 32 * x, 32 * y, 32, 32);
|
||||
}, speed / core.status.replay.speed);
|
||||
core.animateFrame.asyncId[animate] = true;
|
||||
}
|
||||
|
||||
////// 显示图片 //////
|
||||
events.prototype.showImage = function (code, image, x, y, dw, dh, opacityVal, time, callback) {
|
||||
dw /= 100;
|
||||
|
||||
40
libs/maps.js
40
libs/maps.js
@ -331,13 +331,13 @@ maps.prototype.getMapBlocksObj = function (floorId, showDisable) {
|
||||
}
|
||||
|
||||
////// 将背景前景层变成二维数组的形式 //////
|
||||
maps.prototype.getBgFgMapArray = function (name, floorId, useCache) {
|
||||
maps.prototype.getBgFgMapArray = function (name, floorId, noCache) {
|
||||
floorId = floorId || core.status.floorId;
|
||||
if (!floorId) return [];
|
||||
var width = core.floors[floorId].width;
|
||||
var height = core.floors[floorId].height;
|
||||
|
||||
if (useCache && core.status[name + "maps"][floorId])
|
||||
if (!noCache && core.status[name + "maps"][floorId])
|
||||
return core.status[name + "maps"][floorId];
|
||||
|
||||
var arr = core.clone(core.floors[floorId][name + "map"] || []);
|
||||
@ -352,23 +352,34 @@ maps.prototype.getBgFgMapArray = function (name, floorId, useCache) {
|
||||
if (main.mode == 'editor') arr[y][x] = arr[y][x].idnum || arr[y][x] || 0;
|
||||
}
|
||||
}
|
||||
if (useCache)
|
||||
if (core.status[name + "maps"])
|
||||
core.status[name + "maps"][floorId] = core.clone(arr);
|
||||
return arr;
|
||||
}
|
||||
|
||||
maps.prototype.getBgFgNumber = function (name, x, y, floorId, noCache) {
|
||||
if (x == null) x = core.getHeroLoc('x');
|
||||
if (y == null) y = core.getHeroLoc('y');
|
||||
return this.getBgFgMapArray(name, floorId, noCache)[y][x];
|
||||
}
|
||||
|
||||
// ------ 当前能否朝某方向移动,能否瞬间移动 ------ //
|
||||
|
||||
////// 生成全图的当前可移动信息 //////
|
||||
maps.prototype.generateMovableArray = function (floorId, x, y) {
|
||||
maps.prototype.generateMovableArray = function (floorId, x, y, direction) {
|
||||
floorId = floorId || core.status.floorId;
|
||||
if (!floorId) return null;
|
||||
var width = core.floors[floorId].width, height = core.floors[floorId].height;
|
||||
var bgArray = this.getBgFgMapArray('bg', floorId, true),
|
||||
fgArray = this.getBgFgMapArray('fg', floorId, true),
|
||||
var bgArray = this.getBgFgMapArray('bg', floorId),
|
||||
fgArray = this.getBgFgMapArray('fg', floorId),
|
||||
eventArray = this.getMapArray(floorId);
|
||||
|
||||
var generate = function (x, y) {
|
||||
var generate = function (x, y, direction) {
|
||||
if (direction != null) {
|
||||
return core.maps._canMoveHero_checkPoint(x, y, direction, floorId, {
|
||||
bgArray: bgArray, fgArray: fgArray, eventArray: eventArray
|
||||
});
|
||||
}
|
||||
return ["left", "down", "up", "right"].filter(function (direction) {
|
||||
return core.maps._canMoveHero_checkPoint(x, y, direction, floorId, {
|
||||
bgArray: bgArray, fgArray: fgArray, eventArray: eventArray
|
||||
@ -376,7 +387,7 @@ maps.prototype.generateMovableArray = function (floorId, x, y) {
|
||||
});
|
||||
}
|
||||
|
||||
if (x != null && y != null) return generate(x, y);
|
||||
if (x != null && y != null) return generate(x, y, direction);
|
||||
var array = [];
|
||||
for (var x = 0; x < width; x++) {
|
||||
array[x] = [];
|
||||
@ -392,7 +403,7 @@ maps.prototype.canMoveHero = function (x, y, direction, floorId) {
|
||||
if (x == null) x = core.getHeroLoc('x');
|
||||
if (y == null) y = core.getHeroLoc('y');
|
||||
direction = direction || core.getHeroLoc('direction');
|
||||
return core.inArray(this.generateMovableArray(floorId, x, y), direction);
|
||||
return this.generateMovableArray(floorId, x, y, direction);
|
||||
}
|
||||
|
||||
maps.prototype._canMoveHero_checkPoint = function (x, y, direction, floorId, extraData) {
|
||||
@ -472,6 +483,8 @@ maps.prototype._canMoveDirectly_checkStartPoint = function (sx, sy) {
|
||||
maps.prototype._canMoveDirectly_bfs = function (sx, sy, ex, ey) {
|
||||
var canMoveArray = this.generateMovableArray();
|
||||
var blocksObj = this.getMapBlocksObj(core.status.floorId);
|
||||
// 滑冰
|
||||
var bgMap = this.getBgFgMapArray('bg');
|
||||
|
||||
var visited = [], queue = [];
|
||||
visited[sx + "," + sy] = 0;
|
||||
@ -483,6 +496,7 @@ maps.prototype._canMoveDirectly_bfs = function (sx, sy, ex, ey) {
|
||||
if (!core.inArray(canMoveArray[x][y], direction)) continue;
|
||||
var nx = x + core.utils.scan[direction].x, ny = y + core.utils.scan[direction].y, nindex = nx + "," + ny;
|
||||
if (visited[nindex]) continue;
|
||||
if (bgMap[ny][nx] == 167) continue;
|
||||
if (!this._canMoveDirectly_checkNextPoint(blocksObj, nx, ny)) continue;
|
||||
visited[nindex] = visited[now] + 1;
|
||||
if (nx == ex && ny == ey) return visited[nindex];
|
||||
@ -565,7 +579,7 @@ maps.prototype._automaticRoute_deepAdd = function (x, y) {
|
||||
// 绕过血瓶
|
||||
if (!core.flags.potionWhileRouting && id.endsWith("Potion")) deepAdd += 100;
|
||||
// 绕过传送点
|
||||
// if (nextBlock.block.event.trigger == 'changeFloor') deepAdd+=10;
|
||||
// if (block.block.event.trigger == 'changeFloor') deepAdd+=10;
|
||||
}
|
||||
// 绕过存在伤害的地方
|
||||
deepAdd += (core.status.checkBlock.damage[x+","+y]||0) * 100;
|
||||
@ -739,7 +753,7 @@ maps.prototype._drawBgFgMap = function (floorId, ctx, name, onMap) {
|
||||
if (!core.status[name + "maps"])
|
||||
core.status[name + "maps"] = {};
|
||||
|
||||
var arr = this.getBgFgMapArray(name, floorId);
|
||||
var arr = this.getBgFgMapArray(name, floorId, true);
|
||||
for (var x = 0; x < width; x++) {
|
||||
for (var y = 0; y < height; y++) {
|
||||
var block = this.initBlock(x, y, arr[y][x], true);
|
||||
@ -1155,7 +1169,7 @@ maps.prototype.getBlockInfo = function (block) {
|
||||
block = this.initBlock(0, 0, block, true);
|
||||
}
|
||||
var number = block.id, id = block.event.id, cls = block.event.cls,
|
||||
image = null, posX = 0, posY = 0,
|
||||
image = null, posX = 0, posY = 0, animate = block.event.animate,
|
||||
height = block.event.height || 32, faceIds = {};
|
||||
|
||||
if (id == 'none') return null;
|
||||
@ -1179,7 +1193,7 @@ maps.prototype.getBlockInfo = function (block) {
|
||||
faceIds = block.event.faceIds || {};
|
||||
}
|
||||
|
||||
return {number: number, id: id, cls: cls, image: image, posX: posX, posY: posY, height: height, faceIds: faceIds};
|
||||
return {number: number, id: id, cls: cls, image: image, posX: posX, posY: posY, height: height, faceIds: faceIds, animate: animate};
|
||||
}
|
||||
|
||||
////// 搜索某个图块出现的所有位置 //////
|
||||
|
||||
420
libs/ui.js
420
libs/ui.js
@ -8,6 +8,12 @@
|
||||
|
||||
function ui() {
|
||||
this._init();
|
||||
// for convenience
|
||||
this.SIZE = core.__SIZE__;
|
||||
this.HSIZE = core.__HALF_SIZE__;
|
||||
this.LAST = this.SIZE - 1;
|
||||
this.PIXEL = core.__PIXELS__;
|
||||
this.HPIXEL = this.PIX / 2;
|
||||
}
|
||||
|
||||
// 初始化UI
|
||||
@ -19,12 +25,12 @@ ui.prototype._init = function () {
|
||||
|
||||
ui.prototype.getContextByName = function (canvas) {
|
||||
if (typeof canvas == 'string') {
|
||||
if (core.isset(core.canvas[canvas]))
|
||||
if (core.canvas[canvas])
|
||||
canvas = core.canvas[canvas];
|
||||
else if (core.isset(core.dymCanvas[canvas]))
|
||||
else if (core.dymCanvas[canvas])
|
||||
canvas = core.dymCanvas[canvas];
|
||||
}
|
||||
if (core.isset(canvas) && core.isset(canvas.canvas)) {
|
||||
if (canvas && canvas.canvas) {
|
||||
return canvas;
|
||||
}
|
||||
return null;
|
||||
@ -47,12 +53,8 @@ ui.prototype.clearMap = function (name, x, y, width, height) {
|
||||
|
||||
////// 在某个canvas上绘制一段文字 //////
|
||||
ui.prototype.fillText = function (name, text, x, y, style, font) {
|
||||
if (core.isset(style)) {
|
||||
core.setFillStyle(name, style);
|
||||
}
|
||||
if (core.isset(font)) {
|
||||
core.setFont(name, font);
|
||||
}
|
||||
if (style) core.setFillStyle(name, style);
|
||||
if (font) core.setFont(name, font);
|
||||
var ctx = this.getContextByName(name);
|
||||
if (ctx) ctx.fillText(text, x, y);
|
||||
}
|
||||
@ -61,8 +63,8 @@ ui.prototype.fillText = function (name, text, x, y, style, font) {
|
||||
ui.prototype.fillBoldText = function (name, text, x, y, style, font) {
|
||||
var ctx = this.getContextByName(name);
|
||||
if (!ctx) return;
|
||||
if (core.isset(font)) ctx.font = font;
|
||||
if (!core.isset(style)) style = ctx.fillStyle;
|
||||
if (font) ctx.font = font;
|
||||
if (!style) style = ctx.fillStyle;
|
||||
ctx.fillStyle = '#000000';
|
||||
ctx.fillText(text, x-1, y-1);
|
||||
ctx.fillText(text, x-1, y+1);
|
||||
@ -74,33 +76,23 @@ ui.prototype.fillBoldText = function (name, text, x, y, style, font) {
|
||||
|
||||
////// 在某个canvas上绘制一个矩形 //////
|
||||
ui.prototype.fillRect = function (name, x, y, width, height, style) {
|
||||
if (core.isset(style)) {
|
||||
core.setFillStyle(name, style);
|
||||
}
|
||||
if (style) core.setFillStyle(name, style);
|
||||
var ctx = this.getContextByName(name);
|
||||
if (ctx) ctx.fillRect(x, y, width, height);
|
||||
}
|
||||
|
||||
////// 在某个canvas上绘制一个矩形的边框 //////
|
||||
ui.prototype.strokeRect = function (name, x, y, width, height, style, lineWidth) {
|
||||
if (core.isset(style)) {
|
||||
core.setStrokeStyle(name, style);
|
||||
}
|
||||
if (core.isset(lineWidth)) {
|
||||
core.setLineWidth(name, lineWidth);
|
||||
}
|
||||
if (style) core.setStrokeStyle(name, style);
|
||||
if (lineWidth) core.setLineWidth(name, lineWidth);
|
||||
var ctx = this.getContextByName(name);
|
||||
if (ctx) ctx.strokeRect(x, y, width, height);
|
||||
}
|
||||
|
||||
////// 在某个canvas上绘制一条线 //////
|
||||
ui.prototype.drawLine = function (name, x1, y1, x2, y2, style, lineWidth) {
|
||||
if (core.isset(style)) {
|
||||
core.setStrokeStyle(name, style);
|
||||
}
|
||||
if (core.isset(lineWidth)) {
|
||||
core.setLineWidth(name, lineWidth);
|
||||
}
|
||||
if (style) core.setStrokeStyle(name, style);
|
||||
if (lineWidth != null) core.setLineWidth(name, lineWidth);
|
||||
var ctx = this.getContextByName(name);
|
||||
if (!ctx) return;
|
||||
ctx.beginPath();
|
||||
@ -112,12 +104,8 @@ ui.prototype.drawLine = function (name, x1, y1, x2, y2, style, lineWidth) {
|
||||
////// 在某个canvas上绘制一个箭头 //////
|
||||
ui.prototype.drawArrow = function (name, x1, y1, x2, y2, style, lineWidth) {
|
||||
if (x1==x2 && y1==y2) return;
|
||||
if (core.isset(style)) {
|
||||
core.setStrokeStyle(name, style);
|
||||
}
|
||||
if (core.isset(lineWidth)) {
|
||||
core.setLineWidth(name, lineWidth);
|
||||
}
|
||||
if (style) core.setStrokeStyle(name, style);
|
||||
if (lineWidth != null) core.setLineWidth(name, lineWidth);
|
||||
var ctx = this.getContextByName(name);
|
||||
if (!ctx) return;
|
||||
var head = 10;
|
||||
@ -186,11 +174,17 @@ ui.prototype.setTextAlign = function (name, align) {
|
||||
if (ctx) ctx.textAlign = align;
|
||||
}
|
||||
|
||||
////// 设置某个canvas的baseline //////
|
||||
ui.prototype.setTextBaseline = function (name, baseline) {
|
||||
var ctx = this.getContextByName(name);
|
||||
if (ctx) ctx.textBaseline = baseline;
|
||||
}
|
||||
|
||||
////// 计算某段文字的宽度 //////
|
||||
ui.prototype.calWidth = function (name, text, font) {
|
||||
var ctx = this.getContextByName(name);
|
||||
if (ctx) {
|
||||
if (core.isset(font)) ctx.font = font;
|
||||
if (font) ctx.font = font;
|
||||
return ctx.measureText(text).width;
|
||||
}
|
||||
return 0;
|
||||
@ -202,7 +196,7 @@ ui.prototype.drawImage = function (name, image, x, y, w, h, x1, y1, w1, h1) {
|
||||
if (!ctx) return;
|
||||
if (typeof image == 'string') {
|
||||
image = core.material.images.images[image];
|
||||
if (!core.isset(image)) return;
|
||||
if (!image) return;
|
||||
}
|
||||
|
||||
// 只能接受2, 4, 8个参数
|
||||
@ -226,7 +220,7 @@ ui.prototype.drawImage = function (name, image, x, y, w, h, x1, y1, w1, h1) {
|
||||
ui.prototype.closePanel = function () {
|
||||
core.status.boxAnimateObjs = [];
|
||||
clearInterval(core.status.event.interval);
|
||||
core.clearLastEvent();
|
||||
core.clearSelector();
|
||||
core.maps.generateGroundPattern();
|
||||
core.updateStatusBar();
|
||||
core.unLockControl();
|
||||
@ -237,21 +231,20 @@ ui.prototype.closePanel = function () {
|
||||
core.status.event.interval = null;
|
||||
}
|
||||
|
||||
////// 一般清除事件 //////
|
||||
ui.prototype.clearLastEvent = function () {
|
||||
if (core.isset(core.dymCanvas._selector))
|
||||
core.deleteCanvas("_selector");
|
||||
////// 清除光标 //////
|
||||
ui.prototype.clearSelector = function () {
|
||||
if (core.dymCanvas._selector) core.deleteCanvas("_selector");
|
||||
core.clearMap('ui');
|
||||
core.setAlpha('ui', 1);
|
||||
}
|
||||
|
||||
////// 左上角绘制一段提示 //////
|
||||
ui.prototype.drawTip = function (text, itemIcon) {
|
||||
var textX, textY, width, height, hide = false, alpha = 0;
|
||||
var textX, textY, width, height;
|
||||
clearInterval(core.interval.tipAnimate);
|
||||
core.setFont('data', "16px Arial");
|
||||
core.setTextAlign('data', 'left');
|
||||
if (!core.isset(itemIcon)) {
|
||||
if (!itemIcon) {
|
||||
textX = 16;
|
||||
textY = 18;
|
||||
width = textX + core.calWidth('data', text) + 16;
|
||||
@ -263,32 +256,32 @@ ui.prototype.drawTip = function (text, itemIcon) {
|
||||
width = textX + core.calWidth('data', text) + 8;
|
||||
height = 42;
|
||||
}
|
||||
this._drawTip_animate(text, itemIcon, textX, textY, width, height);
|
||||
}
|
||||
|
||||
ui.prototype._drawTip_animate = function (text, itemIcon, textX, textY, width, height) {
|
||||
var alpha = 0, hide = false;
|
||||
core.interval.tipAnimate = window.setInterval(function () {
|
||||
if (hide) {
|
||||
alpha -= 0.1;
|
||||
}
|
||||
else {
|
||||
alpha += 0.1;
|
||||
}
|
||||
core.clearMap('data', 5, 5, 416, height);
|
||||
if (hide) alpha -= 0.1;
|
||||
else alpha += 0.1;
|
||||
core.clearMap('data', 5, 5, core.ui.PIXEL, height);
|
||||
core.setAlpha('data', alpha);
|
||||
core.fillRect('data', 5, 5, width, height, '#000');
|
||||
if (core.isset(itemIcon)) {
|
||||
if (itemIcon)
|
||||
core.drawImage('data', core.material.images.items, 0, itemIcon * 32, 32, 32, 10, 8, 32, 32);
|
||||
}
|
||||
core.fillText('data', text, textX + 5, textY + 15, '#fff');
|
||||
core.setAlpha('data', 1);
|
||||
if (alpha > 0.6 || alpha < 0) {
|
||||
if (hide) {
|
||||
core.clearMap('data', 5, 5, 416, height);
|
||||
core.clearMap('data', 5, 5, core.ui.PIXEL, height);
|
||||
clearInterval(core.interval.tipAnimate);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (!core.isset(core.timeout.getItemTipTimeout)) {
|
||||
core.timeout.getItemTipTimeout = window.setTimeout(function () {
|
||||
if (!core.timeout.tipTimeout) {
|
||||
core.timeout.tipTimeout = window.setTimeout(function () {
|
||||
hide = true;
|
||||
core.timeout.getItemTipTimeout = null;
|
||||
core.timeout.tipTimeout = null;
|
||||
}, 750);
|
||||
}
|
||||
alpha = 0.6;
|
||||
@ -299,41 +292,12 @@ ui.prototype.drawTip = function (text, itemIcon) {
|
||||
|
||||
////// 地图中间绘制一段文字 //////
|
||||
ui.prototype.drawText = function (contents, callback) {
|
||||
if (core.isset(contents)) {
|
||||
|
||||
// 合并
|
||||
if ((core.isset(core.status.event)&&core.status.event.id=='action') || core.isReplaying()) {
|
||||
core.insertAction(contents,null,null,callback);
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof contents == 'string') {
|
||||
contents = [{'content': contents}];
|
||||
}
|
||||
else if (contents instanceof Object && core.isset(contents.content)) {
|
||||
contents = [contents];
|
||||
}
|
||||
else if (!(contents instanceof Array)) {
|
||||
core.drawTip("出错了");
|
||||
console.log(contents);
|
||||
return;
|
||||
}
|
||||
|
||||
core.status.event = {'id': 'text', 'data': {'list': contents, 'callback': callback}};
|
||||
core.lockControl();
|
||||
|
||||
// wait the hero to stop
|
||||
core.stopAutomaticRoute();
|
||||
setTimeout(function() {
|
||||
core.drawText();
|
||||
}, 30);
|
||||
return;
|
||||
}
|
||||
if (contents != null) return this._drawText_setContent(contents, callback);
|
||||
|
||||
if (core.status.event.data.list.length==0) {
|
||||
var callback = core.status.event.data.callback;
|
||||
core.ui.closePanel(false);
|
||||
if (core.isset(callback)) callback();
|
||||
if (callback) callback();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -342,7 +306,58 @@ ui.prototype.drawText = function (contents, callback) {
|
||||
core.ui.drawTextBox(data);
|
||||
else
|
||||
core.ui.drawTextBox(data.content, data.id);
|
||||
// core.drawTextBox(content);
|
||||
}
|
||||
|
||||
ui.prototype._drawText_setContent = function (contents, callback) {
|
||||
// 合并进 insertAction
|
||||
if ((core.status.event && core.status.event.id=='action') || core.isReplaying()) {
|
||||
core.insertAction(contents,null,null,callback);
|
||||
return;
|
||||
}
|
||||
if (!(contents instanceof Array)) contents = [contents];
|
||||
|
||||
core.status.event = {'id': 'text', 'data': {'list': contents, 'callback': callback}};
|
||||
core.lockControl();
|
||||
|
||||
core.waitHeroToStop(core.drawText);
|
||||
return;
|
||||
}
|
||||
|
||||
////// 正则处理 \t[xx,yy] 问题
|
||||
ui.prototype._getTitleAndIcon = function (content) {
|
||||
var title = null, image = null, icon = null, height = 32, animate = 1;
|
||||
content = content.replace(/(\t|\\t)\[(([^\],]+),)?([^\],]+)\]/g, function (s0, s1, s2, s3, s4) {
|
||||
if (s4) {
|
||||
if (s4 == 'hero') {
|
||||
title = core.status.hero.name;
|
||||
image = core.material.images.hero;
|
||||
icon = 0;
|
||||
height = core.material.icons.hero.height;
|
||||
}
|
||||
else if (/^[-\w.]+\.png$/.test(s4))
|
||||
image = core.material.images.images[s4];
|
||||
else {
|
||||
var blockInfo = core.getBlockInfo(s4);
|
||||
if (blockInfo != null) {
|
||||
if (core.material.enemys[s4]) title = core.material.enemys[s4].name;
|
||||
image = blockInfo.image;
|
||||
icon = blockInfo.posX;
|
||||
height = blockInfo.height;
|
||||
animate = blockInfo.animate;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (s3) title = s3;
|
||||
return "";
|
||||
});
|
||||
return {
|
||||
content: content,
|
||||
title: title,
|
||||
image: image,
|
||||
icon: icon,
|
||||
height: height,
|
||||
animate: animate
|
||||
};
|
||||
}
|
||||
|
||||
ui.prototype.getTitleAndIcon = function (content) {
|
||||
@ -406,8 +421,8 @@ ui.prototype.getTitleAndIcon = function (content) {
|
||||
};
|
||||
}
|
||||
|
||||
// 绘制选择光标
|
||||
ui.prototype.drawWindowSelector = function(background,x,y,w,h) {
|
||||
////// 绘制选择光标
|
||||
ui.prototype.drawWindowSelector = function(background, x, y, w, h) {
|
||||
w = Math.round(w), h = Math.round(h);
|
||||
var dstImage = core.ui.createCanvas("_selector", x, y, w, h, 165);
|
||||
core.setOpacity("_selector", 0.8);
|
||||
@ -425,10 +440,10 @@ ui.prototype.drawWindowSelector = function(background,x,y,w,h) {
|
||||
dstImage.drawImage(background, 158, 66, 2, 28,w-2, 2, 2,h-4);
|
||||
}
|
||||
|
||||
// 绘制皮肤
|
||||
ui.prototype.drawWindowSkin = function(background,canvas,x,y,w,h,direction,px,py) {
|
||||
////// 绘制 WindowSkin
|
||||
ui.prototype.drawWindowSkin = function(background, ctx, x, y, w, h, direction, px, py) {
|
||||
// 仿RM窗口皮肤 ↓
|
||||
var dstImage = core.getContextByName(canvas);
|
||||
var dstImage = core.getContextByName(ctx);
|
||||
if (!dstImage) return;
|
||||
// 绘制背景
|
||||
dstImage.drawImage(background, 0, 0, 128, 128, x+2, y+2, w-4, h-4);
|
||||
@ -454,7 +469,7 @@ ui.prototype.drawWindowSkin = function(background,canvas,x,y,w,h,direction,px,py
|
||||
dstImage.drawImage(background, 176,48, 16, 16, x+w-16, y+h-16, 16, 16);
|
||||
|
||||
// arrow
|
||||
if(core.isset(px) && core.isset(py)){
|
||||
if(px != null && py != null){
|
||||
if(direction == 'up'){
|
||||
dstImage.drawImage(background,128,96,32,32,px,y+h-3,32,32);
|
||||
}else if(direction == 'down') {
|
||||
@ -464,57 +479,198 @@ ui.prototype.drawWindowSkin = function(background,canvas,x,y,w,h,direction,px,py
|
||||
// 仿RM窗口皮肤 ↑
|
||||
}
|
||||
|
||||
// 计算有效文本框的宽度
|
||||
ui.prototype.calTextBoxWidth = function (canvas, content, min_width, max_width) {
|
||||
////// 计算有效文本框的宽度
|
||||
ui.prototype.calTextBoxWidth = function (ctx, content, min_width, max_width) {
|
||||
// 无限长度自动换行
|
||||
var allLines = core.splitLines(canvas, content);
|
||||
var allLines = core.splitLines(ctx, content);
|
||||
|
||||
// 如果不存在手动换行,则二分自动换行
|
||||
// 如果不存在手动换行,尽量调成半行形式
|
||||
if (allLines.length == 1) {
|
||||
var w = core.calWidth(canvas, allLines[0]);
|
||||
var w = core.calWidth(ctx, allLines[0]);
|
||||
if (w<min_width*2.3) return core.clamp(w / 1.4, min_width, max_width);
|
||||
if (w<max_width*2.2) return core.clamp(w / 2.4, min_width, max_width);
|
||||
return core.clamp(w / 3.4, min_width, max_width);
|
||||
/*
|
||||
var prefer_lines = 3;
|
||||
var start = Math.floor(min_width), end = Math.floor(max_width);
|
||||
while (start < end) {
|
||||
var mid = Math.floor((start+end)/2);
|
||||
if (core.splitLines(canvas, content, mid).length < prefer_lines)
|
||||
end = mid;
|
||||
else
|
||||
start = mid + 1;
|
||||
}
|
||||
return mid;
|
||||
*/
|
||||
}
|
||||
// 存在手动换行:以最长的为准
|
||||
else {
|
||||
var w = 0;
|
||||
allLines.forEach(function (t) {
|
||||
w = Math.max(w, core.calWidth(canvas, t));
|
||||
});
|
||||
return core.clamp(w, min_width, max_width);
|
||||
return core.clamp(allLines.reduce(function (pre, curr) {
|
||||
return Math.max(pre, core.calWidth(ctx, curr))
|
||||
}, 0), min_width, max_width);
|
||||
}
|
||||
}
|
||||
|
||||
ui.prototype.__getIconInfo = function (id) {
|
||||
////// 处理 \i[xxx] 的问题
|
||||
ui.prototype._getDrawableIconInfo = function (id) {
|
||||
var image = null, icon = null;
|
||||
["terrains","animates","items","npcs","enemys"].forEach(function (v) {
|
||||
if (core.isset(core.material.icons[v][id])) {
|
||||
if (core.material.icons[v][id] != null) {
|
||||
image = core.material.images[v];
|
||||
icon = core.material.icons[v][id];
|
||||
}
|
||||
});
|
||||
if (image == null) {
|
||||
if (id in core.statusBar.icons) {
|
||||
image = core.statusBar.icons[id];
|
||||
icon = 0;
|
||||
}
|
||||
if (image == null && id in core.statusBar.icons) {
|
||||
image = core.statusBar.icons[id];
|
||||
icon = 0;
|
||||
}
|
||||
return [image,icon];
|
||||
}
|
||||
|
||||
ui.prototype._buildFont = function (fontSize) {
|
||||
return (core.status.textAttribute.bold?"bold ":"") + fontSize + "px " +core.status.globalAttribute.font;
|
||||
}
|
||||
|
||||
////// 绘制一段文字到某个画布上面
|
||||
// ctx:要绘制到的画布
|
||||
// content:要绘制的内容;转义字符目前只允许留 \n, \r[...] 和 \i[...]
|
||||
// config:绘制配置项,目前暂时包含如下内容(均为可选)
|
||||
// left, top:起始点位置;maxWidth:单行最大宽度;color:默认颜色;align:左中右
|
||||
// fontSize:字体大小;font:字体样式;lineHeight:行高;time:打字机间隔
|
||||
ui.prototype.drawTextContent = function (ctx, content, config) {
|
||||
ctx = core.getContextByName(ctx);
|
||||
if (!ctx) return;
|
||||
// 设置默认配置项
|
||||
config = core.clone(config || {});
|
||||
config.left = config.left || 0;
|
||||
config.right = config.left + (config.maxWidth == null ? ctx.canvas.width : config.maxWidth);
|
||||
config.top = config.top || 0;
|
||||
config.color = config.color || "#FFFFFF";
|
||||
config.align = config.align || "left";
|
||||
config.fontSize = config.fontSize || core.status.textAttribute.textfont;
|
||||
config.lineHeight = config.lineHeight || (config.fontSize * 1.2);
|
||||
config.time = config.time || 0;
|
||||
|
||||
config.index = 0;
|
||||
config.changed = true;
|
||||
config.currcolor = config.color;
|
||||
config.offsetX = 0;
|
||||
config.offsetY = 0;
|
||||
|
||||
// 创建一个新的临时画布
|
||||
var tempCtx = document.createElement('canvas').getContext('2d');
|
||||
tempCtx.canvas.height = config.lineHeight;
|
||||
tempCtx.canvas.width = ctx.canvas.width;
|
||||
tempCtx.textBaseline = 'top';
|
||||
tempCtx.font = this._buildFont(config.fontSize);
|
||||
|
||||
this._drawTextContent_draw(ctx, tempCtx, content, config);
|
||||
}
|
||||
|
||||
ui.prototype._drawTextContent_draw = function (ctx, tempCtx, content, config) {
|
||||
if (config.time == 0) {
|
||||
while (!core.ui._drawTextContent_next(ctx, tempCtx, content, config));
|
||||
core.ui._drawTextContent_drawLineToCtx(ctx, tempCtx, content, config);
|
||||
}
|
||||
else {
|
||||
core.status.event.interval = setInterval(function () {
|
||||
config.changed = true;
|
||||
if (!core.ui._drawTextContent_next(ctx, tempCtx, content, config)) {
|
||||
clearInterval(core.status.event.interval);
|
||||
core.status.event.interval = null;
|
||||
core.ui._drawTextContent_drawLineToCtx(ctx, tempCtx, content, config);
|
||||
}
|
||||
}, time);
|
||||
}
|
||||
}
|
||||
|
||||
// 进行下一次绘制
|
||||
ui.prototype._drawTextContent_next = function (ctx, tempCtx, content, config) {
|
||||
if (config.index >= content.length) return false;
|
||||
// 是否需要改变颜色
|
||||
if (config.changed) {
|
||||
core.setFillStyle(tempCtx, config.currcolor);
|
||||
config.changed = false;
|
||||
}
|
||||
// get next character
|
||||
var ch = content.charAt(config.index++);
|
||||
return this._drawTextContent_drawChar(ctx, tempCtx, content, config, ch);
|
||||
}
|
||||
|
||||
// 绘制下一个字符
|
||||
ui.prototype._drawTextContent_drawChar = function (ctx, tempCtx, content, config, ch) {
|
||||
// \n, \\n
|
||||
if (ch == '\n' || (ch=='\\' && content.charAt(config.index)=='n')) {
|
||||
this._drawTextContent_drawLineToCtx(ctx, tempCtx, content, config);
|
||||
if (ch=='\\') config.index++;
|
||||
return this._drawTextContent_next(ctx, tempCtx, content, config);
|
||||
}
|
||||
// \r, \\r
|
||||
if (ch == '\r' || (ch=='\\' && content.charAt(config.index)=='r')) {
|
||||
if (ch == '\\') config.index++;
|
||||
return this._drawTextContent_changeColor(ctx, tempCtx, content, config);
|
||||
}
|
||||
// \\i 绘制图标
|
||||
if (ch == '\\' && content.charAt(config.index)=='i') {
|
||||
return this._drawTextContent_drawIcon(ctx, tempCtx, content, config);
|
||||
}
|
||||
// 检查是不是自动换行
|
||||
var charwidth = core.calWidth(tempCtx, ch);
|
||||
if (config.maxWidth != null && config.offsetX + charwidth > config.maxWidth) {
|
||||
this._drawTextContent_drawLineToCtx(ctx, tempCtx, content, config);
|
||||
config.index--;
|
||||
return this._drawTextContent_next(ctx, tempCtx, content, config);
|
||||
}
|
||||
// 输出
|
||||
core.fillText(tempCtx, ch, config.offsetX, 0);
|
||||
config.offsetX += charwidth;
|
||||
return true;
|
||||
}
|
||||
|
||||
// 从临时画布绘制到正式画布上面
|
||||
ui.prototype._drawTextContent_drawLineToCtx = function (ctx, tempCtx, content, config) {
|
||||
// 计算坐标,宽高
|
||||
var left = config.left, top = config.top + config.offsetY;
|
||||
var width = config.offsetX, height = config.lineHeight;
|
||||
// 计算起点横坐标
|
||||
if (config.align == 'center')
|
||||
left = (config.left + config.right - width) / 2;
|
||||
else if (config.align == 'right')
|
||||
left = config.right - width;
|
||||
|
||||
core.drawImage(ctx, tempCtx.canvas, 0, 0, width, height, left, top, width, height);
|
||||
|
||||
config.offsetX = 0;
|
||||
config.offsetY += config.lineHeight;
|
||||
}
|
||||
|
||||
ui.prototype._drawTextContent_changeColor = function (ctx, tempCtx, content, config) {
|
||||
config.changed = true;
|
||||
// 检查是不是 []
|
||||
var index = config.index, index2;
|
||||
if (content.charAt(index) == '[' && ((index2=content.indexOf(']', index))>=0)) {
|
||||
// 变色
|
||||
var str = content.substring(index+1, index2);
|
||||
if (str=="") config.currcolor = config.color;
|
||||
else config.currcolor = str;
|
||||
config.index = index2 + 1;
|
||||
}
|
||||
else config.currcolor = color;
|
||||
return this._drawTextContent_next(ctx, tempCtx,content, config);
|
||||
}
|
||||
|
||||
ui.prototype._drawTextContent_drawIcon = function (ctx, tempCtx, content, config) {
|
||||
// 绘制一个 \i 效果
|
||||
var index = config.index, index2;
|
||||
if (content.charAt(config.index+1) == '[' && ((index2=content.indexOf(']', index+1))>=0)) {
|
||||
var str = content.substring(index+2, index2);
|
||||
// --- 获得图标
|
||||
var iconInfo = core.ui._getDrawableIconInfo(str), image = iconInfo[0], icon = iconInfo[1];
|
||||
if (image == null) return this._drawTextContent_next(ctx, tempCtx, content, config);
|
||||
// 检查自动换行
|
||||
var width = config.fontSize + 2, left = config.offsetX + 2, top = (config.lineHeight - width) / 2;
|
||||
if (config.maxWidth != null && left + width > config.maxWidth) {
|
||||
this._drawTextContent_drawLineToCtx(ctx, tempCtx, content, config);
|
||||
config.index--;
|
||||
this._drawTextContent_next(ctx, tempCtx, content, config);
|
||||
}
|
||||
// 绘制到画布上
|
||||
core.drawImage(tempCtx, image, 0, 32*icon, 32, 32, left, top, width, width);
|
||||
config.offsetX += width + 6;
|
||||
config.index = index2 + 1;
|
||||
return true;
|
||||
}
|
||||
return this._drawTextContent_next(ctx, tempCtx, content, config);
|
||||
}
|
||||
|
||||
ui.prototype.__drawText = function (canvas, content, content_left, content_top, valid_width,
|
||||
color, per_height, text_font, time) {
|
||||
core.setTextAlign(canvas, 'left');
|
||||
@ -562,7 +718,7 @@ ui.prototype.__drawText = function (canvas, content, content_left, content_top,
|
||||
if (content.charAt(index+1) == '[' && ((index2=content.indexOf(']', index+1))>=0)) {
|
||||
var str = content.substring(index+2, index2);
|
||||
// --- 获得图标
|
||||
var iconInfo = core.ui.__getIconInfo(str), image = iconInfo[0], icon = iconInfo[1];
|
||||
var iconInfo = core.ui._getDrawableIconInfo(str), image = iconInfo[0], icon = iconInfo[1];
|
||||
if (image != null) {
|
||||
if (core.isset(valid_width) && offsetx + text_font + 6 > content_left + valid_width) {
|
||||
index --;
|
||||
@ -679,7 +835,7 @@ ui.prototype.drawTextBox = function(content, showAll) {
|
||||
content = core.replaceText(content);
|
||||
|
||||
core.status.boxAnimateObjs = [];
|
||||
core.clearLastEvent();
|
||||
core.clearSelector();
|
||||
|
||||
// drawImage
|
||||
content = content.replace(/(\f|\\f)\[(.*?)]/g, function (text, sympol, str) {
|
||||
@ -1019,7 +1175,7 @@ ui.prototype.drawChoices = function(content, choices) {
|
||||
core.setFillStyle('ui', color);
|
||||
var offset = 208;
|
||||
if (core.isset(choices[i].icon)) {
|
||||
var iconInfo = this.__getIconInfo(choices[i].icon), image = iconInfo[0], icon = iconInfo[1];
|
||||
var iconInfo = this._getDrawableIconInfo(choices[i].icon), image = iconInfo[0], icon = iconInfo[1];
|
||||
if (image != null) {
|
||||
core.drawImage('ui', image, 0, 32*icon, 32, 32,
|
||||
208 - choices[i].width/2, choice_top + 32*i - 17, 22, 22);
|
||||
@ -1087,7 +1243,7 @@ ui.prototype.drawConfirmBox = function (text, yesCallback, noCallback) {
|
||||
if (!core.isset(core.status.event.selection) || core.status.event.selection>1) core.status.event.selection=1;
|
||||
if (core.status.event.selection<0) core.status.event.selection=0;
|
||||
|
||||
core.clearLastEvent();
|
||||
core.clearSelector();
|
||||
|
||||
var background = core.status.textAttribute.background;
|
||||
var isWindowSkin = false;
|
||||
@ -1191,7 +1347,7 @@ ui.prototype.drawWaiting = function(text) {
|
||||
core.lockControl();
|
||||
core.status.event.id = 'waiting';
|
||||
|
||||
core.clearLastEvent();
|
||||
core.clearSelector();
|
||||
|
||||
var background = core.status.textAttribute.background;
|
||||
var isWindowSkin = false;
|
||||
@ -1326,7 +1482,7 @@ ui.prototype.drawBook = function (index) {
|
||||
var floorId = core.floorIds[(core.status.event.ui||{}).index] || core.status.floorId;
|
||||
var enemys = core.enemys.getCurrentEnemys(floorId);
|
||||
|
||||
core.clearLastEvent();
|
||||
core.clearSelector();
|
||||
core.clearMap('data');
|
||||
|
||||
// 生成groundPattern
|
||||
@ -1691,7 +1847,7 @@ ui.prototype.drawMaps = function (index, x, y) {
|
||||
|
||||
if (!core.isset(index)) {
|
||||
core.status.event.data = null;
|
||||
core.clearLastEvent();
|
||||
core.clearSelector();
|
||||
|
||||
core.fillRect('ui', 0, 0, 416, 416, 'rgba(0,0,0,0.4)');
|
||||
|
||||
@ -1758,7 +1914,7 @@ ui.prototype.drawMaps = function (index, x, y) {
|
||||
core.status.event.data = {"index": index, "x": x, "y": y, "damage": damage, "paint": paint, "all": all};
|
||||
|
||||
clearTimeout(core.interval.tipAnimate);
|
||||
core.clearLastEvent();
|
||||
core.clearSelector();
|
||||
core.status.checkBlock.cache = {};
|
||||
core.drawThumbnail(floorId, null, {damage: damage}, {ctx: 'ui', centerX: x, centerY: y, all: all});
|
||||
|
||||
@ -2248,7 +2404,7 @@ ui.prototype.drawKeyBoard = function () {
|
||||
core.lockControl();
|
||||
core.status.event.id = 'keyBoard';
|
||||
|
||||
core.clearLastEvent();
|
||||
core.clearSelector();
|
||||
|
||||
var left = 16, top = 48, width = 416 - 2 * left, height = 416 - 2 * top;
|
||||
|
||||
@ -2522,7 +2678,7 @@ ui.prototype.drawPaint = function () {
|
||||
core.status.event.id = 'paint';
|
||||
core.status.event.data = {"x": null, "y": null, "erase": false};
|
||||
|
||||
core.clearLastEvent();
|
||||
core.clearSelector();
|
||||
core.createCanvas('paint', -core.bigmap.offsetX, -core.bigmap.offsetY, 32*core.bigmap.width, 32*core.bigmap.height, 95);
|
||||
|
||||
// 将已有的内容绘制到route上
|
||||
@ -2549,7 +2705,7 @@ ui.prototype.drawPaint = function () {
|
||||
|
||||
////// 绘制帮助页面 //////
|
||||
ui.prototype.drawHelp = function () {
|
||||
core.clearLastEvent();
|
||||
core.clearSelector();
|
||||
if (core.material.images.keyboard) {
|
||||
core.status.event.id = 'help';
|
||||
core.lockControl();
|
||||
|
||||
@ -66,7 +66,7 @@ utils.prototype.calValue = function (value, prefix, need, times) {
|
||||
value = value.replace(/status:([\w\d_]+)/g, "core.getStatus('$1')");
|
||||
value = value.replace(/item:([\w\d_]+)/g, "core.itemCount('$1')");
|
||||
value = value.replace(/flag:([\w\d_]+)/g, "core.getFlag('$1', 0)");
|
||||
value = value.replace(/switch:([\w\d_]+)/g, "core.getFlag('" + (prefix || "global") + "@$1', 0)");
|
||||
value = value.replace(/switch:([\w\d_]+)/g, "core.getFlag('" + (prefix || ":f@x@y") + "@$1', 0)");
|
||||
return eval(value);
|
||||
}
|
||||
if (value instanceof Function) {
|
||||
|
||||
8
main.js
8
main.js
@ -2,7 +2,7 @@ function main() {
|
||||
|
||||
//------------------------ 用户修改内容 ------------------------//
|
||||
|
||||
this.version = "2.5.5"; // 游戏版本号;如果更改了游戏内容建议修改此version以免造成缓存问题。
|
||||
this.version = "2.6"; // 游戏版本号;如果更改了游戏内容建议修改此version以免造成缓存问题。
|
||||
|
||||
this.useCompress = false; // 是否使用压缩文件
|
||||
// 当你即将发布你的塔时,请使用“JS代码压缩工具”将所有js代码进行压缩,然后将这里的useCompress改为true。
|
||||
@ -188,8 +188,8 @@ function main() {
|
||||
this.floors = {}
|
||||
this.canvas = {};
|
||||
|
||||
this.__VERSION__ = "2.5.5";
|
||||
this.__VERSION_CODE__ = 25;
|
||||
this.__VERSION__ = "2.6";
|
||||
this.__VERSION_CODE__ = 30;
|
||||
}
|
||||
|
||||
main.prototype.init = function (mode, callback) {
|
||||
@ -222,7 +222,7 @@ main.prototype.init = function (mode, callback) {
|
||||
for (i = 0; i < main.loadList.length; i++) {
|
||||
var name = main.loadList[i];
|
||||
if (name === 'core') continue;
|
||||
main.core[name] = new (eval(name))();
|
||||
main.core[name] = new window[name]();
|
||||
}
|
||||
|
||||
main.loadFloors(function() {
|
||||
|
||||
@ -71,7 +71,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
|
||||
"firstData": {
|
||||
"title": "魔塔样板",
|
||||
"name": "template",
|
||||
"version": "Ver 2.5.5",
|
||||
"version": "Ver 2.6",
|
||||
"floorId": "sample0",
|
||||
"hero": {
|
||||
"name": "阳光",
|
||||
|
||||
@ -150,6 +150,93 @@ var events_c12a15a8_c380_4b28_8144_256cba95f760 =
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"滑冰事件": [
|
||||
{
|
||||
"type": "comment",
|
||||
"text": "公共事件:滑冰事件"
|
||||
},
|
||||
{
|
||||
"type": "if",
|
||||
"condition": "core.canMoveHero()",
|
||||
"true": [
|
||||
{
|
||||
"type": "comment",
|
||||
"text": "检测下一个点是否可通行"
|
||||
},
|
||||
{
|
||||
"type": "setValue",
|
||||
"name": "flag:nx",
|
||||
"value": "core.nextX()"
|
||||
},
|
||||
{
|
||||
"type": "setValue",
|
||||
"name": "flag:ny",
|
||||
"value": "core.nextY()"
|
||||
},
|
||||
{
|
||||
"type": "if",
|
||||
"condition": "core.noPass(flag:nx, flag:ny)",
|
||||
"true": [
|
||||
{
|
||||
"type": "comment",
|
||||
"text": "不可通行,触发下一个点的事件"
|
||||
},
|
||||
{
|
||||
"type": "trigger",
|
||||
"loc": [
|
||||
"flag:nx",
|
||||
"flag:ny"
|
||||
]
|
||||
}
|
||||
],
|
||||
"false": [
|
||||
{
|
||||
"type": "comment",
|
||||
"text": "可通行,先移动到下个点,然后检查阻激夹域,并尝试触发该点事件"
|
||||
},
|
||||
{
|
||||
"type": "moveHero",
|
||||
"time": 80,
|
||||
"steps": [
|
||||
"forward"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"function": "function(){\ncore.checkBlock();\n}"
|
||||
},
|
||||
{
|
||||
"type": "comment",
|
||||
"text": "【触发事件】如果该点存在事件则会立刻结束当前事件"
|
||||
},
|
||||
{
|
||||
"type": "trigger",
|
||||
"loc": [
|
||||
"flag:nx",
|
||||
"flag:ny"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "comment",
|
||||
"text": "如果该点不存在事件,则继续检测该点是否是滑冰点"
|
||||
},
|
||||
{
|
||||
"type": "if",
|
||||
"condition": "core.getBgFgNumber('bg') == 167",
|
||||
"true": [
|
||||
{
|
||||
"type": "function",
|
||||
"function": "function(){\ncore.insertAction(\"滑冰事件\",null,null,null,true)\n}"
|
||||
}
|
||||
],
|
||||
"false": []
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"false": []
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -142,7 +142,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
color = core.status.maps[floorId].color;
|
||||
core.clearMap('curtain');
|
||||
core.status.curtainColor = color;
|
||||
if (color) core.fillRect('curtain', 0, 0, core.__SIZE__, core.__SIZE__, core.arrayToRGBA(color));
|
||||
if (color) core.fillRect('curtain', 0, 0, core.__PIXELS__, core.__PIXELS__, core.arrayToRGBA(color));
|
||||
// 更改天气
|
||||
var weather = core.getFlag('__weather__', null);
|
||||
if (!weather && core.status.maps[floorId].weather)
|
||||
@ -172,6 +172,32 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
core.visitFloor(floorId);
|
||||
}
|
||||
}
|
||||
},
|
||||
"flyTo": function (toId, callback) {
|
||||
// 楼层传送器的使用,从当前楼层飞往toId
|
||||
// 如果不能飞行请返回false
|
||||
|
||||
var fromId = core.status.floorId;
|
||||
|
||||
// 检查能否飞行
|
||||
if (!core.status.maps[fromId].canFlyTo || !core.status.maps[toId].canFlyTo) {
|
||||
core.drawTip("无法飞往" + core.status.maps[toId].title + "!");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 获得两个楼层的索引,以决定是上楼梯还是下楼梯
|
||||
var fromIndex = core.floorIds.indexOf(fromId),
|
||||
toIndex = core.floorIds.indexOf(toId);
|
||||
var stair = fromIndex <= toIndex ? "downFloor" : "upFloor";
|
||||
// 地下层:同层传送至上楼梯
|
||||
if (fromIndex == toIndex && core.status.maps[fromId].underGround) stair = "upFloor";
|
||||
// 记录录像
|
||||
core.status.route.push("fly:" + toId);
|
||||
// 传送
|
||||
core.ui.closePanel();
|
||||
core.changeFloor(toId, stair, null, null, callback);
|
||||
|
||||
return true;
|
||||
},
|
||||
"beforeBattle": function (enemyId, x, y) {
|
||||
// 战斗前触发的事件,可以加上一些战前特效(详见下面支援的例子)
|
||||
@ -776,12 +802,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
core.getNextItem();
|
||||
break;
|
||||
case 82: // R:回放录像
|
||||
if (core.hasFlag('debug')) {
|
||||
core.drawText("\t[系统提示]调试模式下无法回放录像");
|
||||
}
|
||||
else {
|
||||
core.ui.drawReplay();
|
||||
}
|
||||
core.actions._clickSyncSave_replay();
|
||||
break;
|
||||
case 33: case 34: // PgUp/PgDn:浏览地图
|
||||
core.ui.drawMaps();
|
||||
@ -796,19 +817,13 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
core.ui.drawHelp();
|
||||
break;
|
||||
case 78: // N:重新开始
|
||||
core.status.event.selection=1;
|
||||
core.ui.drawConfirmBox("你确定要返回标题页面吗?", function () {
|
||||
core.ui.closePanel();
|
||||
core.restart();
|
||||
}, function () {
|
||||
core.ui.closePanel();
|
||||
});
|
||||
core.confirmRestart();
|
||||
break;
|
||||
case 79: // O:查看工程
|
||||
window.open(core.platform.isPC?"editor.html":"editor-mobile.html", "_blank");
|
||||
core.actions._clickGameInfo_openProject();
|
||||
break;
|
||||
case 80: // P:游戏主页
|
||||
window.open("/score.php?name="+core.firstData.name+"&num=10", "_blank");
|
||||
core.actions._clickGameInfo_openComments();
|
||||
break;
|
||||
case 49: // 快捷键1: 破
|
||||
if (core.hasItem('pickaxe')) {
|
||||
@ -957,31 +972,6 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
|
||||
// 切换到对应的楼层
|
||||
core.changeFloor(data.floorId, null, data.hero.loc, 0, callback, true);
|
||||
},
|
||||
"flyTo": function (toId, callback) {
|
||||
// 楼层传送器的使用,从当前楼层飞往toId
|
||||
// 如果不能飞行请返回false
|
||||
|
||||
var fromId = core.status.floorId;
|
||||
|
||||
// 检查能否飞行
|
||||
if (!core.status.maps[fromId].canFlyTo || !core.status.maps[toId].canFlyTo) {
|
||||
core.drawTip("无法飞往" + core.status.maps[toId].title +"!");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 获得两个楼层的索引,以决定是上楼梯还是下楼梯
|
||||
var fromIndex = core.floorIds.indexOf(fromId), toIndex = core.floorIds.indexOf(toId);
|
||||
var stair = fromIndex<=toIndex?"downFloor":"upFloor";
|
||||
// 地下层:同层传送至上楼梯
|
||||
if (fromIndex == toIndex && core.status.maps[fromId].underGround) stair = "upFloor";
|
||||
// 记录录像
|
||||
core.status.route.push("fly:"+toId);
|
||||
// 传送
|
||||
core.ui.closePanel();
|
||||
core.changeFloor(toId, stair, null, null, callback);
|
||||
|
||||
return true;
|
||||
},
|
||||
"updateStatusBar": function () {
|
||||
// 更新状态栏
|
||||
@ -1276,6 +1266,37 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
"parallelDo": function (timestamp) {
|
||||
// 并行事件处理,可以在这里写任何需要并行处理的脚本或事件
|
||||
// 该函数将被系统反复执行,每次执行间隔视浏览器或设备性能而定,一般约为16.6ms一次
|
||||
// 参数timestamp为“从游戏资源加载完毕到当前函数执行时”的时间差,以毫秒为单位
|
||||
|
||||
// 检查当前是否处于游戏开始状态
|
||||
if (!core.isPlaying()) return;
|
||||
|
||||
// 执行当前楼层的并行事件处理
|
||||
if (core.status.floorId) {
|
||||
try {
|
||||
eval(core.floors[core.status.floorId].parallelDo);
|
||||
} catch (e) {
|
||||
main.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
// 下面是一个并行事件开门的样例
|
||||
/*
|
||||
// 如果某个flag为真
|
||||
if (core.hasFlag("xxx")) {
|
||||
// 千万别忘了将该flag清空!否则下次仍然会执行这段代码。
|
||||
core.removeFlag("xxx");
|
||||
// 使用insertAction来插入若干自定义事件执行
|
||||
core.insertAction([
|
||||
{"type":"openDoor", "loc":[0,0], "floorId": "MT0"}
|
||||
])
|
||||
// 也可以写任意其他的脚本代码
|
||||
}
|
||||
*/
|
||||
}
|
||||
},
|
||||
"ui": {
|
||||
@ -1385,59 +1406,6 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
core.fillText('ui', "作者: 艾之葵", text_start, top + 112);
|
||||
core.fillText('ui', 'HTML5魔塔交流群:539113091', text_start, top+112+32);
|
||||
// TODO: 写自己的“关于”页面,每次增加32像素即可
|
||||
}
|
||||
},
|
||||
"plugins": {
|
||||
"parallelDo": function (timestamp) {
|
||||
// 并行事件处理,可以在这里写任何需要并行处理的脚本或事件
|
||||
// 该函数将被系统反复执行,每次执行间隔视浏览器或设备性能而定,一般约为16.6ms一次
|
||||
// 参数timestamp为“从游戏资源加载完毕到当前函数执行时”的时间差,以毫秒为单位
|
||||
|
||||
// 检查当前是否处于游戏开始状态
|
||||
if (!core.isPlaying()) return;
|
||||
|
||||
// 执行当前楼层的并行事件处理
|
||||
if (core.status.floorId) {
|
||||
try {
|
||||
eval(core.floors[core.status.floorId].parallelDo);
|
||||
} catch (e) {
|
||||
main.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
// 下面是一个并行事件开门的样例
|
||||
/*
|
||||
// 如果某个flag为真
|
||||
if (core.hasFlag("xxx")) {
|
||||
// 千万别忘了将该flag清空!否则下次仍然会执行这段代码。
|
||||
core.removeFlag("xxx");
|
||||
// 使用insertAction来插入若干自定义事件执行
|
||||
core.insertAction([
|
||||
{"type":"openDoor", "loc":[0,0], "floorId": "MT0"}
|
||||
])
|
||||
// 也可以写任意其他的脚本代码
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
},
|
||||
"plugin": function () {
|
||||
////// 插件编写,此处会导入插件编写中的所有函数 //////
|
||||
|
||||
// 在这里写的代码,在所有模块加载完毕后,游戏开始前会被执行
|
||||
console.log("插件编写测试");
|
||||
// 可以写一些其他的被直接执行的代码
|
||||
|
||||
var pluginsData=plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1
|
||||
for(var functionName in pluginsData){
|
||||
this[functionName]=pluginsData[functionName]
|
||||
}
|
||||
|
||||
// 可以在任何地方(如afterXXX或自定义脚本事件)调用函数,方法为 core.plugin.xxx();
|
||||
|
||||
// 可以在此处直接执行插件编写中的函数
|
||||
core.plugin.test();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,23 +1,36 @@
|
||||
var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
{
|
||||
"test": function(){
|
||||
"init": function () {
|
||||
// 在这里写的代码,在所有模块加载完毕后,游戏开始前会被执行
|
||||
console.log("插件编写测试");
|
||||
|
||||
// 可以写一些其他的被直接执行的代码
|
||||
|
||||
|
||||
this.test = function () {
|
||||
console.log("插件函数执行测试");
|
||||
},
|
||||
"drawLight": function (name, color, lights, lightDec) {
|
||||
// 绘制灯光/漆黑层效果。调用方式 core.plugin.drawLight(...)
|
||||
// 【参数说明】
|
||||
// name:必填,要绘制到的画布名;可以是一个系统画布,或者是个自定义画布;如果不存在则创建
|
||||
// color:可选,只能是一个0~1之间的数,为不透明度的值。不填则默认为0.9。
|
||||
// lights:可选,一个数组,定义了每个独立的灯光。
|
||||
// 其中每一项是三元组 [x,y,r] x和y分别为该灯光的横纵坐标,r为该灯光的半径。
|
||||
// lightDec:可选,0到1之间,光从多少百分比才开始衰减(在此范围内保持全亮),不设置默认为0。
|
||||
// 比如lightDec为0.5代表,每个灯光部分内圈50%的范围全亮,50%以后才开始快速衰减。
|
||||
// 【调用样例】
|
||||
// core.plugin.drawLight('curtain'); // 在curtain层绘制全图不透明度0.9,等价于更改画面色调为[0,0,0,0.9]。
|
||||
// core.plugin.drawLight('ui', 0.95, [[25,11,46]]); // 在ui层绘制全图不透明度0.95,其中在(25,11)点存在一个半径为46的灯光效果。
|
||||
// core.plugin.drawLight('test', 0.2, [[25,11,46,0.1]]); // 创建一个test图层,不透明度0.2,其中在(25,11)点存在一个半径为46的灯光效果,灯光中心不透明度0.1。
|
||||
// core.plugin.drawLight('test2', 0.9, [[25,11,46],[105,121,88],[301,221,106]]); // 创建test2图层,且存在三个灯光效果,分别是中心(25,11)半径46,中心(105,121)半径88,中心(301,221)半径106。
|
||||
// core.plugin.drawLight('xxx', 0.3, [[25,11,46],[105,121,88,0.2]], 0.4); // 存在两个灯光效果,它们在内圈40%范围内保持全亮,且40%后才开始衰减。
|
||||
console.log(this);
|
||||
}
|
||||
|
||||
// 可以在任何地方(如afterXXX或自定义脚本事件)调用函数,方法为 core.plugin.xxx();
|
||||
},
|
||||
"drawLight": function () {
|
||||
|
||||
// 绘制灯光/漆黑层效果。调用方式 core.plugin.drawLight(...)
|
||||
// 【参数说明】
|
||||
// name:必填,要绘制到的画布名;可以是一个系统画布,或者是个自定义画布;如果不存在则创建
|
||||
// color:可选,只能是一个0~1之间的数,为不透明度的值。不填则默认为0.9。
|
||||
// lights:可选,一个数组,定义了每个独立的灯光。
|
||||
// 其中每一项是三元组 [x,y,r] x和y分别为该灯光的横纵坐标,r为该灯光的半径。
|
||||
// lightDec:可选,0到1之间,光从多少百分比才开始衰减(在此范围内保持全亮),不设置默认为0。
|
||||
// 比如lightDec为0.5代表,每个灯光部分内圈50%的范围全亮,50%以后才开始快速衰减。
|
||||
// 【调用样例】
|
||||
// core.plugin.drawLight('curtain'); // 在curtain层绘制全图不透明度0.9,等价于更改画面色调为[0,0,0,0.9]。
|
||||
// core.plugin.drawLight('ui', 0.95, [[25,11,46]]); // 在ui层绘制全图不透明度0.95,其中在(25,11)点存在一个半径为46的灯光效果。
|
||||
// core.plugin.drawLight('test', 0.2, [[25,11,46,0.1]]); // 创建一个test图层,不透明度0.2,其中在(25,11)点存在一个半径为46的灯光效果,灯光中心不透明度0.1。
|
||||
// core.plugin.drawLight('test2', 0.9, [[25,11,46],[105,121,88],[301,221,106]]); // 创建test2图层,且存在三个灯光效果,分别是中心(25,11)半径46,中心(105,121)半径88,中心(301,221)半径106。
|
||||
// core.plugin.drawLight('xxx', 0.3, [[25,11,46],[105,121,88,0.2]], 0.4); // 存在两个灯光效果,它们在内圈40%范围内保持全亮,且40%后才开始衰减。
|
||||
this.drawLight = function (name, color, lights, lightDec) {
|
||||
|
||||
// 清空色调层;也可以修改成其它层比如animate/weather层,或者用自己创建的canvas
|
||||
var ctx = core.getContextByName(name);
|
||||
@ -26,37 +39,40 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
ctx = core.createCanvas(name, 0, 0, core.__PIXELS__, core.__PIXELS__, 98);
|
||||
else return;
|
||||
}
|
||||
|
||||
|
||||
ctx.mozImageSmoothingEnabled = false;
|
||||
ctx.webkitImageSmoothingEnabled = false;
|
||||
ctx.msImageSmoothingEnabled = false;
|
||||
ctx.imageSmoothingEnabled = false;
|
||||
|
||||
|
||||
core.clearMap(name);
|
||||
// 绘制色调层,默认不透明度
|
||||
if (color == null) color = 0.9;
|
||||
ctx.fillStyle = "rgba(0,0,0,"+color+")";
|
||||
ctx.fillStyle = "rgba(0,0,0," + color + ")";
|
||||
ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);
|
||||
|
||||
|
||||
lightDec = core.clamp(lightDec, 0, 1);
|
||||
|
||||
// 绘制每个灯光效果
|
||||
ctx.globalCompositeOperation = 'destination-out';
|
||||
lights.forEach(function (light) {
|
||||
// 坐标,半径,中心不透明度
|
||||
var x = light[0], y = light[1], r = light[2];
|
||||
var x = light[0],
|
||||
y = light[1],
|
||||
r = light[2];
|
||||
// 计算衰减距离
|
||||
var decDistance = parseInt(r * lightDec);
|
||||
// 正方形区域的直径和左上角坐标
|
||||
var grd=ctx.createRadialGradient(x,y,decDistance,x,y,r);
|
||||
var grd = ctx.createRadialGradient(x, y, decDistance, x, y, r);
|
||||
grd.addColorStop(0, "rgba(0,0,0,1)");
|
||||
grd.addColorStop(1, "rgba(0,0,0,0)");
|
||||
ctx.beginPath();
|
||||
ctx.fillStyle=grd;
|
||||
ctx.arc(x,y,r,0,2*Math.PI);
|
||||
ctx.fillStyle = grd;
|
||||
ctx.arc(x, y, r, 0, 2 * Math.PI);
|
||||
ctx.fill();
|
||||
});
|
||||
ctx.globalCompositeOperation = 'source-over';
|
||||
// 可以在任何地方(如afterXXX或自定义脚本事件)调用函数,方法为 core.plugin.xxx();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user