Reformat code
This commit is contained in:
parent
661e848b7b
commit
31e5f5d81a
410
libs/core.js
410
libs/core.js
@ -113,7 +113,7 @@ core.prototype.init = function (dom, statusBar, canvas, images, sounds, floorIds
|
||||
core[key] = coreData[key];
|
||||
}
|
||||
core.flags = core.data.flags;
|
||||
core.values = core.clone(core.data.values);
|
||||
// core.values = core.clone(core.data.values);
|
||||
core.firstData = core.data.getFirstData();
|
||||
core.initStatus.shops = core.firstData.shops;
|
||||
core.initStatus.npcs = core.firstData.npcs;
|
||||
@ -141,8 +141,7 @@ core.prototype.init = function (dom, statusBar, canvas, images, sounds, floorIds
|
||||
|
||||
core.loader(function () {
|
||||
console.log(core.material);
|
||||
// core.playGame();
|
||||
core.showStartAnimate(function() {});
|
||||
core.showStartAnimate();
|
||||
});
|
||||
}
|
||||
|
||||
@ -179,7 +178,7 @@ core.prototype.hideStartAnimate = function (callback) {
|
||||
if (opacityVal < 0) {
|
||||
clearInterval(startAnimate);
|
||||
core.dom.startPanel.style.display = 'none';
|
||||
callback();
|
||||
if (core.isset(callback)) callback();
|
||||
}
|
||||
core.dom.startPanel.style.opacity = opacityVal;
|
||||
}, 20);
|
||||
@ -194,41 +193,41 @@ core.prototype.setStartLoadTipText = function (text) {
|
||||
}
|
||||
|
||||
core.prototype.loader = function (callback) {
|
||||
var loadedImageNum = 0, allImageNum = 0, loadSoundNum = 0, allSoundNum = 0;
|
||||
var loadedImageNum = 0, allImageNum = 0, allSoundNum = 0;
|
||||
allImageNum = core.images.length;
|
||||
for (var key in core.sounds) {
|
||||
allSoundNum += core.sounds[key].length;
|
||||
}
|
||||
for (var i = 0; i < core.images.length; i++) {
|
||||
core.loadImage(core.images[i], function (imgName, image) {
|
||||
core.setStartLoadTipText('正在加载图片 ' + imgName + "...");
|
||||
imgName = imgName.split('-');
|
||||
imgName = imgName[0];
|
||||
core.material.images[imgName] = image;
|
||||
loadedImageNum++;
|
||||
core.setStartLoadTipText(imgName + ' 加载完毕...');
|
||||
core.setStartProgressVal(loadedImageNum * (100 / allImageNum));
|
||||
if (loadedImageNum == allImageNum) {
|
||||
// 加载音频
|
||||
for (var key in core.sounds) {
|
||||
for (var i = 0; i < core.sounds[key].length; i++) {
|
||||
var soundName=core.sounds[key][i];
|
||||
soundName = soundName.split('-');
|
||||
var sound = new Audio();
|
||||
sound.preload = 'none';
|
||||
sound.src = 'sounds/' + soundName[0] + '.' + key;
|
||||
if (soundName[1] == 'loop') {
|
||||
sound.loop = 'loop';
|
||||
}
|
||||
|
||||
if (!core.isset(core.material.sounds[key]))
|
||||
core.material.sounds[key] = {};
|
||||
core.material.sounds[key][soundName[0]] = sound;
|
||||
for (var i = 0; i < core.images.length; i++) {
|
||||
core.loadImage(core.images[i], function (imgName, image) {
|
||||
core.setStartLoadTipText('正在加载图片 ' + imgName + "...");
|
||||
imgName = imgName.split('-');
|
||||
imgName = imgName[0];
|
||||
core.material.images[imgName] = image;
|
||||
loadedImageNum++;
|
||||
core.setStartLoadTipText(imgName + ' 加载完毕...');
|
||||
core.setStartProgressVal(loadedImageNum * (100 / allImageNum));
|
||||
if (loadedImageNum == allImageNum) {
|
||||
// 加载音频
|
||||
for (var key in core.sounds) {
|
||||
for (var i = 0; i < core.sounds[key].length; i++) {
|
||||
var soundName=core.sounds[key][i];
|
||||
soundName = soundName.split('-');
|
||||
var sound = new Audio();
|
||||
sound.preload = 'none';
|
||||
sound.src = 'sounds/' + soundName[0] + '.' + key;
|
||||
if (soundName[1] == 'loop') {
|
||||
sound.loop = 'loop';
|
||||
}
|
||||
|
||||
if (!core.isset(core.material.sounds[key]))
|
||||
core.material.sounds[key] = {};
|
||||
core.material.sounds[key][soundName[0]] = sound;
|
||||
}
|
||||
callback();
|
||||
}
|
||||
});
|
||||
callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -269,7 +268,6 @@ core.prototype.loadSound = function() {
|
||||
|
||||
core.prototype.loadSoundItem = function (toLoadList) {
|
||||
if (toLoadList.length==0) {
|
||||
// if (core.musicStatus.bgmStatus==0) core.musicStatus.bgmStatus=-1;
|
||||
if (core.musicStatus.bgmStatus>0) return;
|
||||
core.musicStatus.bgmStatus=1;
|
||||
if (core.musicStatus.soundStatus)
|
||||
@ -300,7 +298,7 @@ core.prototype.clearStatus = function() {
|
||||
core.resize(main.dom.body.clientWidth, main.dom.body.clientHeight);
|
||||
}
|
||||
|
||||
core.prototype.resetStatus = function(hero, hard, floorId, maps) {
|
||||
core.prototype.resetStatus = function(hero, hard, floorId, values, maps) {
|
||||
|
||||
// 停止各个Timeout和Interval
|
||||
for (var i in core.interval) {
|
||||
@ -312,6 +310,7 @@ core.prototype.resetStatus = function(hero, hard, floorId, maps) {
|
||||
core.status.played = true;
|
||||
// 初始化maps
|
||||
core.status.floorId = floorId;
|
||||
core.values = core.clone(values);
|
||||
core.status.maps = core.clone(maps);
|
||||
// 初始化怪物
|
||||
core.material.enemys = core.clone(core.enemys.getEnemys());
|
||||
@ -328,7 +327,7 @@ core.prototype.resetStatus = function(hero, hard, floorId, maps) {
|
||||
core.prototype.startGame = function (hard, callback) {
|
||||
console.log('开始游戏');
|
||||
|
||||
core.resetStatus(core.firstData.hero, hard, core.firstData.floorId,
|
||||
core.resetStatus(core.firstData.hero, hard, core.firstData.floorId, core.data.values,
|
||||
core.initStatus.maps);
|
||||
|
||||
core.changeFloor(core.status.floorId, null, core.firstData.hero.loc, function() {
|
||||
@ -339,17 +338,6 @@ core.prototype.startGame = function (hard, callback) {
|
||||
|
||||
|
||||
core.prototype.restart = function() {
|
||||
|
||||
/*
|
||||
core.resetStatus(core.firstData.hero, core.firstData.hard, core.firstData.floorId,
|
||||
core.initStatus.maps);
|
||||
|
||||
core.changeFloor(core.firstData.floorId, null, core.firstData.hero.loc, function() {
|
||||
core.drawTip('重新开始游戏');
|
||||
core.setHeroMoveTriggerInterval();
|
||||
});
|
||||
|
||||
*/
|
||||
core.showStartAnimate();
|
||||
}
|
||||
|
||||
@ -399,9 +387,6 @@ core.prototype.pressKey = function (keyCode) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
core.prototype.keyDown = function(keyCode) {
|
||||
if(!core.status.played) {
|
||||
return;
|
||||
@ -706,6 +691,7 @@ core.prototype.onclick = function (x, y, stepPostfix) {
|
||||
|
||||
var formData = new FormData();
|
||||
formData.append('type', 'save');
|
||||
formData.append('name', core.firstData.name);
|
||||
var saves = [];
|
||||
for (var i=1;i<=180;i++) {
|
||||
var data = core.getLocalStorage("save"+i, null);
|
||||
@ -762,6 +748,7 @@ core.prototype.onclick = function (x, y, stepPostfix) {
|
||||
|
||||
var formData = new FormData();
|
||||
formData.append('type', 'load');
|
||||
formData.append('name', core.firstData.name);
|
||||
formData.append('id', id);
|
||||
formData.append('password', password);
|
||||
|
||||
@ -859,7 +846,7 @@ core.prototype.stopAutomaticRoute = function () {
|
||||
}
|
||||
|
||||
core.prototype.continueAutomaticRoute = function () {
|
||||
//此函数只应由events.afterOpenDoor和events.afterBattle调用
|
||||
// 此函数只应由events.afterOpenDoor和events.afterBattle调用
|
||||
var moveStep = core.status.moveStepBeforeStop;
|
||||
core.status.moveStepBeforeStop = [];
|
||||
if(moveStep.length===0)return;
|
||||
@ -885,15 +872,6 @@ core.prototype.setAutomaticRoute = function (destX, destY, stepPostfix) {
|
||||
core.turnHero();
|
||||
return;
|
||||
}
|
||||
// 直接移动
|
||||
/*
|
||||
if(core.status.automaticRoutingTemp.moveStep.length != 0 && core.status.automaticRoutingTemp.destX == destX && core.status.automaticRoutingTemp.destY == destY) {
|
||||
core.status.automaticRouting = true;
|
||||
core.setAutoHeroMove(core.status.automaticRoutingTemp.moveStep);
|
||||
core.status.automaticRoutingTemp = {'destX': 0, 'destY': 0, 'moveStep': []};
|
||||
return;
|
||||
}
|
||||
*/
|
||||
var step = 0;
|
||||
var tempStep = null;
|
||||
var moveStep;
|
||||
@ -903,7 +881,7 @@ core.prototype.setAutomaticRoute = function (destX, destY, stepPostfix) {
|
||||
moveStep=[];
|
||||
} else {
|
||||
core.canvas.ui.clearRect(0, 0, 416, 416);
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
moveStep=moveStep.concat(stepPostfix);
|
||||
@ -989,9 +967,6 @@ core.prototype.setAutomaticRoute = function (destX, destY, stepPostfix) {
|
||||
core.prototype.automaticRoute = function (destX, destY) {
|
||||
var startX = core.getHeroLoc('x');
|
||||
var startY = core.getHeroLoc('y');
|
||||
var nowX = startX;
|
||||
var nowY = startY;
|
||||
var scanItem = {'x': 0, 'y': 0};
|
||||
var scan = {
|
||||
'up': {'x': 0, 'y': -1},
|
||||
'left': {'x': -1, 'y': 0},
|
||||
@ -1237,7 +1212,6 @@ core.prototype.setHeroMoveTriggerInterval = function () {
|
||||
core.status.autoHeroMove = false;
|
||||
core.status.destStep = 0;
|
||||
core.status.movedStep = 0;
|
||||
// core.stopHero();
|
||||
core.status.moveStepBeforeStop=[];
|
||||
core.stopAutomaticRoute();
|
||||
}
|
||||
@ -1338,8 +1312,7 @@ core.prototype.drawHero = function (direction, x, y, status, offsetX, offsetY) {
|
||||
// 开门
|
||||
core.prototype.openDoor = function (id, x, y, needKey, callback) {
|
||||
// 是否存在门
|
||||
if (!core.terrainExists(x, y, id)) return;
|
||||
// core.lockControl();
|
||||
if (!core.doorExists(x, y, id)) return;
|
||||
if (core.status.moveStepBeforeStop.length==0) {
|
||||
core.status.moveStepBeforeStop=core.status.autoStepRoutes.slice(core.status.autoStep-1,core.status.autoStepRoutes.length);
|
||||
if (core.status.moveStepBeforeStop.length>=1)core.status.moveStepBeforeStop[0].step-=core.status.movedStep;
|
||||
@ -1350,7 +1323,7 @@ core.prototype.openDoor = function (id, x, y, needKey, callback) {
|
||||
var key = id.replace("Door", "Key");
|
||||
if (!core.rmItem(key)) {
|
||||
if (key != "specialKey")
|
||||
core.drawTip("你没有" + core.material.items[key].name + "!");
|
||||
core.drawTip("你没有" + core.material.items[key].name);
|
||||
else core.drawTip("无法开启此门");
|
||||
core.clearContinueAutomaticRoute();
|
||||
return;
|
||||
@ -1364,7 +1337,7 @@ core.prototype.openDoor = function (id, x, y, needKey, callback) {
|
||||
state++;
|
||||
if (state == 4) {
|
||||
clearInterval(core.interval.openDoorAnimate);
|
||||
core.removeBlock('event', x, y);
|
||||
core.removeBlock(x, y);
|
||||
core.events.afterOpenDoor(id,x,y,callback);
|
||||
return;
|
||||
}
|
||||
@ -1374,8 +1347,8 @@ core.prototype.openDoor = function (id, x, y, needKey, callback) {
|
||||
}
|
||||
|
||||
// 战斗
|
||||
core.prototype.battle = function (id, x, y, callback) {
|
||||
if (typeof(core.status.moveStepBeforeStop)=="undefined" || core.status.moveStepBeforeStop.length==0) {
|
||||
core.prototype.battle = function (id, x, y, force, callback) {
|
||||
if (core.status.moveStepBeforeStop.length==0) {
|
||||
core.status.moveStepBeforeStop=core.status.autoStepRoutes.slice(core.status.autoStep-1,core.status.autoStepRoutes.length);
|
||||
if (core.status.moveStepBeforeStop.length>=1)core.status.moveStepBeforeStop[0].step-=core.status.movedStep;
|
||||
}
|
||||
@ -1383,13 +1356,20 @@ core.prototype.battle = function (id, x, y, callback) {
|
||||
core.stopAutomaticRoute();
|
||||
|
||||
var damage = core.enemys.getDamage(id);
|
||||
if (damage >= core.status.hero.hp) {
|
||||
// 非强制战斗
|
||||
if (damage >= core.status.hero.hp && !force) {
|
||||
core.drawTip("你打不过此怪物!");
|
||||
core.clearContinueAutomaticRoute();
|
||||
return;
|
||||
}
|
||||
core.playSound('attack', 'ogg');
|
||||
core.status.hero.hp -= damage;
|
||||
if (core.status.hero.hp<=0) {
|
||||
core.status.hero.hp=0;
|
||||
core.updateStatusBar();
|
||||
core.events.lose('battle');
|
||||
return;
|
||||
}
|
||||
var money = core.material.enemys[id].money;
|
||||
if (core.hasItem('coin')) money *= 2;
|
||||
if (core.hasFlag('curse')) money=0;
|
||||
@ -1398,7 +1378,7 @@ core.prototype.battle = function (id, x, y, callback) {
|
||||
if (core.hasFlag('curse')) experience=0;
|
||||
core.status.hero.experience += experience;
|
||||
core.updateStatusBar();
|
||||
core.removeBlock('event', x, y);
|
||||
core.removeBlock(x, y);
|
||||
core.canvas.event.clearRect(32 * x, 32 * y, 32, 32);
|
||||
core.updateFg();
|
||||
var hint = "打败 " + core.material.enemys[id].name + ",金币+" + money;
|
||||
@ -1422,7 +1402,7 @@ core.prototype.changeFloor = function (floorId, stair, heroLoc, callback) {
|
||||
heroLoc = core.status.hero.loc;
|
||||
var blocks = core.status.maps[floorId].blocks;
|
||||
for (var i in blocks) {
|
||||
if (core.isset(blocks[i].event) && blocks[i].event.id === stair) {
|
||||
if (core.isset(blocks[i].event) && !(core.isset(blocks[i].enable) && !blocks[i].enable) && blocks[i].event.id === stair) {
|
||||
heroLoc.x = blocks[i].x;
|
||||
heroLoc.y = blocks[i].y;
|
||||
}
|
||||
@ -1601,7 +1581,6 @@ core.prototype.drawMap = function (mapName, callback) {
|
||||
var blockIcon, blockImage;
|
||||
core.clearMap('all');
|
||||
core.rmGlobalAnimate(null, null, true);
|
||||
// core.enabledAllTrigger();
|
||||
for (var x = 0; x < 13; x++) {
|
||||
for (var y = 0; y < 13; y++) {
|
||||
blockIcon = core.material.icons.terrains.ground;
|
||||
@ -1610,7 +1589,8 @@ core.prototype.drawMap = function (mapName, callback) {
|
||||
}
|
||||
}
|
||||
for (var b = 0; b < mapBlocks.length; b++) {
|
||||
if (core.isset(mapBlocks[b].event)) {
|
||||
// 事件启用
|
||||
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);
|
||||
@ -1628,14 +1608,21 @@ core.prototype.drawMap = function (mapName, callback) {
|
||||
* @param y
|
||||
* @returns {boolean}
|
||||
*/
|
||||
core.prototype.noPassExists = function (x, y) {
|
||||
core.prototype.noPassExists = function (x, y, floorId) {
|
||||
var block = core.getBlock(x,y,floorId);
|
||||
if (block==null) return false;
|
||||
return core.isset(block.block.event.noPass) && block.block.event.noPass;
|
||||
/*
|
||||
var blocks = core.status.thisMap.blocks;
|
||||
for (var n = 0; n < blocks.length; n++) {
|
||||
if (blocks[n].x == x && blocks[n].y == y && core.isset(blocks[n].event) && core.isset(blocks[n].event.noPass) && blocks[n].event.noPass) {
|
||||
if (blocks[n].x == x && blocks[n].y == y && core.isset(blocks[n].event)
|
||||
&& !(core.isset(blocks[n].enable) && !blocks[n].enable)
|
||||
&& core.isset(blocks[n].event.noPass) && blocks[n].event.noPass) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1644,24 +1631,29 @@ core.prototype.noPassExists = function (x, y) {
|
||||
* @param y
|
||||
* @returns {boolean}
|
||||
*/
|
||||
core.prototype.npcExists = function (x, y) {
|
||||
core.prototype.npcExists = function (x, y, floorId) {
|
||||
var block = core.getBlock(x,y,floorId);
|
||||
if (block==null) return false;
|
||||
return block.block.event.cls == 'npcs';
|
||||
/*
|
||||
var blocks = core.status.thisMap.blocks;
|
||||
for (var n = 0; n < blocks.length; n++) {
|
||||
if (blocks[n].x == x && blocks[n].y == y && core.isset(blocks[n].event) && blocks[n].event.cls == 'npcs') {
|
||||
if (blocks[n].x == x && blocks[n].y == y && core.isset(blocks[n].event)
|
||||
&& !(core.isset(blocks[n].enable) && !blocks[n].enable)
|
||||
&& blocks[n].event.cls == 'npcs') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否存在地形
|
||||
* @param x
|
||||
* @param y
|
||||
* @param id
|
||||
* @returns {boolean}
|
||||
*/
|
||||
core.prototype.terrainExists = function (x, y, id) {
|
||||
core.prototype.doorExists = function (x, y, id, floorId) {
|
||||
var block = core.getBlock(x,y,floorId);
|
||||
if (block==null) return false;
|
||||
return block.block.event.cls=='terrains' && block.block.event.id==id;
|
||||
|
||||
/*
|
||||
if (x > 12 || y > 12 || x < 0 || y < 0) {
|
||||
return true;
|
||||
}
|
||||
@ -1671,14 +1663,13 @@ core.prototype.terrainExists = function (x, y, id) {
|
||||
var blocks = core.status.thisMap.blocks;
|
||||
for (var t = 0; t < blocks.length; t++) {
|
||||
if (blocks[t].x == x && blocks[t].y == y) {
|
||||
for (var map in core.canvas) {
|
||||
if (core.isset(blocks[t][map]) && (blocks[t][map].cls == 'terrains' || (blocks[t][map].cls == 'animates' && core.isset(blocks[t][map].noPass) && blocks[t][map].noPass == true)) && ((core.isset(id) && core.isset(blocks[t][map].id)) ? blocks[t][map].id == id : true)) {
|
||||
return true;
|
||||
}
|
||||
if (core.isset(blocks[t][map]) && (blocks[t][map].cls == 'terrains' || (blocks[t][map].cls == 'animates' && core.isset(blocks[t][map].noPass) && blocks[t][map].noPass == true)) && ((core.isset(id) && core.isset(blocks[t][map].id)) ? blocks[t][map].id == id : true)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1687,7 +1678,11 @@ core.prototype.terrainExists = function (x, y, id) {
|
||||
* @param y
|
||||
* @returns {boolean}
|
||||
*/
|
||||
core.prototype.stairExists = function (x, y) {
|
||||
core.prototype.stairExists = function (x, y, floorId) {
|
||||
var block = core.getBlock(x,y,floorId);
|
||||
if (block==null) return false;
|
||||
return block.block.event.cls=='terrains' && (block.block.event.id=='upFloor' || block.block.event.id=='downFloor');
|
||||
/*
|
||||
var blocks = core.status.thisMap.blocks;
|
||||
for (var s = 0; s < blocks.length; s++) {
|
||||
if (blocks[s].x == x && blocks[s].y == y && core.isset(blocks[s].event) && blocks[s].event.cls == 'terrains' && core.isset(blocks[s].event.id) && (blocks[s].event.id == 'upFloor' || blocks[s].event.id == 'downFloor')) {
|
||||
@ -1695,9 +1690,14 @@ core.prototype.stairExists = function (x, y) {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
*/
|
||||
}
|
||||
|
||||
core.prototype.enemyExists = function (x, y, id) {
|
||||
core.prototype.enemyExists = function (x, y, id,floorId) {
|
||||
var block = core.getBlock(x,y,floorId);
|
||||
if (block==null) return false;
|
||||
return block.block.event.cls=='enemys' && block.block.event.id==id;
|
||||
/*
|
||||
var blocks = core.status.thisMap.blocks;
|
||||
for (var e = 0; e < blocks.length; e++) {
|
||||
if (blocks[e].x == x && blocks[e].y == y && core.isset(blocks[e].event) && blocks[e].event.cls == 'enemys' && ((core.isset(id) && core.isset(blocks[e].event.id)) ? blocks[e].event.id == id : true)) {
|
||||
@ -1705,6 +1705,7 @@ core.prototype.enemyExists = function (x, y, id) {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
*/
|
||||
}
|
||||
|
||||
core.prototype.getBlock = function (x, y, floorId, needEnable) {
|
||||
@ -1720,9 +1721,47 @@ core.prototype.getBlock = function (x, y, floorId, needEnable) {
|
||||
return null;
|
||||
}
|
||||
|
||||
core.prototype.removeBlock = function (map, x, y) {
|
||||
var map = map.split(',');
|
||||
var mapBlocks = core.status.thisMap.blocks;
|
||||
core.prototype.removeBlockById = function (index, floorId) {
|
||||
|
||||
var blocks = core.status.maps[floorId].blocks;
|
||||
var x=blocks[index].x, y=blocks[index].y;
|
||||
|
||||
// 检查该点是否存在事件
|
||||
var event = core.floors[floorId].events[x+","+y];
|
||||
|
||||
// 不存在事件,直接删除
|
||||
if (!core.isset(event)) {
|
||||
blocks.splice(index,1);
|
||||
return;
|
||||
}
|
||||
// 如果该点事件是“checkBlock”,则替换现有的事件
|
||||
if ((event instanceof Object) && event.trigger == 'checkBlock') {
|
||||
blocks[index] = {'x': x, 'y': y, 'event': {'cls': 'terrains', 'id': 'ground', 'noPass': false, 'trigger': 'checkBlock'}};
|
||||
return;
|
||||
}
|
||||
// 否则,则存在自定义事件。简单的将该点的enable置为false
|
||||
blocks[index].enable = false;
|
||||
}
|
||||
|
||||
core.prototype.removeBlock = function (x, y, floorId) {
|
||||
floorId = floorId || core.status.floorId;
|
||||
|
||||
var block = core.getBlock(x,y,floorId,false);
|
||||
if (block==null) return; // 不存在
|
||||
|
||||
var index=block.index;
|
||||
|
||||
// 删除动画,清除地图
|
||||
if (floorId==core.status.floorId) {
|
||||
core.rmGlobalAnimate(x, y);
|
||||
core.canvas.event.clearRect(x * 32, y * 32, 32, 32);
|
||||
}
|
||||
|
||||
// 删除Index
|
||||
core.removeBlockById(index, floorId);
|
||||
|
||||
/*
|
||||
var mapBlocks = core.status.maps[floorId].blocks;
|
||||
var blockIcon;
|
||||
for (var b = 0; b < mapBlocks.length; b++) {
|
||||
if (mapBlocks[b].x == x && mapBlocks[b].y == y) {
|
||||
@ -1739,15 +1778,22 @@ core.prototype.removeBlock = function (map, x, y) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
core.prototype.removeBlockByIds = function (floorId, ids) {
|
||||
ids.sort(function (a,b) {return b-a}).forEach(function (id) {
|
||||
core.status.maps[floorId].blocks.splice(id, 1);
|
||||
// core.status.maps[floorId].blocks.splice(id, 1);
|
||||
core.removeBlockById(id, floorId);
|
||||
});
|
||||
}
|
||||
|
||||
core.prototype.noPass = function (x, y) {
|
||||
if (x > 12 || y > 12 || x < 0 || y < 0) {
|
||||
return true;
|
||||
}
|
||||
return core.noPassExists(x,y);
|
||||
/*
|
||||
if (x > 12 || y > 12 || x < 0 || y < 0) {
|
||||
return true;
|
||||
}
|
||||
@ -1758,14 +1804,15 @@ core.prototype.noPass = function (x, y) {
|
||||
return noPass = (mapBlocks[b].event && mapBlocks[b].event.noPass) || (mapBlocks[b].bg && mapBlocks[b].bg.noPass);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
core.prototype.trigger = function (x, y) {
|
||||
var mapBlocks = core.status.thisMap.blocks;
|
||||
var noPass;
|
||||
for (var b = 0; b < mapBlocks.length; b++) {
|
||||
if (mapBlocks[b].x == x && mapBlocks[b].y == y) {
|
||||
noPass = (mapBlocks[b].event && mapBlocks[b].event.noPass) || (mapBlocks[b].bg && mapBlocks[b].bg.noPass);
|
||||
if (mapBlocks[b].x == x && mapBlocks[b].y == y && !(core.isset(mapBlocks[b].enable) && !mapBlocks[b].enable)) { // 启用事件
|
||||
noPass = mapBlocks[b].event && mapBlocks[b].event.noPass;
|
||||
if (noPass) {
|
||||
core.clearAutomaticRouteNode(x, y);
|
||||
}
|
||||
@ -1785,54 +1832,7 @@ core.prototype.trigger = function (x, y) {
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
core.prototype.setTrigger = function (x, y, map, triggerName) {
|
||||
var mapBlocks = core.status.thisMap.blocks;
|
||||
for (var b = 0; b < mapBlocks.length; b++) {
|
||||
if (mapBlocks[b].x == x && mapBlocks[b].y == y && core.isset(mapBlocks[b][map])) {
|
||||
mapBlocks[b][map].trigger = triggerName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
core.prototype.enabledTrigger = function (x, y, map) {
|
||||
var mapBlocks = core.status.thisMap.blocks;
|
||||
for (var b = 0; b < mapBlocks.length; b++) {
|
||||
if (mapBlocks[b].x == x && mapBlocks[b].y == y && core.isset(mapBlocks[b][map]) && core.isset(mapBlocks[b][map].trigger)) {
|
||||
mapBlocks[b][map].disabledTrigger = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
core.prototype.enabledAllTrigger = function () {
|
||||
var mapBlocks = core.status.thisMap.blocks;
|
||||
for (var b = 0; b < mapBlocks.length; b++) {
|
||||
for (var map in core.canvas) {
|
||||
if (core.isset(mapBlocks[b][map]) && core.isset(mapBlocks[b][map].trigger)) {
|
||||
mapBlocks[b][map].disabledTrigger = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
core.prototype.disabledTrigger = function (x, y, map) {
|
||||
var mapBlocks = core.status.thisMap.blocks;
|
||||
for (var b = 0; b < mapBlocks.length; b++) {
|
||||
if (mapBlocks[b].x == x && mapBlocks[b].y == y && core.isset(mapBlocks[b][map]) && core.isset(mapBlocks[b][map].trigger)) {
|
||||
mapBlocks[b][map].disabledTrigger = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
core.prototype.rmTrigger = function (x, y, map) {
|
||||
var mapBlocks = core.status.thisMap.blocks;
|
||||
for (var b = 0; b < mapBlocks.length; b++) {
|
||||
if (mapBlocks[b].x == x && mapBlocks[b].y == y && core.isset(mapBlocks[b][map]) && core.isset(mapBlocks[b][map].trigger)) {
|
||||
delete mapBlocks[b][map].trigger;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
core.prototype.addGlobalAnimate = function (animateMore, x, y, loc, image) {
|
||||
if (animateMore == 2) {
|
||||
core.status.twoAnimateObjs.push({
|
||||
@ -1882,13 +1882,6 @@ core.prototype.setGlobalAnimate = function (speed) {
|
||||
var obj = core.status.twoAnimateObjs[a];
|
||||
obj.status = (obj.status+1)%2;
|
||||
core.canvas.event.clearRect(obj.x, obj.y, 32, 32);
|
||||
/*
|
||||
for (var b = 0; b < core.status.thisMap.blocks.length; b++) {
|
||||
if (core.status.thisMap.blocks[b].x * 32 == core.status.twoAnimateObjs[a].x && core.status.thisMap.blocks[b].y * 32 == core.status.twoAnimateObjs[a].y && (!core.isset(core.status.thisMap.blocks[b][core.status.twoAnimateObjs[a].map]) || core.status.thisMap.blocks[b][core.status.twoAnimateObjs[a].map].animate == 0)) {
|
||||
animateClose = true;
|
||||
}
|
||||
}
|
||||
*/
|
||||
if (!animateClose) {
|
||||
core.canvas.event.drawImage(obj.image, obj.status * 32, obj.loc * 32, 32, 32, obj.x, obj.y, 32, 32);
|
||||
}
|
||||
@ -1900,13 +1893,6 @@ core.prototype.setGlobalAnimate = function (speed) {
|
||||
var obj=core.status.fourAnimateObjs[a];
|
||||
obj.status = (obj.status+1)%4;
|
||||
core.canvas.event.clearRect(obj.x, obj.y, 32, 32);
|
||||
/*
|
||||
for (var b = 0; b < core.status.thisMap.blocks.length; b++) {
|
||||
if (core.status.thisMap.blocks[b].x * 32 == core.status.fourAnimateObjs[a].x && core.status.thisMap.blocks[b].y * 32 == core.status.fourAnimateObjs[a].y && (!core.isset(core.status.thisMap.blocks[b][core.status.fourAnimateObjs[a].map]) || core.status.thisMap.blocks[b][core.status.fourAnimateObjs[a].map].animate == 0)) {
|
||||
animateClose = true;
|
||||
}
|
||||
}
|
||||
*/
|
||||
if (!animateClose) {
|
||||
core.canvas.event.drawImage(obj.image, obj.status * 32, obj.loc * 32, 32, 32, obj.x, obj.y, 32, 32);
|
||||
}
|
||||
@ -1987,7 +1973,8 @@ core.prototype.updateFg = function () {
|
||||
var hero_hp = core.status.hero.hp;
|
||||
for (var b = 0; b < mapBlocks.length; b++) {
|
||||
var x = mapBlocks[b].x, y = mapBlocks[b].y;
|
||||
if (core.isset(mapBlocks[b].event) && mapBlocks[b].event.cls == 'enemys') {
|
||||
if (core.isset(mapBlocks[b].event) && mapBlocks[b].event.cls == 'enemys'
|
||||
&& !(core.isset(mapBlocks[b].enable && !mapBlocks[b].enable))) {
|
||||
var id = mapBlocks[b].event.id;
|
||||
|
||||
var damage = core.enemys.getDamage(id);
|
||||
@ -2014,8 +2001,6 @@ core.prototype.updateFg = function () {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 物品处理 start
|
||||
*/
|
||||
@ -2031,7 +2016,7 @@ core.prototype.hasItem = function (itemId) {
|
||||
|
||||
core.prototype.setItem = function (itemId, itemNum) {
|
||||
var itemCls = core.material.items[itemId].cls;
|
||||
if (itemCls == 'item') return;
|
||||
if (itemCls == 'items') return;
|
||||
if (!core.isset(core.status.hero.items[itemCls])) {
|
||||
core.status.hero.items[itemCls] = {};
|
||||
}
|
||||
@ -2061,7 +2046,7 @@ core.prototype.canUseItem = function (itemId) {
|
||||
core.prototype.addItem = function (itemId, itemNum) {
|
||||
var itemData = core.material.items[itemId];
|
||||
var itemCls = itemData.cls;
|
||||
if (itemCls == 'item') return;
|
||||
if (itemCls == 'items') return;
|
||||
if (!core.isset(core.status.hero.items[itemCls])) {
|
||||
core.status.hero.items[itemCls] = {};
|
||||
core.status.hero.items[itemCls][itemId] = 0;
|
||||
@ -2077,7 +2062,7 @@ core.prototype.getItem = function (itemId, itemNum, itemX, itemY, callback) {
|
||||
core.playSound('item', 'ogg');
|
||||
var itemCls = core.material.items[itemId].cls;
|
||||
core.items.getItemEffect(itemId, itemNum);
|
||||
core.removeBlock('event', itemX, itemY);
|
||||
core.removeBlock(itemX, itemY);
|
||||
var text = '获得 ' + core.material.items[itemId].name;
|
||||
if (itemNum > 1) text += "x" + itemNum;
|
||||
if (itemCls === 'items') text += core.items.getItemEffectTip(itemId);
|
||||
@ -2297,7 +2282,7 @@ core.prototype.npcAction = function() {
|
||||
}
|
||||
// 消失
|
||||
if (data.action == 'disappear') {
|
||||
core.removeBlock('event', x, y);
|
||||
core.removeBlock(x, y);
|
||||
core.npcAction();
|
||||
return;
|
||||
}
|
||||
@ -2397,7 +2382,7 @@ core.prototype.formatDate = function(date) {
|
||||
}
|
||||
|
||||
core.prototype.setTwoDigits = function (x) {
|
||||
return x<10?"0"+x:x;
|
||||
return parseInt(x)<10?"0"+x:x;
|
||||
}
|
||||
|
||||
core.prototype.lose = function() {
|
||||
@ -2411,53 +2396,6 @@ core.prototype.lose = function() {
|
||||
core.events.lose();
|
||||
}
|
||||
|
||||
core.prototype.win = function() {
|
||||
|
||||
// 正在移动中...
|
||||
if (!core.status.heroStop) {
|
||||
setTimeout(function () {
|
||||
core.win();
|
||||
}, 30);
|
||||
return;
|
||||
}
|
||||
core.events.win();
|
||||
}
|
||||
|
||||
core.prototype.updateTime = function() {
|
||||
var currentTime = new Date();
|
||||
core.status.hero.time.playtime += (currentTime.getTime()-core.status.hero.time.lasttime.getTime())/1000;
|
||||
core.status.hero.time.totaltime += (currentTime.getTime()-core.status.hero.time.lasttime.getTime())/1000;
|
||||
core.status.hero.time.lasttime = currentTime;
|
||||
}
|
||||
|
||||
core.prototype.upload = function (delay) {
|
||||
/*
|
||||
try {
|
||||
|
||||
if (core.isset(delay) && delay>0) {
|
||||
setTimeout(function() {core.upload();}, delay);
|
||||
return;
|
||||
}
|
||||
|
||||
core.updateTime();
|
||||
|
||||
var xmlHttp = new XMLHttpRequest();
|
||||
var parameters = "action=upload";
|
||||
parameters+="&starttime="+core.status.hero.time.starttime.getTime()/1000;
|
||||
parameters+="&hard="+core.status.hard;
|
||||
parameters+="&floor="+core.status.maps[core.status.floorId].name;
|
||||
parameters+="&hp="+core.status.hero.hp+"&atk="+core.status.hero.atk+"&def="+core.status.hero.def+"&mdef="+core.status.hero.mdef+"&money="+core.status.hero.money;
|
||||
parameters+="&yellow="+core.status.hero.items.keys.yellowKey+"&blue="+core.status.hero.items.keys.blueKey;
|
||||
parameters+="&playtime="+core.status.hero.time.playtime+"&totaltime="+core.status.hero.time.totaltime+"&step="+core.status.hero.steps+"&ending="+(core.status.event.id=='win'?1:0);
|
||||
|
||||
//xmlHttp.open("GET", "/service/mota/mota4.php?"+parameters, true);
|
||||
//xmlHttp.send();
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// 作弊
|
||||
core.prototype.debug = function() {
|
||||
core.setStatus('hp', 999999);
|
||||
@ -2478,7 +2416,6 @@ core.prototype.debug = function() {
|
||||
core.drawTip("作弊成功");
|
||||
}
|
||||
|
||||
|
||||
core.prototype.checkStatus = function (name, need, item, clearData) {
|
||||
if (need && core.status.event.id == name) {
|
||||
core.ui.closePanel(clearData);
|
||||
@ -2510,6 +2447,13 @@ core.prototype.openBook = function (need) {
|
||||
core.prototype.useFly = function (need) {
|
||||
if (!core.checkStatus('fly', need, true))
|
||||
return;
|
||||
if (core.flags.flyNearStair && !core.nearStair()) {
|
||||
core.drawTip("只有在楼梯边才能使用传送器");
|
||||
core.unLockControl();
|
||||
core.status.event.data = null;
|
||||
core.status.event.id = null;
|
||||
return;
|
||||
}
|
||||
if (!core.canUseItem('fly')) {
|
||||
core.drawTip("楼层传送器好像失效了");
|
||||
core.unLockControl();
|
||||
@ -2524,7 +2468,6 @@ core.prototype.useFly = function (need) {
|
||||
core.prototype.openToolbox = function (need) {
|
||||
if (!core.checkStatus('toolbox', need))
|
||||
return;
|
||||
// core.drawTip("工具箱还未完成");
|
||||
core.ui.drawToolbox();
|
||||
}
|
||||
|
||||
@ -2579,18 +2522,15 @@ core.prototype.doSL = function (id, type) {
|
||||
}
|
||||
|
||||
core.prototype.saveData = function(dataId) {
|
||||
core.updateTime();
|
||||
var data = {
|
||||
'floorId': core.status.floorId,
|
||||
'hero': core.clone(core.status.hero),
|
||||
'hard': core.status.hard,
|
||||
'values': core.clone(core.values),
|
||||
'maps': core.maps.save(core.status.maps),
|
||||
'npcs': {},
|
||||
'shops': {},
|
||||
'version': core.firstData.version,
|
||||
'time': new Date().getTime()
|
||||
};
|
||||
data.hero.time.starttime=core.status.hero.time.starttime.getTime();
|
||||
// set shop times
|
||||
for (var shop in core.status.shops) {
|
||||
data.shops[shop]={
|
||||
@ -2598,25 +2538,14 @@ core.prototype.saveData = function(dataId) {
|
||||
'visited': core.status.shops[shop].visited
|
||||
}
|
||||
}
|
||||
// core.upload();
|
||||
core.events.beforeSaveData(data);
|
||||
|
||||
return core.setLocalStorage(dataId, data);
|
||||
// console.log(core.getLocalStorage(dataId));
|
||||
}
|
||||
|
||||
core.prototype.loadData = function (data, callback) {
|
||||
core.upload();
|
||||
|
||||
var totaltime=null, lasttime = null;
|
||||
|
||||
if (core.isPlaying()) {
|
||||
core.updateTime();
|
||||
var totaltime = core.status.hero.time.totaltime;
|
||||
var lasttime = core.clone(core.status.hero.time.lasttime);
|
||||
}
|
||||
|
||||
core.resetStatus(data.hero, data.hard, data.floorId,
|
||||
core.resetStatus(data.hero, data.hard, data.floorId, data.values,
|
||||
core.maps.load(data.maps));
|
||||
|
||||
// load shop times
|
||||
@ -2625,21 +2554,12 @@ core.prototype.loadData = function (data, callback) {
|
||||
core.status.shops[shop].visited = data.shops[shop].visited;
|
||||
}
|
||||
|
||||
core.status.hero.time.starttime = new Date(core.status.hero.time.starttime);
|
||||
if (core.isset(totaltime) && totaltime>core.status.hero.time.totaltime)
|
||||
core.status.hero.time.totaltime=totaltime;
|
||||
if (core.isset(lasttime))
|
||||
core.status.hero.time.lasttime = lasttime;
|
||||
else core.status.hero.time.lasttime = new Date();
|
||||
|
||||
core.events.afterLoadData(data);
|
||||
|
||||
core.changeFloor(data.floorId, null, data.hero.loc, function() {
|
||||
core.setHeroMoveTriggerInterval();
|
||||
if (core.isset(callback)) callback();
|
||||
});
|
||||
|
||||
core.upload(1500);
|
||||
}
|
||||
|
||||
core.prototype.setStatus = function (statusName, statusVal) {
|
||||
@ -2691,11 +2611,6 @@ core.prototype.playSound = function (soundName, soundType) {
|
||||
if (!core.musicStatus.soundStatus || !core.musicStatus.loaded) {
|
||||
return;
|
||||
}
|
||||
/*
|
||||
if (core.isset(core.musicStatus.playedSound)) {
|
||||
// core.musicStatus.playedSound.pause();
|
||||
}
|
||||
*/
|
||||
core.musicStatus.playedSound = core.material.sounds[soundType][soundName];
|
||||
core.musicStatus.playedSound.play();
|
||||
}
|
||||
@ -2720,7 +2635,6 @@ core.prototype.changeSoundStatus = function () {
|
||||
}
|
||||
|
||||
core.prototype.enabledSound = function () {
|
||||
// core.musicStatus.playedBgm.play();
|
||||
core.musicStatus.soundStatus = true;
|
||||
core.playBgm('bgm', 'mp3');
|
||||
core.setLocalStorage('soundStatus', true);
|
||||
|
||||
@ -29,6 +29,7 @@ data.prototype.init = function() {
|
||||
'flyRange': [],
|
||||
'loc': {'direction': 'up', 'x': 6, 'y': 10},
|
||||
'flags': {
|
||||
// 游戏过程中的flag变量
|
||||
}
|
||||
},
|
||||
'startText': [
|
||||
@ -94,6 +95,7 @@ data.prototype.init = function() {
|
||||
"poisonDamage": 10, // 经过毒网受到的伤害
|
||||
"weakValue": 20, // 衰弱状态下攻防减少的数值
|
||||
/****** 道具相关 ******/
|
||||
"cannotUseQuickShop": ["MT0"], // 不能使用快捷商店的楼层列表
|
||||
"redJewel": 3, // 红宝石加攻击的数值
|
||||
"blueJewel": 3, // 蓝宝石加防御的数值
|
||||
"greenJewel": 5, // 绿宝石加魔防的数值
|
||||
|
||||
@ -203,7 +203,7 @@ enemys.prototype.getCurrentEnemys = function () {
|
||||
var used = {};
|
||||
var mapBlocks = core.status.thisMap.blocks;
|
||||
for (var b = 0; b < mapBlocks.length; b++) {
|
||||
if (core.isset(mapBlocks[b].event) && mapBlocks[b].event.cls == 'enemys') {
|
||||
if (core.isset(mapBlocks[b].event) && !(core.isset(mapBlocks[b].enable) && !mapBlocks[b].enable) && mapBlocks[b].event.cls == 'enemys') {
|
||||
var monsterId = mapBlocks[b].event.id;
|
||||
if (core.isset(used[monsterId])) continue;
|
||||
|
||||
|
||||
@ -75,10 +75,6 @@ events.prototype.startGame = function (hard) {
|
||||
})
|
||||
}
|
||||
|
||||
////// 走到某位置时触发事件 //////
|
||||
events.prototype.blockEvent = function (data) {
|
||||
}
|
||||
|
||||
////// 检查领域、夹击事件 //////
|
||||
events.prototype.checkBlock = function (x,y) {
|
||||
var damage = 0;
|
||||
@ -172,8 +168,8 @@ events.prototype.doAction = function() {
|
||||
case "text": // 文字/对话
|
||||
core.ui.drawTextBox(data.data);
|
||||
break;
|
||||
case "disappear": // 消失
|
||||
core.removeBlock('event', x, y);
|
||||
case "hide": // 消失
|
||||
core.removeBlock(x, y);
|
||||
this.doAction();
|
||||
break;
|
||||
case "sleep": // 等待多少毫秒
|
||||
@ -214,8 +210,9 @@ events.prototype.decreaseHard = function() {
|
||||
}
|
||||
|
||||
////// 能否使用快捷商店 //////
|
||||
events.prototype.canUseQuickShop = function(index) {
|
||||
if (core.status.floorId == 'MT20') return '当前不能使用快捷商店。';
|
||||
events.prototype.canUseQuickShop = function(shopIndex) {
|
||||
if (core.isset(core.values.cannotUseQuickShop) && core.values.cannotUseQuickShop.indexOf(core.status.floorId)>=0)
|
||||
return '当前不能使用快捷商店。';
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -34,37 +34,43 @@ main.floors.sample0 = {
|
||||
"\t[老人,man]有关道具效果,定义在items.js中。\n目前大多数道具已有默认行为,如有自定义\n的需求则需在items.js中修改代码。",
|
||||
"\t[老人,man]constants 和 tools 各最多只允许12种,\n多了会导致图标溢出。",
|
||||
"\t[老人,man]拾取道具结束后可触发 afterGetItem 事件。\n\n有关事件的各种信息在下一层会有更为详细的\n说明。",
|
||||
{"type": "disappear"} // 消失
|
||||
{"type": "hide"} // 消失
|
||||
],
|
||||
"10,11": [ // 守着门的老人
|
||||
"\t[老人,woman]这些是门,需要对应的钥匙打开。\n机关门必须使用特殊的开法。",
|
||||
"\t[老人,woman]开门后可触发 afterOpenDoor 事件。\n\n有关事件的各种信息在下一层会有更为详细的\n说明。",
|
||||
{'type': 'disappear'}
|
||||
{'type': 'hide'}
|
||||
],
|
||||
"2,10": [ // 守着楼梯、传送门、路障的老人
|
||||
"\t[老人,womanMagician]这些是路障、楼梯、传送门。",
|
||||
"\t[老人,womanMagician]血网的伤害数值、中毒后每步伤害数值、衰弱\n时攻防下降的数值,都在 data.js 内定义。\n\n路障同样会尽量被自动寻路绕过。",
|
||||
"\t[老人,womanMagician]楼梯和传送门需要在events中定义目标楼层\n和位置,可参见样板里已有的的写法。",
|
||||
"\t[老人,womanMagician]楼梯和传送门是否可“穿透”,由data.js中的\n全局变量所决定,你也可以单独设置。\n穿透的意思是,自动寻路得到的路径中间经\n过了楼梯,行走时是否触发楼层转换事件。\n例如,下面的“下箭头”就是不能穿透的。",
|
||||
{"type": "disappear"}
|
||||
{"type": "hide"}
|
||||
],
|
||||
"2,8": [ // 守着第一批怪物的老人
|
||||
"\t[老人,magician]这些都是各种各样的怪物。\n所有怪物的数据都在enemys.js中设置。\n\n每个怪物最多只能有一个特殊属性。",
|
||||
"\t[老人,magician]这批怪物分别为:普通、先攻、魔攻、坚固、\n2连击、3连击、4连击、破甲、反击、净化。",
|
||||
"\t[老人,magician]打败怪物后可触发 afterBattle 事件。\n\n有关事件的各种信息在下一层会有更为详细的\n说明。",
|
||||
{"type": "disappear"}
|
||||
{"type": "hide"}
|
||||
],
|
||||
"2,5": [
|
||||
"\t[老人,magician]模仿、吸血、中毒、衰弱、诅咒。\n\n请注意吸血怪需要设置value为吸血数值,\n可参见样板中黑魔法师的写法。",
|
||||
{"type": "disappear"}
|
||||
{"type": "hide"}
|
||||
],
|
||||
"2,3": [
|
||||
"\t[老人,magician]领域、夹击。\n请注意领域怪需要设置value为伤害数值,\n可参见样板中初级巫师的写法。",
|
||||
"\t[老人,magician]出于游戏性能的考虑,我们不可能每走一步都\n对领域和夹击进行检查。\n因此我们需要在本楼层的 events 中指明哪些\n点可能会触发领域和夹击事件,在这些点才会\n对领域和夹击进行检查和处理。\n\n具体可参见本层样板中events的做法。",
|
||||
"\t[老人,magician]夹击和领域同时发生时先计算领域,再夹击。\n\n另:本塔不支持阻击怪。",
|
||||
"\t[老人,magician]自动寻路会尽量绕过你设置的这些点。",
|
||||
{"type": "disappear"}
|
||||
{"type": "hide"}
|
||||
],
|
||||
"12,10": { // 隐藏的仙子
|
||||
"trigger": "action", "enable": false,
|
||||
"data": [
|
||||
"\t[仙子,fairy]只有楼上启用事件后,才能看到我并可以和我\n对话来触发事件。"
|
||||
]
|
||||
},
|
||||
|
||||
/****** 楼层转换事件 ******/
|
||||
"6,0": {"trigger": "changeFloor", "data": {"floorId": "sample0", "stair": "downFloor"}}, // 目标点:sample0层的下楼梯位置
|
||||
@ -80,8 +86,8 @@ main.floors.sample0 = {
|
||||
|
||||
/****** 领域、夹击检查事件 ******/
|
||||
// 所有可能的的领域、夹击点均需要加上 {"trigger": "ckeckBlock"},否则将不会触发检查事件
|
||||
// 另外,如果该点已经存在events事件(上面有相同点位置定义),则会覆盖
|
||||
// 所以 |****** 强烈要求可能的夹击、领域点不要存在事件!! ******|
|
||||
// 另外,如果该点已经存在events事件(上面有相同点位置定义),则会被覆盖
|
||||
// 所以 |****** 强烈要求可能的夹击、领域点不要存在自定义事件!! ******|
|
||||
"1,0": {"trigger": "checkBlock"},
|
||||
"3,0": {"trigger": "checkBlock"},
|
||||
"0,1": {"trigger": "checkBlock"},
|
||||
@ -89,6 +95,7 @@ main.floors.sample0 = {
|
||||
"4,1": {"trigger": "checkBlock"},
|
||||
"1,2": {"trigger": "checkBlock"},
|
||||
"3,2": {"trigger": "checkBlock"},
|
||||
"6,8": {"trigger": "checkBlock"}
|
||||
|
||||
},
|
||||
"afterOpenDoor": { // 开完门后可能触发的事件列表
|
||||
@ -110,8 +117,7 @@ main.floors.sample0 = {
|
||||
"炸弹可以炸四个方向的怪物。\n如只需要炸前方怪物请使用上面的圣锤。",
|
||||
"不能被炸的怪物在enemys中可以定义。\n可参见样板里黑衣魔王的写法。\n\n炸死怪物是否触发事件由 data.js 中的系统Flag\n所决定。"
|
||||
],
|
||||
"9,4": "中心对称飞行器飞向的目标不能在楼层的events\n列表里存在,即使事件已经结束(如刚刚的老人)。",
|
||||
"10,4": "上楼器和下楼器的目标点要求同中心对称飞行器。\n\n“上楼”和“下楼”的目标层由 main.js 的 floorIds\n顺序所决定。",
|
||||
"10,4": "“上楼”和“下楼”的目标层由 main.js 的 floorIds\n顺序所决定。",
|
||||
"10,3": "十字架目前未被定义,可能需要自行实现功能。\n有关如何实现一个道具功能参见doc文档。",
|
||||
"9,2": "该道具默认是大黄门钥匙,如需改为钥匙盒直接\n修改 data.js 中的系统Flag即可。",
|
||||
"10,2": "屠龙匕首目前未被定义,可能需要自行实现功能。\n有关如何实现一个道具功能参见doc文档。",
|
||||
|
||||
@ -212,7 +212,7 @@ items.prototype.canUseItem = function (itemId) {
|
||||
var ids = [];
|
||||
for (var i in core.status.thisMap.blocks) {
|
||||
var block = core.status.thisMap.blocks[i];
|
||||
if (core.isset(block.event) &&
|
||||
if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) &&
|
||||
(block.event.id == 'yellowWall' || block.event.id=='whiteWall' || block.event.id=='blueWall')) // 能破哪些墙
|
||||
{
|
||||
// 四个方向
|
||||
@ -238,7 +238,7 @@ items.prototype.canUseItem = function (itemId) {
|
||||
// 破冰镐
|
||||
for (var i in core.status.thisMap.blocks) {
|
||||
var block = core.status.thisMap.blocks[i];
|
||||
if (core.isset(block.event) && block.x==core.nextX() && block.y==core.nextY() && block.event.id=='ice') {
|
||||
if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) && block.x==core.nextX() && block.y==core.nextY() && block.event.id=='ice') {
|
||||
core.status.event.data = [i];
|
||||
return true;
|
||||
}
|
||||
@ -250,7 +250,7 @@ items.prototype.canUseItem = function (itemId) {
|
||||
var ids = [];
|
||||
for (var i in core.status.thisMap.blocks) {
|
||||
var block = core.status.thisMap.blocks[i];
|
||||
if (core.isset(block.event) && block.event.cls == 'enemys' && Math.abs(block.x-core.status.hero.loc.x)+Math.abs(block.y-core.status.hero.loc.y)<=1) {
|
||||
if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) && block.event.cls == 'enemys' && Math.abs(block.x-core.status.hero.loc.x)+Math.abs(block.y-core.status.hero.loc.y)<=1) {
|
||||
var enemy = core.material.enemys[block.event.id];
|
||||
if (core.isset(enemy.bomb) && !enemy.bomb) continue;
|
||||
ids.push(i);
|
||||
@ -266,7 +266,7 @@ items.prototype.canUseItem = function (itemId) {
|
||||
// 圣锤
|
||||
for (var i in core.status.thisMap.blocks) {
|
||||
var block = core.status.thisMap.blocks[i];
|
||||
if (core.isset(block.event) && block.event.cls == 'enemys' && block.x==core.nextX() && block.y==core.nextY()) {
|
||||
if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) && block.event.cls == 'enemys' && block.x==core.nextX() && block.y==core.nextY()) {
|
||||
var enemy = core.material.enemys[block.event.id];
|
||||
if (core.isset(enemy.bomb) && !enemy.bomb) continue;
|
||||
core.status.event.data = [i];
|
||||
@ -279,7 +279,7 @@ items.prototype.canUseItem = function (itemId) {
|
||||
var ids = []
|
||||
for (var i in core.status.thisMap.blocks) {
|
||||
var block = core.status.thisMap.blocks[i];
|
||||
if (core.isset(block.event) && (block.event.id == 'yellowWall' || block.event.id == 'blueWall' || block.event.id == 'whiteWall'))
|
||||
if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) && (block.event.id == 'yellowWall' || block.event.id == 'blueWall' || block.event.id == 'whiteWall'))
|
||||
ids.push(i);
|
||||
}
|
||||
if (ids.length>0) {
|
||||
@ -291,14 +291,12 @@ items.prototype.canUseItem = function (itemId) {
|
||||
if (itemId == 'centerFly') {
|
||||
// 中心对称
|
||||
var toX = 12 - core.getHeroLoc('x'), toY = 12-core.getHeroLoc('y');
|
||||
var blocks = core.status.thisMap.blocks;
|
||||
for (var s = 0; s < blocks.length; s++) {
|
||||
if (blocks[s].x == toX && blocks[s].y == toY) {
|
||||
return false;
|
||||
}
|
||||
var block = core.getBlock(toX, toY);
|
||||
if (block==null) {
|
||||
core.status.event.data = {'x': toX, 'y': toY};
|
||||
return true;
|
||||
}
|
||||
core.status.event.data = {'x': toX, 'y': toY};
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
if (itemId == 'upFly') {
|
||||
// 上楼器
|
||||
@ -306,19 +304,14 @@ items.prototype.canUseItem = function (itemId) {
|
||||
var index = core.floorIds.indexOf(floorId);
|
||||
if (index==core.floorIds.length-1) return false;
|
||||
var toId = core.floorIds[index+1];
|
||||
|
||||
// 检查是否存在block(不是空地)
|
||||
var toX = core.getHeroLoc('x'), toY = core.getHeroLoc('y');
|
||||
var blocks = core.status.maps[toId].blocks;
|
||||
for (var s = 0; s < blocks.length; s++) {
|
||||
if (blocks[s].x == toX && blocks[s].y == toY) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 可以上楼,记录下位置信息,返回true
|
||||
core.status.event.data = {'id': toId, 'x': toX, 'y': toY};
|
||||
return true;
|
||||
var block = core.getBlock(toX, toY, toId);
|
||||
if (block==null) {
|
||||
core.status.event.data = {'id': toId, 'x': toX, 'y': toY};
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (itemId == 'downFly') {
|
||||
// 下楼器
|
||||
@ -326,26 +319,21 @@ items.prototype.canUseItem = function (itemId) {
|
||||
var index = core.floorIds.indexOf(floorId);
|
||||
if (index==0) return false;
|
||||
var toId = core.floorIds[index-1];
|
||||
|
||||
// 检查是否存在block(不是空地)
|
||||
var toX = core.getHeroLoc('x'), toY = core.getHeroLoc('y');
|
||||
var blocks = core.status.maps[toId].blocks;
|
||||
for (var s = 0; s < blocks.length; s++) {
|
||||
if (blocks[s].x == toX && blocks[s].y == toY) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 可以上楼,记录下位置信息,返回true
|
||||
core.status.event.data = {'id': toId, 'x': toX, 'y': toY};
|
||||
return true;
|
||||
var block = core.getBlock(toX, toY, toId);
|
||||
if (block==null) {
|
||||
core.status.event.data = {'id': toId, 'x': toX, 'y': toY};
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (itemId=='snow') {
|
||||
// 冰冻徽章
|
||||
var ids = [];
|
||||
for (var i in core.status.thisMap.blocks) {
|
||||
var block = core.status.thisMap.blocks[i];
|
||||
if (core.isset(block.event) && block.event.id == 'lava' && Math.abs(block.x-core.status.hero.loc.x)+Math.abs(block.y-core.status.hero.loc.y)<=1) {
|
||||
if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) && block.event.id == 'lava' && Math.abs(block.x-core.status.hero.loc.x)+Math.abs(block.y-core.status.hero.loc.y)<=1) {
|
||||
ids.push(i);
|
||||
}
|
||||
}
|
||||
@ -360,7 +348,7 @@ items.prototype.canUseItem = function (itemId) {
|
||||
var ids = [];
|
||||
for (var i in core.status.thisMap.blocks) {
|
||||
var block = core.status.thisMap.blocks[i];
|
||||
if (core.isset(block.event) && block.event.id == 'yellowDoor') {
|
||||
if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) && block.event.id == 'yellowDoor') {
|
||||
ids.push(i);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
function maps() {}
|
||||
maps.prototype.init = function() {}
|
||||
|
||||
maps.prototype.loadFloor = function (floorId, map, enables) {
|
||||
maps.prototype.loadFloor = function (floorId, map) {
|
||||
var floor = core.floors[floorId];
|
||||
var content = {};
|
||||
content['floorId'] = floor.floorId;
|
||||
|
||||
10
libs/ui.js
10
libs/ui.js
@ -660,16 +660,6 @@ ui.prototype.drawSLPanel = function(page) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制缩略图
|
||||
* @param canvas
|
||||
* @param blocks
|
||||
* @param x
|
||||
* @param y
|
||||
* @param size
|
||||
* @param heroLoc
|
||||
* @param heroId
|
||||
*/
|
||||
ui.prototype.drawThumbnail = function(canvas, blocks, x, y, size, heroLoc, heroId) {
|
||||
core.clearMap(canvas, x, y, size, size);
|
||||
var persize = size/13;
|
||||
|
||||
@ -7,11 +7,6 @@ html, body {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: number;
|
||||
src: url("fonts/number.ttf");
|
||||
}
|
||||
|
||||
#gameGroup {
|
||||
position: absolute;
|
||||
outline: 3px #fff solid;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user