Merge pull request #501 from ckcz123/v2.x-bigmap

V2.x bigmap
This commit is contained in:
Zhang Chen 2020-07-04 20:19:23 +08:00 committed by GitHub
commit f13e20a992
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 1047 additions and 798 deletions

View File

@ -1222,13 +1222,16 @@ nearStair: fn() -> bool
turnBlock: fn(direction?: string, x?: number, y?: number, floorId?: string) turnBlock: fn(direction?: string, x?: number, y?: number, floorId?: string)
事件转向 事件转向
getMapArray: fn(floorId?: string) -> [[number]] getMapArray: fn(floorId?: string, noCache?: bool) -> [[number]]
生成事件层矩阵 生成事件层矩阵
例如core.getMapArray('MT0'); // 生成主塔0层的事件层矩阵隐藏的图块视为0 例如core.getMapArray('MT0'); // 生成主塔0层的事件层矩阵隐藏的图块视为0
floorId: 地图id不填视为当前地图 floorId: 地图id不填视为当前地图
showDisable: 可选true表示隐藏的图块也会被表示出来 showDisable: 可选true表示隐藏的图块也会被表示出来
返回值:事件层矩阵,注意对其阵元的访问是[y][x] 返回值:事件层矩阵,注意对其阵元的访问是[y][x]
getMapNumber: fn(x: number, y: number, floorId?: string, noCache?: bool) -> number
获得事件层某个点的数字
jumpBlock: fn(sx: number, sy: number, ex: number, ey: number, time?: number, keep?: bool, callback?: fn()) jumpBlock: fn(sx: number, sy: number, ex: number, ey: number, time?: number, keep?: bool, callback?: fn())
跳跃图块从V2.7开始不再有音效 跳跃图块从V2.7开始不再有音效
例如core.jumpBlock(0, 0, 0, 0); // 令地图左上角的图块原地跳跃半秒,再花半秒淡出 例如core.jumpBlock(0, 0, 0, 0); // 令地图左上角的图块原地跳跃半秒,再花半秒淡出
@ -1358,9 +1361,12 @@ canMoveDirectlyArray: fn(locs?: [[number]])
hideFloorImage: fn(loc?: [number]|[[number]], floorId?: string, callback?: fn()) hideFloorImage: fn(loc?: [number]|[[number]], floorId?: string, callback?: fn())
隐藏一个楼层贴图 隐藏一个楼层贴图
extractBlocks: fn(map?: [[number]], flags?: flags) extractBlocks: fn(map?: ?)
根据需求解析出blocks 根据需求解析出blocks
extractBlocksForUI: fn(map?: ?, flags?: flags)
根据需求为UI解析出blocks
getBlockId: fn(x: number, y: number, floorId?: string, showDisable?: bool) -> string getBlockId: fn(x: number, y: number, floorId?: string, showDisable?: bool) -> string
判定某个点的图块id 判定某个点的图块id
例如if(core.getBlockId(x1, y1) != 'greenSlime' && core.getBlockId(x2, y2) != 'redSlime') core.openDoor(x3, y3); // 一个简单的机关门事件,打败或炸掉这一对绿头怪和红头怪就开门 例如if(core.getBlockId(x1, y1) != 'greenSlime' && core.getBlockId(x2, y2) != 'redSlime') core.openDoor(x3, y3); // 一个简单的机关门事件,打败或炸掉这一对绿头怪和红头怪就开门
@ -1370,17 +1376,22 @@ floorId: 地图id不填视为当前地图
showDisable: 隐藏点是否不返回nulltrue表示不返回null showDisable: 隐藏点是否不返回nulltrue表示不返回null
返回值图块id该点无图块则返回null 返回值图块id该点无图块则返回null
getBlockNumber: fn(x: number, y: number, floorId?: string, showDisable?: bool) -> number
判定某个点的图块数字
x: 横坐标
y: 纵坐标
floorId: 地图id不填视为当前地图
showDisable: 隐藏点是否不返回nulltrue表示不返回null
返回值图块数字该点无图块则返回null
loadFloor: fn(floorId?: string, map?: ?) loadFloor: fn(floorId?: string, map?: ?)
从文件或存档中加载某个楼层 从文件或存档中加载某个楼层
generateMovableArray: fn(floorId?: string, x?: number, y?: number, direction?: string) generateMovableArray: fn(floorId?: string)
可通行性判定 可通行性判定
例如core.generateMovableArray(); // 判断当前地图主角从各点能向何方向移动 例如core.generateMovableArray(); // 判断当前地图主角从各点能向何方向移动
floorId: 地图id不填视为当前地图 floorId: 地图id不填视为当前地图
x: 起点横坐标,不填视为挨个判定 返回值:从各点可移动方向的三维数组
y: 起点纵坐标,不填视为挨个判定
direction: 可选,必须和坐标一起使用。填写后将只检查是否可向该方向移动并返回布尔值
返回值:不设置坐标时为从各点可移动方向的三维数组,设置坐标但不设置方向时为该点可移动方向的一维数组,都设置时为布尔值
terrainExists: fn(x: number, y: number, id?: string, floorId?: string) -> bool terrainExists: fn(x: number, y: number, id?: string, floorId?: string) -> bool
某个点是否存在(指定的)地形 某个点是否存在(指定的)地形
@ -1401,7 +1412,7 @@ x: 横坐标
y: 纵坐标 y: 纵坐标
floorId: 地图id不填视为当前地图 floorId: 地图id不填视为当前地图
getMapBlocksObj: fn(floorId?: string, showDisable?: bool) getMapBlocksObj: fn(floorId?: string, noCache?: bool)
以x,y的形式返回每个点的事件 以x,y的形式返回每个点的事件
removeGlobalAnimate: fn(x?: number, y?: number, name?: string) removeGlobalAnimate: fn(x?: number, y?: number, name?: string)
@ -1442,10 +1453,10 @@ drawFg: fn(floorId?: string, ctx?: CanvasRenderingContext2D)
floorId: 地图id不填视为当前地图 floorId: 地图id不填视为当前地图
ctx: 某画布的ctx用于绘制缩略图一般不需要 ctx: 某画布的ctx用于绘制缩略图一般不需要
getBlock: fn(x: number, y: number, floorId?: string, showDisable?: bool) -> {index: number, block: block} getBlock: fn(x: number, y: number, floorId?: string, showDisable?: bool) -> block: block
获得某个点的block 获得某个点的block
initBlock: fn(x: number, y: number, id: string|number, addInfo?: bool, eventFloor?: ?, flags?: ?) -> block initBlock: fn(x: number, y: number, id: string|number, addInfo?: bool, eventFloor?: ?) -> block
初始化一个图块 初始化一个图块
addGlobalAnimate: fn(block?: block) addGlobalAnimate: fn(block?: block)
@ -1486,13 +1497,12 @@ y: 起点纵坐标,不填视为主角当前的
direction: 移动的方向,不填视为主角面对的方向 direction: 移动的方向,不填视为主角面对的方向
floorId: 地图id不填视为当前地图 floorId: 地图id不填视为当前地图
drawThumbnail: fn(floorId?: string, blocks?: [block], options?: ?, toDraw?: string|CanvasRenderingContext2D|?) drawThumbnail: fn(floorId?: string, blocks?: [block], options?: ?)
绘制缩略图 绘制缩略图
例如core.drawThumbnail(); // 绘制当前地图的缩略图 例如core.drawThumbnail(); // 绘制当前地图的缩略图
floorId: 地图id不填视为当前地图 floorId: 地图id不填视为当前地图
blocks: 一般不需要 blocks: 一般不需要
options: 额外的绘制项可选。可以增绘主角位置和朝向、采用不同于游戏中的主角行走图、增绘显伤、提供flags用于存读档 options: 额外的绘制项可选。可以增绘主角位置和朝向、采用不同于游戏中的主角行走图、增绘显伤、提供flags用于存读档
toDraw: 要绘制到的画布名或画布的ctx或还有其他信息如起绘坐标、绘制大小、是否绘制全图、截取中心
hideBlockByIndex: fn(index?: number, floorId?: string) hideBlockByIndex: fn(index?: number, floorId?: string)
根据图块的索引来隐藏图块 根据图块的索引来隐藏图块
@ -1846,6 +1856,10 @@ filter: 过滤器可选表示data为数组或对象时拷贝哪些项或
recursion: 过滤器是否递归可选。true表示过滤器也被递归 recursion: 过滤器是否递归可选。true表示过滤器也被递归
返回值:拷贝的结果,注意函数将原样返回 返回值:拷贝的结果,注意函数将原样返回
cloneArray: fn(data?: [number]|[[number]]) -> [number]|[[number]]
深拷贝一个1D或2D数组对象
例如core.cloneArray(core.status.thisMap.map)
setLocalForage: fn(key: string, value?: ?, successCallback?: fn(), errorCallback?: fn()) setLocalForage: fn(key: string, value?: ?, successCallback?: fn(), errorCallback?: fn())
往数据库写入一段数据 往数据库写入一段数据

View File

@ -260,9 +260,9 @@ this.statusBar = {
6. 显示内容的设置。在脚本编辑的updateStatusBar函数可以对该状态栏显示内容进行设置下面是几个例子。 6. 显示内容的设置。在脚本编辑的updateStatusBar函数可以对该状态栏显示内容进行设置下面是几个例子。
``` js ``` js
// 设置其显示内容为status:speed值需要在project/data.js中firstData的hero那里新增初始值`"speed": 0`。 // 设置其显示内容为status:speed值需要在project/data.js中firstData的hero那里新增初始值`"speed": 0`。
core.statusBar.speed.innerHTML = core.getStatus('speed'); core.setStatusBarInnerHTML('speed', core.getStatus('speed'));
// 设置其显示内容为flag:speed值无需额外进行定义。 // 设置其显示内容为flag:speed值无需额外进行定义。
core.statusBar.speed.innerHTML = core.getFlag('speed', 0); core.setStatusBarInnerHTML('speed', core.getFlag('speed', 0));
``` ```
总的来说不建议这样做,因为 `main.js``html` 文件不在 `project` 文件夹,会导致随样板更新迁移接档变得困难。 总的来说不建议这样做,因为 `main.js``html` 文件不在 `project` 文件夹,会导致随样板更新迁移接档变得困难。
@ -302,7 +302,7 @@ else {
} }
// 设置技能栏 // 设置技能栏
// 可以用flag:skill表示当前开启的技能类型flag:skillName显示技能名 // 可以用flag:skill表示当前开启的技能类型flag:skillName显示技能名
core.statusBar.skill.innerHTML = core.getFlag('skillName', '无'); core.setStatusBarInnerHTML('skill', core.getFlag('skillName', '无'));
``` ```
### 技能的触发 ### 技能的触发

View File

