feat:图块通行性计入存档
This commit is contained in:
parent
656e35bb84
commit
cdb26566c8
56
libs/maps.js
56
libs/maps.js
@ -11,6 +11,19 @@ maps.prototype._init = function () {
|
||||
//delete(maps_90f36752_8815_4be8_b32b_d7fad1d0542e);
|
||||
}
|
||||
|
||||
maps.prototype.getBlocksInfo = function () {
|
||||
let blocksInfo = core.clone(maps_90f36752_8815_4be8_b32b_d7fad1d0542e);
|
||||
const blocksInfo_flag = core.getFlag('blocksInfo', {});
|
||||
for (let i in blocksInfo_flag) {
|
||||
if (blocksInfo.hasOwnProperty(i)) {
|
||||
for (let j in blocksInfo_flag[i]) {
|
||||
blocksInfo[i][j] = blocksInfo_flag[i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
return blocksInfo;
|
||||
}
|
||||
|
||||
maps.prototype._initFloors = function (floorId) {
|
||||
if (!floorId) {
|
||||
core.floorIds.forEach(function (floorId) {
|
||||
@ -2483,6 +2496,49 @@ maps.prototype.setBgFgBlock = function (name, number, x, y, floorId) {
|
||||
}
|
||||
}
|
||||
|
||||
////// 改变事件层图块的连通性 //////
|
||||
maps.prototype.setBlockConnectivity = function (num, statusName, statusValue) {
|
||||
if (typeof num === 'string') num = this.getNumberById(num);
|
||||
if (!core.maps.blocksInfo.hasOwnProperty(num)) return;
|
||||
|
||||
const floorIds = core.floorIds,
|
||||
maps = core.status.maps,
|
||||
mapBlockObjs = core.status.mapBlockObjs,
|
||||
blocksInfo = core.maps.blocksInfo,
|
||||
number2Block = core.status.number2Block;
|
||||
core.maps.blocksInfo = core.clone(maps_90f36752_8815_4be8_b32b_d7fad1d0542e);
|
||||
if (statusName === 'noPass') {
|
||||
floorIds.forEach((floorId) => {
|
||||
if (maps.hasOwnProperty(floorId)) {
|
||||
Object.values(maps[floorId].blocks).forEach(
|
||||
(block) => {
|
||||
if (block.id === num) block.event[statusName] = statusValue;
|
||||
});
|
||||
}
|
||||
if (mapBlockObjs.hasOwnProperty(floorId)) {
|
||||
Object.values(mapBlockObjs[floorId]).forEach(
|
||||
(block) => {
|
||||
if (block.id === num) block.event[statusName] = statusValue;
|
||||
});
|
||||
}
|
||||
});
|
||||
blocksInfo[num]['canPass'] = !statusValue;
|
||||
const blocksInfo_flag = core.getFlag('blocksInfo', {});
|
||||
if (!blocksInfo_flag.hasOwnProperty(num)) blocksInfo_flag[num] = {};
|
||||
blocksInfo_flag[num]['canPass'] = !statusValue;
|
||||
core.setFlag('blocksInfo', blocksInfo_flag);
|
||||
}
|
||||
else if (['cannotOut', 'cannotIn'].includes(statusName)) {
|
||||
if (number2Block) number2Block[num]['event'][statusName] = statusValue;
|
||||
blocksInfo[num][statusName] = statusValue;
|
||||
const blocksInfo_flag = core.getFlag('blocksInfo', {});
|
||||
if (!blocksInfo_flag.hasOwnProperty(num)) blocksInfo_flag[num] = {};
|
||||
blocksInfo_flag[num][statusName] = statusValue;
|
||||
core.setFlag('blocksInfo', blocksInfo_flag);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////// 重置地图 //////
|
||||
maps.prototype.resetMap = function (floorId) {
|
||||
floorId = floorId || core.status.floorId;
|
||||
|
||||
20
mynote.md
Normal file
20
mynote.md
Normal file
@ -0,0 +1,20 @@
|
||||
tileset只有noPass属性。设置noPass为false的瞬间就会写入project/maps.js
|
||||
其它情况只要不是items就不可过。
|
||||
写入可通行性对tileset只用写canPass就好
|
||||
读档:```core.utils.decompress(core.saves.cache['template_save3'] );```
|
||||
解码录像 core.decodeRoute(a.route);
|
||||
|
||||
可通行性,关键在getBlockByNumber函数。它从core.status.number2Block中获取信息。而number2Block不存在该属性时会initBlock
|
||||
initBlock从blocksInfo中读
|
||||
|
||||
改变canPass后:(模仿setBlock)
|
||||
originBlock = core.getBlock(x, y, floorId, true);获取originBlock
|
||||
core.status.maps[floorId].blocks全要改
|
||||
core.status.mapBlockObjs全要改
|
||||
|
||||
enemyInfo进存档的手法非常简单粗暴 就是存了个变量
|
||||
|
||||
extractBlocks->_mapIntoBlocks->initBlock
|
||||
|
||||
cannotOut和cannotIn的关键
|
||||
箭头还在getBlockByNumber中
|
||||
1111
project/functions.js
1111
project/functions.js
File diff suppressed because it is too large
Load Diff
25
runtime.d.ts
vendored
25
runtime.d.ts
vendored
@ -1549,6 +1549,21 @@ interface enemys {
|
||||
/** @file maps.js负责一切和地图相关的处理内容 */
|
||||
interface maps {
|
||||
|
||||
/**
|
||||
* 获取初始core.maps.blockInfo的一个拷贝
|
||||
*/
|
||||
getBlocksInfo(): {
|
||||
[x: string]: {
|
||||
cls: string
|
||||
id: string
|
||||
name: string
|
||||
cannotIn: string[]
|
||||
cannotOut: string[]
|
||||
canPass: boolean
|
||||
[x: string]: any
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据图块id得到数字(地图矩阵中的值)
|
||||
* @example core.getNumberById('yellowWall'); // 1
|
||||
@ -1832,6 +1847,16 @@ interface maps {
|
||||
*/
|
||||
setBgFgBlock(name: 'bg' | 'fg', number: number | string, x: number, y: number, floorId?: string): void
|
||||
|
||||
/**
|
||||
* 改变事件层图块的连通性
|
||||
* @example core.setBlockConnectivity(165, 'noPass', true);
|
||||
* @example core.setBlockConnectivity(162, 'cannotIn', ['left', 'right']);
|
||||
* @param num 图层的数字或id
|
||||
* @param statusName 要修改的图块属性的名称
|
||||
* @param statusValue 要修改到的值
|
||||
*/
|
||||
setBlockConnectivity(num: number | string, statusName: 'noPass' | 'cannotIn' | 'cannotOut', statusValue: unknown): void
|
||||
|
||||
/**
|
||||
* 移动图块
|
||||
* @example core.moveBlock(0, 0, ['down']); // 令地图左上角的图块下移一格,用时半秒,再花半秒淡出
|
||||
|
||||
Loading…
Reference in New Issue
Block a user