循环式地图

This commit is contained in:
unanmed 2023-01-04 16:23:26 +08:00
parent 479cc6fe0f
commit ae3d62211e
17 changed files with 664 additions and 961 deletions

View File

@ -19,6 +19,7 @@ control.prototype._init = function () {
this.weathers = {};
this.resizes = [];
this.noAutoEvents = true;
this.updateNextFrame = false;
// --- 注册系统的animationFrame
this.registerAnimationFrame(
'totalTime',
@ -3862,16 +3863,23 @@ control.prototype.clearStatusBar = function () {
////// 更新状态栏 //////
control.prototype.updateStatusBar = function (doNotCheckAutoEvents, immediate) {
if (!core.isPlaying()) return;
if (immediate) {
return this.updateStatusBar_update();
}
if (!doNotCheckAutoEvents) this.noAutoEvents = false;
if (core.isReplaying()) return this.updateStatusBar_update();
requestAnimationFrame(this.updateStatusBar_update);
if (!core.control.updateNextFrame) {
core.control.updateNextFrame = true;
requestAnimationFrame(this.updateStatusBar_update);
}
};
control.prototype.updateStatusBar_update = function () {
if (!core.isPlaying() || core.hasFlag('__statistics__')) return;
core.control.updateNextFrame = false;
if (!core.isPlaying() || core.hasFlag('__statistics__')) {
return;
}
core.control.controldata.updateStatusBar();
if (!core.control.noAutoEvents) core.checkAutoEvents();
core.control._updateStatusBar_setToolboxIcon();

View File

@ -3186,13 +3186,13 @@ maps.prototype.removeBlock = function (x, y, floorId) {
if (!floorId) return false;
core.extractBlocks(floorId);
for (var i in core.status.maps[floorId].blocks) {
var block = core.status.maps[floorId].blocks[i];
if (block.x == x && block.y == y) {
this.removeBlockByIndex(i, floorId);
this._removeBlockFromMap(floorId, block);
return true;
}
const blocks = core.status.maps[floorId].blocks;
const i = blocks.findIndex(v => v.x === x && v.y === y);
if (i !== -1) {
const block = blocks[i];
this.removeBlockByIndex(i, floorId);
this._removeBlockFromMap(floorId, block);
return true;
}
return false;
};
@ -3295,7 +3295,7 @@ maps.prototype._triggerFloorImage = function (type, loc, floorId, callback) {
};
////// 改变图块 //////
maps.prototype.setBlock = function (number, x, y, floorId) {
maps.prototype.setBlock = function (number, x, y, floorId, noredraw) {
floorId = floorId || core.status.floorId;
if (!floorId || number == null || x == null || y == null) return;
if (
@ -3334,7 +3334,7 @@ maps.prototype.setBlock = function (number, x, y, floorId) {
// 有任何一个是autotile直接重绘地图
if (
(originEvent != null && originEvent.cls == 'autotile') ||
block.event.cls == 'autotile'
(block.event.cls == 'autotile' && !noredraw)
) {
core.redrawMap();
} else {
@ -3346,8 +3346,10 @@ maps.prototype.setBlock = function (number, x, y, floorId) {
});
}
if (!block.disable) {
core.drawBlock(block);
core.addGlobalAnimate(block);
if (!noredraw) {
core.drawBlock(block);
core.addGlobalAnimate(block);
}
core.updateStatusBar();
}
}

View File

@ -279,12 +279,7 @@ main.prototype.init = function (mode, callback) {
main.core.resize();
// 自动放缩最大化
if (core.getLocalStorage('autoScale') == null) {
if (
!data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.flags
.autoScale
)
core.setLocalStorage('autoScale', false);
else core.setLocalStorage('autoScale', true);
core.setLocalStorage('autoScale', true);
}
if (
core.getLocalStorage('autoScale') &&

View File

@ -139,6 +139,12 @@ main.floors.tower1=
],
"time": 500
}
],
"13,1": [
{
"type": "function",
"function": "function(){\nconsole.trace()\n}"
}
]
},
"afterBattle": {},
@ -220,14 +226,14 @@ main.floors.tower1=
"0,7": {
"floorId": "tower6",
"loc": [
18,
24,
58
]
},
"14,7": {
"floorId": "tower6",
"loc": [
6,
12,
58
]
},

View File

@ -72,7 +72,7 @@ main.floors.tower2=
"7,14": {
"floorId": "tower6",
"loc": [
12,
18,
42
]
},

View File

@ -1,74 +1,86 @@
main.floors.tower4 = {
floorId: 'tower4',
title: '智慧之塔',
name: '4',
width: 15,
height: 15,
canFlyTo: true,
canFlyFrom: true,
canUseQuickShop: true,
cannotViewMap: false,
images: [],
ratio: 2,
defaultGround: 'T526',
bgm: 'tower.mp3',
firstArrive: [],
eachArrive: [],
parallelDo: '',
events: {},
afterBattle: {},
afterGetItem: {},
afterOpenDoor: {},
autoEvent: {},
cannotMove: {},
map: [
[
527, 527, 527, 527, 527, 527, 527, 543, 527, 527, 527, 527, 527,
527, 527
],
[527, 31, 31, 536, 0, 528, 0, 547, 0, 31, 0, 544, 0, 381, 527],
[527, 31, 31, 528, 28, 492, 29, 528, 528, 0, 28, 528, 0, 528, 527],
[527, 528, 528, 528, 0, 528, 28, 34, 492, 492, 528, 528, 547, 0, 527],
[527, 381, 0, 550, 0, 528, 528, 528, 528, 0, 31, 528, 0, 528, 527],
[527, 0, 528, 0, 528, 528, 31, 0, 536, 27, 0, 556, 381, 378, 527],
[527, 0, 528, 27, 0, 544, 0, 403, 0, 528, 528, 0, 528, 528, 527],
[
527, 550, 528, 528, 528, 528, 492, 528, 550, 528, 34, 381, 556, 376,
527
],
[527, 0, 0, 31, 492, 88, 403, 528, 31, 528, 27, 32, 528, 0, 527],
[527, 528, 528, 0, 528, 403, 34, 547, 0, 492, 492, 528, 528, 556, 527],
[527, 0, 528, 546, 528, 528, 546, 528, 528, 528, 0, 28, 0, 0, 527],
[527, 0, 544, 32, 0, 536, 32, 528, 32, 0, 536, 528, 528, 556, 527],
[527, 27, 492, 0, 27, 528, 27, 492, 0, 528, 528, 528, 0, 0, 527],
[527, 31, 528, 32, 0, 528, 32, 546, 0, 494, 87, 381, 28, 0, 527],
[
527, 527, 527, 527, 527, 527, 527, 540, 527, 527, 527, 527, 527,
527, 527
]
],
beforeBattle: {},
bgmap: [],
fgmap: [],
bg2map: [],
fg2map: [],
cannotMoveIn: {},
changeFloor: {
'5,8': {
floorId: 'tower3',
loc: [5, 8]
main.floors.tower4=
{
"floorId": "tower4",
"title": "智慧之塔",
"name": "4",
"width": 15,
"height": 15,
"canFlyTo": true,
"canFlyFrom": true,
"canUseQuickShop": true,
"cannotViewMap": false,
"images": [],
"ratio": 2,
"defaultGround": "T526",
"bgm": "tower.mp3",
"firstArrive": [],
"eachArrive": [],
"parallelDo": "",
"events": {},
"afterBattle": {},
"afterGetItem": {},
"afterOpenDoor": {},
"autoEvent": {},
"cannotMove": {},
"map": [
[527,527,527,527,527,527,527,543,527,527,527,527,527,527,527],
[527, 31, 31,536, 0,528, 0,547, 0, 31, 0,544, 0,381,527],
[527, 31, 31,528, 28,492, 29,528,528, 0, 28,528, 0,528,527],
[527,528,528,528, 0,528, 28, 34,492,492,528,528,547, 0,527],
[527,381, 0,550, 0,528,528,528,528, 0, 31,528, 0,528,527],
[527, 0,528, 0,528,528, 31, 0,536, 27, 0,556,381,378,527],
[527, 0,528, 27, 0,544, 0,403, 0,528,528, 0,528,528,527],
[527,550,528,528,528,528,492,528,550,528, 34,381,556,376,527],
[527, 0, 0, 31,492, 88,403,528, 31,528, 27, 32,528, 0,527],
[527,528,528, 0,528,403, 34,547, 0,492,492,528,528,556,527],
[527, 0,528,546,528,528,546,528,528,528, 0, 28, 0, 0,527],
[527, 0,544, 32, 0,536, 32,528, 32, 0,536,528,528,556,527],
[527, 27,492, 0, 27,528, 27,492, 0,528,528,528, 0, 0,527],
[527, 31,528, 32, 0,528, 32,546, 0,494, 87,381, 28, 0,527],
[527,527,527,527,527,527,527,540,527,527,527,527,527,527,527]
],
"beforeBattle": {},
"bgmap": [
],
"fgmap": [
],
"bg2map": [
],
"fg2map": [
],
"cannotMoveIn": {},
"changeFloor": {
"5,8": {
"floorId": "tower3",
"loc": [
5,
8
]
},
'7,0': {
floorId: 'tower6',
loc: [1, 15]
"7,0": {
"floorId": "tower6",
"loc": [
7,
15
]
},
'7,14': {
floorId: 'tower6',
loc: [12, 15]
"7,14": {
"floorId": "tower6",
"loc": [
18,
15
]
},
'10,13': {
floorId: 'tower5',
loc: [10, 13]
"10,13": {
"floorId": "tower5",
"loc": [
10,
13
]
}
}
};
}

View File

@ -79,7 +79,7 @@ main.floors.tower5=
"14,7": {
"floorId": "tower6",
"loc": [
18,
24,
2
]
},

File diff suppressed because it is too large Load Diff

View File

@ -148,9 +148,9 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
heroLoc.direction = core.turnDirection(heroLoc.direction);
core.status.hero.loc = heroLoc;
// tower6
if (floorId == 'tower6') {
core.relocateLoopMap(floorId, heroLoc);
}
// if (floorId == 'tower6') {
// core.relocateLoopMap(floorId, heroLoc);
// }
// 检查重生怪并重置
if (!fromLoad) {
core.extractBlocks(floorId);
@ -174,11 +174,6 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
// ---------- 重绘新地图这一步将会设置core.status.floorId ---------- //
core.drawMap(floorId);
if (floorId == 'tower6') core.backgroundImage('tower6.jpeg');
else {
core.deleteCanvas('bImage');
core.deleteCanvas('eImage');
}
// 切换楼层BGM
if (core.status.maps[floorId].bgm) {
@ -186,9 +181,6 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
if (bgm instanceof Array) bgm = bgm[0];
if (!core.hasFlag('__bgm__')) core.playBgm(bgm);
}
// if (flags.chase && fromLoad) {
// core.startChase();
// }
// 更改画面色调
var color = core.getFlag('__color__', null);
if (!color && core.status.maps[floorId].color)
@ -200,8 +192,8 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
'curtain',
0,
0,
core.__PIXELS__,
core.__PIXELS__,
core._PX_,
core._PY_,
core.arrayToRGBA(color)
);
// 更改天气
@ -1773,6 +1765,8 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
);
}
core.checkLoopMap();
// 追猎
if (core.status.checkBlock.haveHunt) {
var x = core.status.hero.loc.x,

View File

@ -3684,6 +3684,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = {
};
control.prototype.updateStatusBar_update = function () {
core.control.updateNextFrame = false;
if (!core.isPlaying() || core.hasFlag('__statistics__')) return;
core.control.controldata.updateStatusBar();
if (!core.control.noAutoEvents) core.checkAutoEvents();
@ -4028,5 +4029,255 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = {
this.loadSkillTree = function (data) {
levels = data ?? [];
};
},
loopMap: function () {
const list = (this.loopMapList = ['tower6']);
/**
* 设置循环地图的偏移量
* @param {number} offset 横向偏移量
* @param {FloorIds} floorId
*/
this.setLoopMap = function (offset, floorId) {
const floor = core.status.maps[floorId];
if (offset < 9) {
moveMap(floor.width - 17, floorId);
}
if (offset > floor.width - 9) {
moveMap(17 - floor.width, floorId);
}
};
/**
* 当勇士移动时自动设置循环地图
* @param {FloorIds} floorId
*/
this.autoSetLoopMap = function (floorId) {
this.setLoopMap(core.status.hero.loc.x, floorId);
};
this.checkLoopMap = function () {
if (isLoopMap(core.status.floorId)) {
this.autoSetLoopMap(core.status.floorId);
}
};
/**
* 滑动数组
* @param {any[]} arr
* @param {number} delta
*/
this.slide = function (arr, delta) {
if (delta === 0) return arr;
if (delta > 0) {
arr.unshift(...arr.splice(arr.length - delta, delta));
return arr;
}
if (delta < 0) {
arr.push(...arr.splice(0, -delta));
return arr;
}
};
/**
* 移动地图
* @param {number} delta
* @param {FloorIds} floorId
*/
function moveMap(delta, floorId) {
core.extractBlocks(floorId);
const floor = core.status.maps[floorId];
core.setHeroLoc('x', core.status.hero.loc.x + delta);
flags[`loop_${floorId}`] += delta;
flags[`loop_${floorId}`] %= floor.width;
const origin = floor.blocks.slice();
for (let i = 0; i < origin.length; i++) {
core.removeBlockByIndex(0, floorId);
core.removeGlobalAnimate(origin[i].x, origin[i].y);
}
origin.forEach(v => {
let to = v.x + delta;
if (to >= floor.width) to -= floor.width;
if (to < 0) to += floor.width;
core.setBlock(v.id, to, v.y, floorId, true);
core.setMapBlockDisabled(floorId, to, v.y, false);
});
core.drawMap();
core.drawHero();
}
function isLoopMap(floorId) {
return list.includes(floorId);
}
events.prototype._sys_changeFloor = function (data, callback) {
data = data.event.data;
let heroLoc = {};
if (isLoopMap(data.floorId)) {
const floor = core.status.maps[data.floorId];
flags[`loop_${data.floorId}`] ??= 0;
let tx = data.loc[0] + flags[`loop_${data.floorId}`];
tx %= floor.width;
if (tx < 0) tx += floor.width;
console.log(data.loc[0], tx);
heroLoc = {
x: tx,
y: data.loc[1]
};
} else if (data.loc) heroLoc = { x: data.loc[0], y: data.loc[1] };
if (data.direction) heroLoc.direction = data.direction;
if (core.status.event.id != 'action') core.status.event.id = null;
core.changeFloor(
data.floorId,
data.stair,
heroLoc,
data.time,
function () {
core.replay();
if (callback) callback();
}
);
};
events.prototype.trigger = function (x, y, callback) {
var _executeCallback = function () {
// 因为trigger之后还有可能触发其他同步脚本比如阻激夹域检测
// 所以这里强制callback被异步触发
if (callback) {
setTimeout(callback, 1); // +1是为了录像检测系统
}
return;
};
if (core.status.gameOver) return _executeCallback();
if (core.status.event.id == 'action') {
core.insertAction(
{
type: 'function',
function:
'function () { core.events._trigger_inAction(' +
x +
',' +
y +
'); }',
async: true
},
null,
null,
null,
true
);
return _executeCallback();
}
if (core.status.event.id) return _executeCallback();
let block = core.getBlock(x, y);
const id = core.status.floorId;
const loop = isLoopMap(id);
if (loop) {
if (block && block.event.trigger === 'changeFloor') {
delete block.event.trigger;
core.maps._addInfo(block);
} else {
const floor = core.status.maps[id];
let tx = x - flags[`loop_${id}`];
tx %= floor.width;
if (tx < 0) tx += floor.width;
const c = core.floors[id].changeFloor[`${tx},${y}`];
if (c) {
const b = { event: {}, x: tx, y };
b.event.data = c;
b.event.trigger = 'changeFloor';
block = b;
}
}
}
if (block == null) return _executeCallback();
// 执行该点的脚本
if (block.event.script) {
core.clearRouteFolding();
try {
eval(block.event.script);
} catch (ee) {
console.error(ee);
}
}
// 碰触事件
if (block.event.event) {
core.clearRouteFolding();
core.insertAction(block.event.event, block.x, block.y);
// 不再执行该点的系统事件
return _executeCallback();
}
if (block.event.trigger && block.event.trigger != 'null') {
var noPass = block.event.noPass,
trigger = block.event.trigger;
if (noPass) core.clearAutomaticRouteNode(x, y);
// 转换楼层能否穿透
if (
trigger == 'changeFloor' &&
!noPass &&
this._trigger_ignoreChangeFloor(block) &&
!loop
)
return _executeCallback();
core.status.automaticRoute.moveDirectly = false;
this.doSystemEvent(trigger, block);
}
return _executeCallback();
};
maps.prototype._getBgFgMapArray = function (name, floorId, noCache) {
floorId = floorId || core.status.floorId;
if (!floorId) return [];
var width = core.floors[floorId].width;
var height = core.floors[floorId].height;
if (!noCache && core.status[name + 'maps'][floorId])
return core.status[name + 'maps'][floorId];
var arr =
main.mode == 'editor' &&
!(window.editor && editor.uievent && editor.uievent.isOpen)
? core.cloneArray(editor[name + 'map'])
: null;
if (arr == null)
arr = core.cloneArray(core.floors[floorId][name + 'map'] || []);
if (isLoopMap(floorId) && window.flags) {
flags[`loop_${floorId}`] ??= 0;
arr.forEach(v => {
core.slide(v, flags[`loop_${floorId}`] % width);
});
}
for (var y = 0; y < height; ++y) {
if (arr[y] == null) arr[y] = Array(width).fill(0);
}
(core.getFlag('__' + name + 'v__', {})[floorId] || []).forEach(
function (one) {
arr[one[1]][one[0]] = one[2] || 0;
}
);
(core.getFlag('__' + name + 'd__', {})[floorId] || []).forEach(
function (one) {
arr[one[1]][one[0]] = 0;
}
);
if (main.mode == 'editor') {
for (var x = 0; x < width; x++) {
for (var y = 0; y < height; y++) {
arr[y][x] = arr[y][x].idnum || arr[y][x] || 0;
}
}
}
if (core.status[name + 'maps'])
core.status[name + 'maps'][floorId] = arr;
return arr;
};
}
};

View File

@ -298,14 +298,15 @@
"注意,拖动时,滑动条左边会显示当前的加攻或加防次数,这个数值指的是在勇士所在地图中需要吃的最弱的宝石数量。",
"例如当前勇士所在地图中最弱的宝石加2点攻击加攻次数为3那么勇士的攻击增加量就为6。",
"勇士增加的攻击数值也会在下方显示。当加攻次数和加防次数改变时,折线图也会变化。",
"当前状态下怪物的伤害以及减伤总量也会在下方显示。",
"当前状态下怪物的伤害以及减伤总量也会在下方显示。<span style=\"color: gold\">",
"注意在此栏中无法通过点击屏幕回到怪物手册界面,更多信息请查看最后一段</span>。",
"<br>",
"<br>",
"在特殊属性栏,点击下方的怪物更多信息可以进入更多信息栏。此栏中,你可以查看怪物描述。但这不是这一栏的核心功能。",
"这一栏的核心功能是标记怪物。被标记的怪物会有一些非常方便的行为,这些行为可以在“标记怪物”条目中查看。",
"<br>",
"<br>",
"注意,在怪物详细信息中,只有特殊属性栏可以通过点击屏幕返回到怪物手册界面,详细临界与更多信息栏均不行。",
"注意,在怪物详细信息中,除详细临界栏外均可以通过点击屏幕返回到怪物手册界面。",
"如果你是电脑端,在任意栏目中<span style=\"color: gold\">按下X键</span>会退出怪物手册,返回游戏,",
"<span style=\"color: gold\">按下回车Enter键</span>会回到怪物手册界面。"
]

View File

@ -14,7 +14,7 @@
:style="{ color: marked ? 'lightgreen' : 'lightcoral' }"
>{{ marked ? '已标记该怪物' : '未标记该怪物' }}</span
>
<span class="button-text" @click="mark">{{
<span class="button-text" @click.stop="mark">{{
marked ? '取消标记该怪物' : '标记该怪物为目标'
}}</span>
</div>

View File

@ -1,4 +1,5 @@
import { ref, watch } from 'vue';
import { has } from './utils';
/**
* ui时是否展示动画
@ -44,12 +45,16 @@ watch(autoScale, n => {
* localStorage读取即可
*/
function reset() {
transition.value = core.getLocalStorage('transition') ? true : false;
const t = core.getLocalStorage('transition', false);
transition.value = t;
core.plugin.transition.value = transition.value;
autoScale.value = core.getLocalStorage('autoScale') ? true : false;
autoScale.value = core.getLocalStorage('autoScale', true);
}
function resetFlag() {
flags.autoSkill ??= true;
flags.itemDetail ??= true;
itemDetail.value = flags.itemDetail ? true : false;
autoSkill.value = flags.autoSkill ? true : false;
}

4
src/types/map.d.ts vendored
View File

@ -1170,12 +1170,14 @@ interface Maps {
* @param x
* @param y
* @param floorId id
* @param noredraw
*/
setBlock(
number: AllIds | AllNumbers | `${AllNumbers}`,
x: number,
y: number,
floorId?: FloorIds
floorId?: FloorIds,
noredraw?: boolean
): void;
/**

10
src/types/plugin.d.ts vendored
View File

@ -120,6 +120,13 @@ interface PluginUtils {
* @param isStart
*/
autoFixRouteBoss(isStart?: boolean);
/**
*
* @param arr
* @param delta
*/
slide<T>(arr: T[], delta: number): T[];
}
interface PluginUis {
@ -165,6 +172,9 @@ interface PluginUis {
/** 楼传界面是否打开 */
readonly flyOpened: Ref<boolean>;
/** 是否展示标记的怪物 */
readonly showMarkedEnemy: Ref<boolean>;
/** ui栈 */
readonly uiStack: Ref<Component[]>;

View File

@ -618,17 +618,17 @@ interface InitGameStatus {
/**
*
*/
bgmaps: Record<string, number[][]>;
bgmaps: Record<FloorIds, number[][]>;
/**
*
*/
fgmaps: Record<string, number[][]>;
fgmaps: Record<FloorIds, number[][]>;
/**
*
*/
mapBlockObjs: Record<string, Record<LocString, Block>>;
mapBlockObjs: Record<FloorIds, Record<LocString, Block>>;
/**
*

View File

@ -124,7 +124,7 @@ onMounted(async () => {
if (y > (parseFloat(style.height) * 4) / 5) moved = true;
},
() => {
if (moved === false && panel.value === 'special') {
if (moved === false && panel.value !== 'critical') {
close();
}
moved = false;