@ -313,9 +313,9 @@ core.events.openShop = function (shopId, needVisited) {
```js ```js
var drawMap = core.maps.drawMap; // 先把原始函数用一个变量记录下来 var drawMap = core.maps.drawMap; // 先把原始函数用一个变量记录下来
core.maps.drawMap = function (floorId, callback) { core.maps.drawMap = function (floorId) {
console.log("drawMap..."); // 控制台打出一条信息 console.log("drawMap..."); // 控制台打出一条信息
return drawMap.call(core.maps, floorId, callback); // 需要使用`call`来告知this是core.maps return drawMap.call(core.maps, floorId); // 需要使用`call`来告知this是core.maps
} }
``` ```

View File

@ -1867,6 +1867,30 @@ var terndefs_f6783a0a_522d_417e_8407_94c67b692e50 = [
"!type": "number", "!type": "number",
"!doc": "大地图视角纵向偏移量" "!doc": "大地图视角纵向偏移量"
}, },
"posX": {
"!type": "number",
"!doc": "大地图视角横向基准格"
},
"posY": {
"!type": "number",
"!doc": "大地图视角纵向基准格"
},
"v2": {
"!type": "bool",
"!doc": "是否是新版大地图绘制方式"
},
"threshold": {
"!type": "number",
"!doc": "新版大地图绘制方式的分界线"
},
"extend": {
"!type": "number",
"!doc": "新版大地图模式下向每一侧额外计算的数量"
},
"scale": {
"!type": "number",
"!doc": "缩略图的比例放缩"
},
"tempCanvas": { "tempCanvas": {
"!type": "CanvasRenderingContext2D", "!type": "CanvasRenderingContext2D",
"!doc": "临时画布" "!doc": "临时画布"
@ -1908,6 +1932,9 @@ var terndefs_f6783a0a_522d_417e_8407_94c67b692e50 = [
"fgmaps": { "fgmaps": {
"!doc": "各地图前景层" "!doc": "各地图前景层"
}, },
"mapBlockObjs": {
"!doc": "以<位置,block>存放的各地图图块信息"
},
"boxAnimateObjs": { "boxAnimateObjs": {
"!doc": "(手册和剧情文本的)帧动画对象" "!doc": "(手册和剧情文本的)帧动画对象"
}, },
@ -1933,6 +1960,9 @@ var terndefs_f6783a0a_522d_417e_8407_94c67b692e50 = [
"!doc": "每个点的光环缓存" "!doc": "每个点的光环缓存"
}, },
}, },
"damage": {
"!doc": "每个点的显伤信息",
},
"ctrlDown": { "ctrlDown": {
"!type": "bool", "!type": "bool",
"!doc": "Ctrl键是否被按下" "!doc": "Ctrl键是否被按下"
@ -2111,9 +2141,13 @@ var terndefs_f6783a0a_522d_417e_8407_94c67b692e50 = [
"!type": "fn(color?: [number], time?: number, callback?: fn())" "!type": "fn(color?: [number], time?: number, callback?: fn())"
}, },
"updateDamage": { "updateDamage": {
"!doc": "更新地图显伤<br/>例如core.updateDamage(); // 更新当前地图的显伤,绘制在显伤层(废话)<br/>floorId: 地图id不填视为当前地图。预览地图时填写<br/>ctx: 绘制到的画布,如果填写了就会画在该画布而不是显伤层", "!doc": "重算并绘制地图显伤<br/>例如core.updateDamage(); // 更新当前地图的显伤,绘制在显伤层(废话)<br/>floorId: 地图id不填视为当前地图。预览地图时填写<br/>ctx: 绘制到的画布,如果填写了就会画在该画布而不是显伤层",
"!type": "fn(floorId?: string, ctx?: string|CanvasRenderingContext2D)" "!type": "fn(floorId?: string, ctx?: string|CanvasRenderingContext2D)"
}, },
"drawDamage": {
"!doc": "仅绘制地图显伤",
"!type": "fn(string|CanvasRenderingContext2D)"
},
"nextX": { "nextX": {
"!doc": "获取主角面前第n格的横坐标<br/>例如core.closeDoor(core.nextX(), core.nextY(), 'yellowDoor', core.turnHero); // 在主角面前关上一扇黄门然后主角顺时针旋转90°<br/>n: 目标格与主角的距离面前为正数背后为负数脚下为0不填视为1", "!doc": "获取主角面前第n格的横坐标<br/>例如core.closeDoor(core.nextX(), core.nextY(), 'yellowDoor', core.turnHero); // 在主角面前关上一扇黄门然后主角顺时针旋转90°<br/>n: 目标格与主角的距离面前为正数背后为负数脚下为0不填视为1",
"!type": "fn(n?: number) -> number" "!type": "fn(n?: number) -> number"
@ -2694,6 +2728,10 @@ var terndefs_f6783a0a_522d_417e_8407_94c67b692e50 = [
"!doc": "深拷贝一个对象(函数将原样返回)<br/>例如core.clone(core.status.hero, (name, value) => (name == 'items' || typeof value == 'number'), false); // 深拷贝主角的属性和道具<br/>data: 待拷贝对象<br/>filter: 过滤器可选表示data为数组或对象时拷贝哪些项或属性true表示拷贝<br/>recursion: 过滤器是否递归可选。true表示过滤器也被递归<br/>返回值:拷贝的结果,注意函数将原样返回", "!doc": "深拷贝一个对象(函数将原样返回)<br/>例如core.clone(core.status.hero, (name, value) => (name == 'items' || typeof value == 'number'), false); // 深拷贝主角的属性和道具<br/>data: 待拷贝对象<br/>filter: 过滤器可选表示data为数组或对象时拷贝哪些项或属性true表示拷贝<br/>recursion: 过滤器是否递归可选。true表示过滤器也被递归<br/>返回值:拷贝的结果,注意函数将原样返回",
"!type": "fn(data?: ?, filter?: fn(name: string, value: ?) -> bool, recursion?: bool)" "!type": "fn(data?: ?, filter?: fn(name: string, value: ?) -> bool, recursion?: bool)"
}, },
"cloneArray": {
"!doc": "深拷贝一个1D或2D数组对象<br/>例如core.cloneArray(core.status.thisMap.map)",
"!type": "fn(data?: [number]|[[number]]) -> [number]|[[number]]"
},
"setLocalForage": { "setLocalForage": {
"!doc": "往数据库写入一段数据", "!doc": "往数据库写入一段数据",
"!type": "fn(key: string, value?: ?, successCallback?: fn(), errorCallback?: fn())" "!type": "fn(key: string, value?: ?, successCallback?: fn(), errorCallback?: fn())"
@ -3025,8 +3063,12 @@ var terndefs_f6783a0a_522d_417e_8407_94c67b692e50 = [
}, },
"getMapArray": { "getMapArray": {
"!doc": "生成事件层矩阵<br/>例如core.getMapArray('MT0'); // 生成主塔0层的事件层矩阵隐藏的图块视为0<br/>floorId: 地图id不填视为当前地图<br/>showDisable: 可选true表示隐藏的图块也会被表示出来<br/>返回值:事件层矩阵,注意对其阵元的访问是[y][x]", "!doc": "生成事件层矩阵<br/>例如core.getMapArray('MT0'); // 生成主塔0层的事件层矩阵隐藏的图块视为0<br/>floorId: 地图id不填视为当前地图<br/>showDisable: 可选true表示隐藏的图块也会被表示出来<br/>返回值:事件层矩阵,注意对其阵元的访问是[y][x]",
"!type": "fn(floorId?: string) -> [[number]]" "!type": "fn(floorId?: string, noCache?: bool) -> [[number]]"
}, },
"getMapNumber": {
"!doc": "获得事件层某个点的数字",
"!type": "fn(x: number, y: number, floorId?: string, noCache?: bool) -> number"
},
"jumpBlock": { "jumpBlock": {
"!doc": "跳跃图块从V2.7开始不再有音效<br/>例如core.jumpBlock(0, 0, 0, 0); // 令地图左上角的图块原地跳跃半秒,再花半秒淡出<br/>sx: 起点的横坐标<br/>sy: 起点的纵坐标<br/>ex: 终点的横坐标<br/>ey: 终点的纵坐标<br/>time: 单步和淡出用时,单位为毫秒。不填视为半秒<br/>keep: 是否不淡出true表示不淡出<br/>callback: 落地或淡出后的回调函数,可选", "!doc": "跳跃图块从V2.7开始不再有音效<br/>例如core.jumpBlock(0, 0, 0, 0); // 令地图左上角的图块原地跳跃半秒,再花半秒淡出<br/>sx: 起点的横坐标<br/>sy: 起点的纵坐标<br/>ex: 终点的横坐标<br/>ey: 终点的纵坐标<br/>time: 单步和淡出用时,单位为毫秒。不填视为半秒<br/>keep: 是否不淡出true表示不淡出<br/>callback: 落地或淡出后的回调函数,可选",
"!type": "fn(sx: number, sy: number, ex: number, ey: number, time?: number, keep?: bool, callback?: fn())" "!type": "fn(sx: number, sy: number, ex: number, ey: number, time?: number, keep?: bool, callback?: fn())"
@ -3141,19 +3183,27 @@ var terndefs_f6783a0a_522d_417e_8407_94c67b692e50 = [
}, },
"extractBlocks": { "extractBlocks": {
"!doc": "根据需求解析出blocks", "!doc": "根据需求解析出blocks",
"!type": "fn(map?: [[number]], flags?: flags)" "!type": "fn(map?: ?)"
},
"extractBlocksForUI": {
"!doc": "根据需求为UI解析出blocks",
"!type": "fn(map?: ?, flags?: ?)"
}, },
"getBlockId": { "getBlockId": {
"!doc": "判定某个点的图块id<br/>例如if(core.getBlockId(x1, y1) != 'greenSlime' && core.getBlockId(x2, y2) != 'redSlime') core.openDoor(x3, y3); // 一个简单的机关门事件,打败或炸掉这一对绿头怪和红头怪就开门<br/>x: 横坐标<br/>y: 纵坐标<br/>floorId: 地图id不填视为当前地图<br/>showDisable: 隐藏点是否不返回nulltrue表示不返回null<br/>返回值图块id该点无图块则返回null", "!doc": "判定某个点的图块id<br/>例如if(core.getBlockId(x1, y1) != 'greenSlime' && core.getBlockId(x2, y2) != 'redSlime') core.openDoor(x3, y3); // 一个简单的机关门事件,打败或炸掉这一对绿头怪和红头怪就开门<br/>x: 横坐标<br/>y: 纵坐标<br/>floorId: 地图id不填视为当前地图<br/>showDisable: 隐藏点是否不返回nulltrue表示不返回null<br/>返回值图块id该点无图块则返回null",
"!type": "fn(x: number, y: number, floorId?: string, showDisable?: bool) -> string" "!type": "fn(x: number, y: number, floorId?: string, showDisable?: bool) -> string"
}, },
"getBlockNumber": {
"!doc": "判定某个点的图块数字<br/>x: 横坐标<br/>y: 纵坐标<br/>floorId: 地图id不填视为当前地图<br/>showDisable: 隐藏点是否不返回nulltrue表示不返回null<br/>返回值图块数字该点无图块则返回null",
"!type": "fn(x: number, y: number, floorId?: string, showDisable?: bool) -> number"
},
"loadFloor": { "loadFloor": {
"!doc": "从文件或存档中加载某个楼层", "!doc": "从文件或存档中加载某个楼层",
"!type": "fn(floorId?: string, map?: ?)" "!type": "fn(floorId?: string, map?: ?)"
}, },
"generateMovableArray": { "generateMovableArray": {
"!doc": "可通行性判定<br/>例如core.generateMovableArray(); // 判断当前地图主角从各点能向何方向移动<br/>floorId: 地图id不填视为当前地图<br/>x: 起点横坐标,不填视为挨个判定<br/>y: 起点纵坐标,不填视为挨个判定<br/>direction: 可选,必须和坐标一起使用。填写后将只检查是否可向该方向移动并返回布尔值<br/>返回值:不设置坐标时为从各点可移动方向的三维数组,设置坐标但不设置方向时为该点可移动方向的一维数组,都设置时为布尔值", "!doc": "可通行性判定<br/>例如core.generateMovableArray(); // 判断当前地图主角从各点能向何方向移动<br/>floorId: 地图id不填视为当前地图<br/>返回值:从各点可移动方向的三维数组",
"!type": "fn(floorId?: string, x?: number, y?: number, direction?: string)" "!type": "fn(floorId?: string) -> [[[string]]]"
}, },
"terrainExists": { "terrainExists": {
"!doc": "某个点是否存在(指定的)地形", "!doc": "某个点是否存在(指定的)地形",
@ -3173,7 +3223,7 @@ var terndefs_f6783a0a_522d_417e_8407_94c67b692e50 = [
}, },
"getMapBlocksObj": { "getMapBlocksObj": {
"!doc": "以x,y的形式返回每个点的事件", "!doc": "以x,y的形式返回每个点的事件",
"!type": "fn(floorId?: string, showDisable?: bool)" "!type": "fn(floorId?: string, noCache?: bool)"
}, },
"removeGlobalAnimate": { "removeGlobalAnimate": {
"!doc": "删除一个或所有全局动画", "!doc": "删除一个或所有全局动画",
@ -3205,11 +3255,11 @@ var terndefs_f6783a0a_522d_417e_8407_94c67b692e50 = [
}, },
"getBlock": { "getBlock": {
"!doc": "获得某个点的block", "!doc": "获得某个点的block",
"!type": "fn(x: number, y: number, floorId?: string, showDisable?: bool) -> {index: number, block: block}" "!type": "fn(x: number, y: number, floorId?: string, showDisable?: bool) -> block"
}, },
"initBlock": { "initBlock": {
"!doc": "初始化一个图块", "!doc": "初始化一个图块",
"!type": "fn(x: number, y: number, id: string|number, addInfo?: bool, eventFloor?: ?, flags?: ?) -> block" "!type": "fn(x: number, y: number, id: string|number, addInfo?: bool, eventFloor?: ?) -> block"
}, },
"addGlobalAnimate": { "addGlobalAnimate": {
"!doc": "添加一个全局动画", "!doc": "添加一个全局动画",
@ -3240,8 +3290,8 @@ var terndefs_f6783a0a_522d_417e_8407_94c67b692e50 = [
"!type": "fn(x?: number, y?: number, direction?: string, floorId?: string) -> bool" "!type": "fn(x?: number, y?: number, direction?: string, floorId?: string) -> bool"
}, },
"drawThumbnail": { "drawThumbnail": {
"!doc": "绘制缩略图<br/>例如core.drawThumbnail(); // 绘制当前地图的缩略图<br/>floorId: 地图id不填视为当前地图<br/>blocks: 一般不需要<br/>options: 额外的绘制项可选。可以增绘主角位置和朝向、采用不同于游戏中的主角行走图、增绘显伤、提供flags用于存读档<br/>toDraw: 要绘制到的画布名或画布的ctx或还有其他信息如起绘坐标、绘制大小、是否绘制全图、截取中心", "!doc": "绘制缩略图<br/>例如core.drawThumbnail(); // 绘制当前地图的缩略图<br/>floorId: 地图id不填视为当前地图<br/>blocks: 一般不需要<br/>options: 绘制信息可选。可以增绘主角位置和朝向、采用不同于游戏中的主角行走图、增绘显伤、提供flags用于存读档,同时包含要绘制到的画布名或画布的ctx或还有其他信息如起绘坐标、绘制大小、是否绘制全图、截取中心",
"!type": "fn(floorId?: string, blocks?: [block], options?: ?, toDraw?: string|CanvasRenderingContext2D|?)" "!type": "fn(floorId?: string, blocks?: [block], options?: ?)"
}, },
"hideBlockByIndex": { "hideBlockByIndex": {
"!doc": "根据图块的索引来隐藏图块", "!doc": "根据图块的索引来隐藏图块",

View File

@ -1 +1 @@
{"lastUsed":[],"foldPerCol":50,"folded":false,"editorLastFloorId":"sample0","disableBlocklyReplace":false,"disableBlocklyExpandCompare":false,"shortcut":{"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0}} {"lastUsed":[],"foldPerCol":50,"folded":false,"editorLastFloorId":"sample0","disableBlocklyReplace":false,"disableBlocklyExpandCompare":false,"shortcut":{"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0},"viewportLoc":[0,0]}

View File

@ -223,13 +223,17 @@ editor.prototype.init = function (callback) {
for (var one in canvases) { for (var one in canvases) {
canvases[one].width = canvases[one].height = core.__PIXELS__; canvases[one].width = canvases[one].height = core.__PIXELS__;
} }
core.resetGame(core.firstData.hero, null, core.firstData.floorId, core.cloneArray(core.initStatus.maps));
var floorId = editor.config.get('editorLastFloorId', core.status.floorId);
if (core.floorIds.indexOf(floorId) < 0) floorId = core.status.floorId;
core.resetGame(core.firstData.hero, null, core.firstData.floorId, core.clone(core.initStatus.maps)); core.status.floorId = floorId;
var lastFloorId = editor.config.get('editorLastFloorId', core.status.floorId); core.resizeMap(floorId);
if (core.floorIds.indexOf(lastFloorId) < 0) lastFloorId = core.status.floorId; core.clearMap('all');
core.changeFloor(lastFloorId, null, {x: 0, y: 0, direction:"up"}, null, function () { core.generateGroundPattern(floorId);
afterCoreReset(); core.extractBlocks(floorId);
}, true); core.status.thisMap = core.status.maps[floorId];
afterCoreReset();
}); });
} }
@ -239,11 +243,13 @@ editor.prototype.init = function (callback) {
editor.drawInitData(core.icons.icons); // 初始化绘图 editor.drawInitData(core.icons.icons); // 初始化绘图
editor.game.fetchMapFromCore(); editor.game.fetchMapFromCore();
editor.pos = {x: 0, y: 0};
editor.updateMap(); editor.updateMap();
editor.buildMark(); editor.buildMark();
var viewportLoc = editor.config.get('viewportLoc', []);
editor.setViewport(viewportLoc[0] || 0, viewportLoc[1] || 0);
editor.drawEventBlock(); editor.drawEventBlock();
editor.pos = {x: 0, y: 0};
editor.mode.loc(); editor.mode.loc();
editor.info = editor.ids[editor.indexs[201]]; editor.info = editor.ids[editor.indexs[201]];
editor.mode.enemyitem(); editor.mode.enemyitem();
@ -335,20 +341,26 @@ editor.prototype.changeFloor = function (floorId, callback) {
editor.uivalues.preMapData = []; editor.uivalues.preMapData = [];
editor.uivalues.postMapData = []; editor.uivalues.postMapData = [];
editor.uifunctions._extraEvent_bindSpecialDoor_doAction(true); editor.uifunctions._extraEvent_bindSpecialDoor_doAction(true);
core.changeFloor(floorId, null, {"x": 0, "y": 0, "direction": "up"}, null, function () {
editor.game.fetchMapFromCore();
editor.updateMap();
editor_mode.floor();
editor.drawEventBlock();
editor.viewportLoc = editor.viewportLoc || {}; core.status.floorId = floorId;
var loc = editor.viewportLoc[floorId] || [], x = loc[0] || 0, y = loc[1] || 0; core.resizeMap(floorId);
editor.setViewport(x, y); core.clearMap('all');
editor.uifunctions.unhighlightSaveFloorButton(); core.generateGroundPattern(floorId);
core.extractBlocks(floorId);
core.status.thisMap = core.status.maps[floorId];
editor.config.set('editorLastFloorId', floorId, function() { editor.game.fetchMapFromCore();
if (callback) callback(); editor.updateMap();
}); editor_mode.floor();
editor.drawEventBlock();
editor.viewportLoc = editor.viewportLoc || {};
var loc = editor.viewportLoc[floorId] || [], x = loc[0] || 0, y = loc[1] || 0;
editor.setViewport(x, y);
editor.uifunctions.unhighlightSaveFloorButton();
editor.config.set('editorLastFloorId', floorId, function() {
if (callback) callback();
}); });
} }
@ -445,8 +457,7 @@ editor.prototype._updateMap_bigmap = function () {
bm.clearRect(0, 0, core.__PIXELS__, core.__PIXELS__); bm.clearRect(0, 0, core.__PIXELS__, core.__PIXELS__);
bm.fillStyle = '#000000'; bm.fillStyle = '#000000';
bm.fillRect(0, 0, core.__PIXELS__, core.__PIXELS__); bm.fillRect(0, 0, core.__PIXELS__, core.__PIXELS__);
core.drawThumbnail(editor.currentFloorId, core.status.thisMap.blocks, null, core.drawThumbnail(editor.currentFloorId, null, {ctx: bm, all: true});
{ctx: bm, all: true});
var width = editor.currentFloorData.width; var width = editor.currentFloorData.width;
var height = editor.currentFloorData.height; var height = editor.currentFloorData.height;
editor.uivalues.bigmapInfo.top = core.__PIXELS__ * Math.max(0, (1 - height / width) / 2); editor.uivalues.bigmapInfo.top = core.__PIXELS__ * Math.max(0, (1 - height / width) / 2);
@ -573,6 +584,7 @@ editor.prototype.setViewport=function (x, y) {
editor.viewportLoc = editor.viewportLoc || {}; editor.viewportLoc = editor.viewportLoc || {};
editor.viewportLoc[editor.currentFloorId] = [core.bigmap.offsetX, core.bigmap.offsetY]; editor.viewportLoc[editor.currentFloorId] = [core.bigmap.offsetX, core.bigmap.offsetY];
core.control.updateViewport(); core.control.updateViewport();
editor.config.set('viewportLoc', editor.viewportLoc[editor.currentFloorId]);
editor.buildMark(); editor.buildMark();
editor.drawPosSelection(); editor.drawPosSelection();
} }

View File

@ -631,7 +631,6 @@ editor_blockly = function () {
namesObj.allIds = ["this"].concat(core.getAllIconIds()); namesObj.allIds = ["this"].concat(core.getAllIconIds());
namesObj.allIconIds = namesObj.allIds.concat(Object.keys(core.statusBar.icons).filter(function (x) { namesObj.allIconIds = namesObj.allIds.concat(Object.keys(core.statusBar.icons).filter(function (x) {
return core.statusBar.icons[x] instanceof Image; return core.statusBar.icons[x] instanceof Image;
})); }));
namesObj.allImages = Object.keys(core.material.images.images); namesObj.allImages = Object.keys(core.material.images.images);

View File

@ -148,8 +148,8 @@ editor_datapanel_wrapper = function (editor) {
} }
var width = parseInt(document.getElementById('newMapWidth').value); var width = parseInt(document.getElementById('newMapWidth').value);
var height = parseInt(document.getElementById('newMapHeight').value); var height = parseInt(document.getElementById('newMapHeight').value);
if (!core.isset(width) || !core.isset(height) || width < core.__SIZE__ || height < core.__SIZE__ || width * height > 1000) { if (!core.isset(width) || !core.isset(height) || width < core.__SIZE__ || height < core.__SIZE__ || width > 128 || height > 128) {
printe("新建地图的宽高都不得小于" + core.__SIZE__ + ",且宽高之积不能超过1000"); printe("新建地图的宽高都不得小于" + core.__SIZE__ + ",且都不得大于128");
return; return;
} }
@ -217,8 +217,8 @@ editor_datapanel_wrapper = function (editor) {
var width = parseInt(document.getElementById('newMapsWidth').value); var width = parseInt(document.getElementById('newMapsWidth').value);
var height = parseInt(document.getElementById('newMapsHeight').value); var height = parseInt(document.getElementById('newMapsHeight').value);
if (!core.isset(width) || !core.isset(height) || width < core.__SIZE__ || height < core.__SIZE__ || width * height > 1000) { if (!core.isset(width) || !core.isset(height) || width < core.__SIZE__ || height < core.__SIZE__ || width > 128 || height > 128) {
printe("新建地图的宽高都不得小于" + core.__SIZE__ + ",且宽高之积不能超过1000"); printe("新建地图的宽高都不得小于" + core.__SIZE__ + ",且都不得大于128");
return; return;
} }
editor_mode.onmode(''); editor_mode.onmode('');

View File

@ -375,7 +375,7 @@ editor_ui_wrapper = function (editor) {
// 绘制UI // 绘制UI
var background = uievent.elements.selectBackground.value; var background = uievent.elements.selectBackground.value;
if (background == 'thumbnail') { if (background == 'thumbnail') {
core.drawThumbnail(editor.currentFloorId, null, {}, 'uievent'); core.drawThumbnail(editor.currentFloorId, null, {ctx: 'uievent'});
} }
else { else {
core.fillRect('uievent', 0, 0, core.__PIXELS__, core.__PIXELS__, background); core.fillRect('uievent', 0, 0, core.__PIXELS__, core.__PIXELS__, background);
@ -482,11 +482,10 @@ editor_ui_wrapper = function (editor) {
if (redraw) { if (redraw) {
core.setAlpha('uievent', 1); core.setAlpha('uievent', 1);
core.clearMap('uievent'); core.clearMap('uievent');
core.drawThumbnail(uievent.values.floorId, null, null, core.drawThumbnail(uievent.values.floorId, null, {
{ ctx: 'uievent', centerX: uievent.values.left + core.__HALF_SIZE__,
ctx: 'uievent', centerX: uievent.values.left + core.__HALF_SIZE__, centerY: uievent.values.top + core.__HALF_SIZE__, all: uievent.values.bigmap
centerY: uievent.values.top + core.__HALF_SIZE__, all: uievent.values.bigmap });
});
uievent.values.multipoints = uievent.values.multipoints || []; uievent.values.multipoints = uievent.values.multipoints || [];
core.setTextAlign('uievent', 'right'); core.setTextAlign('uievent', 'right');
for (var i = 0; i < uievent.values.multipoints.length; ++i) { for (var i = 0; i < uievent.values.multipoints.length; ++i) {
@ -857,7 +856,7 @@ editor_ui_wrapper = function (editor) {
var canvas = document.createElement('canvas'); var canvas = document.createElement('canvas');
canvas.width = canvas.height = core.__PIXELS__; canvas.width = canvas.height = core.__PIXELS__;
canvas.style.position = 'absolute'; canvas.style.position = 'absolute';
core.drawThumbnail(editor.currentFloorId, null, {}, canvas.getContext('2d')); core.drawThumbnail(editor.currentFloorId, null, {ctx: canvas.getContext('2d')});
dom.appendChild(canvas); dom.appendChild(canvas);
var canvas2 = document.createElement('canvas'); var canvas2 = document.createElement('canvas');
canvas2.style.position = 'absolute'; canvas2.style.position = 'absolute';

View File

@ -75,12 +75,6 @@ var plugins_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"_range": "typeof(thiseval)=='string' || thiseval==null", "_range": "typeof(thiseval)=='string' || thiseval==null",
"_data": "物品分类插件" "_data": "物品分类插件"
}, },
"smoothCamera": {
"_leaf": true,
"_type": "textarea",
"_range": "typeof(thiseval)=='string' || thiseval==null",
"_data": "平滑移动镜头"
},
} }
if (obj[key]) return obj[key]; if (obj[key]) return obj[key];
return { return {

View File

@ -1211,11 +1211,11 @@ actions.prototype._clickViewMaps = function (x, y) {
return; return;
} }
if (x >= per && x <= this.LAST - per && y <= per - 1 && mh > this.SIZE) { if (x >= per && x <= this.LAST - per && y <= per - 1 && (!core.status.event.data.all && mh > this.SIZE)) {
core.ui.drawMaps(index, cx, cy - 1); core.ui.drawMaps(index, cx, cy - 1);
return; return;
} }
if (x >= per && x <= this.LAST - per && y >= this.SIZE - per && mh > this.SIZE) { if (x >= per && x <= this.LAST - per && y >= this.SIZE - per && (!core.status.event.data.all && mh > this.SIZE)) {
core.ui.drawMaps(index, cx, cy + 1); core.ui.drawMaps(index, cx, cy + 1);
return; return;
} }
@ -2531,7 +2531,7 @@ actions.prototype._clickReplay = function (x, y) {
actions.prototype._clickReplay_fromBeginning = function () { actions.prototype._clickReplay_fromBeginning = function () {
core.ui.closePanel(); core.ui.closePanel();
core.startGame(core.status.hard, core.getFlag('__seed__'), core.clone(core.status.route)); core.startGame(core.status.hard, core.getFlag('__seed__'), core.cloneArray(core.status.route));
} }
actions.prototype._clickReplay_fromLoad = function () { actions.prototype._clickReplay_fromLoad = function () {

View File

@ -143,7 +143,7 @@ control.prototype._animationFrame_globalAnimate = function (timestamp) {
core.maps._drawFloorImages(core.status.floorId, core.canvas.fg, 'fg', core.status.floorAnimateObjs||[], core.status.globalAnimateStatus); core.maps._drawFloorImages(core.status.floorId, core.canvas.fg, 'fg', core.status.floorAnimateObjs||[], core.status.globalAnimateStatus);
// Global Autotile Animate // Global Autotile Animate
core.status.autotileAnimateObjs.blocks.forEach(function (block) { core.status.autotileAnimateObjs.forEach(function (block) {
core.maps._drawAutotileAnimate(block, core.status.globalAnimateStatus); core.maps._drawAutotileAnimate(block, core.status.globalAnimateStatus);
}); });
@ -770,7 +770,7 @@ control.prototype.tryMoveDirectly = function (destX, destY) {
if (this.nearHero(destX, destY)) return false; if (this.nearHero(destX, destY)) return false;
var canMoveArray = core.maps.generateMovableArray(); var canMoveArray = core.maps.generateMovableArray();
var dirs = [[destX,destY],[destX-1,destY,"right"],[destX,destY-1,"down"],[destX,destY+1,"up"],[destX+1,destY,"left"]]; var dirs = [[destX,destY],[destX-1,destY,"right"],[destX,destY-1,"down"],[destX,destY+1,"up"],[destX+1,destY,"left"]];
var canMoveDirectlyArray = core.canMoveDirectlyArray(dirs); var canMoveDirectlyArray = core.canMoveDirectlyArray(dirs, canMoveArray);
for (var i = 0; i < dirs.length; ++i) { for (var i = 0; i < dirs.length; ++i) {
var d = dirs[i], dx = d[0], dy = d[1], dir = d[2]; var d = dirs[i], dx = d[0], dy = d[1], dir = d[2];
@ -915,8 +915,13 @@ control.prototype.addGameCanvasTranslate = function (x, y) {
if (id=='ui' || id=='data') continue; // UI层和data层不移动 if (id=='ui' || id=='data') continue; // UI层和data层不移动
var offsetX = x, offsetY = y; var offsetX = x, offsetY = y;
if (core.bigmap.canvas.indexOf(id)>=0) { if (core.bigmap.canvas.indexOf(id)>=0) {
offsetX -= core.bigmap.offsetX; if (core.bigmap.v2) {
offsetY -= core.bigmap.offsetY; offsetX -= (core.bigmap.offsetX - 32 * core.bigmap.posX) + 32;
offsetY -= (core.bigmap.offsetY - 32 * core.bigmap.posY) + 32;
} else {
offsetX -= core.bigmap.offsetX;
offsetY -= core.bigmap.offsetY;
}
} }
core.control.setGameCanvasTranslate(id, offsetX, offsetY); core.control.setGameCanvasTranslate(id, offsetX, offsetY);
} }
@ -924,8 +929,24 @@ control.prototype.addGameCanvasTranslate = function (x, y) {
////// 更新视野范围 ////// ////// 更新视野范围 //////
control.prototype.updateViewport = function() { control.prototype.updateViewport = function() {
// 当前是否应该重绘?
if (core.bigmap.v2) {
if (core.bigmap.offsetX >= core.bigmap.posX * 32 + 32
|| core.bigmap.offsetX <= core.bigmap.posX * 32 - 32
|| core.bigmap.offsetY >= core.bigmap.posY * 32 + 32
|| core.bigmap.offsetY <= core.bigmap.posY * 32 - 32) {
core.bigmap.posX = parseInt(core.bigmap.offsetX / 32);
core.bigmap.posY = parseInt(core.bigmap.offsetY / 32);
core.redrawMap();
}
} else {
core.bigmap.posX = core.bigmap.posY = 0;
}
var offsetX = core.bigmap.v2 ? -(core.bigmap.offsetX - 32 * core.bigmap.posX) - 32 : -core.bigmap.offsetX;
var offsetY = core.bigmap.v2 ? -(core.bigmap.offsetY - 32 * core.bigmap.posY) - 32 : -core.bigmap.offsetY;
core.bigmap.canvas.forEach(function(cn){ core.bigmap.canvas.forEach(function(cn){
core.control.setGameCanvasTranslate(cn,-core.bigmap.offsetX,-core.bigmap.offsetY); core.control.setGameCanvasTranslate(cn, offsetX, offsetY);
}); });
// ------ 路线 // ------ 路线
core.relocateCanvas('route', core.status.automaticRoute.offsetX - core.bigmap.offsetX, core.status.automaticRoute.offsetY - core.bigmap.offsetY); core.relocateCanvas('route', core.status.automaticRoute.offsetX - core.bigmap.offsetX, core.status.automaticRoute.offsetY - core.bigmap.offsetY);
@ -1095,65 +1116,136 @@ control.prototype._checkBlock_ambush = function (ambush) {
////// 更新全地图显伤 ////// ////// 更新全地图显伤 //////
control.prototype.updateDamage = function (floorId, ctx) { control.prototype.updateDamage = function (floorId, ctx) {
floorId = floorId || core.status.floorId; floorId = floorId || core.status.floorId;
if (!core.isset(floorId) || core.status.gameOver) return; if (!floorId || core.status.gameOver) return;
if (core.status.gameOver) return; var onMap = ctx == null;
var refreshCheckBlock = true;
if (!core.isset(ctx)) {
ctx = core.canvas.damage;
core.clearMap('damage');
refreshCheckBlock = false;
}
// 没有怪物手册 // 没有怪物手册
if (!core.hasItem('book')) return; if (!core.hasItem('book')) return;
core.setFont(ctx, "bold 11px Arial"); core.status.damage.posX = core.bigmap.posX;
this._updateDamage_damage(floorId, ctx); core.status.damage.posY = core.bigmap.posY;
this._updateDamage_extraDamage(floorId, ctx, refreshCheckBlock); if (!onMap) {
var width = core.floors[floorId].width, height = core.floors[floorId].height;
// 地图过大的缩略图不绘制显伤
if (width * height > (core.__SIZE__ + 2 * core.bigmap.extend) * (core.__SIZE__ + 2 * core.bigmap.extend)) return;
}
this._updateDamage_damage(floorId, onMap);
this._updateDamage_extraDamage(floorId, onMap);
this.drawDamage(ctx);
} }
control.prototype._updateDamage_damage = function (floorId, ctx) { control.prototype._updateDamage_damage = function (floorId, onMap) {
core.setTextAlign(ctx, 'left'); core.status.damage.data = [];
if (!core.flags.displayEnemyDamage && !core.flags.displayExtraDamage) return;
core.extractBlocks(floorId); core.extractBlocks(floorId);
core.status.maps[floorId].blocks.forEach(function (block) { core.status.maps[floorId].blocks.forEach(function (block) {
var x = block.x, y = block.y; var x = block.x, y = block.y;
// v2优化只绘制范围内的部分
if (onMap && core.bigmap.v2) {
if (x < core.bigmap.posX - core.bigmap.extend || x > core.bigmap.posX + core.__SIZE__ + core.bigmap.extend
|| y < core.bigmap.posY - core.bigmap.extend || y > core.bigmap.posY + core.__SIZE__ + core.bigmap.extend) {
return;
}
}
if (!block.disable && block.event.cls.indexOf('enemy') == 0 && block.event.displayDamage !== false) { if (!block.disable && block.event.cls.indexOf('enemy') == 0 && block.event.displayDamage !== false) {
if (core.flags.displayEnemyDamage) { if (core.flags.displayEnemyDamage) {
var damageString = core.enemys.getDamageString(block.event.id, x, y, floorId); var damageString = core.enemys.getDamageString(block.event.id, x, y, floorId);
var damage = damageString.damage, color = damageString.color; core.status.damage.data.push({text: damageString.damage, px: 32*x+1, py: 32*(y+1)-1, color: damageString.color});
core.fillBoldText(ctx, damage, 32*x+1, 32*(y+1)-1, color); }
} if (core.flags.displayCritical) {
if (core.flags.displayCritical) {
var critical = core.enemys.nextCriticals(block.event.id, 1, x, y, floorId); var critical = core.enemys.nextCriticals(block.event.id, 1, x, y, floorId);
critical = core.formatBigNumber((critical[0]||[])[0], true); critical = core.formatBigNumber((critical[0]||[])[0], true);
if (critical == '???') critical = '?'; if (critical == '???') critical = '?';
core.fillBoldText(ctx, critical, 32*x+1, 32*(y+1)-11, '#FFFFFF'); core.status.damage.data.push({text: critical, px: 32*x+1, py: 32*(y+1)-11, color: '#FFFFFF'});
} }
} }
}); });
} }
control.prototype._updateDamage_extraDamage = function (floorId, ctx, refresh) { control.prototype._updateDamage_extraDamage = function (floorId, onMap) {
core.setTextAlign(ctx, 'center'); core.status.damage.extraData = [];
if (refresh) this.updateCheckBlock(floorId); if (!core.flags.displayExtraDamage) return;
if (core.flags.displayExtraDamage) {
var width = core.floors[floorId].width, height = core.floors[floorId].height; var width = core.floors[floorId].width, height = core.floors[floorId].height;
for (var x=0;x<width;x++) { var startX = onMap && core.bigmap.v2 ? Math.max(0, core.bigmap.posX - core.bigmap.extend) : 0;
for (var y=0;y<height;y++) { var endX = onMap && core.bigmap.v2 ? Math.min(width, core.bigmap.posX + core.__SIZE__ + core.bigmap.extend + 1) : width;
var damage = core.status.checkBlock.damage[x+","+y]||0; var startY = onMap && core.bigmap.v2 ? Math.max(0, core.bigmap.posY - core.bigmap.extend) : 0;
if (damage>0) { // 该点伤害 var endY = onMap && core.bigmap.v2 ? Math.min(height, core.bigmap.posY + core.__SIZE__ + core.bigmap.extend + 1) : height;
damage = core.formatBigNumber(damage, true);
core.fillBoldText(ctx, damage, 32*x+16, 32*(y+1)-14, '#ffaa33'); for (var x=startX;x<endX;x++) {
} for (var y=startY;y<endY;y++) {
else { // 检查捕捉 var damage = core.status.checkBlock.damage[x+","+y]||0;
if (core.status.checkBlock.ambush[x+","+y]) { if (damage>0) { // 该点伤害
core.fillBoldText(ctx, '!', 32*x+16, 32*(y+1)-14, '#ffaa33'); damage = core.formatBigNumber(damage, true);
} core.status.damage.extraData.push({text: damage, px: 32*x+16, py: 32*(y+1)-14, color: '#ffaa33'});
}
else { // 检查捕捉
if (core.status.checkBlock.ambush[x+","+y]) {
core.status.damage.extraData.push({text: '!', px: 32*x+16, py: 32*(y+1)-14, color: '#ffaa33'});
} }
} }
} }
} }
} }
////// 重绘地图显伤 //////
control.prototype.drawDamage = function (ctx) {
if (core.status.gameOver || !core.status.damage) return;
var onMap = false;
if (ctx == null) {
ctx = core.canvas.damage;
core.clearMap('damage');
onMap = true;
}
if (onMap && core.bigmap.v2) {
// 检查是否需要重算...
if (Math.abs(core.bigmap.posX - core.status.damage.posX) >= core.bigmap.extend - 1
|| Math.abs(core.bigmap.posY - core.status.damage.posY) >= core.bigmap.extend - 1) {
return this.updateDamage();
}
}
return this._drawDamage_draw(ctx, onMap);
}
control.prototype._drawDamage_draw = function (ctx, onMap) {
if (!core.hasItem('book')) return;
// 双缓冲
var cacheCtx = core.bigmap.cacheCanvas;
cacheCtx.canvas.width = ctx.canvas.width;
cacheCtx.canvas.height = ctx.canvas.height;
cacheCtx.clearRect(0, 0, cacheCtx.canvas.width, cacheCtx.canvas.height);
core.setFont(cacheCtx, "bold 11px Arial");
core.setTextAlign(cacheCtx, 'left');
core.status.damage.data.forEach(function (one) {
var px = one.px, py = one.py;
if (onMap && core.bigmap.v2) {
px -= core.bigmap.posX * 32;
py -= core.bigmap.posY * 32;
if (px < -32 * 2 || px > core.__PIXELS__ + 32 || py < -32 || py > core.__PIXELS__ + 32)
return;
}
core.fillBoldText(cacheCtx, one.text, px, py, one.color);
});
core.setTextAlign(cacheCtx, 'center');
core.status.damage.extraData.forEach(function (one) {
var px = one.px, py = one.py;
if (onMap && core.bigmap.v2) {
px -= core.bigmap.posX * 32;
py -= core.bigmap.posY * 32;
if (px < -32 || px > core.__PIXELS__ + 32 || py < -32 || py > core.__PIXELS__ + 32)
return;
}
core.fillBoldText(cacheCtx, one.text, px, py, one.color);
});
core.drawImage(ctx, cacheCtx.canvas, 0, 0);
}
// ------ 录像相关 ------ // // ------ 录像相关 ------ //
////// 选择录像文件 ////// ////// 选择录像文件 //////
@ -1178,7 +1270,7 @@ control.prototype.startReplay = function (list) {
core.status.replay.replaying=true; core.status.replay.replaying=true;
core.status.replay.pausing=true; core.status.replay.pausing=true;
core.status.replay.speed=1.0; core.status.replay.speed=1.0;
core.status.replay.toReplay = core.clone(list); core.status.replay.toReplay = core.cloneArray(list);
core.status.replay.totalList = core.status.route.concat(list); core.status.replay.totalList = core.status.route.concat(list);
core.status.replay.steps = 0; core.status.replay.steps = 0;
core.status.replay.save = []; core.status.replay.save = [];
@ -1433,8 +1525,8 @@ control.prototype._replay_save = function () {
if (core.status.replay.save.length == 30) if (core.status.replay.save.length == 30)
core.status.replay.save.shift(); core.status.replay.save.shift();
core.status.replay.save.push({"data": core.saveData(), "replay": { core.status.replay.save.push({"data": core.saveData(), "replay": {
"totalList": core.clone(core.status.replay.totalList), "totalList": core.cloneArray(core.status.replay.totalList),
"toReplay": core.clone(core.status.replay.toReplay), "toReplay": core.cloneArray(core.status.replay.toReplay),
"speed": core.status.replay.speed, "speed": core.status.replay.speed,
"steps": core.status.replay.steps "steps": core.status.replay.steps
}}); }});
@ -2541,8 +2633,12 @@ control.prototype.checkBgm = function() {
////// 清空状态栏 ////// ////// 清空状态栏 //////
control.prototype.clearStatusBar = function() { control.prototype.clearStatusBar = function() {
Object.keys(core.statusBar).forEach(function (e) { Object.keys(core.statusBar).forEach(function (e) {
if (core.statusBar[e].innerHTML != null) if (core.statusBar[e].innerHTML != null) {
core.statusBar[e].innerHTML = "&nbsp;"; core.statusBar[e].innerHTML = "&nbsp;";
core.statusBar[e].removeAttribute('_isNumber');
core.statusBar[e].removeAttribute('_style');
core.statusBar[e].removeAttribute('_value');
}
}) })
core.statusBar.image.book.style.opacity = 0.3; core.statusBar.image.book.style.opacity = 0.3;
if (!core.flags.equipboxButton) if (!core.flags.equipboxButton)
@ -2856,9 +2952,9 @@ control.prototype._resize_canvas = function (obj) {
core.dom.gameDraw.style.right = 0; core.dom.gameDraw.style.right = 0;
core.dom.gameDraw.style.border = obj.border; core.dom.gameDraw.style.border = obj.border;
// resize bigmap // resize bigmap
core.bigmap.canvas.forEach(function(cn){ core.bigmap.canvas.forEach(function (cn) {
core.canvas[cn].canvas.style.width = core.bigmap.width * 32 * core.domStyle.scale + "px"; core.canvas[cn].canvas.style.width = core.canvas[cn].canvas.width * core.domStyle.scale + "px";
core.canvas[cn].canvas.style.height = core.bigmap.height * 32 * core.domStyle.scale + "px"; core.canvas[cn].canvas.style.height = core.canvas[cn].canvas.height * core.domStyle.scale + "px";
}); });
// resize dynamic canvas // resize dynamic canvas
for (var name in core.dymCanvas) { for (var name in core.dymCanvas) {

View File

@ -93,9 +93,16 @@ function core() {
canvas: ["bg", "event", "event2", "fg", "damage"], canvas: ["bg", "event", "event2", "fg", "damage"],
offsetX: 0, // in pixel offsetX: 0, // in pixel
offsetY: 0, offsetY: 0,
posX: 0, //
posY: 0,
width: this.__SIZE__, // map width and height width: this.__SIZE__, // map width and height
height: this.__SIZE__, height: this.__SIZE__,
v2: false,
threshold: 512,
extend: 10,
scale: 1.0,
tempCanvas: null, // A temp canvas for drawing tempCanvas: null, // A temp canvas for drawing
cacheCanvas: null, // A cache canvas
} }
this.saves = { this.saves = {
"saveIndex": null, "saveIndex": null,
@ -125,7 +132,14 @@ function core() {
'maps': null, 'maps': null,
'bgmaps': {}, 'bgmaps': {},
'fgmaps': {}, 'fgmaps': {},
'checkBlock': {}, // 显伤伤害 'mapBlockObjs': {},
'checkBlock': {}, // 每个点的阻激夹域信息
'damage': { // 每个点的显伤绘制
'posX': 0,
'posY': 0,
'data': [],
'extraData': [],
},
'lockControl': false, 'lockControl': false,
@ -208,7 +222,7 @@ function core() {
'globalAnimateObjs': [], 'globalAnimateObjs': [],
'floorAnimateObjs': [], 'floorAnimateObjs': [],
'boxAnimateObjs': [], 'boxAnimateObjs': [],
'autotileAnimateObjs': {"blocks": [], "map": null, "bgmap": null, "fgmap": null}, 'autotileAnimateObjs': [],
"globalAnimateStatus": 0, "globalAnimateStatus": 0,
'animateObjs': [], 'animateObjs': [],
}; };
@ -392,6 +406,7 @@ core.prototype._init_others = function () {
core.material.groundCanvas.canvas.width = core.material.groundCanvas.canvas.height = 32; core.material.groundCanvas.canvas.width = core.material.groundCanvas.canvas.height = 32;
core.material.groundPattern = core.material.groundCanvas.createPattern(core.material.groundCanvas.canvas, 'repeat'); core.material.groundPattern = core.material.groundCanvas.createPattern(core.material.groundCanvas.canvas, 'repeat');
core.bigmap.tempCanvas = document.createElement('canvas').getContext('2d'); core.bigmap.tempCanvas = document.createElement('canvas').getContext('2d');
core.bigmap.cacheCanvas = document.createElement('canvas').getContext('2d');
core.loadImage("materials", 'fog', function (name, img) { core.animateFrame.weather.fog = img; }); core.loadImage("materials", 'fog', function (name, img) { core.animateFrame.weather.fog = img; });
core.loadImage("materials", "cloud", function (name, img) { core.animateFrame.weather.cloud = img; }) core.loadImage("materials", "cloud", function (name, img) { core.animateFrame.weather.cloud = img; })
core.loadImage("materials", 'keyboard', function (name, img) {core.material.images.keyboard = img; }); core.loadImage("materials", 'keyboard', function (name, img) {core.material.images.keyboard = img; });

View File

@ -336,12 +336,11 @@ enemys.prototype.getCurrentEnemys = function (floorId) {
floorId = floorId || core.status.floorId; floorId = floorId || core.status.floorId;
var enemys = [], used = {}; var enemys = [], used = {};
core.extractBlocks(floorId); core.extractBlocks(floorId);
var mapBlocks = core.status.maps[floorId].blocks; core.status.maps[floorId].blocks.forEach(function (block) {
for (var b = 0; b < mapBlocks.length; b++) { if (!block.disable && block.event.cls.indexOf('enemy') == 0) {
if (!mapBlocks[b].disable && mapBlocks[b].event.cls.indexOf('enemy') == 0) { this._getCurrentEnemys_addEnemy(block.event.id, enemys, used, floorId);
this._getCurrentEnemys_addEnemy(mapBlocks[b].event.id, enemys, used, floorId);
} }
} }, this);
return this._getCurrentEnemys_sort(enemys); return this._getCurrentEnemys_sort(enemys);
} }

View File

@ -43,7 +43,7 @@ events.prototype.startGame = function (hard, seed, route, callback) {
events.prototype._startGame_start = function (hard, seed, route, callback) { events.prototype._startGame_start = function (hard, seed, route, callback) {
console.log('开始游戏'); console.log('开始游戏');
core.resetGame(core.firstData.hero, hard, null, core.clone(core.initStatus.maps)); core.resetGame(core.firstData.hero, hard, null, core.cloneArray(core.initStatus.maps));
core.setHeroLoc('x', -1); core.setHeroLoc('x', -1);
core.setHeroLoc('y', -1); core.setHeroLoc('y', -1);
@ -335,7 +335,6 @@ events.prototype.trigger = function (x, y, callback) {
var block = core.getBlock(x, y); var block = core.getBlock(x, y);
if (block == null) return _executeCallback(); if (block == null) return _executeCallback();
block = block.block;
// 执行该点的脚本 // 执行该点的脚本
if (block.event.script) { if (block.event.script) {
@ -363,7 +362,6 @@ events.prototype._trigger_inAction = function (x, y) {
var block = core.getBlock(x, y); var block = core.getBlock(x, y);
if (block == null) return core.doAction(); if (block == null) return core.doAction();
block = block.block;
// 执行该点的脚本 // 执行该点的脚本
try { try {
@ -612,7 +610,7 @@ events.prototype._canGetNextItem = function (direction) {
var nx = core.getHeroLoc('x') + core.utils.scan[direction].x; var nx = core.getHeroLoc('x') + core.utils.scan[direction].x;
var ny = core.getHeroLoc('y') + core.utils.scan[direction].y; var ny = core.getHeroLoc('y') + core.utils.scan[direction].y;
var block = core.getBlock(nx, ny); var block = core.getBlock(nx, ny);
return block != null && block.block.event.trigger == 'getItem'; return block != null && block.event.trigger == 'getItem';
} }
events.prototype._getNextItem = function (direction, noRoute) { events.prototype._getNextItem = function (direction, noRoute) {

File diff suppressed because it is too large Load Diff

View File

@ -50,14 +50,20 @@ ui.prototype._createUIEvent = function () {
ui.prototype.clearMap = function (name, x, y, width, height) { ui.prototype.clearMap = function (name, x, y, width, height) {
if (name == 'all') { if (name == 'all') {
for (var m in core.canvas) { for (var m in core.canvas) {
core.canvas[m].clearRect(0, 0, core.bigmap.width*32, core.bigmap.height*32); core.canvas[m].clearRect(-32, -32, core.canvas[m].width+32, core.canvas[m].height+32);
} }
core.dom.gif.innerHTML = ""; core.dom.gif.innerHTML = "";
core.removeGlobalAnimate(); core.removeGlobalAnimate();
} }
else { else {
var ctx = this.getContextByName(name); var ctx = this.getContextByName(name);
if (ctx) ctx.clearRect(x||0, y||0, width||ctx.canvas.width, height||ctx.canvas.height); if (ctx) {
if (x != null && y != null && width != null && height != null) {
ctx.clearRect(x, y, width, height);
} else {
ctx.clearRect(-32, -32, ctx.canvas.width + 32, ctx.canvas.height + 32);
}
}
} }
} }
@ -2274,7 +2280,7 @@ ui.prototype.drawFly = function(page) {
} }
var size = this.PIXEL - 143; var size = this.PIXEL - 143;
core.strokeRect('ui', 20, 100, size, size, '#FFFFFF', 2); core.strokeRect('ui', 20, 100, size, size, '#FFFFFF', 2);
core.drawThumbnail(floorId, null, null, {ctx: 'ui', x: 20, y: 100, size: size}); core.drawThumbnail(floorId, null, {ctx: 'ui', x: 20, y: 100, size: size});
} }
////// 绘制中心对称飞行器 ////// 绘制中心对称飞行器
@ -2286,8 +2292,7 @@ ui.prototype.drawCenterFly = function () {
var toX = core.bigmap.width - 1 - core.getHeroLoc('x'), toY = core.bigmap.height - 1 - core.getHeroLoc('y'); var toX = core.bigmap.width - 1 - core.getHeroLoc('x'), toY = core.bigmap.height - 1 - core.getHeroLoc('y');
this.clearUI(); this.clearUI();
core.fillRect('ui', 0, 0, this.PIXEL, this.PIXEL, '#000000'); core.fillRect('ui', 0, 0, this.PIXEL, this.PIXEL, '#000000');
core.drawThumbnail(null, null, {heroLoc: core.status.hero.loc, heroIcon: core.status.hero.image}, core.drawThumbnail(null, null, {heroLoc: core.status.hero.loc, heroIcon: core.status.hero.image, ctx: 'ui', centerX: toX, centerY: toY});
{ctx: 'ui', centerX: toX, centerY: toY});
var offsetX = core.clamp(toX - core.__HALF_SIZE__, 0, core.bigmap.width - core.__SIZE__), var offsetX = core.clamp(toX - core.__HALF_SIZE__, 0, core.bigmap.width - core.__SIZE__),
offsetY = core.clamp(toY - core.__HALF_SIZE__, 0, core.bigmap.height - core.__SIZE__); offsetY = core.clamp(toY - core.__HALF_SIZE__, 0, core.bigmap.height - core.__SIZE__);
core.fillRect('ui', (toX - offsetX) * 32, (toY - offsetY) * 32, 32, 32, fillstyle); core.fillRect('ui', (toX - offsetX) * 32, (toY - offsetY) * 32, 32, 32, fillstyle);
@ -2306,8 +2311,7 @@ ui.prototype.drawMaps = function (index, x, y) {
core.status.checkBlock.cache = {}; core.status.checkBlock.cache = {};
var data = this._drawMaps_buildData(index, x, y); var data = this._drawMaps_buildData(index, x, y);
core.fillRect('ui', 0, 0, this.PIXEL, this.PIXEL, '#000000'); core.fillRect('ui', 0, 0, this.PIXEL, this.PIXEL, '#000000');
core.drawThumbnail(data.floorId, null, {damage: data.damage}, core.drawThumbnail(data.floorId, null, {damage: data.damage, ctx: 'ui', centerX: data.x, centerY: data.y, all: data.all});
{ctx: 'ui', centerX: data.x, centerY: data.y, all: data.all});
core.clearMap('data'); core.clearMap('data');
core.setTextAlign('data', 'left'); core.setTextAlign('data', 'left');
core.setFont('data', '16px Arial'); core.setFont('data', '16px Arial');
@ -2772,10 +2776,9 @@ ui.prototype._drawSLPanel_drawRecord = function(title, data, x, y, size, cho, hi
if (data && data.floorId) { if (data && data.floorId) {
core.setTextAlign('ui', "center"); core.setTextAlign('ui', "center");
var map = core.maps.loadMap(data.maps, data.floorId); var map = core.maps.loadMap(data.maps, data.floorId);
core.extractBlocks(map, data.hero.flags); core.extractBlocksForUI(map, data.hero.flags);
core.drawThumbnail(data.floorId, map.blocks, { core.drawThumbnail(data.floorId, map.blocks, {
heroLoc: data.hero.loc, heroIcon: data.hero.image, flags: data.hero.flags heroLoc: data.hero.loc, heroIcon: data.hero.image, flags: data.hero.flags,
}, {
ctx: 'ui', x: x-size/2, y: y+15, size: size, centerX: data.hero.loc.x, centerY: data.hero.loc.y ctx: 'ui', x: x-size/2, y: y+15, size: size, centerX: data.hero.loc.x, centerY: data.hero.loc.y
}); });
if (core.isPlaying() && core.getFlag("hard") != data.hero.flags.hard) { if (core.isPlaying() && core.getFlag("hard") != data.hero.flags.hard) {

View File

@ -58,6 +58,14 @@ utils.prototype._init = function () {
return this.substring(0, search.length) === search; return this.substring(0, search.length) === search;
} }
} }
if (typeof Array.prototype.fill != "function") {
Array.prototype.fill = function (value) {
for (var i = 0; i < this.length; ++i)
if (this[i] == null)
this[i] = value;
return this;
}
}
} }
@ -342,6 +350,16 @@ utils.prototype.clone = function (data, filter, recursion) {
return data; return data;
} }
////// 深拷贝1D/2D数组优化 //////
utils.prototype.cloneArray = function (data) {
if (!(data instanceof Array)) return this.clone(data);
if (data[0] instanceof Array) {
return data.map(function (one) { return one.slice(); });
} else {
return data.slice();
}
}
////// 裁剪图片 ////// ////// 裁剪图片 //////
utils.prototype.splitImage = function (image, width, height) { utils.prototype.splitImage = function (image, width, height) {
if (typeof image == "string") { if (typeof image == "string") {
@ -660,7 +678,7 @@ utils.prototype.isset = function (val) {
utils.prototype.subarray = function (a, b) { utils.prototype.subarray = function (a, b) {
if (!(a instanceof Array) || !(b instanceof Array) || a.length < b.length) if (!(a instanceof Array) || !(b instanceof Array) || a.length < b.length)
return null; return null;
var na = core.clone(a), nb = core.clone(b); var na = core.cloneArray(a), nb = core.cloneArray(b);
while (nb.length > 0) { while (nb.length > 0) {
if (na.shift() != nb.shift()) return null; if (na.shift() != nb.shift()) return null;
} }
@ -697,11 +715,30 @@ utils.prototype.setStatusBarInnerHTML = function (name, value, css) {
var length = this.strlen(value) || 1; var length = this.strlen(value) || 1;
style += 'font-size: ' + Math.min(1, 7 / length) + 'em; '; style += 'font-size: ' + Math.min(1, 7 / length) + 'em; ';
if (css) style += css; if (css) style += css;
var _isNumber = core.statusBar[name].getAttribute('_isNumber') == "1";
var _style = core.statusBar[name].getAttribute('_style');
var _value = core.statusBar[name].getAttribute('_value');
if (isNumber) { if (isNumber) {
core.statusBar[name].innerHTML = "<span class='_status' style='" + style + "'>" + value + "</span>"; if (_isNumber && _style == style) {
if (value == _value) return;
core.statusBar[name].innerText = value;
} else {
core.statusBar[name].innerHTML = "<span class='_status' style='" + style + "'>" + value + "</span>";
core.statusBar[name].setAttribute('_isNumber', '1');
core.statusBar[name].setAttribute('_style', style);
}
core.statusBar[name].setAttribute('_value', value);
} else { } else {
core.statusBar[name].innerHTML = "<span class='_status' style='" + style + "'></span>"; if (!_isNumber && _style == style) {
core.statusBar[name].children[0].innerText = value; if (value == _value) return;
core.statusBar[name].children[0].innerText = value;
} else {
core.statusBar[name].innerHTML = "<span class='_status' style='" + style + "'></span>";
core.statusBar[name].children[0].innerText = value;
core.statusBar[name].setAttribute('_isNumber', '0');
core.statusBar[name].setAttribute('_style', style);
}
core.statusBar[name].setAttribute('_value', value);
} }
} }

View File

@ -483,8 +483,8 @@ function action_items(callback) {
"cls": "tools", "cls": "tools",
"name": "破墙镐", "name": "破墙镐",
"text": "可以破坏勇士面前的墙", "text": "可以破坏勇士面前的墙",
"useItemEffect": "(function () {\n\tvar canBreak = function (x, y) {\n\t\tvar block = core.getBlock(x, y);\n\t\tif (block == null || block.block.disable) return false;\n\t\treturn block.block.event.canBreak;\n\t};\n\n\tvar success = false;\n\tvar pickaxeFourDirections = false; // 是否四方向破如果是将其改成true\n\tif (pickaxeFourDirections) {\n\t\t// 四方向破\n\t\tfor (var direction in core.utils.scan) {\n\t\t\tvar delta = core.utils.scan[direction];\n\t\t\tvar nx = core.getHeroLoc('x') + delta.x,\n\t\t\t\tny = core.getHeroLoc('y') + delta.y;\n\t\t\tif (canBreak(nx, ny)) {\n\t\t\t\tcore.removeBlock(nx, ny);\n\t\t\t\tsuccess = true;\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// 仅破当前\n\t\tif (canBreak(core.nextX(), core.nextY())) {\n\t\t\tcore.removeBlock(core.nextX(), core.nextY());\n\t\t\tsuccess = true;\n\t\t}\n\t}\n\n\tif (success) {\n\t\tcore.playSound('pickaxe.mp3');\n\t\tcore.drawTip(core.material.items[itemId].name + '使用成功');\n\t} else {\n\t\t// 无法使用\n\t\tcore.drawTip(\"当前无法使用\" + core.material.items[itemId].name);\n\t\tcore.addItem(itemId, 1);\n\t\treturn;\n\t}\n})();", "useItemEffect": "(function () {\n\tvar canBreak = function (x, y) {\n\t\tvar block = core.getBlock(x, y);\n\t\tif (block == null || block.disable) return false;\n\t\treturn block.event.canBreak;\n\t};\n\n\tvar success = false;\n\tvar pickaxeFourDirections = false; // 是否四方向破如果是将其改成true\n\tif (pickaxeFourDirections) {\n\t\t// 四方向破\n\t\tfor (var direction in core.utils.scan) {\n\t\t\tvar delta = core.utils.scan[direction];\n\t\t\tvar nx = core.getHeroLoc('x') + delta.x,\n\t\t\t\tny = core.getHeroLoc('y') + delta.y;\n\t\t\tif (canBreak(nx, ny)) {\n\t\t\t\tcore.removeBlock(nx, ny);\n\t\t\t\tsuccess = true;\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// 仅破当前\n\t\tif (canBreak(core.nextX(), core.nextY())) {\n\t\t\tcore.removeBlock(core.nextX(), core.nextY());\n\t\t\tsuccess = true;\n\t\t}\n\t}\n\n\tif (success) {\n\t\tcore.playSound('pickaxe.mp3');\n\t\tcore.drawTip(core.material.items[itemId].name + '使用成功');\n\t} else {\n\t\t// 无法使用\n\t\tcore.drawTip(\"当前无法使用\" + core.material.items[itemId].name);\n\t\tcore.addItem(itemId, 1);\n\t\treturn;\n\t}\n})();",
"canUseItemEffect": "true" "canUseItemEffect": "true"
}, },
"icePickaxe": { "icePickaxe": {
"cls": "tools", "cls": "tools",
@ -497,8 +497,8 @@ function action_items(callback) {
"cls": "tools", "cls": "tools",
"name": "炸弹", "name": "炸弹",
"text": "可以炸掉勇士面前的怪物", "text": "可以炸掉勇士面前的怪物",
"useItemEffect": "(function () {\n\tvar canBomb = function (x, y) {\n\t\tvar block = core.getBlock(x, y);\n\t\tif (block == null || block.block.disable || block.block.event.cls.indexOf('enemy') != 0) return false;\n\t\tvar enemy = core.material.enemys[block.block.event.id];\n\t\treturn enemy && !enemy.notBomb;\n\t};\n\n\tvar bombList = []; // 炸掉的怪物坐标列表\n\tvar bombFourDirections = false; // 是否四方向可炸如果是将其改成true。\n\tif (bombFourDirections) {\n\t\t// 四方向炸\n\t\tfor (var direction in core.utils.scan) {\n\t\t\tvar delta = core.utils.scan[direction];\n\t\t\tvar nx = core.getHeroLoc('x') + delta.x,\n\t\t\t\tny = core.getHeroLoc('y') + delta.y;\n\t\t\tif (canBomb(nx, ny)) {\n\t\t\t\tbombList.push([nx, ny]);\n\t\t\t\tcore.removeBlock(nx, ny);\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// 仅炸当前\n\t\tif (canBomb(core.nextX(), core.nextY())) {\n\t\t\tbombList.push([core.nextX(), core.nextY()]);\n\t\t\tcore.removeBlock(core.nextX(), core.nextY());\n\t\t}\n\t}\n\n\tif (bombList.length > 0) {\n\t\tcore.playSound('bomb.mp3');\n\t\tcore.drawTip(core.material.items[itemId].name + '使用成功');\n\t} else {\n\t\tcore.drawTip('当前无法使用' + core.material.items[itemId].name);\n\t\tcore.addItem(itemId, 1);\n\t\treturn;\n\t}\n\n\t// 炸弹后事件\n\t// 这是一个使用炸弹也能开门的例子\n\t/*\n\tif (core.status.floorId=='xxx' && core.terrainExists(x0,y0,'specialDoor') // 某个楼层,该机关门存在\n\t\t&& !core.enemyExists(x1,y1) && !core.enemyExists(x2,y2)) // 且守门的怪物都不存在\n\t{\n\t\tcore.insertAction([ // 插入事件\n\t\t\t{\"type\": \"openDoor\", \"loc\": [x0,y0]} // 开门\n\t\t])\n\t}\n\t*/\n})();", "useItemEffect": "(function () {\n\tvar canBomb = function (x, y) {\n\t\tvar block = core.getBlock(x, y);\n\t\tif (block == null || block.disable || block.event.cls.indexOf('enemy') != 0) return false;\n\t\tvar enemy = core.material.enemys[block.event.id];\n\t\treturn enemy && !enemy.notBomb;\n\t};\n\n\tvar bombList = []; // 炸掉的怪物坐标列表\n\tvar bombFourDirections = false; // 是否四方向可炸如果是将其改成true。\n\tif (bombFourDirections) {\n\t\t// 四方向炸\n\t\tfor (var direction in core.utils.scan) {\n\t\t\tvar delta = core.utils.scan[direction];\n\t\t\tvar nx = core.getHeroLoc('x') + delta.x,\n\t\t\t\tny = core.getHeroLoc('y') + delta.y;\n\t\t\tif (canBomb(nx, ny)) {\n\t\t\t\tbombList.push([nx, ny]);\n\t\t\t\tcore.removeBlock(nx, ny);\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// 仅炸当前\n\t\tif (canBomb(core.nextX(), core.nextY())) {\n\t\t\tbombList.push([core.nextX(), core.nextY()]);\n\t\t\tcore.removeBlock(core.nextX(), core.nextY());\n\t\t}\n\t}\n\n\tif (bombList.length > 0) {\n\t\tcore.playSound('bomb.mp3');\n\t\tcore.drawTip(core.material.items[itemId].name + '使用成功');\n\t} else {\n\t\tcore.drawTip('当前无法使用' + core.material.items[itemId].name);\n\t\tcore.addItem(itemId, 1);\n\t\treturn;\n\t}\n\n\t// 炸弹后事件\n\t// 这是一个使用炸弹也能开门的例子\n\t/*\n\tif (core.status.floorId=='xxx' && core.terrainExists(x0,y0,'specialDoor') // 某个楼层,该机关门存在\n\t\t&& !core.enemyExists(x1,y1) && !core.enemyExists(x2,y2)) // 且守门的怪物都不存在\n\t{\n\t\tcore.insertAction([ // 插入事件\n\t\t\t{\"type\": \"openDoor\", \"loc\": [x0,y0]} // 开门\n\t\t])\n\t}\n\t*/\n})();",
"canUseItemEffect": "true" "canUseItemEffect": "true"
}, },
"upFly": { "upFly": {
"cls": "tools", "cls": "tools",
@ -518,7 +518,7 @@ function action_items(callback) {
"cls": "tools", "cls": "tools",
"name": "地震卷轴", "name": "地震卷轴",
"text": "可以破坏当前层的所有墙", "text": "可以破坏当前层的所有墙",
"useItemEffect": "(function () {\n\tvar indexes = [];\n\tfor (var index in core.status.thisMap.blocks) {\n\t\tvar block = core.status.thisMap.blocks[index];\n\t\tif (!block.disable && block.event.canBreak) {\n\t\t\tindexes.push(index);\n\t\t}\n\t}\n\tcore.removeBlockByIndexes(indexes);\n\tcore.drawMap(core.status.floorId, function () {\n\t\tcore.drawTip(core.material.items[itemId].name + '使用成功');\n\t});\n})();", "useItemEffect": "(function () {\n\tvar indexes = [];\n\tfor (var index in core.status.thisMap.blocks) {\n\t\tvar block = core.status.thisMap.blocks[index];\n\t\tif (!block.disable && block.event.canBreak) {\n\t\t\tindexes.push(index);\n\t\t}\n\t}\n\tcore.removeBlockByIndexes(indexes);\n\tcore.drawMap();\n\tcore.drawTip(core.material.items[itemId].name + '使用成功');\n})();",
"canUseItemEffect": "(function () {\n\treturn core.status.thisMap.blocks.filter(function (block) {\n\t\treturn !block.disable && block.event.canBreak;\n\t}).length > 0;\n})();" "canUseItemEffect": "(function () {\n\treturn core.status.thisMap.blocks.filter(function (block) {\n\t\treturn !block.disable && block.event.canBreak;\n\t}).length > 0;\n})();"
}, },
}; };

View File

@ -125,6 +125,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
if (block.disable && core.enemys.hasSpecial(block.event.id, 23)) { if (block.disable && core.enemys.hasSpecial(block.event.id, 23)) {
block.disable = false; block.disable = false;
core.setMapBlockDisabled(floorId, block.x, block.y, false); core.setMapBlockDisabled(floorId, block.x, block.y, false);
core.maps._updateMapArray(floorId, block.x, block.y);
} }
}); });
core.control.gatherFollowers(); core.control.gatherFollowers();
@ -284,15 +285,8 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
return; return;
} }
// 删除该块
var guards = []; // 支援 var guards = []; // 支援
if (x != null && y != null) { if (x != null && y != null) {
// 检查是否是重生怪物;如果是则仅隐藏不删除
if (core.hasSpecial(enemy.special, 23)) {
core.hideBlock(x, y);
} else {
core.removeBlock(x, y);
}
guards = core.getFlag("__guards__" + x + "_" + y, []); guards = core.getFlag("__guards__" + x + "_" + y, []);
core.removeFlag("__guards__" + x + "_" + y); core.removeFlag("__guards__" + x + "_" + y);
} }
@ -389,7 +383,18 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
// 如果事件不为空,将其插入 // 如果事件不为空,将其插入
if (todo.length > 0) core.insertAction(todo, x, y); if (todo.length > 0) core.insertAction(todo, x, y);
core.updateStatusBar();
// 因为removeBlock和hideBlock都会刷新状态栏因此移动到这里并保证刷新只执行一次以提升效率
if (core.getBlock(x, y) != null) {
// 检查是否是重生怪物;如果是则仅隐藏不删除
if (core.hasSpecial(enemy.special, 23)) {
core.hideBlock(x, y);
} else {
core.removeBlock(x, y);
}
} else {
core.updateStatusBar();
}
// 如果已有事件正在处理中 // 如果已有事件正在处理中
if (core.status.event.id == null) if (core.status.event.id == null)
@ -1137,8 +1142,10 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
core.setStatusBarInnerHTML('fly', "飞" + core.itemCount('centerFly')); core.setStatusBarInnerHTML('fly', "飞" + core.itemCount('centerFly'));
// 难度 // 难度
core.statusBar.hard.innerText = core.status.hard; if (core.statusBar.hard.innerText != core.status.hard) {
core.statusBar.hard.style.color = core.getFlag('__hardColor__', 'red'); core.statusBar.hard.innerText = core.status.hard;
core.statusBar.hard.style.color = core.getFlag('__hardColor__', 'red');
}
// 自定义状态栏绘制 // 自定义状态栏绘制
core.drawStatusBar(); core.drawStatusBar();
@ -1160,6 +1167,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
type = {}, // 每个点的伤害类型 type = {}, // 每个点的伤害类型
repulse = {}, // 每个点的阻击怪信息 repulse = {}, // 每个点的阻击怪信息
ambush = {}; // 每个点的捕捉信息 ambush = {}; // 每个点的捕捉信息
var betweenAttackLocs = {}; // 所有带夹击的怪物
var needCache = false; var needCache = false;
var canGoDeadZone = core.flags.canGoDeadZone; var canGoDeadZone = core.flags.canGoDeadZone;
core.flags.canGoDeadZone = true; core.flags.canGoDeadZone = true;
@ -1171,6 +1179,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
y = block.y, y = block.y,
id = block.event.id, id = block.event.id,
enemy = core.material.enemys[id]; enemy = core.material.enemys[id];
if (block.disable) continue;
type[loc] = type[loc] || {}; type[loc] = type[loc] || {};
@ -1266,6 +1275,18 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
} }
} }
// 夹击;在这里提前计算所有可能的夹击点,具体计算逻辑在下面
// 如果要防止夹击伤害,可以简单的将 flag:no_betweenAttack 设为true
if (enemy && core.enemys.hasSpecial(enemy.special, 16) && !core.hasFlag('no_betweenAttack')) {
for (var dir in core.utils.scan) {
var nx = x + core.utils.scan[dir].x,
ny = y + core.utils.scan[dir].y,
currloc = nx + "," + ny;
if (nx < 0 || nx >= width || ny < 0 || ny >= height) continue;
betweenAttackLocs[currloc] = true;
}
}
// 检查地图范围类技能 // 检查地图范围类技能
var specialFlag = core.getSpecialFlag(enemy); var specialFlag = core.getSpecialFlag(enemy);
if (specialFlag & 1) needCache = true; if (specialFlag & 1) needCache = true;
@ -1275,48 +1296,46 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
// 更新夹击伤害 // 更新夹击伤害
// 如果要防止夹击伤害,可以简单的将 flag:no_betweenAttack 设为true // 如果要防止夹击伤害,可以简单的将 flag:no_betweenAttack 设为true
if (!core.hasFlag('no_betweenAttack')) { for (var loc in betweenAttackLocs) {
for (var x = 0; x < width; x++) { var xy = loc.split(","),
for (var y = 0; y < height; y++) { x = parseInt(xy[0]),
var loc = x + "," + y; y = parseInt(xy[1]);
// 夹击怪物的ID // 夹击怪物的ID
var enemyId1 = null, var enemyId1 = null,
enemyId2 = null; enemyId2 = null;
// 检查左右夹击 // 检查左右夹击
var leftBlock = blocks[(x - 1) + "," + y], var leftBlock = blocks[(x - 1) + "," + y],
rightBlock = blocks[(x + 1) + "," + y]; rightBlock = blocks[(x + 1) + "," + y];
if (leftBlock && rightBlock && leftBlock.id == rightBlock.id) { if (leftBlock && !leftBlock.disable && rightBlock && !rightBlock.disable && leftBlock.id == rightBlock.id) {
if (core.hasSpecial(leftBlock.event.id, 16)) if (core.hasSpecial(leftBlock.event.id, 16))
enemyId1 = leftBlock.event.id; enemyId1 = leftBlock.event.id;
} }
// 检查上下夹击 // 检查上下夹击
var topBlock = blocks[x + "," + (y - 1)], var topBlock = blocks[x + "," + (y - 1)],
bottomBlock = blocks[x + "," + (y + 1)]; bottomBlock = blocks[x + "," + (y + 1)];
if (topBlock && bottomBlock && topBlock.id == bottomBlock.id) { if (topBlock && !topBlock.disable && bottomBlock && !bottomBlock.disable && topBlock.id == bottomBlock.id) {
if (core.hasSpecial(topBlock.event.id, 16)) if (core.hasSpecial(topBlock.event.id, 16))
enemyId2 = topBlock.event.id; enemyId2 = topBlock.event.id;
} }
if (enemyId1 != null || enemyId2 != null) { if (enemyId1 != null || enemyId2 != null) {
var leftHp = core.status.hero.hp - (damage[loc] || 0); var leftHp = core.status.hero.hp - (damage[loc] || 0);
if (leftHp > 1) { if (leftHp > 1) {
// 夹击伤害值 // 夹击伤害值
var value = Math.floor(leftHp / 2); var value = Math.floor(leftHp / 2);
// 是否不超过怪物伤害值 // 是否不超过怪物伤害值
if (core.flags.betweenAttackMax) { if (core.flags.betweenAttackMax) {
var enemyDamage1 = core.getDamage(enemyId1, x, y, floorId); var enemyDamage1 = core.getDamage(enemyId1, x, y, floorId);
if (enemyDamage1 != null && enemyDamage1 < value) if (enemyDamage1 != null && enemyDamage1 < value)
value = enemyDamage1; value = enemyDamage1;
var enemyDamage2 = core.getDamage(enemyId2, x, y, floorId); var enemyDamage2 = core.getDamage(enemyId2, x, y, floorId);
if (enemyDamage2 != null && enemyDamage2 < value) if (enemyDamage2 != null && enemyDamage2 < value)
value = enemyDamage2; value = enemyDamage2;
} }
if (value > 0) { if (value > 0) {
damage[loc] = (damage[loc] || 0) + value; damage[loc] = (damage[loc] || 0) + value;
type[loc] = type[loc] || {}; type[loc] = type[loc] || {};
type[loc]["夹击伤害"] = true; type[loc]["夹击伤害"] = true;
}
}
} }
} }
} }
@ -1372,7 +1391,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
nowy = core.getHeroLoc('y'); nowy = core.getHeroLoc('y');
var block = core.getBlock(nowx, nowy); var block = core.getBlock(nowx, nowy);
var hasTrigger = false; var hasTrigger = false;
if (block != null && block.block.event.trigger == 'getItem' && if (block != null && block.event.trigger == 'getItem' &&
!core.floors[core.status.floorId].afterGetItem[nowx + "," + nowy]) { !core.floors[core.status.floorId].afterGetItem[nowx + "," + nowy]) {
hasTrigger = true; hasTrigger = true;
core.trigger(nowx, nowy, callback); core.trigger(nowx, nowy, callback);

View File

@ -374,7 +374,7 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"cls": "tools", "cls": "tools",
"name": "破墙镐", "name": "破墙镐",
"text": "可以破坏勇士面前的墙", "text": "可以破坏勇士面前的墙",
"useItemEffect": "(function () {\n\tvar canBreak = function (x, y) {\n\t\tvar block = core.getBlock(x, y);\n\t\tif (block == null || block.block.disable) return false;\n\t\treturn block.block.event.canBreak;\n\t};\n\n\tvar success = false;\n\tvar pickaxeFourDirections = false; // 是否四方向破如果是将其改成true\n\tif (pickaxeFourDirections) {\n\t\t// 四方向破\n\t\tfor (var direction in core.utils.scan) {\n\t\t\tvar delta = core.utils.scan[direction];\n\t\t\tvar nx = core.getHeroLoc('x') + delta.x,\n\t\t\t\tny = core.getHeroLoc('y') + delta.y;\n\t\t\tif (canBreak(nx, ny)) {\n\t\t\t\tcore.removeBlock(nx, ny);\n\t\t\t\tsuccess = true;\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// 仅破当前\n\t\tif (canBreak(core.nextX(), core.nextY())) {\n\t\t\tcore.removeBlock(core.nextX(), core.nextY());\n\t\t\tsuccess = true;\n\t\t}\n\t}\n\n\tif (success) {\n\t\tcore.playSound('pickaxe.mp3');\n\t\tcore.drawTip(core.material.items[itemId].name + '使用成功');\n\t} else {\n\t\t// 无法使用\n\t\tcore.drawTip(\"当前无法使用\" + core.material.items[itemId].name);\n\t\tcore.addItem(itemId, 1);\n\t\treturn;\n\t}\n})();", "useItemEffect": "(function () {\n\tvar canBreak = function (x, y) {\n\t\tvar block = core.getBlock(x, y);\n\t\tif (block == null || block.disable) return false;\n\t\treturn block.event.canBreak;\n\t};\n\n\tvar success = false;\n\tvar pickaxeFourDirections = false; // 是否四方向破如果是将其改成true\n\tif (pickaxeFourDirections) {\n\t\t// 四方向破\n\t\tfor (var direction in core.utils.scan) {\n\t\t\tvar delta = core.utils.scan[direction];\n\t\t\tvar nx = core.getHeroLoc('x') + delta.x,\n\t\t\t\tny = core.getHeroLoc('y') + delta.y;\n\t\t\tif (canBreak(nx, ny)) {\n\t\t\t\tcore.removeBlock(nx, ny);\n\t\t\t\tsuccess = true;\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// 仅破当前\n\t\tif (canBreak(core.nextX(), core.nextY())) {\n\t\t\tcore.removeBlock(core.nextX(), core.nextY());\n\t\t\tsuccess = true;\n\t\t}\n\t}\n\n\tif (success) {\n\t\tcore.playSound('pickaxe.mp3');\n\t\tcore.drawTip(core.material.items[itemId].name + '使用成功');\n\t} else {\n\t\t// 无法使用\n\t\tcore.drawTip(\"当前无法使用\" + core.material.items[itemId].name);\n\t\tcore.addItem(itemId, 1);\n\t\treturn;\n\t}\n})();",
"canUseItemEffect": "true" "canUseItemEffect": "true"
}, },
"icePickaxe": { "icePickaxe": {
@ -388,7 +388,7 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"cls": "tools", "cls": "tools",
"name": "炸弹", "name": "炸弹",
"text": "可以炸掉勇士面前的怪物", "text": "可以炸掉勇士面前的怪物",
"useItemEffect": "(function () {\n\tvar canBomb = function (x, y) {\n\t\tvar block = core.getBlock(x, y);\n\t\tif (block == null || block.block.disable || block.block.event.cls.indexOf('enemy') != 0) return false;\n\t\tvar enemy = core.material.enemys[block.block.event.id];\n\t\treturn enemy && !enemy.notBomb;\n\t};\n\n\tvar bombList = []; // 炸掉的怪物坐标列表\n\tvar bombFourDirections = false; // 是否四方向可炸如果是将其改成true。\n\tif (bombFourDirections) {\n\t\t// 四方向炸\n\t\tfor (var direction in core.utils.scan) {\n\t\t\tvar delta = core.utils.scan[direction];\n\t\t\tvar nx = core.getHeroLoc('x') + delta.x,\n\t\t\t\tny = core.getHeroLoc('y') + delta.y;\n\t\t\tif (canBomb(nx, ny)) {\n\t\t\t\tbombList.push([nx, ny]);\n\t\t\t\tcore.removeBlock(nx, ny);\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// 仅炸当前\n\t\tif (canBomb(core.nextX(), core.nextY())) {\n\t\t\tbombList.push([core.nextX(), core.nextY()]);\n\t\t\tcore.removeBlock(core.nextX(), core.nextY());\n\t\t}\n\t}\n\n\tif (bombList.length > 0) {\n\t\tcore.playSound('bomb.mp3');\n\t\tcore.drawTip(core.material.items[itemId].name + '使用成功');\n\t} else {\n\t\tcore.drawTip('当前无法使用' + core.material.items[itemId].name);\n\t\tcore.addItem(itemId, 1);\n\t\treturn;\n\t}\n\n\t// 炸弹后事件\n\t// 这是一个使用炸弹也能开门的例子\n\t/*\n\tif (core.status.floorId=='xxx' && core.terrainExists(x0,y0,'specialDoor') // 某个楼层,该机关门存在\n\t\t&& !core.enemyExists(x1,y1) && !core.enemyExists(x2,y2)) // 且守门的怪物都不存在\n\t{\n\t\tcore.insertAction([ // 插入事件\n\t\t\t{\"type\": \"openDoor\", \"loc\": [x0,y0]} // 开门\n\t\t])\n\t}\n\t*/\n})();", "useItemEffect": "(function () {\n\tvar canBomb = function (x, y) {\n\t\tvar block = core.getBlock(x, y);\n\t\tif (block == null || block.disable || block.event.cls.indexOf('enemy') != 0) return false;\n\t\tvar enemy = core.material.enemys[block.event.id];\n\t\treturn enemy && !enemy.notBomb;\n\t};\n\n\tvar bombList = []; // 炸掉的怪物坐标列表\n\tvar bombFourDirections = false; // 是否四方向可炸如果是将其改成true。\n\tif (bombFourDirections) {\n\t\t// 四方向炸\n\t\tfor (var direction in core.utils.scan) {\n\t\t\tvar delta = core.utils.scan[direction];\n\t\t\tvar nx = core.getHeroLoc('x') + delta.x,\n\t\t\t\tny = core.getHeroLoc('y') + delta.y;\n\t\t\tif (canBomb(nx, ny)) {\n\t\t\t\tbombList.push([nx, ny]);\n\t\t\t\tcore.removeBlock(nx, ny);\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// 仅炸当前\n\t\tif (canBomb(core.nextX(), core.nextY())) {\n\t\t\tbombList.push([core.nextX(), core.nextY()]);\n\t\t\tcore.removeBlock(core.nextX(), core.nextY());\n\t\t}\n\t}\n\n\tif (bombList.length > 0) {\n\t\tcore.playSound('bomb.mp3');\n\t\tcore.drawTip(core.material.items[itemId].name + '使用成功');\n\t} else {\n\t\tcore.drawTip('当前无法使用' + core.material.items[itemId].name);\n\t\tcore.addItem(itemId, 1);\n\t\treturn;\n\t}\n\n\t// 炸弹后事件\n\t// 这是一个使用炸弹也能开门的例子\n\t/*\n\tif (core.status.floorId=='xxx' && core.terrainExists(x0,y0,'specialDoor') // 某个楼层,该机关门存在\n\t\t&& !core.enemyExists(x1,y1) && !core.enemyExists(x2,y2)) // 且守门的怪物都不存在\n\t{\n\t\tcore.insertAction([ // 插入事件\n\t\t\t{\"type\": \"openDoor\", \"loc\": [x0,y0]} // 开门\n\t\t])\n\t}\n\t*/\n})();",
"canUseItemEffect": "true" "canUseItemEffect": "true"
}, },
"centerFly": { "centerFly": {
@ -416,7 +416,7 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"cls": "tools", "cls": "tools",
"name": "地震卷轴", "name": "地震卷轴",
"text": "可以破坏当前层的所有墙", "text": "可以破坏当前层的所有墙",
"useItemEffect": "(function () {\n\tvar indexes = [];\n\tfor (var index in core.status.thisMap.blocks) {\n\t\tvar block = core.status.thisMap.blocks[index];\n\t\tif (!block.disable && block.event.canBreak) {\n\t\t\tindexes.push(index);\n\t\t}\n\t}\n\tcore.removeBlockByIndexes(indexes);\n\tcore.drawMap(core.status.floorId, function () {\n\t\tcore.drawTip(core.material.items[itemId].name + '使用成功');\n\t});\n})();", "useItemEffect": "(function () {\n\tvar indexes = [];\n\tfor (var index in core.status.thisMap.blocks) {\n\t\tvar block = core.status.thisMap.blocks[index];\n\t\tif (!block.disable && block.event.canBreak) {\n\t\t\tindexes.push(index);\n\t\t}\n\t}\n\tcore.removeBlockByIndexes(indexes);\n\tcore.drawMap();\n\tcore.drawTip(core.material.items[itemId].name + '使用成功');\n})();",
"canUseItemEffect": "(function () {\n\treturn core.status.thisMap.blocks.filter(function (block) {\n\t\treturn !block.disable && block.event.canBreak;\n\t}).length > 0;\n})();" "canUseItemEffect": "(function () {\n\treturn core.status.thisMap.blocks.filter(function (block) {\n\t\treturn !block.disable && block.event.canBreak;\n\t}).length > 0;\n})();"
}, },
"poisonWine": { "poisonWine": {

View File

@ -321,7 +321,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
// 背景层2将会覆盖背景层 被事件层覆盖 前景层2将会覆盖前景层 // 背景层2将会覆盖背景层 被事件层覆盖 前景层2将会覆盖前景层
// 另外 请注意加入两个新图层 会让大地图的性能降低一些 // 另外 请注意加入两个新图层 会让大地图的性能降低一些
// 插件作者ad // 插件作者ad
var __enable = false; var __enable = true;
if (!__enable) return; if (!__enable) return;
// 创建新图层 // 创建新图层
@ -353,7 +353,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
// 背景层2(bg2) 插入事件层(event)之前(即bg与event之间) // 背景层2(bg2) 插入事件层(event)之前(即bg与event之间)
document.getElementById('mapEdit').insertBefore(bg2Canvas, document.getElementById('event')); document.getElementById('mapEdit').insertBefore(bg2Canvas, document.getElementById('event'));
// 前景层2(fg2) 插入编辑器前景(efg)之前(即fg之后) // 前景层2(fg2) 插入编辑器前景(efg)之前(即fg之后)
document.getElementById('mapEdit').insertBefore(fg2Canvas, document.getElementById('efg')); document.getElementById('mapEdit').insertBefore(fg2Canvas, document.getElementById('ebm'));
// 原本有三个图层 从4开始添加 // 原本有三个图层 从4开始添加
var num = 4; var num = 4;
// 新增图层存入editor.dom中 // 新增图层存入editor.dom中
@ -364,16 +364,6 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
editor.dom.maps.push('bg2map', 'fg2map'); editor.dom.maps.push('bg2map', 'fg2map');
editor.dom.canvas.push('bg2', 'fg2'); editor.dom.canvas.push('bg2', 'fg2');
// 默认全空
var defaultMap = [];
for (var i = 0; i < core.__SIZE__; ++i) {
var row = [];
for (var j = 0; j < core.__SIZE__; ++j) {
row.push(0);
}
defaultMap.push(row);
}
// 创建编辑器上的按钮 // 创建编辑器上的按钮
var createCanvasBtn = function (name) { var createCanvasBtn = function (name) {
// 电脑端创建按钮 // 电脑端创建按钮
@ -390,7 +380,6 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
input.onchange = function () { input.onchange = function () {
editor.uifunctions.setLayerMod(value); editor.uifunctions.setLayerMod(value);
} }
editor[value] = editor[value] || defaultMap;
return input; return input;
}; };
@ -402,7 +391,6 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
input.name = 'layerMod'; input.name = 'layerMod';
input.value = value; input.value = value;
editor.dom[id] = input; editor.dom[id] = input;
editor[value] = editor[value] || defaultMap;
return input; return input;
}; };
if (!editor.isMobile) { if (!editor.isMobile) {
@ -432,157 +420,54 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
parent.appendChild(input2); parent.appendChild(input2);
} }
} }
core.maps._loadFloor_doNotCopy = function () {
return [
"firstArrive", "eachArrive", "blocks", "parallelDo", "map", "bgmap", "fgmap", "bg2map", "fg2map",
"events", "changeFloor", "afterBattle", "afterGetItem", "afterOpenDoor", "cannotMove"
];
}
////// 绘制背景层 ////// ////// 绘制背景和前景层 //////
core.maps.drawBg = function (floorId, ctx) { core.maps._drawBg_draw = function (floorId, toDrawCtx, cacheCtx, config) {
floorId = floorId || core.status.floorId; config.ctx = cacheCtx;
var onMap = ctx == null; core.maps._drawBg_drawBackground(floorId, config);
if (onMap) {
ctx = core.canvas.bg;
core.clearMap(ctx);
core.status.floorAnimateObjs = this._getFloorImages(floorId);
}
core.maps._drawBg_drawBackground(floorId, ctx);
// ------ 调整这两行的顺序来控制是先绘制贴图还是先绘制背景图块;后绘制的覆盖先绘制的。 // ------ 调整这两行的顺序来控制是先绘制贴图还是先绘制背景图块;后绘制的覆盖先绘制的。
core.maps._drawFloorImages(floorId, ctx, 'bg'); core.maps._drawFloorImages(floorId, config.ctx, 'bg', null, null, config.onMap);
core.maps._drawBgFgMap(floorId, ctx, 'bg', onMap); core.maps._drawBgFgMap(floorId, 'bg', config);
// 绘制背景层2 if (config.onMap) {
core.maps._drawBgFgMap(floorId, ctx, 'bg2', onMap); core.drawImage(toDrawCtx, cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0);
}; core.clearMap('bg2');
core.clearMap(cacheCtx);
////// 绘制前景层 //////
core.maps.drawFg = function (floorId, ctx) {
floorId = floorId || core.status.floorId;
var onMap = ctx == null;
if (onMap) {
ctx = core.canvas.fg;
core.status.floorAnimateObjs = this._getFloorImages(floorId);
} }
core.maps._drawBgFgMap(floorId, 'bg2', config);
if (config.onMap) core.drawImage('bg2', cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0);
config.ctx = toDrawCtx;
}
core.maps._drawFg_draw = function (floorId, toDrawCtx, cacheCtx, config) {
config.ctx = cacheCtx;
// ------ 调整这两行的顺序来控制是先绘制贴图还是先绘制前景图块;后绘制的覆盖先绘制的。 // ------ 调整这两行的顺序来控制是先绘制贴图还是先绘制前景图块;后绘制的覆盖先绘制的。
this._drawFloorImages(floorId, ctx, 'fg'); core.maps._drawFloorImages(floorId, config.ctx, 'fg', null, null, config.onMap);
this._drawBgFgMap(floorId, ctx, 'fg', onMap); core.maps._drawBgFgMap(floorId, 'fg', config);
// 绘制前景层2 if (config.onMap) {
this._drawBgFgMap(floorId, ctx, 'fg2', onMap); core.drawImage(toDrawCtx, cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0);
}; core.clearMap('fg2');
core.clearMap(cacheCtx);
}
core.maps._drawBgFgMap(floorId, 'fg2', config);
if (config.onMap) core.drawImage('fg2', cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0);
config.ctx = toDrawCtx;
}
/* cannotIn/cannotOut适配 start*/ /* cannotIn/cannotOut适配 start*/
core.maps.generateMovableArray = function (floorId, x, y, direction) { core.maps._generateMovableArray_arrays = function (floorId) {
floorId = floorId || core.status.floorId; return {
if (!floorId) return null; bgArray: this.getBgMapArray(floorId),
var width = core.floors[floorId].width, fgArray: this.getFgMapArray(floorId),
height = core.floors[floorId].height; eventArray: this.getMapArray(floorId),
var bgArray = this.getBgMapArray(floorId), bg2Array: this._getBgFgMapArray('bg2', floorId),
bg2Array = this._getBgFgMapArray('bg2', floorId), fg2Array: this._getBgFgMapArray('fg2', floorId)
fgArray = this.getFgMapArray(floorId),
fg2Array = this._getBgFgMapArray('fg2', floorId),
eventArray = this.getMapArray(floorId);
var generate = function (x, y, direction) {
if (direction != null) {
return core.maps._canMoveHero_checkPoint(x, y, direction, floorId, {
bgArray: bgArray,
fgArray: fgArray,
bg2Array: bg2Array,
fg2Array: fg2Array,
eventArray: eventArray
});
}
return ["left", "down", "up", "right"].filter(function (direction) {
return core.maps._canMoveHero_checkPoint(x, y, direction, floorId, {
bgArray: bgArray,
fgArray: fgArray,
bg2Array: bg2Array,
fg2Array: fg2Array,
eventArray: eventArray
});
});
}; };
}
if (x != null && y != null) return generate(x, y, direction);
var array = [];
for (var x = 0; x < width; x++) {
array[x] = [];
for (var y = 0; y < height; y++) {
array[x][y] = generate(x, y);
}
}
return array;
};
core.maps._canMoveHero_checkPoint = function (x, y, direction, floorId, extraData) {
// 1. 检查该点 cannotMove
if (core.inArray((core.floors[floorId].cannotMove || {})[x + "," + y], direction))
return false;
var nx = x + core.utils.scan[direction].x,
ny = y + core.utils.scan[direction].y;
if (nx < 0 || ny < 0 || nx >= core.floors[floorId].width || ny >= core.floors[floorId].height)
return false;
// 2. 检查该点素材的 cannotOut 和下一个点的 cannotIn
if (this._canMoveHero_checkCannotInOut([
extraData.bgArray[y][x], extraData.bg2Array[y][x], extraData.fgArray[y][x], extraData.fg2Array[y][x], extraData.eventArray[y][x]
], "cannotOut", direction))
return false;
if (this._canMoveHero_checkCannotInOut([
extraData.bgArray[ny][nx], extraData.bg2Array[ny][nx], extraData.fgArray[ny][nx], extraData.fg2Array[ny][nx], extraData.eventArray[ny][nx]
], "cannotIn", direction))
return false;
// 3. 检查是否能进将死的领域
if (floorId == core.status.floorId && !core.flags.canGoDeadZone &&
core.status.hero.hp <= (core.status.checkBlock.damage[nx + "," + ny] || 0) &&
extraData.eventArray[ny][nx] == 0)
return false;
return true;
};
/* cannotIn/cannotOut适配 end*/
// 前景层2与背景层2的隐藏与显示适配
// 比如:可以用core.hideBgFgMap("bg2",[x, y], floorId)隐藏当前楼层的背景层2图块
core.maps._triggerBgFgMap = function (type, name, loc, floorId, callback) {
if (type != 'show') type = 'hide';
if (!name) name = 'bg';
if (typeof loc[0] == 'number' && typeof loc[1] == 'number')
loc = [loc];
floorId = floorId || core.status.floorId;
if (!floorId) return;
if (loc.length == 0) return;
loc.forEach(function (t) {
var x = t[0],
y = t[1];
var flag = [floorId, x, y, name + '_disable'].join('@');
if (type == 'hide') core.setFlag(flag, true);
else core.removeFlag(flag);
});
core.status[name + "maps"][floorId] = null;
if (floorId == core.status.floorId) {
core.drawMap(floorId, callback);
} else {
if (callback) callback();
}
};
// 改变背景层2与前景层2图块 例:core.setBgFgBlock('fg2',312,core.nextX(),core.nextY())
core.maps.setBgFgBlock = function (name, number, x, y, floorId) {
floorId = floorId || core.status.floorId;
if (!floorId || number == null || x == null || y == null) return;
if (x < 0 || x >= core.floors[floorId].width || y < 0 || y >= core.floors[floorId].height) return;
if (name != 'bg' && name != 'fg' && name != 'bg2' && name != 'fg2') return;
if (typeof number == 'string') {
if (/^\d+$/.test(number)) number = parseInt(number);
else number = core.getNumberById(number);
}
var vFlag = [floorId, x, y, name + "_value"].join('@');
core.setFlag(vFlag, number);
core.status[name + "maps"][floorId] = null;
if (floorId == core.status.floorId) {
core.clearMap(name);
if (name.startsWith('bg')) core.drawBg(floorId);
else core.drawFg(floorId);
}
};
}, },
"itemShop": function () { "itemShop": function () {
// 道具商店相关的插件 // 道具商店相关的插件
@ -1373,125 +1258,5 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
return true; return true;
}, 100); }, 100);
},
"smoothCamera": function () {
// 此插件开启后,大地图的瞬间移动将开启平滑镜头移动,避免突兀感
// 插件作者:老黄鸡
// 是否启用本插件,默认不启用
var __enable = false;
if (!__enable) return;
this.Camera = function () {
// 下面这个变量决定本插件的开关
// 你可以在游戏中使用core.setFlag('smoothCamera',false)来关闭本插件的功能
// 同时也可以core.setFlag('smoothCamera',true)重新开启
// 此项默认为true
//
this.__switchName = 'smoothCamera';
// 初始化成员变量
this._cameraNeedRefresh = true;
this._nowOffsetX = 0;
this._nowOffsetY = 0;
this._targetOffsetX = 0;
this._targetOffsetY = 0;
this._currentFloorId = null;
// 重置镜头,在楼层变更时使用
this.resetCamera = function () {
this._targetOffsetX = core.bigmap.offsetX;
this._targetOffsetY = core.bigmap.offsetY;
this._nowOffsetX = this._targetOffsetX;
this._nowOffsetY = this._targetOffsetY;
this._cameraNeedRefresh = true;
};
// 设置焦点坐标,目前没有用
this.setTarget = function (x, y) {
this._targetOffsetX = x;
this._targetOffsetY = y;
};
// 请求镜头更新
this.requestCameraUpdate = function () {
this._cameraNeedRefresh = true;
};
// 更新焦点坐标,目前仅根据大地图偏移决定
this.updateTargetPosition = function () {
this._targetOffsetX = core.bigmap.offsetX;
this._targetOffsetY = core.bigmap.offsetY;
};
// 更新额外的刷新条件,即镜头未指向焦点时
this.updateRefreshFlag = function () {
if (this._nowOffsetX != this._targetOffsetX || this._nowOffsetY != this._targetOffsetY) {
this._cameraNeedRefresh = true;
}
};
// 判断是否禁止了弹性滚动
this.canDirectMove = function () {
return !core.getFlag(this.__switchName, true);
};
// 更新镜头坐标
this.updateCameraPosition = function () {
if (this._cameraNeedRefresh) {
this._cameraNeedRefresh = false;
var disX = this._targetOffsetX - this._nowOffsetX;
var disY = this._targetOffsetY - this._nowOffsetY;
if (Math.abs(disX) <= 2 && Math.abs(disY) <= 2 || this.canDirectMove()) {
this._nowOffsetX = this._targetOffsetX;
this._nowOffsetY = this._targetOffsetY;
} else {
this._nowOffsetX += disX / 10;
this._nowOffsetY += disY / 10;
}
var x = -Math.floor(this._nowOffsetX);
var y = -Math.floor(this._nowOffsetY);
core.bigmap.canvas.forEach(function (cn) {
core.control.setGameCanvasTranslate(cn, x, y);
});
core.relocateCanvas('route', core.status.automaticRoute.offsetX + x, core.status.automaticRoute.offsetY + y);
core.setGameCanvasTranslate('hero', x + this._targetOffsetX, y + this._targetOffsetY);
}
};
// 更新逻辑主体
this.update = function () {
this.updateTargetPosition();
this.updateRefreshFlag();
this.updateCameraPosition();
};
};
// 创建摄像机对象
this.camera = new this.Camera();
// 帧事件 更新摄像机
this.updateCameraEx = function () {
this.camera.update();
};
core.control._drawHero_updateViewport = function () {
core.control.updateViewport();
}
// 代理原本的镜头事件
core.control.updateViewport = function () {
core.plugin.camera.requestCameraUpdate();
};
// 更变楼层的行为追加,重置镜头
core.events.changingFloor = function (floorId, heroLoc) {
this.eventdata.changingFloor(floorId, heroLoc);
core.plugin.camera.resetCamera();
};
// 注册帧事件
core.registerAnimationFrame('smoothCameraFlash', true, this.updateCameraEx.bind(this));
} }
} }

51
runtime.d.ts vendored
View File

@ -149,8 +149,10 @@ type gameStatus = {
thisMap: ResolvedMap thisMap: ResolvedMap
bgmaps: { [key: string]: number[][] } bgmaps: { [key: string]: number[][] }
fgmaps: { [key: string]: number[][] } fgmaps: { [key: string]: number[][] }
mapBlockObjs: { [key: string]: any }
/** 显伤伤害 */ /** 显伤伤害 */
checkBlock: {} checkBlock: {}
damage: {}
lockControl: boolean lockControl: boolean
@ -230,12 +232,7 @@ type gameStatus = {
globalAnimateObjs: [] globalAnimateObjs: []
floorAnimateObjs: [] floorAnimateObjs: []
boxAnimateObjs: [] boxAnimateObjs: []
autotileAnimateObjs: { autotileAnimateObjs: []
blocks: [],
map: any
bgmap: any
fgmap: null
}
globalAnimateStatus: number globalAnimateStatus: number
animateObjs: [] animateObjs: []
} }
@ -393,13 +390,16 @@ declare class control {
nearHero(x: number, y: number, n?: number): boolean nearHero(x: number, y: number, n?: number): boolean
/** /**
* *
* @example core.updateDamage(); // 更新当前地图的显伤,绘制在显伤层(废话) * @example core.updateDamage(); // 更新当前地图的显伤,绘制在显伤层(废话)
* @param floorId id * @param floorId id
* @param ctx * @param ctx
*/ */
updateDamage(floorId?: string, ctx?: CanvasRenderingContext2D): void updateDamage(floorId?: string, ctx?: CanvasRenderingContext2D): void
/** 仅重绘地图显伤 */
drawDamage(ctx?: CanvasRenderingContext2D): void
/** /**
* *
* @example core.setStatus('loc', {x : 0, y : 0, direction : 'up'}); // 设置主角位置为地图左上角,脸朝上 * @example core.setStatus('loc', {x : 0, y : 0, direction : 'up'}); // 设置主角位置为地图左上角,脸朝上
@ -1410,7 +1410,10 @@ declare class maps {
* @param showDisable true表示隐藏的图块也会被表示出来 * @param showDisable true表示隐藏的图块也会被表示出来
* @returns 访[y][x] * @returns 访[y][x]
*/ */
getMapArray(floorId?: string): number[][] getMapArray(floorId?: string, noCache?: boolean): number[][]
/** 判定图块的事件层数字不存在为0 */
getMapNumber(floorId?: string, noCache?: boolean): number
/** /**
* *
@ -1454,12 +1457,9 @@ declare class maps {
* *
* @example core.generateMovableArray(); // 判断当前地图主角从各点能向何方向移动 * @example core.generateMovableArray(); // 判断当前地图主角从各点能向何方向移动
* @param floorId id * @param floorId id
* @param x * @returns
* @param y
* @param direction 使
* @returns
*/ */
generateMovableArray(floorId?: string, x?: number, y?: number, direction?: direction): boolean | Array<direction | Array<Array<direction>>> generateMovableArray(floorId?: string): Array<Array<Array<direction>>>
/** /**
* *
@ -1529,9 +1529,8 @@ declare class maps {
* @param floorId id * @param floorId id
* @param blocks * @param blocks
* @param options flags用于存读档 * @param options flags用于存读档
* @param toDraw ctx或还有其他信息
*/ */
drawThumbnail(floorId?: string, blocks?: Block[], options?: object, toDraw?: string | CanvasRenderingContext2D | object): void drawThumbnail(floorId?: string, blocks?: Block[], options?: object): void
/** /**
* cannotIn属性 * cannotIn属性
@ -1554,6 +1553,9 @@ declare class maps {
*/ */
getBlockId(x: number, y: number, floorId?: string, showDisable?: boolean): string | null getBlockId(x: number, y: number, floorId?: string, showDisable?: boolean): string | null
/** 判定某个点的图块数字空图块为0 */
getBlockNumber(x: number, y: number, floorId?: string, showDisable?: boolean): number
/** /**
* *
* @example if(core.getBlockCls(x1, y1) != 'enemys' && core.getBlockCls(x2, y2) != 'enemy48') core.openDoor(x3, y3); // 另一个简单的机关门事件,打败或炸掉这一对不同身高的敌人就开门 * @example if(core.getBlockCls(x1, y1) != 'enemys' && core.getBlockCls(x2, y2) != 'enemy48') core.openDoor(x3, y3); // 另一个简单的机关门事件,打败或炸掉这一对不同身高的敌人就开门
@ -1709,6 +1711,9 @@ declare class maps {
loadFloor(floorId?: string, map?: any): any loadFloor(floorId?: string, map?: any): any
/** 根据需求解析出blocks */ /** 根据需求解析出blocks */
extractBlocks(map?: any): void
/** 根据需求为UI解析出blocks */
extractBlocks(map?: any, flags?: any): void extractBlocks(map?: any, flags?: any): void
/** 根据数字获得图块 */ /** 根据数字获得图块 */
@ -1721,7 +1726,7 @@ declare class maps {
getIdOfThis(id?: string): string getIdOfThis(id?: string): string
/** 初始化一个图块 */ /** 初始化一个图块 */
initBlock(x?: number, y?: number, id?: string | number, addInfo?: boolean, eventFloor?: any, flags?: any): any initBlock(x?: number, y?: number, id?: string | number, addInfo?: boolean, eventFloor?: any): any
/** 压缩地图 */ /** 压缩地图 */
compressMap(mapArr?: any, floorId?: string): any compressMap(mapArr?: any, floorId?: string): any
@ -1739,7 +1744,7 @@ declare class maps {
resizeMap(floorId?: string): void resizeMap(floorId?: string): void
/** 以x,y的形式返回每个点的事件 */ /** 以x,y的形式返回每个点的事件 */
getMapBlocksObj(floorId?: string, showDisable?: any): any getMapBlocksObj(floorId?: string, noCache?: boolean): any
/** 获得某些点可否通行的信息 */ /** 获得某些点可否通行的信息 */
canMoveDirectlyArray(locs?: any): any canMoveDirectlyArray(locs?: any): any
@ -1766,7 +1771,7 @@ declare class maps {
enemyExists(x?: number, y?: number, id?: string, floorId?: string): boolean enemyExists(x?: number, y?: number, id?: string, floorId?: string): boolean
/** 获得某个点的block */ /** 获得某个点的block */
getBlock(x?: number, y?: number, floorId?: string, showDisable?: boolean): any getBlock(x?: number, y?: number, floorId?: string, showDisable?: boolean): Block
/** 获得某个图块或素材的信息包括IDcls图片坐标faceIds等等 */ /** 获得某个图块或素材的信息包括IDcls图片坐标faceIds等等 */
getBlockInfo(block?: any): any getBlockInfo(block?: any): any
@ -2372,6 +2377,9 @@ declare class utils {
*/ */
clone<T>(data?: T, filter?: (name: string, value: any) => boolean, recursion?: boolean): T clone<T>(data?: T, filter?: (name: string, value: any) => boolean, recursion?: boolean): T
/** 深拷贝一个1D或2D的数组 */
cloneArray(data?: Array<number>|Array<Array<number>>): Array<number>|Array<Array<number>>
/** /**
* *
* @example core.splitImage(core.material.images.images['npc48.png'], 32, 48); // 把npc48.png切分成若干32×48px的小人 * @example core.splitImage(core.material.images.images['npc48.png'], 32, 48); // 把npc48.png切分成若干32×48px的小人
@ -2748,9 +2756,16 @@ type core = {
canvas: string[], canvas: string[],
offsetX: number // in pixel offsetX: number // in pixel
offsetY: number offsetY: number
posX: number
posY: number
width: number // map width and height width: number // map width and height
height: number height: number
v2: boolean
threshold: number
extend: number
scale: number
tempCanvas: CanvasRenderingContext2D // A temp canvas for drawing tempCanvas: CanvasRenderingContext2D // A temp canvas for drawing
cacheCanvas: CanvasRenderingContext2D
} }
saves: { saves: {
saveIndex: number saveIndex: number