Save Floor Mata

This commit is contained in:
oc 2018-10-18 23:57:47 +08:00
parent 4bd24e665b
commit dd33b635de
7 changed files with 41 additions and 33 deletions

View File

@ -1047,14 +1047,14 @@ actions.prototype.clickViewMaps = function (x,y) {
if(y<=4 && (mh==13 || (x>=2 && x<=10))) { if(y<=4 && (mh==13 || (x>=2 && x<=10))) {
index++; 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++; index++;
if (index<core.floorIds.length) if (index<core.floorIds.length)
core.ui.drawMaps(index); core.ui.drawMaps(index);
} }
else if (y>=8 && (mh==13 || (x>=2 && x<=10))) { else if (y>=8 && (mh==13 || (x>=2 && x<=10))) {
index--; 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--; index--;
if (index>=0) if (index>=0)
core.ui.drawMaps(index); core.ui.drawMaps(index);

View File

@ -2590,8 +2590,8 @@ control.prototype.resumeBgm = function () {
} }
else { else {
if (core.bgms.length>0) { if (core.bgms.length>0) {
if (core.isset(core.floors[core.status.floorId].bgm)) { if (core.isset(core.status.thisMap.bgm)) {
core.playBgm(core.floors[core.status.floorId].bgm); core.playBgm(core.status.thisMap.bgm);
} }
else else
core.playBgm(core.bgms[0]); core.playBgm(core.bgms[0]);

View File

@ -1219,9 +1219,9 @@ events.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback
if (core.isset(stair)) { if (core.isset(stair)) {
if (!core.isset(heroLoc)) heroLoc={}; if (!core.isset(heroLoc)) heroLoc={};
if (core.isset(core.floors[floorId][stair])) { if (core.isset(core.status.maps[floorId][stair])) {
heroLoc.x = core.floors[floorId][stair][0]; heroLoc.x = core.status.maps[floorId][stair][0];
heroLoc.y = core.floors[floorId][stair][1]; heroLoc.y = core.status.maps[floorId][stair][1];
} }
else { else {
var blocks = core.status.maps[floorId].blocks; var blocks = core.status.maps[floorId].blocks;
@ -1268,16 +1268,16 @@ events.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback
} }
// 更改BGM // 更改BGM
if (core.isset(core.floors[floorId].bgm)) { if (core.isset(core.status.maps[floorId].bgm)) {
var bgm = core.floors[floorId].bgm; var bgm = core.status.maps[floorId].bgm;
if (bgm instanceof Array) bgm = bgm[0]; if (bgm instanceof Array) bgm = bgm[0];
core.playBgm(bgm); core.playBgm(bgm);
} }
// 不存在事件时,更改画面色调 // 不存在事件时,更改画面色调
var color = core.getFlag('color', null); var color = core.getFlag('color', null);
if (!core.isset(color) && core.isset(core.floors[floorId].color)) { if (!core.isset(color) && core.isset(core.status.maps[floorId].color)) {
color = core.floors[floorId].color; color = core.status.maps[floorId].color;
} }
if (core.isset(color)) { if (core.isset(color)) {
// 直接变色 // 直接变色
@ -1296,8 +1296,8 @@ events.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback
// 更改天气 // 更改天气
var weather = core.getFlag('weather', null); var weather = core.getFlag('weather', null);
if (!core.isset(weather) && core.isset(core.floors[floorId].weather)) { if (!core.isset(weather) && core.isset(core.status.maps[floorId].weather)) {
weather = core.floors[floorId].weather; weather = core.status.maps[floorId].weather;
} }
if (core.isset(weather)) { if (core.isset(weather)) {
core.setWeather(weather[0], weather[1]) core.setWeather(weather[0], weather[1])

View File

@ -22,7 +22,7 @@ items.prototype.getItemEffect = function(itemId, itemNum) {
var itemCls = core.material.items[itemId].cls; var itemCls = core.material.items[itemId].cls;
// 消耗品 // 消耗品
if (itemCls === 'items') { 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; var curr_hp = core.status.hero.hp;
if (itemId in this.itemEffect)eval(this.itemEffect[itemId]); if (itemId in this.itemEffect)eval(this.itemEffect[itemId]);
core.status.hero.statistics.hp += core.status.hero.hp - curr_hp; 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; var itemCls = core.material.items[itemId].cls;
// 消耗品 // 消耗品
if (itemCls === 'items') { 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])||""; if (itemId in this.itemEffectTip) return eval(this.itemEffectTip[itemId])||"";
} }
return ""; return "";

View File

@ -10,12 +10,18 @@ maps.prototype.init = function() {
////// 加载某个楼层(从剧本或存档中) ////// ////// 加载某个楼层(从剧本或存档中) //////
maps.prototype.loadFloor = function (floorId, map) { maps.prototype.loadFloor = function (floorId, map) {
var floor = core.floors[floorId]; var floor = core.floors[floorId];
if (!core.isset(map)) map = floor.map;
if (map instanceof Array) {
map = {"map": map};
}
var content = {}; var content = {};
content['floorId'] = floor.floorId; ["floorId", "title", "name", "canFlyTo", "canUseQuickShop", "cannotViewMap",
content['name'] = floor.name; "defaultGround", "images", "item_ratio", "upFloor", "bgm", "downFloor"].forEach(function (e) {
content['title'] = floor.title; if (core.isset(map) && core.isset(map[e])) content[e] = core.clone(map[e]);
content['canFlyTo'] = floor.canFlyTo; else content[e] = core.clone(floor[e]);
if (!core.isset(map)) map=floor.map; });
map=map.map;
var mapIntoBlocks = function(map,maps,floor,floorId){ var mapIntoBlocks = function(map,maps,floor,floorId){
var blocks = []; var blocks = [];
var mw = core.floors[floorId].width || 13; var mw = core.floors[floorId].width || 13;
@ -168,7 +174,7 @@ maps.prototype.save = function(maps, floorId) {
return map; return map;
} }
var thisFloor = maps[floorId]; var thisFloor = core.clone(maps[floorId]);
var mw = core.floors[floorId].width || 13; var mw = core.floors[floorId].width || 13;
var mh = core.floors[floorId].height || 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; 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 width = core.floors[floorId].width || 13;
var height = core.floors[floorId].height || 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 blockIcon = core.material.icons.terrains[groundId];
var blockImage = core.material.images.terrains; var blockImage = core.material.images.terrains;
@ -442,8 +450,8 @@ maps.prototype.drawMap = function (mapName, callback) {
core.maps.drawBgFgMap(mapName, core.canvas.fg, "fg"); core.maps.drawBgFgMap(mapName, core.canvas.fg, "fg");
var images = []; var images = [];
if (core.isset(core.floors[mapName].images)) { if (core.isset(core.status.maps[mapName].images)) {
images = core.floors[mapName].images; images = core.status.maps[mapName].images;
if (typeof images == 'string') { if (typeof images == 'string') {
images = [[0, 0, images]]; images = [[0, 0, images]];
} }

View File

@ -1628,7 +1628,7 @@ ui.prototype.drawMaps = function (index, x, y) {
core.setFont('data', '16px Arial'); 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)+"]"; 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; var textX = 16, textY = 18, width = textX + core.canvas.data.measureText(text).width + 16, height = 42;
core.fillRect('data', 5, 5, width, height, '#000'); 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 // background image
var images = []; var images = [];
if (core.isset(core.floors[floorId].images)) { if (core.isset((core.status.maps||core.floors)[floorId].images)) {
images = core.floors[floorId].images; images = (core.status.maps||core.floors)[floorId].images;
if (typeof images == 'string') { if (typeof images == 'string') {
images = [[0, 0, images]]; images = [[0, 0, images]];
} }
@ -2203,7 +2203,7 @@ ui.prototype.drawStatistics = function () {
var current = core.clone(total); var current = core.clone(total);
core.floorIds.forEach(function (floorId) { core.floorIds.forEach(function (floorId) {
var floor=core.floors[floorId]; var floor=core.status.maps[floorId];
var blocks=core.status.maps[floorId].blocks; var blocks=core.status.maps[floorId].blocks;
// 隐藏层不给看 // 隐藏层不给看
if (floor.cannotViewMap && floorId!=core.status.floorId) return; if (floor.cannotViewMap && floorId!=core.status.floorId) return;

View File

@ -345,7 +345,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
// 返回null代表可以使用 // 返回null代表可以使用
// 检查当前楼层的canUseQuickShop选项是否为false // 检查当前楼层的canUseQuickShop选项是否为false
if (core.floors[core.status.floorId].canUseQuickShop === false) if (core.status.thisMap.canUseQuickShop === false)
return '当前楼层不能使用快捷商店。'; return '当前楼层不能使用快捷商店。';
return null; return null;
@ -574,8 +574,8 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
var fromId = core.status.floorId; var fromId = core.status.floorId;
// 检查能否飞行 // 检查能否飞行
if (!core.floors[fromId].canFlyTo || !core.floors[toId].canFlyTo) { if (!core.status.maps[fromId].canFlyTo || !core.status.maps[toId].canFlyTo) {
core.drawTip("无法飞往" + core.floors[toId].title +""); core.drawTip("无法飞往" + core.status.maps[toId].title +"");
return false; return false;
} }
@ -583,7 +583,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
var fromIndex = core.floorIds.indexOf(fromId), toIndex = core.floorIds.indexOf(toId); var fromIndex = core.floorIds.indexOf(fromId), toIndex = core.floorIds.indexOf(toId);
var stair = fromIndex<=toIndex?"downFloor":"upFloor"; 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); core.status.route.push("fly:"+toId);
// 传送 // 传送