Merge branch 'ckcz123-master'
This commit is contained in:
commit
c32ed6b5aa
BIN
images/autotile.png
Normal file
BIN
images/autotile.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.4 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 7.1 KiB |
@ -35,7 +35,6 @@
|
||||
<span class='startButton' id='aboutGame'>关于本塔</span>
|
||||
</div>
|
||||
<div id='levelChooseButtons'>
|
||||
<!-- 如果不需要三个难度,直接像这样注释掉即可 -->
|
||||
<span class='startButton' id='easyLevel'>简单</span>
|
||||
<span class='startButton' id='normalLevel'>普通</span>
|
||||
<span class='startButton' id='hardLevel'>困难</span>
|
||||
|
||||
249
libs/core.js
249
libs/core.js
@ -425,49 +425,48 @@ core.prototype.keyDown = function(keyCode) {
|
||||
}
|
||||
|
||||
core.prototype.keyUp = function(keyCode) {
|
||||
if(!core.status.played) {
|
||||
return;
|
||||
}
|
||||
if(!core.status.played)
|
||||
return;
|
||||
|
||||
if (core.status.lockControl) {
|
||||
if (core.status.event.id == 'book' && (keyCode==27 || keyCode==88))
|
||||
core.ui.closePanel(true);
|
||||
if (core.status.event.id == 'fly' && (keyCode==71 || keyCode==27))
|
||||
core.ui.closePanel();
|
||||
if (core.status.event.id == 'fly' && keyCode==13) {
|
||||
var index=core.status.hero.flyRange.indexOf(core.status.floorId);
|
||||
var stair=core.status.event.data<index?"upFloor":"downFloor";
|
||||
var floorId=core.status.event.data;
|
||||
core.ui.closePanel();
|
||||
core.changeFloor(core.status.hero.flyRange[floorId], stair);
|
||||
}
|
||||
if (core.status.event.id == 'save' && (keyCode==83 || keyCode==27))
|
||||
core.ui.closePanel();
|
||||
if (core.status.event.id == 'load' && (keyCode==76 || keyCode==27))
|
||||
core.ui.closePanel();
|
||||
if ((core.status.event.id == 'settings' || core.status.event.id == 'selectShop') && keyCode==27)
|
||||
core.ui.closePanel();
|
||||
if (core.status.event.id == 'selectShop' && keyCode==75)
|
||||
core.ui.closePanel();
|
||||
if (core.status.event.id == 'shop' && keyCode==27) {
|
||||
core.status.boxAnimateObjs = [];
|
||||
core.setBoxAnimate();
|
||||
if (core.status.event.data.fromList)
|
||||
core.ui.drawQuickShop();
|
||||
else core.ui.closePanel();
|
||||
}
|
||||
if (core.status.event.id == 'toolbox' && (keyCode==84 || keyCode==27))
|
||||
core.ui.closePanel();
|
||||
if (core.status.event.id == 'about' && (keyCode==13 || keyCode==32))
|
||||
core.ui.closePanel();
|
||||
if (core.status.event.id == 'text' && (keyCode==13 || keyCode==32))
|
||||
core.drawText();
|
||||
if (core.status.event.id == 'action' && core.isset(core.status.event.data.current)
|
||||
&& core.status.event.data.type=='text' && (keyCode==13 || keyCode==32))
|
||||
core.events.doAction();
|
||||
if (core.status.lockControl) {
|
||||
if (core.status.event.id == 'book' && (keyCode==27 || keyCode==88))
|
||||
core.ui.closePanel(true);
|
||||
if (core.status.event.id == 'fly' && (keyCode==71 || keyCode==27))
|
||||
core.ui.closePanel();
|
||||
if (core.status.event.id == 'fly' && keyCode==13) {
|
||||
var index=core.status.hero.flyRange.indexOf(core.status.floorId);
|
||||
var stair=core.status.event.data<index?"upFloor":"downFloor";
|
||||
var floorId=core.status.event.data;
|
||||
core.ui.closePanel();
|
||||
core.changeFloor(core.status.hero.flyRange[floorId], stair);
|
||||
}
|
||||
if (core.status.event.id == 'save' && (keyCode==83 || keyCode==27))
|
||||
core.ui.closePanel();
|
||||
if (core.status.event.id == 'load' && (keyCode==68 || keyCode==27))
|
||||
core.ui.closePanel();
|
||||
if ((core.status.event.id == 'settings' || core.status.event.id == 'selectShop') && keyCode==27)
|
||||
core.ui.closePanel();
|
||||
if (core.status.event.id == 'selectShop' && keyCode==75)
|
||||
core.ui.closePanel();
|
||||
if (core.status.event.id == 'shop' && keyCode==27) {
|
||||
core.status.boxAnimateObjs = [];
|
||||
core.setBoxAnimate();
|
||||
if (core.status.event.data.fromList)
|
||||
core.ui.drawQuickShop();
|
||||
else core.ui.closePanel();
|
||||
}
|
||||
if (core.status.event.id == 'toolbox' && (keyCode==84 || keyCode==27))
|
||||
core.ui.closePanel();
|
||||
if (core.status.event.id == 'about' && (keyCode==13 || keyCode==32))
|
||||
core.ui.closePanel();
|
||||
if (core.status.event.id == 'text' && (keyCode==13 || keyCode==32))
|
||||
core.drawText();
|
||||
if (core.status.event.id == 'action' && core.isset(core.status.event.data.current)
|
||||
&& core.status.event.data.type=='text' && (keyCode==13 || keyCode==32))
|
||||
core.events.doAction();
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
switch (keyCode) {
|
||||
case 27: // ESC
|
||||
@ -482,7 +481,7 @@ if (core.status.lockControl) {
|
||||
case 83: // S
|
||||
core.save(true);
|
||||
break;
|
||||
case 76: // L
|
||||
case 68: // D
|
||||
core.load(true);
|
||||
break;
|
||||
case 84: // T
|
||||
@ -502,9 +501,38 @@ if (core.status.lockControl) {
|
||||
break;
|
||||
case 40: // DOWN
|
||||
break;
|
||||
case 49: // 快捷键1:破
|
||||
if (core.status.heroStop && core.hasItem('pickaxe')) {
|
||||
if (core.canUseItem('pickaxe')) {
|
||||
core.useItem('pickaxe');
|
||||
}
|
||||
else {
|
||||
core.drawTip('当前不能使用破墙镐');
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 50: // 快捷键2:炸
|
||||
if (core.status.heroStop && core.hasItem('bomb')) {
|
||||
if (core.canUseItem('bomb')) {
|
||||
core.useItem('bomb');
|
||||
}
|
||||
else {
|
||||
core.drawTip('当前不能使用炸弹');
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 51: // 快捷键3:飞
|
||||
if (core.status.heroStop && core.hasItem('centerFly')) {
|
||||
if (core.canUseItem('centerFly')) {
|
||||
core.useItem('centerFly');
|
||||
}
|
||||
else {
|
||||
core.drawTip('当前不能使用中心对称飞行器');
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
core.stopHero();
|
||||
|
||||
}
|
||||
|
||||
core.prototype.ondown = function (x ,y) {
|
||||
@ -1547,21 +1575,146 @@ core.prototype.drawMap = function (mapName, callback) {
|
||||
core.canvas.bg.drawImage(blockImage, 0, blockIcon * 32, 32, 32, x * 32, y * 32, 32, 32);
|
||||
}
|
||||
}
|
||||
var autotileMaps = [];
|
||||
for (var b = 0; b < mapBlocks.length; b++) {
|
||||
// 事件启用
|
||||
if (core.isset(mapBlocks[b].event) && !(core.isset(mapBlocks[b].enable) && !mapBlocks[b].enable)) {
|
||||
blockIcon = core.material.icons[mapBlocks[b].event.cls][mapBlocks[b].event.id];
|
||||
blockImage = core.material.images[mapBlocks[b].event.cls];
|
||||
core.canvas.event.drawImage(core.material.images[mapBlocks[b].event.cls], 0, blockIcon * 32, 32, 32, mapBlocks[b].x * 32, mapBlocks[b].y * 32, 32, 32);
|
||||
core.addGlobalAnimate(mapBlocks[b].event.animate, mapBlocks[b].x * 32, mapBlocks[b].y * 32, blockIcon, blockImage);
|
||||
var block = mapBlocks[b];
|
||||
if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable)) {
|
||||
if (block.event.cls == 'autotile') {
|
||||
// core.drawAutotile();
|
||||
autotileMaps[13*block.x + block.y] = true;
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
blockIcon = core.material.icons[block.event.cls][block.event.id];
|
||||
blockImage = core.material.images[block.event.cls];
|
||||
core.canvas.event.drawImage(core.material.images[block.event.cls], 0, blockIcon * 32, 32, 32, block.x * 32, block.y * 32, 32, 32);
|
||||
core.addGlobalAnimate(block.event.animate, block.x * 32, block.y * 32, blockIcon, blockImage);
|
||||
}
|
||||
}
|
||||
}
|
||||
core.drawAutotile('event', autotileMaps, 0, 0, 32);
|
||||
core.setGlobalAnimate(core.values.animateSpeed);
|
||||
|
||||
if (core.isset(callback))
|
||||
callback();
|
||||
}
|
||||
|
||||
core.prototype.drawAutotile = function (canvas, autotileMaps, left, top, size) {
|
||||
var isAutotile = function(x, y) {
|
||||
if (x<0 || x>12 || y<0 || y>12) return 0;
|
||||
return autotileMaps[13*x+y]?1:0;
|
||||
}
|
||||
for (var xx=0;xx<13;xx++) {
|
||||
for (var yy=0;yy<13;yy++) {
|
||||
if (isAutotile(xx, yy)) {
|
||||
// 绘制autotile
|
||||
var id=isAutotile(xx, yy - 1) + 2 * isAutotile(xx - 1, yy) + 4 * isAutotile(xx, yy + 1) + 8 * isAutotile(xx + 1, yy);
|
||||
core.drawAutotileBlock(canvas, left + xx * size, top + yy * size, size, core.material.images.autotile, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var xx=0;xx<13;xx++) {
|
||||
for (var yy=0;yy<13;yy++) {
|
||||
if (isAutotile(xx, yy) + isAutotile(xx + 1, yy) + isAutotile(xx + 1, yy + 1) + isAutotile(xx, yy + 1) != 3) continue;
|
||||
if (!isAutotile(xx, yy)) {
|
||||
core.drawAutotileBlock(canvas, left + xx * size + size, top + yy * size + size, size, core.material.images.autotile, 16);
|
||||
}
|
||||
if (!isAutotile(xx + 1, yy)) {
|
||||
core.drawAutotileBlock(canvas, left + xx * size + size / 2, top + yy * size + size, size, core.material.images.autotile, 17);
|
||||
}
|
||||
if (!isAutotile(xx + 1, yy + 1)) {
|
||||
core.drawAutotileBlock(canvas, left + xx * size + size / 2, top + yy * size + size / 2, size, core.material.images.autotile, 18);
|
||||
}
|
||||
if (!isAutotile(xx, yy + 1)) {
|
||||
core.drawAutotileBlock(canvas, left + xx * size + size, top + yy * size + size / 2, size, core.material.images.autotile, 19);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
core.prototype.drawAutotileBlock = function (map, x, y, size, autotile, index) {
|
||||
var canvas = core.canvas[map];
|
||||
var blockIcon = core.material.icons.terrains.ground;
|
||||
var blockImage = core.material.images.terrains;
|
||||
switch (index) {
|
||||
case 0:
|
||||
canvas.drawImage(autotile, 0, 0, 32, 32, x, y, size, size);
|
||||
break;
|
||||
case 1:
|
||||
canvas.drawImage(autotile, 0, 3 * 32, 16, 32, x, y, size / 2, size);
|
||||
canvas.drawImage(autotile, 2 * 32 + 16, 3 * 32, 16, 32, x + size / 2, y, size / 2, size);
|
||||
break;
|
||||
case 2:
|
||||
canvas.drawImage(autotile, 2 * 32, 32, 32, 16, x, y, size, size / 2);
|
||||
canvas.drawImage(autotile, 2 * 32, 3 * 32 + 16, 32, 16, x, y + size / 2, size, size / 2);
|
||||
break;
|
||||
case 3:
|
||||
canvas.drawImage(autotile, 2 * 32, 3 * 32, 32, 32, x, y, size, size);
|
||||
break;
|
||||
case 4:
|
||||
canvas.drawImage(autotile, 0, 1 * 32, 16, 32, x, y, size / 2, size);
|
||||
canvas.drawImage(autotile, 2 * 32 + 16, 1 * 32, 16, 32, x + size / 2, y, size / 2, size);
|
||||
break;
|
||||
case 5:
|
||||
canvas.drawImage(autotile, 0, 2 * 32, 16, 32, x, y, size / 2, size);
|
||||
canvas.drawImage(autotile, 2 * 32 + 16, 2 * 32, 16, 32, x + size / 2, y, size / 2, size);
|
||||
break;
|
||||
case 6:
|
||||
canvas.drawImage(autotile, 2 * 32, 1 * 32, 32, 32, x, y, size, size);
|
||||
break;
|
||||
case 7:
|
||||
canvas.drawImage(autotile, 2 * 32, 2 * 32, 32, 32, x, y, size, size);
|
||||
break;
|
||||
case 8:
|
||||
canvas.drawImage(autotile, 0, 32, 32, 16, x, y, size, size / 2);
|
||||
canvas.drawImage(autotile, 0, 3 * 32 + 16, 32, 16, x, y + size / 2, size, size / 2);
|
||||
break;
|
||||
case 9:
|
||||
canvas.drawImage(autotile, 0, 3 * 32, 32, 32, x, y, size, size);
|
||||
break;
|
||||
case 10:
|
||||
canvas.drawImage(autotile, 32, 32, 32, 16, x, y, size, size / 2);
|
||||
canvas.drawImage(autotile, 32, 3 * 32 + 16, 32, 16, x, y + size / 2, size, size / 2);
|
||||
break;
|
||||
case 11:
|
||||
canvas.drawImage(autotile, 32, 3 * 32, 32, 32, x, y, size, size);
|
||||
break;
|
||||
case 12:
|
||||
canvas.drawImage(autotile, 0, 32, 32, 32, x, y, size, size);
|
||||
break;
|
||||
case 13:
|
||||
canvas.drawImage(autotile, 0, 2 * 32, 32, 32, x, y, size, size);
|
||||
break;
|
||||
case 14:
|
||||
canvas.drawImage(autotile, 32, 32, 32, 32, x, y, size, size);
|
||||
break;
|
||||
case 15:
|
||||
canvas.drawImage(autotile, 32, 2 * 32, 32, 32, x, y, size, size);
|
||||
break;
|
||||
case 16:
|
||||
canvas.clearRect(x, y, size / 2, size / 2);
|
||||
canvas.drawImage(blockImage, 0, blockIcon * 32, 16, 16, x, y, size / 2, size / 2);
|
||||
canvas.drawImage(autotile, 2 * 32, 0, 16, 16, x, y, size / 2, size / 2);
|
||||
break;
|
||||
case 17:
|
||||
canvas.clearRect(x, y, size / 2, size / 2);
|
||||
canvas.drawImage(blockImage, 0, blockIcon * 32, 16, 16, x, y, size / 2, size / 2);
|
||||
canvas.drawImage(autotile, 2 * 32 + 16, 0, 16, 16, x, y, size / 2, size / 2);
|
||||
break;
|
||||
case 18:
|
||||
canvas.clearRect(x, y, size / 2, size / 2);
|
||||
canvas.drawImage(blockImage, 0, blockIcon * 32, 16, 16, x, y, size / 2, size / 2);
|
||||
canvas.drawImage(autotile, 2 * 32 + 16, 16, 16, 16, x, y, size / 2, size / 2);
|
||||
break;
|
||||
case 19:
|
||||
canvas.clearRect(x, y, size / 2, size / 2);
|
||||
canvas.drawImage(blockImage, 0, blockIcon * 32, 16, 16, x, y, size / 2, size / 2);
|
||||
canvas.drawImage(autotile, 2 * 32, 16, 16, 16, x, y, size / 2, size / 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
core.prototype.noPassExists = function (x, y, floorId) {
|
||||
var block = core.getBlock(x,y,floorId);
|
||||
if (block==null) return false;
|
||||
|
||||
@ -107,9 +107,12 @@ data.prototype.init = function() {
|
||||
"sword5": 160, // 神圣剑加攻数值
|
||||
"shield5": 160, // 神圣盾加防数值
|
||||
"moneyPocket": 500, // 金钱袋加金币的数值
|
||||
|
||||
/****** 怪物相关 ******/
|
||||
'breakArmor': 0.9, // 破甲的比例(战斗前,怪物附加角色防御的x%作为伤害)
|
||||
'counterAttack': 0.1, // 反击的比例(战斗时,怪物每回合附加角色攻击的x%作为伤害,无视角色防御)
|
||||
'purify': 3, // 净化的比例(战斗前,怪物附加勇士魔防的x倍作为伤害)
|
||||
/****** 系统相关 ******/
|
||||
'animateSpeed': 500,
|
||||
'animateSpeed': 500, // 动画时间
|
||||
}
|
||||
// 系统FLAG,在游戏运行中中请不要修改它。
|
||||
this.flags = {
|
||||
|
||||
@ -50,7 +50,7 @@ enemys.prototype.init = function () {
|
||||
'demonPriest': {'name': '魔神法师', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 0, 'special': 0},
|
||||
'goldHornSlime': {'name': '金角怪', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 0, 'special': 0},
|
||||
'redKing': {'name': '红衣魔王', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 0, 'special': 0},
|
||||
'whiteKing': {'name': '白衣武士', 'hp': 100, 'atk': 120, 'def': 0, 'money': 17, 'experience': 0, 'special': 16},
|
||||
'whiteKing': {'name': '白衣武士', 'hp': 100, 'atk': 120, 'def': 0, 'money': 17, 'experience': 0, 'special': 15016},
|
||||
'blackMagician': {'name': '黑暗大法师', 'hp': 100, 'atk': 120, 'def': 0, 'money': 12, 'experience': 0, 'special': 11, 'value': 1/3, 'bomb': false}, // 吸血怪需要在后面添加value代表吸血比例
|
||||
'silverSlime': {'name': '银头怪', 'hp': 100, 'atk': 120, 'def': 0, 'money': 15, 'experience': 0, 'special': 14},
|
||||
'swordEmperor': {'name': '剑圣', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 0, 'special': 0},
|
||||
@ -75,26 +75,31 @@ enemys.prototype.getEnemys = function (enemyId) {
|
||||
return this.enemys[enemyId];
|
||||
}
|
||||
|
||||
enemys.prototype.hasSpecial = function (special, test) {
|
||||
return parseInt(special/1000) == test || special % 1000 == test;
|
||||
}
|
||||
|
||||
enemys.prototype.getSpecialText = function (enemyId) {
|
||||
if (enemyId == undefined) return "";
|
||||
var special = this.enemys[enemyId].special;
|
||||
if (special == 1) return "先攻";
|
||||
if (special == 2) return "魔攻";
|
||||
if (special == 3) return "坚固";
|
||||
if (special == 4) return "2连击";
|
||||
if (special == 5) return "3连击";
|
||||
if (special == 6) return "4连击";
|
||||
if (special == 7) return "破甲";
|
||||
if (special == 8) return "反击";
|
||||
if (special == 9) return "净化";
|
||||
if (special == 10) return "模仿";
|
||||
if (special == 11) return "吸血";
|
||||
if (special == 12) return "中毒";
|
||||
if (special == 13) return "衰弱";
|
||||
if (special == 14) return "诅咒";
|
||||
if (special == 15) return "领域";
|
||||
if (special == 16) return "夹击";
|
||||
return "";
|
||||
var text = [];
|
||||
if (this.hasSpecial(special, 1)) text.push("先攻");
|
||||
if (this.hasSpecial(special, 2)) text.push("魔攻");
|
||||
if (this.hasSpecial(special, 3)) text.push("坚固");
|
||||
if (this.hasSpecial(special, 4)) text.push("2连击");
|
||||
if (this.hasSpecial(special, 5)) text.push("3连击");
|
||||
if (this.hasSpecial(special, 6)) text.push("4连击");
|
||||
if (this.hasSpecial(special, 7)) text.push("破甲");
|
||||
if (this.hasSpecial(special, 8)) text.push("反击");
|
||||
if (this.hasSpecial(special, 9)) text.push("净化");
|
||||
if (this.hasSpecial(special, 10)) text.push("模仿");
|
||||
if (this.hasSpecial(special, 11)) text.push("吸血");
|
||||
if (this.hasSpecial(special, 12)) text.push("中毒");
|
||||
if (this.hasSpecial(special, 13)) text.push("衰弱");
|
||||
if (this.hasSpecial(special, 14)) text.push("诅咒");
|
||||
if (this.hasSpecial(special, 15)) text.push("领域");
|
||||
if (this.hasSpecial(special, 16)) text.push("夹击");
|
||||
return text.join(" ");
|
||||
}
|
||||
|
||||
enemys.prototype.getDamage = function (monsterId) {
|
||||
@ -108,7 +113,7 @@ enemys.prototype.getDamage = function (monsterId) {
|
||||
|
||||
enemys.prototype.getExtraDamage = function (monster) {
|
||||
var extra_damage = 0;
|
||||
if (monster.special == 11) { // 吸血
|
||||
if (this.hasSpecial(monster.special, 11)) { // 吸血
|
||||
// 吸血的比例
|
||||
extra_damage = core.status.hero.hp * monster.value;
|
||||
extra_damage = parseInt(extra_damage);
|
||||
@ -119,7 +124,7 @@ enemys.prototype.getExtraDamage = function (monster) {
|
||||
// 临界值计算
|
||||
enemys.prototype.getCritical = function (monsterId) {
|
||||
var monster = core.material.enemys[monsterId];
|
||||
if (monster.special == 3 || monster.special == 10) return "???";
|
||||
if (this.hasSpecial(monster.special, 3) || this.hasSpecial(monster.special, 10)) return "???";
|
||||
var last = this.calDamage(core.status.hero.atk, core.status.hero.def, core.status.hero.mdef,
|
||||
monster.hp, monster.atk, monster.def, monster.special);
|
||||
if (last == 0) return 0;
|
||||
@ -160,11 +165,11 @@ enemys.prototype.getDefDamage = function (monsterId) {
|
||||
|
||||
enemys.prototype.calDamage = function (hero_atk, hero_def, hero_mdef, mon_hp, mon_atk, mon_def, mon_special) {
|
||||
// 魔攻
|
||||
if (mon_special == 2) hero_def = 0;
|
||||
if (this.hasSpecial(mon_special,2)) hero_def = 0;
|
||||
// 坚固
|
||||
if (mon_special == 3 && mon_def < hero_atk - 1) mon_def = hero_atk - 1;
|
||||
if (this.hasSpecial(mon_special,3) && mon_def < hero_atk - 1) mon_def = hero_atk - 1;
|
||||
// 模仿
|
||||
if (mon_special == 10) {
|
||||
if (this.hasSpecial(mon_special,10)) {
|
||||
mon_atk = hero_atk;
|
||||
mon_def = hero_def;
|
||||
}
|
||||
@ -174,21 +179,23 @@ enemys.prototype.calDamage = function (hero_atk, hero_def, hero_mdef, mon_hp, mo
|
||||
if (per_damage < 0) per_damage = 0;
|
||||
// 2连击 & 3连击
|
||||
|
||||
if (mon_special == 4) per_damage *= 2;
|
||||
if (mon_special == 5) per_damage *= 3;
|
||||
if (mon_special == 6) per_damage *= 4;
|
||||
if (this.hasSpecial(mon_special, 4)) per_damage *= 2;
|
||||
if (this.hasSpecial(mon_special, 5)) per_damage *= 3;
|
||||
if (this.hasSpecial(mon_special, 6)) per_damage *= 4;
|
||||
|
||||
var counterDamage = 0;
|
||||
// 反击
|
||||
if (mon_special == 8) per_damage += parseInt(0.1 * hero_atk);
|
||||
if (this.hasSpecial(mon_special, 8)) counterDamage += parseInt(core.values.counterAttack * hero_atk);
|
||||
|
||||
// 先攻
|
||||
var damage = mon_special == 1 ? per_damage : 0;
|
||||
// 破甲
|
||||
if (mon_special == 7) damage = parseInt(0.9 * hero_def);
|
||||
if (this.hasSpecial(mon_special, 7)) damage += parseInt(core.values.breakArmor * hero_def);
|
||||
// 净化
|
||||
if (mon_special == 9) damage = 3 * hero_mdef;
|
||||
if (this.hasSpecial(mon_special, 9)) damage = core.values.purify * hero_mdef;
|
||||
|
||||
var turn = parseInt((mon_hp - 1) / (hero_atk - mon_def));
|
||||
var ans = damage + turn * per_damage;
|
||||
var ans = damage + turn * per_damage + (turn + 1) * counterDamage;
|
||||
ans -= hero_mdef;
|
||||
|
||||
// 魔防回血
|
||||
@ -211,9 +218,9 @@ enemys.prototype.getCurrentEnemys = function () {
|
||||
var monster = core.material.enemys[monsterId];
|
||||
var mon_atk = monster.atk, mon_def = monster.def;
|
||||
// 坚固
|
||||
if (monster.special == 3 && mon_def < core.status.hero.atk - 1)
|
||||
if (this.hasSpecial(monster.special, 3) && mon_def < core.status.hero.atk - 1)
|
||||
mon_def = core.status.hero.atk - 1;
|
||||
if (monster.special==10) {
|
||||
if (this.hasSpecial(monster.special, 10)) {
|
||||
mon_atk=core.status.hero.atk;
|
||||
mon_def=core.status.hero.def;
|
||||
}
|
||||
|
||||
@ -39,6 +39,11 @@ events.prototype.init = function () {
|
||||
if (core.isset(callback))
|
||||
callback();
|
||||
},
|
||||
"changeLight": function (data, core, callback) {
|
||||
core.events.changeLight(data.x, data.y);
|
||||
if (core.isset(callback))
|
||||
callback();
|
||||
},
|
||||
'action': function (data, core, callback) {
|
||||
core.events.doEvents(data.event.data, data.x, data.y);
|
||||
if (core.isset(callback)) callback();
|
||||
@ -124,7 +129,7 @@ events.prototype.checkBlock = function (x,y) {
|
||||
|
||||
// 领域
|
||||
for (var i in enemys) {
|
||||
if (enemys[i]!=null && enemys[i].special==15) {
|
||||
if (enemys[i]!=null && core.enemys.hasSpecial(enemys[i].special, 15)) {
|
||||
damage+=enemys[i].value;
|
||||
}
|
||||
}
|
||||
@ -140,9 +145,9 @@ events.prototype.checkBlock = function (x,y) {
|
||||
|
||||
// 夹击
|
||||
var has=false;
|
||||
if (enemys[0]!=null && enemys[2]!=null && enemys[0].id==enemys[2].id && enemys[0].special==16)
|
||||
if (enemys[0]!=null && enemys[2]!=null && enemys[0].id==enemys[2].id && core.enemys.hasSpecial(enemys[0].special, 16))
|
||||
has=true;
|
||||
if (enemys[1]!=null && enemys[3]!=null && enemys[1].id==enemys[3].id && enemys[1].special==16)
|
||||
if (enemys[1]!=null && enemys[3]!=null && enemys[1].id==enemys[3].id && core.enemys.hasSpecial(enemys[1].special, 16))
|
||||
has=true;
|
||||
if (has && core.status.hero.hp>1) { // 1血夹击不死
|
||||
core.status.hero.hp = parseInt(core.status.hero.hp/2);
|
||||
@ -490,19 +495,19 @@ events.prototype.afterBattle = function(enemyId,x,y,callback) {
|
||||
// 毒衰咒的处理
|
||||
var special = core.material.enemys[enemyId].special;
|
||||
// 中毒
|
||||
if (special==12 && !core.hasFlag('poison')) {
|
||||
if (core.enemys.hasSpecial(special, 12) && !core.hasFlag('poison')) {
|
||||
core.setFlag('poison', true);
|
||||
core.updateStatusBar();
|
||||
}
|
||||
// 衰弱
|
||||
if (special==13 && !core.hasFlag('weak')) {
|
||||
if (core.enemys.hasSpecial(special, 13) && !core.hasFlag('weak')) {
|
||||
core.setFlag('weak', true);
|
||||
core.status.hero.atk-=core.values.weakValue;
|
||||
core.status.hero.def-=core.values.weakValue;
|
||||
core.updateStatusBar();
|
||||
}
|
||||
// 诅咒
|
||||
if (special==14 && !core.hasFlag('curse')) {
|
||||
if (core.enemys.hasSpecial(special, 14) && !core.hasFlag('curse')) {
|
||||
core.setFlag('curse', true);
|
||||
core.updateStatusBar();
|
||||
}
|
||||
@ -577,6 +582,27 @@ events.prototype.passNet = function (data) {
|
||||
core.updateStatusBar();
|
||||
}
|
||||
|
||||
events.prototype.changeLight = function(x, y) {
|
||||
var block = core.getBlock(x, y);
|
||||
if (block==null) return;
|
||||
var index = block.index;
|
||||
block = block.block;
|
||||
if (block.event.id != 'light') return;
|
||||
// 改变为dark
|
||||
block.id = 166;
|
||||
block.event = {'cls': 'terrains', 'id': 'darkLight', 'noPass': true};
|
||||
// 更新地图
|
||||
core.canvas.event.clearRect(x * 32, y * 32, 32, 32);
|
||||
var blockIcon = core.material.icons[block.event.cls][block.event.id];
|
||||
core.canvas.event.drawImage(core.material.images[block.event.cls], 0, blockIcon * 32, 32, 32, block.x * 32, block.y * 32, 32, 32);
|
||||
this.afterChangeLight();
|
||||
}
|
||||
|
||||
// 改变灯后的事件
|
||||
events.prototype.afterChangeLight = function() {
|
||||
|
||||
}
|
||||
|
||||
// 存档事件前一刻的处理
|
||||
events.prototype.beforeSaveData = function(data) {
|
||||
|
||||
|
||||
@ -8,12 +8,12 @@ main.floors.sample0 = {
|
||||
"canFlyTo": true, // 该楼能否被楼传器飞到(不能的话在该楼也不允许使用楼传器)
|
||||
"canUseQuickShop": true, // 该层是否允许使用快捷商店
|
||||
"map": [ // 地图数据,需要是13x13,建议使用地图生成器来生成
|
||||
[0, 0, 220, 0, 0, 6, 87, 3, 65, 64, 44, 43, 42],
|
||||
[0, 246, 0, 246, 0, 6, 0, 3, 58, 59, 60, 61, 41],
|
||||
[219, 0, 0, 0, 219, 6, 0, 3, 57, 26, 62, 63, 40],
|
||||
[6, 6, 125, 6, 6, 6, 0, 3, 53, 54, 55, 56, 39],
|
||||
[0, 0, 220, 0, 0, 20, 87, 3, 65, 64, 44, 43, 42],
|
||||
[0, 246, 0, 246, 0, 20, 0, 3, 58, 59, 60, 61, 41],
|
||||
[219, 0, 0, 0, 219, 20, 0, 3, 57, 26, 62, 63, 40],
|
||||
[20, 20, 20, 20, 20, 20, 0, 3, 53, 54, 55, 56, 39],
|
||||
[216, 247, 256, 235, 248, 6, 0, 3, 49, 50, 51, 52, 38],
|
||||
[5, 5, 125, 5, 5, 5, 0, 1, 45, 46, 47, 48, 37],
|
||||
[6, 6, 125, 6, 6, 6, 0, 1, 45, 46, 47, 48, 37],
|
||||
[224, 254, 212, 232, 204, 5, 0, 1, 31, 32, 34, 33, 36],
|
||||
[201, 205, 217, 215, 207, 5, 0, 1, 27, 28, 29, 30, 35],
|
||||
[5, 5, 125, 5, 5, 5, 0, 1, 21, 22, 23, 24, 25],
|
||||
|
||||
@ -8,11 +8,11 @@ main.floors.sample1 = {
|
||||
"canFlyTo": true, // 该楼能否被楼传器飞到(不能的话在该楼也不允许使用楼传器)
|
||||
"canUseQuickShop": true, // 该层是否允许使用快捷商店
|
||||
"map": [ // 地图数据,需要是13x13,建议使用地图生成器来生成
|
||||
[7, 131, 8, 2, 9, 130, 10, 2, 0, 0, 132, 0, 0],
|
||||
[0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0],
|
||||
[7, 131, 8, 2, 9, 130, 10, 2, 166, 165, 132, 165, 166],
|
||||
[0, 0, 0, 0, 0, 0, 0, 2, 165, 164, 0, 162, 165],
|
||||
[2, 2, 2, 2, 121, 2, 2, 2, 0, 0, 229, 0, 0],
|
||||
[43, 33, 44, 1, 0, 0, 0, 2, 0, 0, 0, 0, 0],
|
||||
[21, 22, 21, 1, 0, 0, 0, 2, 0, 0, 0, 0, 0],
|
||||
[43, 33, 44, 1, 0, 0, 0, 2, 165, 161, 0, 163, 165],
|
||||
[21, 22, 21, 1, 0, 0, 0, 2, 166, 165, 0, 165, 166],
|
||||
[1, 245, 1, 1, 0, 87, 0, 2, 2, 2, 85, 2, 2],
|
||||
[0, 246, 0, 1, 0, 0, 0, 2, 2, 221, 0, 221, 2],
|
||||
[246, 0, 246, 1, 0, 0, 0, 121, 85, 0, 0, 0, 2],
|
||||
|
||||
@ -29,7 +29,13 @@ icons.prototype.init = function () {
|
||||
'blueShop-left': 15,
|
||||
'blueShop-right': 16,
|
||||
'pinkShop-left': 17,
|
||||
'pinkShop-right': 18
|
||||
'pinkShop-right': 18,
|
||||
'up': 19,
|
||||
'down': 20,
|
||||
'left': 21,
|
||||
'right': 22,
|
||||
'light': 23,
|
||||
'darkLight': 24
|
||||
},
|
||||
'animates': {
|
||||
'star': 0,
|
||||
|
||||
@ -63,7 +63,7 @@ maps.prototype.getBlock = function (x, y, id) {
|
||||
var tmp = {'x': x, 'y': y, 'id': id};
|
||||
if (enable!=null) tmp.enable = enable;
|
||||
|
||||
// 0-9 地形
|
||||
// 0-20 地形
|
||||
if (id == 1) tmp.event = {'cls': 'terrains', 'id': 'yellowWall'}; // 黄墙
|
||||
if (id == 2) tmp.event = {'cls': 'terrains', 'id': 'whiteWall'}; // 白墙
|
||||
if (id == 3) tmp.event = {'cls': 'terrains', 'id': 'blueWall'}; // 白墙
|
||||
@ -78,7 +78,13 @@ maps.prototype.getBlock = function (x, y, id) {
|
||||
if (id == 12) tmp.event = {'cls': 'animates', 'id': 'poisonNet', 'noPass': false, 'trigger': 'passNet'}; // 毒网
|
||||
if (id == 13) tmp.event = {'cls': 'animates', 'id': 'weakNet', 'noPass': false, 'trigger': 'passNet'}; // 衰网
|
||||
if (id == 14) tmp.event = {'cls': 'animates', 'id': 'curseNet', 'noPass': false, 'trigger': 'passNet'}; // 咒网
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
|
||||
if (id == 20) tmp.event = {'cls': 'autotile', 'id': 'autotile', 'noPass': true};
|
||||
|
||||
>>>>>>> 0de35b6258ac07977783fbb03f6a2d491faf4cf1
|
||||
// 21-80 物品
|
||||
if (id == 21) tmp.event = {'cls': 'items', 'id': 'yellowKey'}; // 黄钥匙
|
||||
if (id == 22) tmp.event = {'cls': 'items', 'id': 'blueKey'}; // 蓝钥匙
|
||||
|
||||
93
libs/ui.js
93
libs/ui.js
@ -377,28 +377,34 @@ ui.prototype.drawBattleAnimate = function(monsterId, callback) {
|
||||
|
||||
hero_hp -= core.enemys.getExtraDamage(monster);
|
||||
|
||||
if (mon_special==2) hero_def=0; // 魔攻
|
||||
if (mon_special==3 && mon_def<hero_atk) mon_def=hero_atk-1; // 坚固
|
||||
if (mon_special==10) { // 模仿
|
||||
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; // 坚固
|
||||
if (core.enemys.hasSpecial(mon_special, 10)) { // 模仿
|
||||
mon_atk=hero_atk;
|
||||
mon_def=hero_def;
|
||||
}
|
||||
|
||||
// 实际操作
|
||||
var turn = 0; // 0为勇士攻击
|
||||
if (core.enemys.hasSpecial(mon_special, 1)) turn=1;
|
||||
|
||||
// 回合
|
||||
var turns = 2;
|
||||
if (mon_special==4) turns=3;
|
||||
if (mon_special==5) turns=4;
|
||||
if (mon_special==6) turns=5;
|
||||
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=5;
|
||||
|
||||
|
||||
// 初始伤害(破甲、净化)
|
||||
var initDamage = 0;
|
||||
if (mon_special==7) initDamage=parseInt(0.9 * hero_def);
|
||||
if (mon_special==9) initDamage=parseInt(3*hero_mdef);
|
||||
if (core.enemys.hasSpecial(mon_special, 7)) initDamage+=parseInt(core.values.breakArmor * hero_def);
|
||||
if (core.enemys.hasSpecial(mon_special, 9)) initDamage=parseInt(core.values.purify * hero_mdef);
|
||||
hero_mdef-=initDamage;
|
||||
if (hero_mdef<0) {
|
||||
hero_hp+=hero_mdef;
|
||||
hero_mdef=0;
|
||||
}
|
||||
|
||||
|
||||
var specialText = core.enemys.getSpecialText(monsterId);
|
||||
|
||||
var background = core.canvas.ui.createPattern(core.material.ground, "repeat");
|
||||
@ -434,7 +440,12 @@ ui.prototype.drawBattleAnimate = function(monsterId, callback) {
|
||||
core.canvas.ui.textAlign='center';
|
||||
core.fillText('ui', core.status.hero.name, left+margin+boxWidth/2, top+margin+heroHeight+40, '#FFD700', 'bold 22px Verdana');
|
||||
core.fillText('ui', "怪物", left+right-margin-boxWidth/2, top+margin+32+40);
|
||||
core.fillText('ui', specialText, left+right-margin-boxWidth/2, top+margin+32+40+24, '#FF6A6A', '15px Verdana');
|
||||
var specialTexts = specialText.split(" ");
|
||||
for (var i=0, j=0; i<specialTexts.length;i++) {
|
||||
if (specialTexts[i]!='') {
|
||||
core.fillText('ui', specialTexts[i], left+right-margin-boxWidth/2, top+margin+32+44+20*(++j), '#FF6A6A', '15px Verdana');
|
||||
}
|
||||
}
|
||||
|
||||
// 图标
|
||||
core.clearMap('ui', left + margin, top + margin, boxWidth, heroHeight+boxWidth-32);
|
||||
@ -538,9 +549,6 @@ ui.prototype.drawBattleAnimate = function(monsterId, callback) {
|
||||
left+margin+boxWidth-6, top+margin+6, '#FF0000', 4);
|
||||
*/
|
||||
|
||||
// 实际操作
|
||||
var turn = 0; // 0为勇士攻击
|
||||
if (mon_special==1) turn=1;
|
||||
var battleInterval = setInterval(function() {
|
||||
core.playSound("attack", "ogg");
|
||||
|
||||
@ -562,6 +570,27 @@ ui.prototype.drawBattleAnimate = function(monsterId, callback) {
|
||||
core.canvas.data.textAlign='left';
|
||||
core.fillText('data', mon_hp, right_start, top+margin+10+26, '#DDDDDD', 'bold 16px Verdana');
|
||||
|
||||
// 反击
|
||||
if (core.enemys.hasSpecial(mon_special, 8)) {
|
||||
var counterDamage = parseInt(core.values.counterAttack * hero_atk);
|
||||
hero_mdef -= counterDamage;
|
||||
|
||||
if (hero_mdef<0) {
|
||||
hero_hp+=hero_mdef;
|
||||
hero_mdef=0;
|
||||
}
|
||||
// 更新勇士数据
|
||||
core.clearMap('data', left_start, top+margin+10, lineWidth, 40);
|
||||
core.canvas.data.textAlign='right';
|
||||
core.fillText('data', hero_hp, left_end, top+margin+10+26, '#DDDDDD', 'bold 16px Verdana');
|
||||
|
||||
if (core.flags.enableMDef) {
|
||||
core.clearMap('data', left_start, top+margin+10+3*lineHeight, lineWidth, 40);
|
||||
core.fillText('data', hero_mdef, left_end, top+margin+10+26+3*lineHeight);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
// 怪物攻击
|
||||
@ -572,7 +601,7 @@ ui.prototype.drawBattleAnimate = function(monsterId, callback) {
|
||||
}, 250);
|
||||
|
||||
var per_damage = mon_atk-hero_def;
|
||||
if (mon_special == 8) per_damage += parseInt(0.1 * hero_atk); // 反击
|
||||
if (per_damage < 0) per_damage = 0;
|
||||
|
||||
hero_mdef-=per_damage;
|
||||
if (hero_mdef<0) {
|
||||
@ -741,7 +770,14 @@ ui.prototype.drawEnemyBook = function (page) {
|
||||
|
||||
// 数据
|
||||
core.canvas.ui.textAlign = "center";
|
||||
core.fillText('ui', enemy.name, 115, 62 * i + 47, '#DDDDDD', 'bold 17px Verdana');
|
||||
|
||||
if (enemy.special=='') {
|
||||
core.fillText('ui', enemy.name, 115, 62 * i + 47, '#DDDDDD', 'bold 17px Verdana');
|
||||
}
|
||||
else {
|
||||
core.fillText('ui', enemy.name, 115, 62 * i + 40, '#DDDDDD', 'bold 17px Verdana');
|
||||
core.fillText('ui', enemy.special, 115, 62 * i + 62, '#FF6A6A', 'bold 15px Verdana');
|
||||
}
|
||||
core.canvas.ui.textAlign = "left";
|
||||
core.fillText('ui', '生命', 165, 62 * i + 32, '#DDDDDD', '13px Verdana');
|
||||
core.fillText('ui', enemy.hp, 195, 62 * i + 32, '#DDDDDD', 'bold 13px Verdana');
|
||||
@ -770,15 +806,6 @@ ui.prototype.drawEnemyBook = function (page) {
|
||||
core.fillText('ui', damage, damage_offset, 62 * i + 50, color, 'bold 13px Verdana');
|
||||
|
||||
core.canvas.ui.textAlign = "left";
|
||||
// 属性
|
||||
if (enemy.special != '') {
|
||||
core.setFont('data', 'bold 12px Verdana');
|
||||
var length = core.canvas.data.measureText(enemy.special).width;
|
||||
core.setAlpha('data', '0.4');
|
||||
core.fillRect('data', 64 - 4 - length, 62 * i + 46, length + 4, 17, '#000000');
|
||||
core.setAlpha('data', '1');
|
||||
core.fillText('data', enemy.special, 64 - 2 - length, 62 * i + 59, '#FF6A6A', 'bold 12px Verdana')
|
||||
}
|
||||
|
||||
core.fillText('ui', '临界', 165, 62 * i + 68, '#DDDDDD', '13px Verdana');
|
||||
core.fillText('ui', enemy.critical, 195, 62 * i + 68, '#DDDDDD', 'bold 13px Verdana');
|
||||
@ -986,16 +1013,24 @@ ui.prototype.drawThumbnail = function(canvas, blocks, x, y, size, heroLoc) {
|
||||
core.canvas[canvas].drawImage(blockImage, 0, blockIcon * 32, 32, 32, x + i * persize, y + j * persize, persize, persize);
|
||||
}
|
||||
}
|
||||
var autotileMaps = [];
|
||||
for (var b in blocks) {
|
||||
var block = blocks[b];
|
||||
if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable)) {
|
||||
var i = block.x, j = block.y;
|
||||
var blockIcon = core.material.icons[block.event.cls][block.event.id];
|
||||
var blockImage = core.material.images[block.event.cls];
|
||||
//core.canvas[canvas].clearRect(x + i * persize, y + j * persize, persize, persize);
|
||||
core.canvas[canvas].drawImage(blockImage, 0, blockIcon * 32, 32, 32, x + i * persize, y + j * persize, persize, persize);
|
||||
if (block.event.cls == 'autotile') {
|
||||
// core.drawAutotile();
|
||||
autotileMaps[13*block.x + block.y] = true;
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
var blockIcon = core.material.icons[block.event.cls][block.event.id];
|
||||
var blockImage = core.material.images[block.event.cls];
|
||||
core.canvas[canvas].drawImage(blockImage, 0, blockIcon * 32, 32, 32, x + block.x * persize, y + block.y * persize, persize, persize);
|
||||
}
|
||||
}
|
||||
}
|
||||
core.drawAutotile('ui', autotileMaps, x, y, persize);
|
||||
|
||||
if (core.isset(heroLoc)) {
|
||||
var heroIcon = core.material.icons.hero[heroLoc.direction];
|
||||
var height = core.material.icons.hero.height;
|
||||
|
||||
2
main.js
2
main.js
@ -40,7 +40,7 @@ function main() {
|
||||
];
|
||||
// console.log('加载js文件列表加载完成' + this.loadList);
|
||||
this.images = [
|
||||
'animates', 'enemys', 'hero', 'items', 'npcs', 'terrains'
|
||||
'animates', 'enemys', 'hero', 'items', 'npcs', 'terrains', "autotile"
|
||||
];
|
||||
this.sounds = {
|
||||
'mp3': ['bgm-loop', 'floor'],
|
||||
|
||||
Loading…
Reference in New Issue
Block a user