commit
21520a0989
@ -351,6 +351,12 @@ data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
|
||||
"_bool": "bool",
|
||||
"_data": "是否在状态栏显示当前楼层"
|
||||
},
|
||||
"enableName": {
|
||||
"_leaf": true,
|
||||
"_type": "checkbox",
|
||||
"_bool": "bool",
|
||||
"_data": "是否在状态栏显示勇士名字"
|
||||
},
|
||||
"enableLv": {
|
||||
"_leaf": true,
|
||||
"_type": "checkbox",
|
||||
|
||||
@ -90,6 +90,12 @@ functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
|
||||
"_type": "textarea",
|
||||
"_lint": true,
|
||||
"_data": "读档事件后,载入事件前,可以执行的操作"
|
||||
},
|
||||
"canUseQuickShop": {
|
||||
"_leaf": true,
|
||||
"_type": "textarea",
|
||||
"_lint": true,
|
||||
"_data": "当前能否使用快捷商店"
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -103,6 +109,12 @@ functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
|
||||
"_lint": true,
|
||||
"_data": "怪物特殊属性的定义(获得怪物的特殊属性)"
|
||||
},
|
||||
"getEnemyInfo": {
|
||||
"_leaf": true,
|
||||
"_type": "textarea",
|
||||
"_lint": true,
|
||||
"_data": "获得某个怪物的当前属性数据\n该函数主要是会被伤害计算和怪物手册等使用"
|
||||
},
|
||||
"getDamageInfo": {
|
||||
"_leaf": true,
|
||||
"_type": "textarea",
|
||||
@ -121,6 +133,12 @@ functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
|
||||
"_leaf": false,
|
||||
"_type": "object",
|
||||
"_data": {
|
||||
"flyTo": {
|
||||
"_leaf": true,
|
||||
"_type": "textarea",
|
||||
"_lint": true,
|
||||
"_data": "使用楼层传送器飞到某层"
|
||||
},
|
||||
"updateStatusBar": {
|
||||
"_leaf": true,
|
||||
"_type": "textarea",
|
||||
@ -132,13 +150,19 @@ functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
|
||||
"_type": "textarea",
|
||||
"_lint": true,
|
||||
"_data": "阻激夹域的伤害值计算"
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
"ui": {
|
||||
"_leaf": false,
|
||||
"_type": "object",
|
||||
"_data": {
|
||||
"drawStatistics": {
|
||||
"_leaf": true,
|
||||
"_type": "textarea",
|
||||
"_lint": true,
|
||||
"_data": "地图数据统计项的注册"
|
||||
},
|
||||
"drawAbout": {
|
||||
"_leaf": true,
|
||||
"_type": "textarea",
|
||||
|
||||
14
docs/api.md
14
docs/api.md
@ -349,34 +349,36 @@ core.enemys.getSpecialHint(enemy, special)
|
||||
获得怪物某个(或全部)特殊属性的文字说明。
|
||||
|
||||
|
||||
core.enemys.canBattle(enemyId)
|
||||
core.enemys.canBattle(enemyId, x, y, floorId)
|
||||
返回当前能否战胜某个怪物。
|
||||
后面三个参数是怪物坐标和楼层。
|
||||
|
||||
|
||||
core.enemys.getDamage(enemyId)
|
||||
core.enemys.getDamage(enemyId, x, y, floorId)
|
||||
返回当前对某个怪物的战斗伤害。如果无法战斗,返回null。
|
||||
后面三个参数是怪物坐标和楼层。
|
||||
|
||||
|
||||
core.enemys.getExtraDamage(enemyId)
|
||||
返回某个怪物会对勇士造成的额外伤害(不可被魔防抵消),例如仇恨、固伤等等。
|
||||
|
||||
|
||||
core.enemys.nextCriticals(enemyId, number)
|
||||
core.enemys.nextCriticals(enemyId, number, x, y, floorId)
|
||||
返回一个列表,为接下来number(可忽略,默认为1)个该怪物的临界值和临界减伤。
|
||||
列表每一项类似 [x,y] 表示临界值为x,且临界减伤为y。
|
||||
如果无临界值,则返回空列表。
|
||||
|
||||
|
||||
core.enemys.getDefDamage(enemyId, k)
|
||||
core.enemys.getDefDamage(enemyId, k, x, y, floorId)
|
||||
获得k(可忽略,默认为1)防减伤值。
|
||||
|
||||
|
||||
core.enemys.getDamageInfo(enemy, hero_hp, hero_atk, hero_def, hero_mdef)
|
||||
core.enemys.getDamageInfo(enemy, hero_hp, hero_atk, hero_def, hero_mdef, x, y, floorId)
|
||||
获得实际战斗信息,比如伤害,回合数,每回合伤害等等。
|
||||
此函数是实际战斗过程的计算。
|
||||
|
||||
|
||||
core.enemys.calDamage(enemy, hero_hp, hero_atk, hero_def, hero_mdef)
|
||||
core.enemys.calDamage(enemy, hero_hp, hero_atk, hero_def, hero_mdef, x, y, floorId)
|
||||
获得在某个勇士属性下怪物伤害;实际返回的是上面getDamageInfo中伤害的数值。
|
||||
|
||||
|
||||
|
||||
@ -320,7 +320,7 @@ core.setFlag("shield5", true); // 增加一个自定义Flag:已经拿到神圣
|
||||
```
|
||||
2. 免疫吸血效果:在脚本编辑的getDamageInfo中,编辑成如果存在神圣盾标记,吸血伤害为0。
|
||||
``` js
|
||||
function (enemy, hero_hp, hero_atk, hero_def, hero_mdef) {
|
||||
function (enemy, hero_hp, hero_atk, hero_def, hero_mdef, x, y, floorId) {
|
||||
// ... 上略
|
||||
// 吸血
|
||||
if (this.hasSpecial(mon_special, 11)) {
|
||||
@ -501,7 +501,7 @@ case 87: // W
|
||||
// 请使用同步脚本,请勿执行任何异步代码,否则可能导致游戏过程或录像出现问题。
|
||||
core.insertAction([...]) // 例如,插入一段自定义事件并执行。
|
||||
|
||||
core.status.route.push("key:"+keyCode); // 录像的支持!这句话必须要加,不然录像回放会出错!
|
||||
// core.status.route.push("key:"+keyCode); // 录像的支持,这句话加不加最好仔细进行测试
|
||||
}
|
||||
break;
|
||||
```
|
||||
@ -509,7 +509,9 @@ case 87: // W
|
||||
|
||||
在勇士处于停止的条件下,按下W键时,将执行你写的脚本代码。请只使用同步脚本而不要使用异步代码,不然可能导致游戏出现问题。
|
||||
|
||||
`core.status.route.push("key:"+keyCode);` 这句话是对录像的支持,一定要加(这样录像播放时也会模拟该按键)。
|
||||
`core.status.route.push("key:"+keyCode);` 这句话是对录像的支持。
|
||||
|
||||
**录像的支持可能比较诡异,在不同条件下都是不同的;因此加不加最好分开独立进行测试。**
|
||||
|
||||
!> H5不支持组合快捷键,所以不存在`W+1`这种组合快捷键的说法!
|
||||
|
||||
@ -560,8 +562,8 @@ this.myfunc = function(x) {
|
||||
<p class='statusLabel' id='mana'></p>
|
||||
</div>
|
||||
```
|
||||
3. 在editor.html中的statusBar(305行起),仿照第二点同样添加;这一项如果不进行则会地图编辑器报错。
|
||||
4. 使用便捷PS工具,打开icons.png,新增一行并将魔力的图标P上去;记下其索引比如23(减速播放图标的下方)。
|
||||
3. 在editor.html中的statusBar(317行起),仿照第二点同样添加;这一项如果不进行则会地图编辑器报错。editor-mobile.html同理。
|
||||
4. 使用便捷PS工具,打开icons.png,新增一行并将魔力的图标P上去;记下其索引比如24(从0开始数)。
|
||||
5. 在main.js的this.statusBar中增加图片、图标和内容的定义。
|
||||
``` js
|
||||
this.statusBar = {
|
||||
@ -571,7 +573,7 @@ this.statusBar = {
|
||||
},
|
||||
'icons': {
|
||||
// ...其他略
|
||||
'mana': 23, // 图标的定义,这里对应的是icons.png中的索引
|
||||
'mana': 24, // 图标的定义,这里对应的是icons.png中的索引
|
||||
},
|
||||
// ...其他略
|
||||
'mana': document.getElementById('mana'), // 显示内容(数据)的定义
|
||||
@ -583,7 +585,6 @@ core.statusBar.mana.innerHTML = core.getFlag('mana', 0); // 设置其显示内
|
||||
core.statusBar.mana.innerHTML = core.getFlag('mana', 0) + '/' + core.getFlag('manaMax', 0); // 显示内容将类似 "32/60" 这样。
|
||||
core.statusBar.mana.style.fontStyle = 'normal'; // 这一行会取消斜体。如果是汉字(比如技能名)的话,斜体起来会非常难看,可以通过这一句取消。
|
||||
```
|
||||
7. 在control.js的clearStatusBar函数,`statusList`里面也要增加mana项,这样清空状态栏时也会对其清空。
|
||||
|
||||
## 技能塔的支持
|
||||
|
||||
|
||||
@ -333,6 +333,10 @@
|
||||
<img id="img-floor">
|
||||
<p class='statusLabel' id='floor'></p>
|
||||
</div>
|
||||
<div class="status" id="nameCol">
|
||||
<img id="img-name">
|
||||
<p class='statusLabel' id='name'></p>
|
||||
</div>
|
||||
<div class="status" id="lvCol">
|
||||
<img id="img-lv">
|
||||
<p class='statusLabel' id='lv'></p>
|
||||
|
||||
@ -319,6 +319,10 @@
|
||||
<img id="img-floor">
|
||||
<p class='statusLabel' id='floor'></p>
|
||||
</div>
|
||||
<div class="status" id="nameCol">
|
||||
<img id="img-name">
|
||||
<p class='statusLabel' id='name'></p>
|
||||
</div>
|
||||
<div class="status" id="lvCol">
|
||||
<img id="img-lv">
|
||||
<p class='statusLabel' id='lv'></p>
|
||||
|
||||
@ -46,6 +46,10 @@
|
||||
<img id="img-floor">
|
||||
<p class='statusLabel' id='floor'></p>
|
||||
</div>
|
||||
<div class="status" id="nameCol">
|
||||
<img id="img-name">
|
||||
<p class='statusLabel' id='name'></p>
|
||||
</div>
|
||||
<div class="status" id="lvCol">
|
||||
<img id="img-lv">
|
||||
<p class='statusLabel' id='lv'></p>
|
||||
|
||||
@ -969,24 +969,15 @@ actions.prototype.clickFly = function(x,y) {
|
||||
if ((x==10 || x==11) && y==10) core.ui.drawFly(core.status.event.data-10);
|
||||
if ((x==10 || x==11) && y==4) core.ui.drawFly(core.status.event.data+10);
|
||||
if (x>=5 && x<=7 && y==12) core.ui.closePanel();
|
||||
if (x>=0 && x<=9 && y>=3 && y<=11) {
|
||||
var index=core.status.hero.flyRange.indexOf(core.status.floorId);
|
||||
var stair=core.status.event.data<index?"upFloor":"downFloor";
|
||||
if (core.status.event.data==index && core.floors[core.status.floorId].underGround)
|
||||
stair = "upFloor";
|
||||
var floorId=core.status.event.data;
|
||||
var toFloor = core.status.hero.flyRange[floorId];
|
||||
core.status.route.push("fly:"+toFloor);
|
||||
core.ui.closePanel();
|
||||
core.changeFloor(toFloor, stair);
|
||||
}
|
||||
if (x>=0 && x<=9 && y>=3 && y<=11)
|
||||
core.control.flyTo(core.status.hero.flyRange[core.status.event.data]);
|
||||
return;
|
||||
}
|
||||
|
||||
////// 楼层传送器界面时,按下某个键的操作 //////
|
||||
actions.prototype.keyDownFly = function (keycode) {
|
||||
if (keycode==37) core.ui.drawFly(core.status.event.data-10);
|
||||
else if ( keycode==38) core.ui.drawFly(core.status.event.data+1);
|
||||
else if (keycode==38) core.ui.drawFly(core.status.event.data+1);
|
||||
else if (keycode==39) core.ui.drawFly(core.status.event.data+10);
|
||||
else if (keycode==40) core.ui.drawFly(core.status.event.data-1);
|
||||
return;
|
||||
@ -1030,14 +1021,14 @@ actions.prototype.clickViewMaps = function (x,y) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(x>=2 && x<=10 && y<=4) {
|
||||
if(y<=4 && (mh==13 || (x>=2 && x<=10))) {
|
||||
index++;
|
||||
while (index<core.floorIds.length && index!=now && core.floors[core.floorIds[index]].cannotViewMap)
|
||||
index++;
|
||||
if (index<core.floorIds.length)
|
||||
core.ui.drawMaps(index);
|
||||
}
|
||||
else if (x>=2 && x<=10 && y>=8) {
|
||||
else if (y>=8 && (mh==13 || (x>=2 && x<=10))) {
|
||||
index--;
|
||||
while (index>=0 && index!=now && core.floors[core.floorIds[index]].cannotViewMap)
|
||||
index--;
|
||||
@ -1231,7 +1222,7 @@ actions.prototype.keyUpQuickShop = function (keycode) {
|
||||
////// 工具栏界面时的点击操作 //////
|
||||
actions.prototype.clickToolbox = function(x,y) {
|
||||
// 装备栏
|
||||
if (x>=10 && x<=12 && y==0 && core.flags.equipment) {
|
||||
if (x>=10 && x<=12 && y==0) {
|
||||
core.ui.closePanel();
|
||||
core.openEquipbox();
|
||||
return;
|
||||
@ -2067,6 +2058,10 @@ actions.prototype.clickSyncSave = function (x,y) {
|
||||
});
|
||||
break;
|
||||
case 4:
|
||||
core.status.event.selection=0;
|
||||
core.ui.drawReplay();
|
||||
break;
|
||||
case 5:
|
||||
if (core.hasFlag('debug')) {
|
||||
core.drawText("\t[系统提示]调试模式下无法下载录像");
|
||||
break;
|
||||
@ -2078,11 +2073,11 @@ actions.prototype.clickSyncSave = function (x,y) {
|
||||
'route': core.encodeRoute(core.status.route)
|
||||
}));
|
||||
break;
|
||||
case 5:
|
||||
case 6:
|
||||
core.status.event.selection=0;
|
||||
core.ui.drawStorageRemove();
|
||||
break;
|
||||
case 6:
|
||||
case 7:
|
||||
core.status.event.selection=3;
|
||||
core.ui.drawSettings();
|
||||
break;
|
||||
|
||||
104
libs/control.js
104
libs/control.js
@ -250,6 +250,8 @@ control.prototype.clearStatus = function() {
|
||||
}
|
||||
core.status = {};
|
||||
core.clearStatusBar();
|
||||
core.status.played = false;
|
||||
core.events.setHeroIcon('hero.png', true);
|
||||
}
|
||||
|
||||
////// 重置游戏状态和初始数据 //////
|
||||
@ -266,7 +268,6 @@ control.prototype.resetStatus = function(hero, hard, floorId, route, maps, value
|
||||
|
||||
// 初始化status
|
||||
core.status = core.clone(core.initStatus);
|
||||
core.status.played = true;
|
||||
// 初始化maps
|
||||
core.status.floorId = floorId;
|
||||
core.status.maps = core.clone(maps);
|
||||
@ -275,6 +276,8 @@ control.prototype.resetStatus = function(hero, hard, floorId, route, maps, value
|
||||
core.material.items = core.clone(core.items.getItems());
|
||||
// 初始化人物属性
|
||||
core.status.hero = core.clone(hero);
|
||||
// 初始化人物图标
|
||||
core.events.setHeroIcon(core.getFlag('heroIcon', 'hero.png'), true);
|
||||
// 统计数据
|
||||
if (!core.isset(core.status.hero.statistics))
|
||||
core.status.hero.statistics = {
|
||||
@ -302,6 +305,7 @@ control.prototype.resetStatus = function(hero, hard, floorId, route, maps, value
|
||||
else core.values = core.clone(core.data.values);
|
||||
|
||||
core.events.initGame();
|
||||
core.status.played = true;
|
||||
}
|
||||
|
||||
////// 开始游戏 //////
|
||||
@ -1022,6 +1026,8 @@ control.prototype.updateViewport = function() {
|
||||
////// 绘制勇士 //////
|
||||
control.prototype.drawHero = function (direction, x, y, status, offset) {
|
||||
|
||||
if (!core.isPlaying()) return;
|
||||
|
||||
var scan = {
|
||||
'up': {'x': 0, 'y': -1},
|
||||
'left': {'x': -1, 'y': 0},
|
||||
@ -1197,20 +1203,22 @@ control.prototype.checkBlock = function () {
|
||||
|
||||
// 检查阻击事件
|
||||
var snipe = [];
|
||||
var scan = {
|
||||
'up': {'x': 0, 'y': -1},
|
||||
'left': {'x': -1, 'y': 0},
|
||||
'down': {'x': 0, 'y': 1},
|
||||
'right': {'x': 1, 'y': 0}
|
||||
}
|
||||
for (var direction in scan) {
|
||||
var nx = x+scan[direction].x, ny=y+scan[direction].y;
|
||||
if (nx<0 || nx>=core.bigmap.width || ny<0 || ny>=core.bigmap.height) continue;
|
||||
var id=core.status.checkBlock.map[nx+core.bigmap.width*ny];
|
||||
if (core.isset(id)) {
|
||||
var enemy = core.material.enemys[id];
|
||||
if (core.isset(enemy) && core.enemys.hasSpecial(enemy.special, 18)) {
|
||||
snipe.push({'direction': direction, 'x': nx, 'y': ny});
|
||||
if (!core.hasFlag("no_snipe")) {
|
||||
var scan = {
|
||||
'up': {'x': 0, 'y': -1},
|
||||
'left': {'x': -1, 'y': 0},
|
||||
'down': {'x': 0, 'y': 1},
|
||||
'right': {'x': 1, 'y': 0}
|
||||
}
|
||||
for (var direction in scan) {
|
||||
var nx = x+scan[direction].x, ny=y+scan[direction].y;
|
||||
if (nx<0 || nx>=core.bigmap.width || ny<0 || ny>=core.bigmap.height) continue;
|
||||
var id=core.status.checkBlock.map[nx+core.bigmap.width*ny];
|
||||
if (core.isset(id)) {
|
||||
var enemy = core.material.enemys[id];
|
||||
if (core.isset(enemy) && core.enemys.hasSpecial(enemy.special, 18)) {
|
||||
snipe.push({'direction': direction, 'x': nx, 'y': ny});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1280,7 +1288,7 @@ control.prototype.snipe = function (snipes) {
|
||||
snipe.blockImage = core.material.images[cls];
|
||||
snipe.height = height;
|
||||
|
||||
var damage = core.enemys.getDamage(block.event.id);
|
||||
var damage = core.enemys.getDamage(block.event.id, x, y);
|
||||
var color = '#000000';
|
||||
|
||||
if (damage == null) {
|
||||
@ -1506,7 +1514,7 @@ control.prototype.updateDamage = function () {
|
||||
// 判断显伤
|
||||
var event = core.floors[core.status.floorId].events[x+","+y];
|
||||
if (core.isset(event) && !(event instanceof Array)) {
|
||||
if (core.isset(event.displayDamage) && !event.displayDamage)
|
||||
if (event.displayDamage === false)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -1514,7 +1522,7 @@ control.prototype.updateDamage = function () {
|
||||
var id = mapBlocks[b].event.id;
|
||||
|
||||
if (core.flags.displayEnemyDamage) {
|
||||
var damage = core.enemys.getDamage(id);
|
||||
var damage = core.enemys.getDamage(id, x, y);
|
||||
var color = '#000000';
|
||||
|
||||
if (damage == null) {
|
||||
@ -1901,14 +1909,10 @@ control.prototype.replay = function () {
|
||||
if (core.hasItem('fly') && toIndex>=0 && nowIndex>=0) {
|
||||
core.ui.drawFly(toIndex);
|
||||
setTimeout(function () {
|
||||
core.ui.closePanel();
|
||||
var stair=toIndex<nowIndex?"upFloor":"downFloor";
|
||||
if (toIndex==nowIndex && core.floors[core.status.floorId].underGround)
|
||||
stair = "upFloor";
|
||||
core.status.route.push("fly:"+floorId);
|
||||
core.changeFloor(floorId, stair, null, null, function () {
|
||||
core.replay();
|
||||
});
|
||||
if (!core.control.flyTo(floorId, function () {core.replay()})) {
|
||||
core.stopReplay();
|
||||
core.insertAction("录像文件出错");
|
||||
}
|
||||
}, 750 / Math.max(1, core.status.replay.speed));
|
||||
return;
|
||||
}
|
||||
@ -2059,6 +2063,10 @@ control.prototype.useFly = function (need) {
|
||||
return;
|
||||
}
|
||||
|
||||
control.prototype.flyTo = function (toId, callback) {
|
||||
return this.controldata.flyTo(toId, callback);
|
||||
}
|
||||
|
||||
////// 点击装备栏时的打开操作 //////
|
||||
control.prototype.openEquipbox = function (need) {
|
||||
if (core.isset(core.status.replay)&&core.status.replay.replaying) return;
|
||||
@ -2433,9 +2441,7 @@ control.prototype.getStatus = function (statusName) {
|
||||
|
||||
////// 获得某个等级的名称 //////
|
||||
control.prototype.getLvName = function () {
|
||||
if (!core.isset(core.firstData.levelUp) || core.status.hero.lv<=0
|
||||
|| core.status.hero.lv>core.firstData.levelUp.length) return core.status.hero.lv;
|
||||
return core.firstData.levelUp[core.status.hero.lv-1].name || core.status.hero.lv;
|
||||
return ((core.firstData.levelUp||[])[core.status.hero.lv-1]||{}).name || core.status.hero.lv;
|
||||
}
|
||||
|
||||
////// 设置某个自定义变量或flag //////
|
||||
@ -2585,11 +2591,11 @@ control.prototype.playSound = function (sound) {
|
||||
|
||||
////// 清空状态栏 //////
|
||||
control.prototype.clearStatusBar = function() {
|
||||
var statusList = ['floor', 'lv', 'hpmax', 'hp', 'atk', 'def', 'mdef', 'money', 'experience',
|
||||
'up', 'yellowKey', 'blueKey', 'redKey', 'poison', 'weak', 'curse', 'hard'];
|
||||
statusList.forEach(function (e) {
|
||||
core.statusBar[e].innerHTML = " ";
|
||||
});
|
||||
|
||||
Object.keys(core.statusBar).forEach(function (e) {
|
||||
if (core.isset(core.statusBar[e].innerHTML))
|
||||
core.statusBar[e].innerHTML = " ";
|
||||
})
|
||||
core.statusBar.image.book.style.opacity = 0.3;
|
||||
if (!core.flags.equipboxButton) {
|
||||
core.statusBar.image.fly.style.opacity = 0.3;
|
||||
@ -2645,6 +2651,27 @@ control.prototype.updateStatusBar = function () {
|
||||
}
|
||||
}
|
||||
|
||||
control.prototype.updateHeroIcon = function (name) {
|
||||
name = name || "hero.png";
|
||||
if (core.statusBar.icons.name == name) return;
|
||||
core.statusBar.icons.name = name;
|
||||
|
||||
var image = core.material.images.hero;
|
||||
|
||||
var canvas = document.createElement("canvas");
|
||||
var context = canvas.getContext("2d");
|
||||
canvas.width = 32;
|
||||
canvas.height = 32;
|
||||
context.drawImage(image, 0, 0, 32, 32, 0, 0, 32, 32);
|
||||
if (core.material.icons.hero.height>=48) {
|
||||
context.lineWidth = 5;
|
||||
context.strokeStyle = '#FFFFFF';
|
||||
context.strokeRect(0, 0, 32, 32);
|
||||
}
|
||||
core.statusBar.image.name.src = canvas.toDataURL("image/png");
|
||||
|
||||
}
|
||||
|
||||
////// 屏幕分辨率改变后重新自适应 //////
|
||||
control.prototype.resize = function(clientWidth, clientHeight) {
|
||||
if (main.mode=='editor')return;
|
||||
@ -2685,8 +2712,9 @@ control.prototype.resize = function(clientWidth, clientHeight) {
|
||||
if (!core.flags.enableExperience) count--;
|
||||
if (!core.flags.enableLevelUp) count--;
|
||||
if (!core.flags.enableDebuff) count--;
|
||||
if (core.isset(core.flags.enableKeys) && !core.flags.enableKeys) count--;
|
||||
if (!core.flags.enableKeys) count--;
|
||||
if (!core.flags.enablePZF) count--;
|
||||
if (!core.flags.enableName) count--;
|
||||
|
||||
var statusLineHeight = BASE_LINEHEIGHT * 9 / count;
|
||||
var statusLineFontSize = DEFAULT_FONT_SIZE;
|
||||
@ -2940,6 +2968,12 @@ control.prototype.resize = function(clientWidth, clientHeight) {
|
||||
display: core.flags.enableFloor ? 'block': 'none'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'nameCol',
|
||||
rules: {
|
||||
display: core.flags.enableName ? 'block': 'none'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'lvCol',
|
||||
rules: {
|
||||
|
||||
34
libs/core.js
34
libs/core.js
@ -232,19 +232,23 @@ core.prototype.init = function (coreData, callback) {
|
||||
core.platform.isQQ = /QQ/i.test(navigator.userAgent);
|
||||
core.platform.isWeChat = /MicroMessenger/i.test(navigator.userAgent);
|
||||
core.platform.useLocalForage = core.getLocalStorage('useLocalForage', true);
|
||||
if (core.platform.isIOS) core.platform.useLocalForage=false;
|
||||
if (core.platform.useLocalForage) {
|
||||
try {
|
||||
core.setLocalForage("__test__", "__test__", function() {
|
||||
core.setLocalForage("__test__", LZString.compress("__test__"), function() {
|
||||
try {
|
||||
core.getLocalForage("__test__", null, function(data) {
|
||||
if (data!="__test__") {
|
||||
console.log("localForage unsupported!");
|
||||
core.platform.useLocalForage=false;
|
||||
}
|
||||
else {
|
||||
console.log("localForage supported!")
|
||||
core.removeLocalForage("__test__");
|
||||
try {
|
||||
if (LZString.decompress(data)!="__test__") {
|
||||
console.log("localForage unsupported!");
|
||||
core.platform.useLocalForage=false;
|
||||
}
|
||||
else {
|
||||
console.log("localForage supported!")
|
||||
core.removeLocalForage("__test__");
|
||||
}
|
||||
}
|
||||
catch (e) {console.log(e); core.platform.useLocalForage=false;}
|
||||
}, function(e) {console.log(e); core.platform.useLocalForage=false;})
|
||||
}
|
||||
catch (e) {console.log(e); core.platform.useLocalForage=false;}
|
||||
@ -288,8 +292,7 @@ core.prototype.init = function (coreData, callback) {
|
||||
core.flags.displayEnemyDamage = core.getLocalStorage('enemyDamage', core.flags.displayEnemyDamage);
|
||||
core.flags.displayCritical = core.getLocalStorage('critical', core.flags.displayCritical);
|
||||
core.flags.displayExtraDamage = core.getLocalStorage('extraDamage', core.flags.displayExtraDamage);
|
||||
core.flags.clickMoveDirectly = core.getLocalStorage('clickMoveDirectly',
|
||||
!(core.isset(core.flags.clickMoveDirectly) && !core.flags.clickMoveDirectly));
|
||||
core.flags.clickMoveDirectly = core.getLocalStorage('clickMoveDirectly', core.flags.clickMoveDirectly);
|
||||
|
||||
core.material.ground = new Image();
|
||||
core.material.ground.src = "project/images/ground.png";
|
||||
@ -300,6 +303,9 @@ core.prototype.init = function (coreData, callback) {
|
||||
console.log(core.material);
|
||||
// 设置勇士高度
|
||||
core.material.icons.hero.height = core.material.images.hero.height/4;
|
||||
// 行走图
|
||||
core.control.updateHeroIcon();
|
||||
|
||||
core.initStatus.maps = core.maps.initMaps(core.floorIds);
|
||||
core.setRequestAnimationFrame();
|
||||
core.showStartAnimate();
|
||||
@ -821,13 +827,13 @@ core.prototype.hasSpecial = function (special, test) {
|
||||
}
|
||||
|
||||
////// 判断能否战斗 //////
|
||||
core.prototype.canBattle = function(enemyId) {
|
||||
return core.enemys.canBattle(enemyId);
|
||||
core.prototype.canBattle = function(enemyId, x, y, floorId) {
|
||||
return core.enemys.canBattle(enemyId, x, y, floorId);
|
||||
}
|
||||
|
||||
////// 获得伤害数值 //////
|
||||
core.prototype.getDamage = function(enemy) {
|
||||
return core.enemys.getDamage(enemy);
|
||||
core.prototype.getDamage = function(enemy, x, y, floorId) {
|
||||
return core.enemys.getDamage(enemy, x, y, floorId);
|
||||
}
|
||||
|
||||
////// 获得某个物品的个数 //////
|
||||
|
||||
@ -99,15 +99,15 @@ enemys.prototype.getSpecialHint = function (enemy, special) {
|
||||
}
|
||||
|
||||
////// 能否获胜 //////
|
||||
enemys.prototype.canBattle = function (enemyId) {
|
||||
var damage = this.getDamage(enemyId);
|
||||
enemys.prototype.canBattle = function (enemyId, x, y, floorId) {
|
||||
var damage = this.getDamage(enemyId, x, y, floorId);
|
||||
return damage != null && damage < core.status.hero.hp;
|
||||
}
|
||||
|
||||
////// 获得某个怪物的伤害 //////
|
||||
enemys.prototype.getDamage = function (enemy) {
|
||||
enemys.prototype.getDamage = function (enemy, x, y, floorId) {
|
||||
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
|
||||
var damage = this.calDamage(enemy, core.status.hero.hp, core.status.hero.atk, core.status.hero.def, core.status.hero.mdef);
|
||||
var damage = this.calDamage(enemy, core.status.hero.hp, core.status.hero.atk, core.status.hero.def, core.status.hero.mdef, x, y, floorId);
|
||||
if (damage == null) return null;
|
||||
return damage + this.getExtraDamage(enemy);
|
||||
}
|
||||
@ -126,7 +126,7 @@ enemys.prototype.getExtraDamage = function (enemy) {
|
||||
}
|
||||
|
||||
////// 接下来N个临界值和临界减伤计算 //////
|
||||
enemys.prototype.nextCriticals = function (enemy, number) {
|
||||
enemys.prototype.nextCriticals = function (enemy, number, x, y, floorId) {
|
||||
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
|
||||
|
||||
var useTurn = !core.flags.useLoop;
|
||||
@ -142,7 +142,7 @@ enemys.prototype.nextCriticals = function (enemy, number) {
|
||||
|
||||
// 坚固、模仿怪物没有临界!
|
||||
if (this.hasSpecial(enemy.special, 10)) return [];
|
||||
var info = this.getDamageInfo(enemy, core.status.hero.hp, core.status.hero.atk, core.status.hero.def, core.status.hero.mdef);
|
||||
var info = this.getDamageInfo(enemy, core.status.hero.hp, core.status.hero.atk, core.status.hero.def, core.status.hero.mdef, x, y, floorId);
|
||||
|
||||
if (info == null) {
|
||||
if (core.status.hero.atk<=enemy.def) {
|
||||
@ -167,7 +167,7 @@ enemys.prototype.nextCriticals = function (enemy, number) {
|
||||
}
|
||||
if (nextAtk<=hero_atk) break;
|
||||
if (nextAtk!=pre) {
|
||||
var nextInfo = this.getDamageInfo(enemy, core.status.hero.hp, nextAtk, core.status.hero.def, core.status.hero.mdef);
|
||||
var nextInfo = this.getDamageInfo(enemy, core.status.hero.hp, nextAtk, core.status.hero.def, core.status.hero.mdef, x, y, floorId);
|
||||
if (nextInfo==null) break;
|
||||
list.push([nextAtk-hero_atk,info.damage-nextInfo.damage]);
|
||||
if (nextInfo.damage<=0 && !core.flags.enableNegativeDamage) break;
|
||||
@ -180,7 +180,7 @@ enemys.prototype.nextCriticals = function (enemy, number) {
|
||||
else { // 暴力for循环法
|
||||
pre = info.damage;
|
||||
for (var atk=hero_atk+1;atk<=mon_hp+mon_def;atk++) {
|
||||
var nextInfo = this.getDamageInfo(enemy, core.status.hero.hp, atk, core.status.hero.def, core.status.hero.mdef);
|
||||
var nextInfo = this.getDamageInfo(enemy, core.status.hero.hp, atk, core.status.hero.def, core.status.hero.mdef, x, y, floorId);
|
||||
if (nextInfo==null) break;
|
||||
if (pre>nextInfo.damage) {
|
||||
pre = nextInfo.damage;
|
||||
@ -195,27 +195,32 @@ enemys.prototype.nextCriticals = function (enemy, number) {
|
||||
}
|
||||
|
||||
////// N防减伤计算 //////
|
||||
enemys.prototype.getDefDamage = function (enemy, k) {
|
||||
enemys.prototype.getDefDamage = function (enemy, k, x, y, floorId) {
|
||||
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
|
||||
k = k || 1;
|
||||
var nowDamage = this.calDamage(enemy, core.status.hero.hp, core.status.hero.atk, core.status.hero.def, core.status.hero.mdef);
|
||||
var nextDamage = this.calDamage(enemy, core.status.hero.hp, core.status.hero.atk, core.status.hero.def + k, core.status.hero.mdef);
|
||||
var nowDamage = this.calDamage(enemy, core.status.hero.hp, core.status.hero.atk, core.status.hero.def, core.status.hero.mdef, x, y, floorId);
|
||||
var nextDamage = this.calDamage(enemy, core.status.hero.hp, core.status.hero.atk, core.status.hero.def + k, core.status.hero.mdef, x, y, floorId);
|
||||
if (nowDamage == null || nextDamage ==null) return "???";
|
||||
return nowDamage - nextDamage;
|
||||
}
|
||||
|
||||
enemys.prototype.getEnemyInfo = function (enemy, hero_hp, hero_atk, hero_def, hero_mdef, x, y, floorId) {
|
||||
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
|
||||
return this.enemydata.getEnemyInfo(enemy, hero_hp, hero_atk, hero_def, hero_mdef, x, y, floorId)
|
||||
}
|
||||
|
||||
////// 获得战斗伤害信息(实际伤害计算函数) //////
|
||||
enemys.prototype.getDamageInfo = function(enemy, hero_hp, hero_atk, hero_def, hero_mdef) {
|
||||
enemys.prototype.getDamageInfo = function(enemy, hero_hp, hero_atk, hero_def, hero_mdef, x, y, floorId) {
|
||||
// 移动到了脚本编辑 - getDamageInfo中
|
||||
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
|
||||
return this.enemydata.getDamageInfo(enemy, hero_hp, hero_atk, hero_def, hero_mdef);
|
||||
return this.enemydata.getDamageInfo(enemy, hero_hp, hero_atk, hero_def, hero_mdef, x, y, floorId);
|
||||
}
|
||||
|
||||
////// 获得在某个勇士属性下怪物伤害 //////
|
||||
enemys.prototype.calDamage = function (enemy, hero_hp, hero_atk, hero_def, hero_mdef) {
|
||||
enemys.prototype.calDamage = function (enemy, hero_hp, hero_atk, hero_def, hero_mdef, x, y, floorId) {
|
||||
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
|
||||
|
||||
var info = this.getDamageInfo(enemy, hero_hp, hero_atk, hero_def, hero_mdef);
|
||||
var info = this.getDamageInfo(enemy, hero_hp, hero_atk, hero_def, hero_mdef, x, y, floorId);
|
||||
if (info == null) return null;
|
||||
return info.damage;
|
||||
}
|
||||
@ -246,12 +251,7 @@ enemys.prototype.getCurrentEnemys = function (floorId) {
|
||||
hero_def = Math.floor(core.getFlag('equip_def_buff',1)*hero_def);
|
||||
hero_mdef = Math.floor(core.getFlag('equip_mdef_buff',1)*hero_mdef);
|
||||
}
|
||||
if (this.hasSpecial(enemy.special, 10)) {
|
||||
mon_atk=hero_atk;
|
||||
mon_def=hero_def;
|
||||
}
|
||||
if (this.hasSpecial(enemy.special, 3) && mon_def < hero_atk - 1)
|
||||
mon_def = hero_atk - 1;
|
||||
var enemyInfo = this.getEnemyInfo(enemy, core.status.hero.hp, hero_atk, hero_def, hero_mdef, null, null, floorId);
|
||||
|
||||
var specialText = core.enemys.getSpecialText(enemyId);
|
||||
if (specialText.length>=3) specialText = "多属性...";
|
||||
@ -263,17 +263,17 @@ enemys.prototype.getCurrentEnemys = function (floorId) {
|
||||
enemys.push({
|
||||
'id': enemyId,
|
||||
'name': enemy.name,
|
||||
'hp': mon_hp,
|
||||
'atk': mon_atk,
|
||||
'def': mon_def,
|
||||
'money': enemy.money,
|
||||
'experience': enemy.experience,
|
||||
'point': enemy.point||0, // 加点
|
||||
'hp': enemyInfo.hp,
|
||||
'atk': enemyInfo.atk,
|
||||
'def': enemyInfo.def,
|
||||
'money': enemyInfo.money||0,
|
||||
'experience': enemyInfo.experience||0,
|
||||
'point': enemyInfo.point||0, // 加点
|
||||
'special': specialText,
|
||||
'damage': this.getDamage(enemyId),
|
||||
'damage': this.getDamage(enemyId,null,null,floorId),
|
||||
'critical': critical[0],
|
||||
'criticalDamage': critical[1],
|
||||
'defDamage': this.getDefDamage(enemyId)
|
||||
'defDamage': this.getDefDamage(enemyId,1,null,null,floorId)
|
||||
});
|
||||
|
||||
used[enemyId] = true;
|
||||
|
||||
@ -657,16 +657,21 @@ events.prototype.doAction = function() {
|
||||
case "setFg": // 颜色渐变
|
||||
if (data.async) {
|
||||
core.setFg(data.color, data.time);
|
||||
core.setFlag('color', data.color||null);
|
||||
this.doAction();
|
||||
}
|
||||
else {
|
||||
core.setFg(data.color, data.time, function() {
|
||||
core.setFlag('color', data.color||null);
|
||||
core.events.doAction();
|
||||
});
|
||||
}
|
||||
break;
|
||||
case "setWeather": // 更改天气
|
||||
core.setWeather(data.name, data.level);
|
||||
if (core.isset(data.name))
|
||||
core.setFlag('weather', [data.name, data.level]);
|
||||
else core.setFlag('weather', null);
|
||||
this.doAction();
|
||||
break;
|
||||
case "openDoor": // 开一个门,包括暗墙
|
||||
@ -1120,7 +1125,7 @@ events.prototype.battle = function (id, x, y, force, callback) {
|
||||
core.stopAutomaticRoute();
|
||||
|
||||
// 非强制战斗
|
||||
if (!core.enemys.canBattle(id) && !force && !core.isset(core.status.event.id)) {
|
||||
if (!core.enemys.canBattle(id, x, y) && !force && !core.isset(core.status.event.id)) {
|
||||
core.drawTip("你打不过此怪物!");
|
||||
core.clearContinueAutomaticRoute();
|
||||
return;
|
||||
@ -1272,29 +1277,32 @@ events.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback
|
||||
}
|
||||
|
||||
// 不存在事件时,更改画面色调
|
||||
if (core.status.event.id == null) {
|
||||
// 默认画面色调
|
||||
if (core.isset(core.floors[floorId].color)) {
|
||||
var color = core.floors[floorId].color;
|
||||
|
||||
// 直接变色
|
||||
core.clearMap('curtain');
|
||||
if (core.isset(color[3]))
|
||||
core.setAlpha('curtain', color[3]);
|
||||
else
|
||||
core.setAlpha('curtain', 1);
|
||||
core.fillRect('curtain', 0, 0, 416, 416, core.arrayToRGB(color));
|
||||
core.status.curtainColor = color;
|
||||
}
|
||||
else {
|
||||
core.clearMap('curtain');
|
||||
core.setAlpha('curtain', 0);
|
||||
}
|
||||
var color = core.getFlag('color', null);
|
||||
if (!core.isset(color) && core.isset(core.floors[floorId].color)) {
|
||||
color = core.floors[floorId].color;
|
||||
}
|
||||
if (core.isset(color)) {
|
||||
// 直接变色
|
||||
core.clearMap('curtain');
|
||||
if (core.isset(color[3]))
|
||||
core.setAlpha('curtain', color[3]);
|
||||
else
|
||||
core.setAlpha('curtain', 1);
|
||||
core.fillRect('curtain', 0, 0, 416, 416, core.arrayToRGB(color));
|
||||
core.status.curtainColor = color;
|
||||
}
|
||||
else {
|
||||
core.clearMap('curtain');
|
||||
core.setAlpha('curtain', 0);
|
||||
}
|
||||
|
||||
// 更改天气
|
||||
if (core.isset(core.floors[floorId].weather)) {
|
||||
core.setWeather(core.floors[floorId].weather[0], core.floors[floorId].weather[1])
|
||||
var weather = core.getFlag('weather', null);
|
||||
if (!core.isset(weather) && core.isset(core.floors[floorId].weather)) {
|
||||
weather = core.floors[floorId].weather;
|
||||
}
|
||||
if (core.isset(weather)) {
|
||||
core.setWeather(weather[0], weather[1])
|
||||
}
|
||||
else core.setWeather();
|
||||
|
||||
@ -1561,19 +1569,19 @@ events.prototype.disableQuickShop = function (shopId) {
|
||||
|
||||
////// 能否使用快捷商店 //////
|
||||
events.prototype.canUseQuickShop = function(shopId) {
|
||||
if (core.isset(core.floors[core.status.floorId].canUseQuickShop) && !core.floors[core.status.floorId].canUseQuickShop)
|
||||
return '当前不能使用快捷商店。';
|
||||
|
||||
return null;
|
||||
return this.eventdata.canUseQuickShop(shopId);
|
||||
}
|
||||
|
||||
////// 设置角色行走图 //////
|
||||
events.prototype.setHeroIcon = function (name) {
|
||||
events.prototype.setHeroIcon = function (name, noDraw) {
|
||||
if (core.isset(core.material.images.images[name]) && core.material.images.images[name].width==128) {
|
||||
core.setFlag("heroIcon", name);
|
||||
core.material.images.hero.onload = function () {
|
||||
core.material.icons.hero.height = core.material.images.images[name].height/4;
|
||||
core.control.updateHeroIcon(name);
|
||||
if (!noDraw) core.drawHero();
|
||||
}
|
||||
core.material.images.hero.src = core.material.images.images[name].src;
|
||||
core.material.icons.hero.height = core.material.images.images[name].height/4;
|
||||
core.drawHero();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1582,7 +1590,7 @@ events.prototype.checkLvUp = function () {
|
||||
if (!core.flags.enableLevelUp || !core.isset(core.firstData.levelUp)
|
||||
|| core.status.hero.lv>=core.firstData.levelUp.length) return;
|
||||
// 计算下一个所需要的数值
|
||||
var need=core.firstData.levelUp[core.status.hero.lv].need;
|
||||
var need=(core.firstData.levelUp[core.status.hero.lv]||{}).need;
|
||||
if (!core.isset(need)) return;
|
||||
if (core.status.hero.experience>=need) {
|
||||
// 升级
|
||||
|
||||
53
libs/ui.js
53
libs/ui.js
@ -862,8 +862,11 @@ ui.prototype.drawBattleAnimate = function(monsterId, callback) {
|
||||
|
||||
var hero_hp = core.getStatus('hp'), hero_atk = core.getStatus('atk'), hero_def = core.getStatus('def'),
|
||||
hero_mdef = core.getStatus('mdef');
|
||||
var monster = core.material.enemys[monsterId];
|
||||
var mon_hp = monster.hp, mon_atk = monster.atk, mon_def = monster.def, mon_money=monster.money, mon_exp = monster.experience, mon_special=monster.special;
|
||||
|
||||
hero_hp=Math.max(0, hero_hp);
|
||||
hero_atk=Math.max(0, hero_atk);
|
||||
hero_def=Math.max(0, hero_def);
|
||||
hero_mdef=Math.max(0, hero_mdef);
|
||||
|
||||
if (core.flags.equipPercentage) {
|
||||
hero_atk = Math.floor(core.getFlag('equip_atk_buff',1)*hero_atk);
|
||||
@ -871,30 +874,30 @@ ui.prototype.drawBattleAnimate = function(monsterId, callback) {
|
||||
hero_mdef = Math.floor(core.getFlag('equip_mdef_buff',1)*hero_mdef);
|
||||
}
|
||||
|
||||
var enemy = core.material.enemys[monsterId];
|
||||
var enemyInfo = core.enemys.getEnemyInfo(enemy, hero_hp, hero_atk, hero_def, hero_mdef);
|
||||
var mon_hp = enemyInfo.hp, mon_atk = enemyInfo.atk, mon_def = enemyInfo.def, mon_money=enemyInfo.money,
|
||||
mon_exp = enemyInfo.experience, mon_special=enemyInfo.special;
|
||||
|
||||
var initDamage = 0; // 战前伤害
|
||||
|
||||
// 吸血
|
||||
if (core.enemys.hasSpecial(mon_special, 11)) {
|
||||
var vampireDamage = hero_hp * monster.value;
|
||||
var vampireDamage = hero_hp * enemy.value;
|
||||
|
||||
// 如果有神圣盾免疫吸血等可以在这里写
|
||||
|
||||
vampireDamage = Math.floor(vampireDamage);
|
||||
vampireDamage = Math.floor(vampireDamage) || 0;
|
||||
// 加到自身
|
||||
if (monster.add) // 如果加到自身
|
||||
if (enemy.add) // 如果加到自身
|
||||
mon_hp += vampireDamage;
|
||||
|
||||
initDamage += vampireDamage;
|
||||
}
|
||||
|
||||
hero_hp -= core.enemys.getExtraDamage(monster);
|
||||
hero_hp -= core.enemys.getExtraDamage(enemy);
|
||||
|
||||
if (core.enemys.hasSpecial(mon_special, 10)) { // 模仿
|
||||
mon_atk=hero_atk;
|
||||
mon_def=hero_def;
|
||||
}
|
||||
if (core.enemys.hasSpecial(mon_special, 2)) hero_def=0; // 魔攻
|
||||
if (core.enemys.hasSpecial(mon_special, 3) && mon_def<hero_atk) mon_def=hero_atk-1; // 坚固
|
||||
|
||||
// 实际操作
|
||||
var turn = 0; // 0为勇士攻击
|
||||
@ -904,7 +907,7 @@ ui.prototype.drawBattleAnimate = function(monsterId, callback) {
|
||||
var turns = 2;
|
||||
if (core.enemys.hasSpecial(mon_special, 4)) turns=3;
|
||||
if (core.enemys.hasSpecial(mon_special, 5)) turns=4;
|
||||
if (core.enemys.hasSpecial(mon_special, 6)) turns=1+(monster.n||4);
|
||||
if (core.enemys.hasSpecial(mon_special, 6)) turns=1+(enemy.n||4);
|
||||
|
||||
// 初始伤害
|
||||
if (core.enemys.hasSpecial(mon_special, 7)) initDamage+=Math.floor(core.values.breakArmor * hero_def);
|
||||
@ -1158,7 +1161,7 @@ ui.prototype.drawBattleAnimate = function(monsterId, callback) {
|
||||
return;
|
||||
}
|
||||
|
||||
}, 500);
|
||||
}, 400);
|
||||
}
|
||||
|
||||
////// 绘制等待界面 //////
|
||||
@ -1192,7 +1195,7 @@ ui.prototype.drawSyncSave = function () {
|
||||
core.status.event.id = 'syncSave';
|
||||
|
||||
this.drawChoices(null, [
|
||||
"同步存档到服务器", "从服务器加载存档", "存档至本地文件", "从本地文件读档", "下载当前录像", "清空本地存档", "返回主菜单"
|
||||
"同步存档到服务器", "从服务器加载存档", "存档至本地文件", "从本地文件读档", "回放当前录像", "下载当前录像", "清空本地存档", "返回主菜单"
|
||||
]);
|
||||
|
||||
}
|
||||
@ -1744,8 +1747,8 @@ ui.prototype.drawToolbox = function(index) {
|
||||
core.canvas.ui.textAlign = 'center';
|
||||
|
||||
// 装备栏
|
||||
if (core.flags.equipment)
|
||||
core.fillText('ui', '[装备栏]', 370, 25,'#DDDDDD', 'bold 15px Verdana');
|
||||
// if (core.flags.equipment)
|
||||
core.fillText('ui', '[装备栏]', 370, 25,'#DDDDDD', 'bold 15px Verdana');
|
||||
// core.fillText('ui', '删除道具', 370, 32,'#DDDDDD', 'bold 15px Verdana');
|
||||
// 退出
|
||||
core.fillText('ui', '返回游戏', 370, 403,'#DDDDDD', 'bold 15px Verdana');
|
||||
@ -2156,21 +2159,15 @@ ui.prototype.drawStatistics = function () {
|
||||
// 5. 当前已走的步数;瞬间移动的步数,瞬间移动的次数(和少走的步数);游戏时长
|
||||
// 6. 当前已恢复的生命值;当前总伤害、战斗伤害、阻激夹域血网伤害、中毒伤害。
|
||||
|
||||
var ids = this.uidata.drawStatistics();
|
||||
var obj = {};
|
||||
ids.forEach(function (e) {obj[e] = 0;})
|
||||
|
||||
var total = {
|
||||
'monster': {
|
||||
'count': 0, 'money': 0, 'experience': 0, 'point': 0,
|
||||
},
|
||||
'count': {
|
||||
'yellowDoor': 0, 'blueDoor': 0, 'redDoor': 0, 'greenDoor': 0, 'steelDoor': 0,
|
||||
'yellowKey': 0, 'blueKey': 0, 'redKey': 0, 'greenKey': 0, 'steelKey': 0,
|
||||
'redJewel': 0, 'blueJewel': 0, 'greenJewel': 0, 'yellowJewel': 0,
|
||||
'redPotion': 0, 'bluePotion': 0, 'greenPotion': 0, 'yellowPotion': 0, 'superPotion': 0,
|
||||
'pickaxe': 0, 'bomb': 0, 'centerFly': 0,
|
||||
'poisonWine': 0, 'weakWine': 0, 'curseWine': 0, 'superWine': 0,
|
||||
'sword1': 0, 'sword2': 0, 'sword3': 0, 'sword4': 0, 'sword5': 0,
|
||||
'shield1': 0, 'shield2': 0, 'shield3': 0, 'shield4': 0, 'shield5': 0,
|
||||
},
|
||||
'count': obj,
|
||||
'add': {
|
||||
'hp': 0, 'atk': 0, 'def': 0, 'mdef': 0
|
||||
}
|
||||
@ -2262,13 +2259,13 @@ ui.prototype.drawStatistics = function () {
|
||||
Object.keys(data.count).forEach(function (key) {
|
||||
var value=data.count[key];
|
||||
if (value>0) {
|
||||
var name="";
|
||||
var name=null;
|
||||
if (key=='yellowDoor') name="黄门";
|
||||
else if (key=='blueDoor') name="蓝门";
|
||||
else if (key=='redDoor') name="红门";
|
||||
else if (key=='greenDoor') name="绿门";
|
||||
else if (key=='steelDoor') name="铁门";
|
||||
else name=core.material.items[key].name;
|
||||
else name=(core.material.items[key]||{}).name;
|
||||
if (core.isset(name)) {
|
||||
text+=name+value+"个;";
|
||||
}
|
||||
|
||||
20
main.js
20
main.js
@ -51,6 +51,7 @@ function main() {
|
||||
'data': document.getElementById('data'),
|
||||
'statusLabels': document.getElementsByClassName('statusLabel'),
|
||||
'floorCol': document.getElementById('floorCol'),
|
||||
'nameCol': document.getElementById('nameCol'),
|
||||
'lvCol': document.getElementById('lvCol'),
|
||||
'hpmaxCol': document.getElementById('hpmaxCol'),
|
||||
'mdefCol': document.getElementById('mdefCol'),
|
||||
@ -76,6 +77,7 @@ function main() {
|
||||
this.statusBar = {
|
||||
'image': {
|
||||
'floor': document.getElementById('img-floor'),
|
||||
'name': document.getElementById('img-name'),
|
||||
'lv': document.getElementById('img-lv'),
|
||||
'hpmax': document.getElementById('img-hpmax'),
|
||||
'hp': document.getElementById("img-hp"),
|
||||
@ -95,6 +97,7 @@ function main() {
|
||||
},
|
||||
'icons': {
|
||||
'floor': 0,
|
||||
'name': null,
|
||||
'lv': 1,
|
||||
'hpmax': 2,
|
||||
'hp': 3,
|
||||
@ -120,6 +123,7 @@ function main() {
|
||||
'equipbox': 23,
|
||||
},
|
||||
'floor': document.getElementById('floor'),
|
||||
'name': document.getElementById('name'),
|
||||
'lv': document.getElementById('lv'),
|
||||
'hpmax': document.getElementById('hpmax'),
|
||||
'hp': document.getElementById('hp'),
|
||||
@ -413,8 +417,22 @@ main.statusBar.image.toolbox.onclick = function () {
|
||||
return;
|
||||
}
|
||||
|
||||
if (main.core.isPlaying()) {
|
||||
main.core.openToolbox(core.status.event.id != 'equipbox');
|
||||
}
|
||||
}
|
||||
|
||||
////// 双击状态栏中的工具箱时 //////
|
||||
main.statusBar.image.toolbox.ondblclick = function () {
|
||||
|
||||
if (core.isset(core.status.replay) && core.status.replay.replaying) {
|
||||
core.rewindReplay();
|
||||
return;
|
||||
}
|
||||
|
||||
if (main.core.isPlaying())
|
||||
main.core.openToolbox(true);
|
||||
main.core.openEquipbox(true);
|
||||
|
||||
}
|
||||
|
||||
////// 点击状态栏中的快捷商店时 //////
|
||||
|
||||
@ -187,6 +187,7 @@ data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
|
||||
},
|
||||
"flags": {
|
||||
"enableFloor": true,
|
||||
"enableName": false,
|
||||
"enableLv": false,
|
||||
"enableHPMax": false,
|
||||
"enableMDef": true,
|
||||
|
||||
@ -129,7 +129,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
core.playSound('attack.mp3');
|
||||
core.drawAnimate(equipAnimate, x, y);
|
||||
|
||||
var damage = core.enemys.getDamage(enemyId);
|
||||
var damage = core.enemys.getDamage(enemyId, x, y);
|
||||
if (damage == null) damage = core.status.hero.hp+1;
|
||||
|
||||
// 扣减体力值
|
||||
@ -336,6 +336,18 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
// 怪物数据的动态修改迁移到了“脚本编辑 - updateEnemys”中,详见文档说明
|
||||
|
||||
core.enemys.updateEnemys();
|
||||
},
|
||||
"canUseQuickShop": function(shopId) {
|
||||
// 当前能否使用某个快捷商店
|
||||
// shopId:快捷商店ID
|
||||
// 如果返回一个字符串,表示不能,字符串为不能使用的提示
|
||||
// 返回null代表可以使用
|
||||
|
||||
// 检查当前楼层的canUseQuickShop选项是否为false
|
||||
if (core.floors[core.status.floorId].canUseQuickShop === false)
|
||||
return '当前楼层不能使用快捷商店。';
|
||||
|
||||
return null;
|
||||
}
|
||||
},
|
||||
"enemys": {
|
||||
@ -367,14 +379,86 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
[21, "退化", function (enemy) {return "战斗后勇士永久下降"+(enemy.atkValue||0)+"点攻击和"+(enemy.defValue||0)+"点防御";}],
|
||||
[22, "固伤", function (enemy) {return "战斗前,怪物对勇士造成"+(enemy.damage||0)+"点固定伤害,无视勇士魔防。";}],
|
||||
[23, "重生", "怪物被击败后,角色转换楼层则怪物将再次出现"],
|
||||
[24, "激光", function (enemy) {return "经过怪物同行或同列时自动减生命"+(enemy.value||0)+"点";}]
|
||||
[24, "激光", function (enemy) {return "经过怪物同行或同列时自动减生命"+(enemy.value||0)+"点";}],
|
||||
[25, "光环", function (enemy) {return "同楼层所有怪物生命提升"+(enemy.value||0)+"%,攻击提升"+(enemy.atkValue||0)+"%,防御提升"+(enemy.defValue||0)+"%,"+(enemy.add?"可叠加":"不可叠加");}]
|
||||
];
|
||||
},
|
||||
"getDamageInfo": function (enemy, hero_hp, hero_atk, hero_def, hero_mdef) {
|
||||
// 获得战斗伤害信息(实际伤害计算函数)
|
||||
|
||||
// 怪物生命,怪物攻击、防御、特殊属性
|
||||
"getEnemyInfo": function (enemy, hero_hp, hero_atk, hero_def, hero_mdef, x, y, floorId) {
|
||||
// 获得某个怪物变化后的数据;该函数将被伤害计算和怪物手册使用
|
||||
// 例如:坚固、模仿、仿攻等等
|
||||
//
|
||||
// 参数说明:
|
||||
// enemy:该怪物信息
|
||||
// hero_hp,hero_atk,hero_def,hero_mdef:勇士的生命攻防魔防数据
|
||||
// x,y:该怪物的坐标(查看手册和强制战斗时为undefined)
|
||||
// floorId:该怪物所在的楼层
|
||||
// 后面三个参数主要是可以在光环等效果上可以适用(也可以按需制作部分范围光环效果)
|
||||
floorId = floorId || core.status.floorId;
|
||||
var mon_hp = enemy.hp, mon_atk = enemy.atk, mon_def = enemy.def, mon_special = enemy.special;
|
||||
var mon_money = enemy.money, mon_experience = enemy.experience, mon_point = enemy.point;
|
||||
// 模仿
|
||||
if (this.hasSpecial(mon_special, 10)) {
|
||||
mon_atk = hero_atk;
|
||||
mon_def = hero_def;
|
||||
}
|
||||
// 坚固
|
||||
if (this.hasSpecial(mon_special, 3) && mon_def < hero_atk - 1) {
|
||||
mon_def = hero_atk - 1;
|
||||
}
|
||||
|
||||
// 光环效果
|
||||
// 检查当前楼层所有光环怪物(数字25)
|
||||
var hp_delta = 0, atk_delta = 0, def_delta = 0, cnt = 0;
|
||||
// 遍历每个图块
|
||||
core.status.maps[floorId].blocks.forEach(function (block) {
|
||||
if (core.isset(block.event) && !block.disable) {
|
||||
// 获得该图块的ID
|
||||
var id = block.event.id, enemy = core.material.enemys[id];
|
||||
// 检查是不是怪物,且是否拥有该特殊属性
|
||||
if (core.isset(enemy) && core.hasSpecial(enemy.special, 25)) {
|
||||
// 检查是否可叠加
|
||||
if (enemy.add || cnt == 0) {
|
||||
hp_delta += enemy.value || 0;
|
||||
atk_delta += enemy.atkValue || 0;
|
||||
def_delta += enemy.defValue || 0;
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
// 增加比例;如果要增加数值可以直接在这里修改
|
||||
mon_hp *= (1+hp_delta/100);
|
||||
mon_atk *= (1+atk_delta/100);
|
||||
mon_def *= (1+def_delta/100);
|
||||
|
||||
// TODO:可以在这里新增其他的怪物数据变化
|
||||
// 比如仿攻(怪物攻击不低于勇士攻击):
|
||||
// if (this.hasSpecial(mon_special, 27) && mon_atk < hero_atk) {
|
||||
// mon_atk = hero_atk;
|
||||
// }
|
||||
// 也可以按需增加各种自定义内容(比如幻塔的魔杖效果等)
|
||||
|
||||
return {
|
||||
"hp": Math.floor(mon_hp),
|
||||
"atk": Math.floor(mon_atk),
|
||||
"def": Math.floor(mon_def),
|
||||
"money": Math.floor(mon_money),
|
||||
"experience": Math.floor(mon_experience),
|
||||
"point": Math.floor(mon_point),
|
||||
"special": mon_special
|
||||
};
|
||||
},
|
||||
"getDamageInfo": function (enemy, hero_hp, hero_atk, hero_def, hero_mdef, x, y, floorId) {
|
||||
// 获得战斗伤害信息(实际伤害计算函数)
|
||||
//
|
||||
// 参数说明:
|
||||
// enemy:该怪物信息
|
||||
// hero_hp,hero_atk,hero_def,hero_mdef:勇士的生命攻防魔防数据
|
||||
// x,y:该怪物的坐标(查看手册和强制战斗时为undefined)
|
||||
// floorId:该怪物所在的楼层
|
||||
// 后面三个参数主要是可以在光环等效果上可以适用
|
||||
floorId = floorId || core.status.floorId;
|
||||
|
||||
// 勇士的负属性都按0计算
|
||||
hero_hp=Math.max(0, hero_hp);
|
||||
hero_atk=Math.max(0, hero_atk);
|
||||
@ -387,11 +471,16 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
hero_def = Math.floor(core.getFlag('equip_def_buff',1)*hero_def);
|
||||
hero_mdef = Math.floor(core.getFlag('equip_mdef_buff',1)*hero_mdef);
|
||||
}
|
||||
|
||||
// 怪物的各项数据
|
||||
// 对坚固模仿等处理扔到了脚本编辑-getEnemyInfo之中
|
||||
var enemyInfo = core.enemys.getEnemyInfo(enemy, hero_hp, hero_atk, hero_def, hero_mdef, x, y, floorId);
|
||||
var mon_hp = enemyInfo.hp, mon_atk = enemyInfo.atk, mon_def = enemyInfo.def, mon_special = enemyInfo.special;
|
||||
|
||||
// 如果是无敌属性,且勇士未持有十字架
|
||||
if (this.hasSpecial(mon_special, 20) && !core.hasItem("cross"))
|
||||
return null; // 不可战斗
|
||||
|
||||
|
||||
// 战前造成的额外伤害(可被魔防抵消)
|
||||
var init_damage = 0;
|
||||
|
||||
@ -410,15 +499,6 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
init_damage += vampire_damage;
|
||||
}
|
||||
|
||||
// 模仿
|
||||
if (this.hasSpecial(mon_special, 10)) {
|
||||
mon_atk = hero_atk;
|
||||
mon_def = hero_def;
|
||||
}
|
||||
// 坚固
|
||||
if (this.hasSpecial(mon_special, 3) && mon_def < hero_atk - 1)
|
||||
mon_def = hero_atk - 1;
|
||||
|
||||
// 检查是否破防;否则直接返回不可战斗
|
||||
if (hero_atk <= mon_def) return null;
|
||||
|
||||
@ -486,6 +566,31 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
}
|
||||
},
|
||||
"control": {
|
||||
"flyTo": function (toId, callback) {
|
||||
// 楼层传送器的使用,从当前楼层飞往toId
|
||||
// 如果不能飞行请返回false
|
||||
|
||||
var fromId = core.status.floorId;
|
||||
|
||||
// 检查能否飞行
|
||||
if (!core.floors[fromId].canFlyTo || !core.floors[toId].canFlyTo) {
|
||||
core.drawTip("无法飞往" + core.floors[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.floorIds[fromId].underGround) stair = "upFloor";
|
||||
// 记录录像
|
||||
core.status.route.push("fly:"+toId);
|
||||
// 传送
|
||||
core.ui.closePanel();
|
||||
core.changeFloor(toId, stair, null, null, callback);
|
||||
|
||||
return true;
|
||||
},
|
||||
"updateStatusBar": function () {
|
||||
// 更新状态栏
|
||||
|
||||
@ -497,7 +602,10 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
core.setStatus('hp', Math.min(core.getStatus('hpmax'), core.getStatus('hp')));
|
||||
}
|
||||
|
||||
// 设置等级奴名称
|
||||
// 设置勇士名字和图标
|
||||
core.statusBar.name.innerHTML = core.getStatus('name');
|
||||
|
||||
// 设置等级名称
|
||||
var lvName = core.getLvName();
|
||||
core.statusBar.lv.innerHTML = lvName;
|
||||
// 检测是不是纯数字;如果带中文等需要取消斜体(不然很难看的!)
|
||||
@ -584,7 +692,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
}
|
||||
|
||||
// Step2: 更新领域、阻击伤害
|
||||
core.status.checkBlock.damage = []; // 记录(x,y)点的伤害;(x,y)对应的值是 x+y*core.bigmap
|
||||
core.status.checkBlock.damage = []; // 记录(x,y)点的伤害;(x,y)对应的值是 x+core.bigmap.width*y
|
||||
for (var x=0;x<core.bigmap.width*core.bigmap.height;x++) core.status.checkBlock.damage[x]=0;
|
||||
|
||||
for (var x=0;x<core.bigmap.width;x++) {
|
||||
@ -657,7 +765,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
// 检测左右是否存在相同的怪物,且拥有夹击属性
|
||||
if (x>0 && x<core.bigmap.width-1) {
|
||||
var id1=core.status.checkBlock.map[x-1+core.bigmap.width*y],
|
||||
id2=core.status.checkBlock.map[x+1+core.bigmap.height*y];
|
||||
id2=core.status.checkBlock.map[x+1+core.bigmap.width*y];
|
||||
if (core.isset(id1) && core.isset(id2) && id1==id2) {
|
||||
var enemy = core.material.enemys[id1];
|
||||
if (core.isset(enemy) && core.enemys.hasSpecial(enemy.special, 16)) {
|
||||
@ -691,6 +799,21 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
}
|
||||
},
|
||||
"ui": {
|
||||
"drawStatistics": function () {
|
||||
// 浏览地图时参与的统计项目
|
||||
|
||||
return [
|
||||
'yellowDoor', 'blueDoor', 'redDoor', 'greenDoor', 'steelDoor',
|
||||
'yellowKey', 'blueKey', 'redKey', 'greenKey', 'steelKey',
|
||||
'redJewel', 'blueJewel', 'greenJewel', 'yellowJewel',
|
||||
'redPotion', 'bluePotion', 'greenPotion', 'yellowPotion', 'superPotion',
|
||||
'pickaxe', 'bomb', 'centerFly',
|
||||
'poisonWine', 'weakWine', 'curseWine', 'superWine',
|
||||
'sword1', 'sword2', 'sword3', 'sword4', 'sword5',
|
||||
'shield1', 'shield2', 'shield3', 'shield4', 'shield5',
|
||||
// 在这里可以增加新的ID来进行统计个数,只能增加道具ID
|
||||
];
|
||||
},
|
||||
"drawAbout": function() {
|
||||
// 绘制“关于”界面
|
||||
if (!core.isPlaying()) {
|
||||
|
||||
@ -227,6 +227,10 @@ span#poison, span#weak, span#curse, span#pickaxe, span#bomb, span#fly {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
p#name {
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
.gameCanvas {
|
||||
position: absolute;
|
||||
box-sizing: border-box;
|
||||
|
||||
17
更新说明.txt
17
更新说明.txt
@ -1,4 +1,19 @@
|
||||
HTML5魔塔样板V2.4.2
|
||||
HTML5魔塔样板V2.4.3
|
||||
|
||||
增加光环属性
|
||||
将部分代码移动到脚本编辑中
|
||||
(怪物属性获取、楼层传送、数据统计等)
|
||||
事件改变天气或画面色调,读档后仍有效
|
||||
Autotile注册优化
|
||||
状态栏可以显示角色名字
|
||||
双击道具栏图标直接进入装备栏
|
||||
修复大地图的夹击Bug
|
||||
iOS设备默认关闭新版存档
|
||||
部分其他细节优化
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
HTML5魔塔样板V2.4.2
|
||||
|
||||
允许导入tilesets直接使用,无需PS和注册
|
||||
tilesets的素材允许以矩形方式整体绘制
|
||||
|
||||
Loading…
Reference in New Issue
Block a user