Save Floor Mata
This commit is contained in:
parent
4bd24e665b
commit
dd33b635de
@ -1047,14 +1047,14 @@ actions.prototype.clickViewMaps = function (x,y) {
|
||||
|
||||
if(y<=4 && (mh==13 || (x>=2 && x<=10))) {
|
||||
index++;
|
||||
while (index<core.floorIds.length && index!=now && core.floors[core.floorIds[index]].cannotViewMap)
|
||||
while (index<core.floorIds.length && index!=now && core.status.maps[core.floorIds[index]].cannotViewMap)
|
||||
index++;
|
||||
if (index<core.floorIds.length)
|
||||
core.ui.drawMaps(index);
|
||||
}
|
||||
else if (y>=8 && (mh==13 || (x>=2 && x<=10))) {
|
||||
index--;
|
||||
while (index>=0 && index!=now && core.floors[core.floorIds[index]].cannotViewMap)
|
||||
while (index>=0 && index!=now && core.status.maps[core.floorIds[index]].cannotViewMap)
|
||||
index--;
|
||||
if (index>=0)
|
||||
core.ui.drawMaps(index);
|
||||
|
||||
@ -2590,8 +2590,8 @@ control.prototype.resumeBgm = function () {
|
||||
}
|
||||
else {
|
||||
if (core.bgms.length>0) {
|
||||
if (core.isset(core.floors[core.status.floorId].bgm)) {
|
||||
core.playBgm(core.floors[core.status.floorId].bgm);
|
||||
if (core.isset(core.status.thisMap.bgm)) {
|
||||
core.playBgm(core.status.thisMap.bgm);
|
||||
}
|
||||
else
|
||||
core.playBgm(core.bgms[0]);
|
||||
|
||||
@ -1219,9 +1219,9 @@ events.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback
|
||||
if (core.isset(stair)) {
|
||||
if (!core.isset(heroLoc)) heroLoc={};
|
||||
|
||||
if (core.isset(core.floors[floorId][stair])) {
|
||||
heroLoc.x = core.floors[floorId][stair][0];
|
||||
heroLoc.y = core.floors[floorId][stair][1];
|
||||
if (core.isset(core.status.maps[floorId][stair])) {
|
||||
heroLoc.x = core.status.maps[floorId][stair][0];
|
||||
heroLoc.y = core.status.maps[floorId][stair][1];
|
||||
}
|
||||
else {
|
||||
var blocks = core.status.maps[floorId].blocks;
|
||||
@ -1268,16 +1268,16 @@ events.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback
|
||||
}
|
||||
|
||||
// 更改BGM
|
||||
if (core.isset(core.floors[floorId].bgm)) {
|
||||
var bgm = core.floors[floorId].bgm;
|
||||
if (core.isset(core.status.maps[floorId].bgm)) {
|
||||
var bgm = core.status.maps[floorId].bgm;
|
||||
if (bgm instanceof Array) bgm = bgm[0];
|
||||
core.playBgm(bgm);
|
||||
}
|
||||
|
||||
// 不存在事件时,更改画面色调
|
||||
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.isset(core.status.maps[floorId].color)) {
|
||||
color = core.status.maps[floorId].color;
|
||||
}
|
||||
if (core.isset(color)) {
|
||||
// 直接变色
|
||||
@ -1296,8 +1296,8 @@ events.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback
|
||||
|
||||
// 更改天气
|
||||
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.isset(core.status.maps[floorId].weather)) {
|
||||
weather = core.status.maps[floorId].weather;
|
||||
}
|
||||
if (core.isset(weather)) {
|
||||
core.setWeather(weather[0], weather[1])
|
||||
|
||||
@ -22,7 +22,7 @@ items.prototype.getItemEffect = function(itemId, itemNum) {
|
||||
var itemCls = core.material.items[itemId].cls;
|
||||
// 消耗品
|
||||
if (itemCls === 'items') {
|
||||
var ratio = parseInt(core.floors[core.status.floorId].item_ratio) || 1;
|
||||
var ratio = parseInt(core.status.thisMap.item_ratio) || 1;
|
||||
var curr_hp = core.status.hero.hp;
|
||||
if (itemId in this.itemEffect)eval(this.itemEffect[itemId]);
|
||||
core.status.hero.statistics.hp += core.status.hero.hp - curr_hp;
|
||||
@ -37,7 +37,7 @@ items.prototype.getItemEffectTip = function(itemId) {
|
||||
var itemCls = core.material.items[itemId].cls;
|
||||
// 消耗品
|
||||
if (itemCls === 'items') {
|
||||
var ratio = parseInt(core.floors[core.status.floorId].item_ratio) || 1;
|
||||
var ratio = parseInt(core.status.thisMap.item_ratio) || 1;
|
||||
if (itemId in this.itemEffectTip) return eval(this.itemEffectTip[itemId])||"";
|
||||
}
|
||||
return "";
|
||||
|
||||
28
libs/maps.js
28
libs/maps.js
@ -10,12 +10,18 @@ maps.prototype.init = function() {
|
||||
////// 加载某个楼层(从剧本或存档中) //////
|
||||
maps.prototype.loadFloor = function (floorId, map) {
|
||||
var floor = core.floors[floorId];
|
||||
|
||||
if (!core.isset(map)) map = floor.map;
|
||||
if (map instanceof Array) {
|
||||
map = {"map": map};
|
||||
}
|
||||
var content = {};
|
||||
content['floorId'] = floor.floorId;
|
||||
content['name'] = floor.name;
|
||||
content['title'] = floor.title;
|
||||
content['canFlyTo'] = floor.canFlyTo;
|
||||
if (!core.isset(map)) map=floor.map;
|
||||
["floorId", "title", "name", "canFlyTo", "canUseQuickShop", "cannotViewMap",
|
||||
"defaultGround", "images", "item_ratio", "upFloor", "bgm", "downFloor"].forEach(function (e) {
|
||||
if (core.isset(map) && core.isset(map[e])) content[e] = core.clone(map[e]);
|
||||
else content[e] = core.clone(floor[e]);
|
||||
});
|
||||
map=map.map;
|
||||
var mapIntoBlocks = function(map,maps,floor,floorId){
|
||||
var blocks = [];
|
||||
var mw = core.floors[floorId].width || 13;
|
||||
@ -168,7 +174,7 @@ maps.prototype.save = function(maps, floorId) {
|
||||
return map;
|
||||
}
|
||||
|
||||
var thisFloor = maps[floorId];
|
||||
var thisFloor = core.clone(maps[floorId]);
|
||||
var mw = core.floors[floorId].width || 13;
|
||||
var mh = core.floors[floorId].height || 13;
|
||||
|
||||
@ -186,7 +192,9 @@ maps.prototype.save = function(maps, floorId) {
|
||||
}
|
||||
else blocks[block.y][block.x] = block.id;
|
||||
});
|
||||
return blocks;
|
||||
delete thisFloor.blocks;
|
||||
thisFloor.map = blocks;
|
||||
return thisFloor;
|
||||
}
|
||||
|
||||
////// 更改地图画布的尺寸
|
||||
@ -383,7 +391,7 @@ maps.prototype.drawBgFgMap = function (floorId, canvas, name) {
|
||||
var width = core.floors[floorId].width || 13;
|
||||
var height = core.floors[floorId].height || 13;
|
||||
|
||||
var groundId = core.floors[floorId].defaultGround || "ground";
|
||||
var groundId = (core.status.maps||core.floors)[floorId].defaultGround || "ground";
|
||||
var blockIcon = core.material.icons.terrains[groundId];
|
||||
var blockImage = core.material.images.terrains;
|
||||
|
||||
@ -442,8 +450,8 @@ maps.prototype.drawMap = function (mapName, callback) {
|
||||
core.maps.drawBgFgMap(mapName, core.canvas.fg, "fg");
|
||||
|
||||
var images = [];
|
||||
if (core.isset(core.floors[mapName].images)) {
|
||||
images = core.floors[mapName].images;
|
||||
if (core.isset(core.status.maps[mapName].images)) {
|
||||
images = core.status.maps[mapName].images;
|
||||
if (typeof images == 'string') {
|
||||
images = [[0, 0, images]];
|
||||
}
|
||||
|
||||
@ -1628,7 +1628,7 @@ ui.prototype.drawMaps = function (index, x, y) {
|
||||
core.setFont('data', '16px Arial');
|
||||
|
||||
|
||||
var text = core.floors[floorId].title;
|
||||
var text = core.status.maps[floorId].title;
|
||||
if (mw>13 || mh>13) text+=" ["+(x-6)+","+(y-6)+"]";
|
||||
var textX = 16, textY = 18, width = textX + core.canvas.data.measureText(text).width + 16, height = 42;
|
||||
core.fillRect('data', 5, 5, width, height, '#000');
|
||||
@ -2050,8 +2050,8 @@ ui.prototype.drawThumbnail = function(floorId, canvas, blocks, x, y, size, cente
|
||||
|
||||
// background image
|
||||
var images = [];
|
||||
if (core.isset(core.floors[floorId].images)) {
|
||||
images = core.floors[floorId].images;
|
||||
if (core.isset((core.status.maps||core.floors)[floorId].images)) {
|
||||
images = (core.status.maps||core.floors)[floorId].images;
|
||||
if (typeof images == 'string') {
|
||||
images = [[0, 0, images]];
|
||||
}
|
||||
@ -2203,7 +2203,7 @@ ui.prototype.drawStatistics = function () {
|
||||
var current = core.clone(total);
|
||||
|
||||
core.floorIds.forEach(function (floorId) {
|
||||
var floor=core.floors[floorId];
|
||||
var floor=core.status.maps[floorId];
|
||||
var blocks=core.status.maps[floorId].blocks;
|
||||
// 隐藏层不给看
|
||||
if (floor.cannotViewMap && floorId!=core.status.floorId) return;
|
||||
|
||||
@ -345,7 +345,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
// 返回null代表可以使用
|
||||
|
||||
// 检查当前楼层的canUseQuickShop选项是否为false
|
||||
if (core.floors[core.status.floorId].canUseQuickShop === false)
|
||||
if (core.status.thisMap.canUseQuickShop === false)
|
||||
return '当前楼层不能使用快捷商店。';
|
||||
|
||||
return null;
|
||||
@ -574,8 +574,8 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
var fromId = core.status.floorId;
|
||||
|
||||
// 检查能否飞行
|
||||
if (!core.floors[fromId].canFlyTo || !core.floors[toId].canFlyTo) {
|
||||
core.drawTip("无法飞往" + core.floors[toId].title +"!");
|
||||
if (!core.status.maps[fromId].canFlyTo || !core.status.maps[toId].canFlyTo) {
|
||||
core.drawTip("无法飞往" + core.status.maps[toId].title +"!");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -583,7 +583,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
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";
|
||||
if (fromIndex == toIndex && core.status.maps[fromId].underGround) stair = "upFloor";
|
||||
// 记录录像
|
||||
core.status.route.push("fly:"+toId);
|
||||
// 传送
|
||||
|
||||
Loading…
Reference in New Issue
Block a user