插件转为es模块

This commit is contained in:
unanmed 2023-04-16 17:05:47 +08:00
parent d56e54135a
commit 81f6815429
25 changed files with 3265 additions and 3391 deletions

View File

@ -28,14 +28,14 @@
#### 技能
闪避:每 M 回合闪避一次,减少 N%的伤害
闪避:每 M 回合闪避一次,减少 N% 的伤害
## 机制
### 通用
- 实时天气
- 成就系统
- 成就系统(完成)
- 装备合成、装备(孔)强化
- 宝石目标设定
- 自动宝物规划,选中两个或更多宝物后自动在本地图中规划出最优拾取路线,原则是尽量减少其余宝物的捡拾,自动切换主动技能,怪物造成的伤害最低的路线

View File

@ -5,9 +5,9 @@
"type": "module",
"scripts": {
"dev": "vite",
"build": "vue-tsc && vite build && ts-node-esm script/compress.ts",
"build-gh": "vue-tsc && vite build --base=/HumanBreak/ && ts-node-esm script/compress.ts",
"build-local": "vue-tsc && vite build --base=/ && ts-node-esm script/compress.ts",
"build": "vue-tsc && vite build && ts-node-esm script/build.ts",
"build-gh": "vue-tsc && vite build --base=/HumanBreak/ && ts-node-esm script/build.ts",
"build-local": "vue-tsc && vite build --base=/ && ts-node-esm script/build.ts",
"preview": "vite preview",
"preview-node": "cd dist && node server.cjs",
"update": "ts-node-esm script/update.ts",
@ -42,6 +42,7 @@
"form-data": "^4.0.0",
"fs-extra": "^10.1.0",
"less": "^4.1.3",
"rollup": "^3.20.2",
"terser": "^5.16.9",
"ts-node": "^10.9.1",
"typescript": "^4.9.5",

View File

@ -24,6 +24,7 @@ specifiers:
lodash: ^4.17.21
lz-string: ^1.5.0
mutate-animate: ^1.1.1
rollup: ^3.20.2
terser: ^5.16.9
three: ^0.149.0
ts-node: ^10.9.1
@ -61,10 +62,11 @@ devDependencies:
form-data: 4.0.0
fs-extra: 10.1.0
less: 4.1.3
rollup: 3.20.2
terser: 5.16.9
ts-node: 10.9.1_o6avl3oodj6mwqsx3rm2wfkgv4
typescript: 4.9.5
unplugin-vue-components: 0.22.12_vue@3.2.47
unplugin-vue-components: 0.22.12_rollup@3.20.2+vue@3.2.47
vite: 4.2.1_lu7yuwtv4qfbkrotoux232iypi
vue-tsc: 1.2.0_typescript@4.9.5
@ -1620,7 +1622,7 @@ packages:
rimraf: 3.0.2
dev: true
/@rollup/pluginutils/5.0.2:
/@rollup/pluginutils/5.0.2_rollup@3.20.2:
resolution: {integrity: sha512-pTd9rIsP92h+B6wWwFbW8RkZv4hiR/xKsqre4SIuAOaOEQRxi0lqLke9k2/7WegC85GgUs9pjmOjCUi3In4vwA==}
engines: {node: '>=14.0.0'}
peerDependencies:
@ -1632,6 +1634,7 @@ packages:
'@types/estree': 1.0.0
estree-walker: 2.0.2
picomatch: 2.3.1
rollup: 3.20.2
dev: true
/@simonwep/pickr/1.8.2:
@ -4399,7 +4402,7 @@ packages:
engines: {node: '>= 10.0.0'}
dev: true
/unplugin-vue-components/0.22.12_vue@3.2.47:
/unplugin-vue-components/0.22.12_rollup@3.20.2+vue@3.2.47:
resolution: {integrity: sha512-FxyzsuBvMCYPIk+8cgscGBQ345tvwVu+qY5IhE++eorkyvA4Z1TiD/HCiim+Kbqozl10i4K+z+NCa2WO2jexRA==}
engines: {node: '>=14'}
peerDependencies:
@ -4410,7 +4413,7 @@ packages:
optional: true
dependencies:
'@antfu/utils': 0.7.2
'@rollup/pluginutils': 5.0.2
'@rollup/pluginutils': 5.0.2_rollup@3.20.2
chokidar: 3.5.3
debug: 4.3.4
fast-glob: 3.2.12

View File

@ -1,9 +1,8 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict';
export {};
(function () {
// 创建新图层
function createCanvas(name, zIndex) {
// 创建新图层
function createCanvas(name, zIndex) {
if (!name) return;
var canvas = document.createElement('canvas');
canvas.id = name;
@ -16,24 +15,16 @@
core.canvas[name] = ctx;
return canvas;
}
}
var bg2Canvas = createCanvas('bg2', 20);
var fg2Canvas = createCanvas('fg2', 63);
// 大地图适配
core.bigmap.canvas = [
'bg2',
'fg2',
'bg',
'event',
'event2',
'fg',
'damage'
];
core.initStatus.bg2maps = {};
core.initStatus.fg2maps = {};
var bg2Canvas = createCanvas('bg2', 20);
var fg2Canvas = createCanvas('fg2', 63);
// 大地图适配
core.bigmap.canvas = ['bg2', 'fg2', 'bg', 'event', 'event2', 'fg', 'damage'];
core.initStatus.bg2maps = {};
core.initStatus.fg2maps = {};
if (main.mode == 'editor') {
if (main.mode == 'editor') {
/*插入编辑器的图层 不做此步新增图层无法在编辑器显示*/
// 编辑器图层覆盖优先级 eui > efg > fg(前景层) > event2(48*32图块的事件层) > event(事件层) > bg(背景层)
// 背景层2(bg2) 插入事件层(event)之前(即bg与event之间)
@ -109,8 +100,8 @@
parent.insertBefore(input, parent.children[1]);
parent.appendChild(input2);
}
}
core.maps._loadFloor_doNotCopy = function () {
}
core.maps._loadFloor_doNotCopy = function () {
return [
'firstArrive',
'eachArrive',
@ -128,9 +119,9 @@
'afterOpenDoor',
'cannotMove'
];
};
////// 绘制背景和前景层 //////
core.maps._drawBg_draw = function (floorId, toDrawCtx, cacheCtx, config) {
};
////// 绘制背景和前景层 //////
core.maps._drawBg_draw = function (floorId, toDrawCtx, cacheCtx, config) {
config.ctx = cacheCtx;
core.maps._drawBg_drawBackground(floorId, config);
// ------ 调整这两行的顺序来控制是先绘制贴图还是先绘制背景图块;后绘制的覆盖先绘制的。
@ -162,8 +153,8 @@
core.bigmap.v2 ? -32 : 0
);
config.ctx = toDrawCtx;
};
core.maps._drawFg_draw = function (floorId, toDrawCtx, cacheCtx, config) {
};
core.maps._drawFg_draw = function (floorId, toDrawCtx, cacheCtx, config) {
config.ctx = cacheCtx;
// ------ 调整这两行的顺序来控制是先绘制贴图还是先绘制前景图块;后绘制的覆盖先绘制的。
core.maps._drawFloorImages(
@ -194,9 +185,9 @@
core.bigmap.v2 ? -32 : 0
);
config.ctx = toDrawCtx;
};
////// 移动判定 //////
core.maps._generateMovableArray_arrays = function (floorId) {
};
////// 移动判定 //////
core.maps._generateMovableArray_arrays = function (floorId) {
return {
bgArray: this.getBgMapArray(floorId),
fgArray: this.getFgMapArray(floorId),
@ -204,5 +195,4 @@
bg2Array: this._getBgFgMapArray('bg2', floorId),
fg2Array: this._getBgFgMapArray('fg2', floorId)
};
};
})();
};

View File

@ -1,13 +1,11 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict';
(function () {
/**
/**
* 绘制光环范围
* @param {CanvasRenderingContext2D} ctx
* @param {boolean} onMap
*/
function drawHalo(ctx, onMap) {
export function drawHalo(ctx, onMap) {
if (main.replayChecking) return;
if (!core.getLocalStorage('showHalo', true)) return;
const halo = core.status.checkBlock.halo;
@ -49,9 +47,8 @@
}
}
ctx.restore();
}
}
core.plugin.halo = {
core.plugin.halo = {
drawHalo
};
})();
};

View File

@ -1,23 +1,21 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict';
(function () {
/**
/**
* 获取勇士在某一点的属性
* @param {keyof HeroStatus | 'all'} name
* @param {number} x
* @param {number} y
* @param {FloorIds} floorId
*/
function getHeroStatusOn(name, x, y, floorId) {
return getRealStatusOf(core.status.hero, name, x, y, floorId);
}
export function getHeroStatusOn(name, x, y, floorId) {
return getHeroStatusOf(core.status.hero, name, x, y, floorId);
}
function getHeroStatusOf(status, name, x, y, floorId) {
export function getHeroStatusOf(status, name, x, y, floorId) {
return getRealStatus(status, name, x, y, floorId);
}
}
function getRealStatus(status, name, x, y, floorId) {
function getRealStatus(status, name, x, y, floorId) {
if (name instanceof Array) {
return Object.fromEntries(
name.map(v => [
@ -78,10 +76,9 @@
// 取整
if (typeof s === 'number') s = Math.floor(s);
return s;
}
}
core.plugin.hero = {
core.plugin.hero = {
getHeroStatusOf,
getHeroStatusOn
};
})();
};

View File

@ -1,13 +1,12 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict';
export {};
(function () {
['up', 'down', 'left', 'right'].forEach(one => {
['up', 'down', 'left', 'right'].forEach(one => {
// 指定中间帧动画
core.material.icons.hero[one].midFoot = 2;
});
});
var heroMoving = timestamp => {
var heroMoving = timestamp => {
if (core.status.heroMoving <= 0) return;
if (timestamp - core.animateFrame.moveTime > core.values.moveSpeed) {
core.animateFrame.leftLeg++;
@ -19,10 +18,10 @@
],
4 * core.status.heroMoving
);
};
core.registerAnimationFrame('heroMoving', true, heroMoving);
};
core.registerAnimationFrame('heroMoving', true, heroMoving);
core.events._eventMoveHero_moving = function (step, moveSteps) {
core.events._eventMoveHero_moving = function (step, moveSteps) {
var curr = moveSteps[0];
var direction = curr[0],
x = core.getHeroLoc('x'),
@ -56,5 +55,4 @@
return step == 16;
}
return false;
};
})();
};

View File

@ -1,5 +1,5 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict';
export {};
(function () {
if (main.mode !== 'play' || main.replayChecking) return;

View File

@ -0,0 +1,32 @@
import './fiveLayer';
import './heroFourFrames';
import './hotReload';
import './itemDetail';
import './popup';
import './replay';
import './ui';
import * as halo from './halo';
import * as hero from './hero';
import * as loopMap from './loopMap';
import * as remainEnemy from './remainEnemy';
import * as removeMap from './removeMap';
import * as shop from './shop';
import * as skill from './skills';
import * as skillTree from './skillTree';
import * as study from './study';
import * as towerBoss from './towerBoss';
import * as utils from './utils';
export {
halo,
hero,
loopMap,
remainEnemy,
removeMap,
shop,
skill,
skillTree,
study,
towerBoss,
utils
};

View File

@ -1,8 +1,7 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict';
export {};
(function () {
core.control.updateDamage = function (floorId, ctx) {
core.control.updateDamage = function (floorId, ctx) {
floorId = floorId || core.status.floorId;
if (!floorId || core.status.gameOver || main.mode != 'play') return;
const onMap = ctx == null;
@ -21,10 +20,10 @@
this._updateDamage_extraDamage(floorId, onMap);
getItemDetail(floorId, onMap); // 宝石血瓶详细信息
this.drawDamage(ctx);
};
};
// 获取宝石信息 并绘制
function getItemDetail(floorId, onMap) {
// 获取宝石信息 并绘制
function getItemDetail(floorId, onMap) {
if (!core.getFlag('itemDetail')) return;
floorId ??= core.status.thisMap.floorId;
let diff = {};
@ -77,10 +76,10 @@
core.status.hero = before;
window.hero = before;
window.flags = before.flags;
}
}
// 绘制
function drawItemDetail(diff, x, y) {
// 绘制
function drawItemDetail(diff, x, y) {
const px = 32 * x + 2,
py = 32 * y + 31;
let content = '';
@ -126,5 +125,4 @@
});
i++;
}
}
})();
}

View File

@ -1,16 +1,14 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict';
import { slide } from './utils';
(function () {
const { slide } = core.plugin.utils;
const list = ['tower6'];
const list = ['tower6'];
/**
/**
* 设置循环地图的偏移量
* @param {number} offset 横向偏移量
* @param {FloorIds} floorId
*/
function setLoopMap(offset, floorId) {
function setLoopMap(offset, floorId) {
const floor = core.status.maps[floorId];
if (offset < 9) {
moveMap(floor.width - 17, floorId);
@ -18,28 +16,28 @@
if (offset > floor.width - 9) {
moveMap(17 - floor.width, floorId);
}
}
}
/**
/**
* 当勇士移动时自动设置循环地图
* @param {FloorIds} floorId
*/
function autoSetLoopMap(floorId) {
function autoSetLoopMap(floorId) {
setLoopMap(core.status.hero.loc.x, floorId);
}
}
function checkLoopMap() {
export function checkLoopMap() {
if (isLoopMap(core.status.floorId)) {
autoSetLoopMap(core.status.floorId);
}
}
}
/**
/**
* 移动地图
* @param {number} delta
* @param {FloorIds} floorId
*/
function moveMap(delta, floorId) {
function moveMap(delta, floorId) {
core.extractBlocks(floorId);
const floor = core.status.maps[floorId];
core.setHeroLoc('x', core.status.hero.loc.x + delta);
@ -59,13 +57,13 @@
});
core.drawMap();
core.drawHero();
}
}
function isLoopMap(floorId) {
function isLoopMap(floorId) {
return list.includes(floorId);
}
}
events.prototype._sys_changeFloor = function (data, callback) {
events.prototype._sys_changeFloor = function (data, callback) {
data = data.event.data;
let heroLoc = {};
if (isLoopMap(data.floorId)) {
@ -81,19 +79,13 @@
} 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.changeFloor(data.floorId, data.stair, heroLoc, data.time, function () {
core.replay();
if (callback) callback();
}
);
};
});
};
events.prototype.trigger = function (x, y, callback) {
events.prototype.trigger = function (x, y, callback) {
var _executeCallback = function () {
// 因为trigger之后还有可能触发其他同步脚本比如阻激夹域检测
// 所以这里强制callback被异步触发
@ -183,9 +175,9 @@
this.doSystemEvent(trigger, block);
}
return _executeCallback();
};
};
maps.prototype._getBgFgMapArray = function (name, floorId, noCache) {
maps.prototype._getBgFgMapArray = function (name, floorId, noCache) {
floorId = floorId || core.status.floorId;
if (!floorId) return [];
var width = core.floors[floorId].width;
@ -212,16 +204,16 @@
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) {
(core.getFlag('__' + name + 'v__', {})[floorId] || []).forEach(function (
one
) {
arr[one[1]][one[0]] = one[2] || 0;
}
);
(core.getFlag('__' + name + 'd__', {})[floorId] || []).forEach(
function (one) {
});
(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++) {
@ -229,12 +221,10 @@
}
}
}
if (core.status[name + 'maps'])
core.status[name + 'maps'][floorId] = arr;
if (core.status[name + 'maps']) core.status[name + 'maps'][floorId] = arr;
return arr;
};
};
core.plugin.loopMap = {
core.plugin.loopMap = {
checkLoopMap
};
})();
};

View File

@ -1,10 +1,9 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict';
export {};
(function () {
// 伤害弹出
// 复写阻激夹域检测
control.prototype.checkBlock = function (forceMockery) {
// 伤害弹出
// 复写阻激夹域检测
control.prototype.checkBlock = function (forceMockery) {
var x = core.getHeroLoc('x'),
y = core.getHeroLoc('y'),
loc = x + ',' + y;
@ -18,9 +17,8 @@
);
core.status.hero.hp -= damage;
var text =
Object.keys(core.status.checkBlock.type[loc] || {}).join(
''
) || '伤害';
Object.keys(core.status.checkBlock.type[loc] || {}).join('') ||
'伤害';
core.drawTip('受到' + text + damage + '点');
core.drawHeroAnimate('zone');
this._checkBlock_disableQuickShop();
@ -36,9 +34,9 @@
}
this._checkBlock_repulse(core.status.checkBlock.repulse[loc]);
checkMockery(loc, forceMockery);
};
};
control.prototype.moveHero = function (direction, callback) {
control.prototype.moveHero = function (direction, callback) {
// 如果正在移动直接return
if (core.status.heroMoving != 0) return;
if (core.isset(direction)) core.setHeroLoc('direction', direction);
@ -51,14 +49,14 @@
if (callback) return this.moveAction(callback);
this._moveHero_moving();
};
};
/**
/**
* 电摇嘲讽
* @param {LocString} loc
* @param {boolean} force
*/
function checkMockery(loc, force) {
function checkMockery(loc, force) {
if (core.status.lockControl && !force) return;
const mockery = core.status.checkBlock.mockery[loc];
if (mockery) {
@ -66,8 +64,7 @@
const action = [];
const [tx, ty] = mockery[0];
let { x, y } = core.status.hero.loc;
const dir =
x > tx ? 'left' : x < tx ? 'right' : y > ty ? 'up' : 'down';
const dir = x > tx ? 'left' : x < tx ? 'right' : y > ty ? 'up' : 'down';
const { x: dx, y: dy } = core.utils.scan[dir];
action.push({ type: 'changePos', direction: dir });
@ -120,5 +117,4 @@
action.push({ type: 'stopAsync' });
core.insertAction(action);
}
}
})();
}

View File

@ -1,12 +1,10 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict';
(function () {
/**
/**
* 检查漏怪
* @param {FloorIds[]} floorIds
*/
function checkRemainEnemy(floorIds) {
export function checkRemainEnemy(floorIds) {
/**
* @type {Record<FloorIds, {loc: LocArr, id: EnemyIds}[]>}
*/
@ -15,8 +13,7 @@
core.extractBlocks(v);
const blocks = core.status.maps[v].blocks;
blocks.forEach(block => {
if (!block.event.cls.startsWith('enemy') || block.disable)
return;
if (!block.event.cls.startsWith('enemy') || block.disable) return;
/**
* @type {EnemyIds}
*/
@ -27,13 +24,13 @@
});
});
return enemy;
}
}
/**
/**
* 获取剩余怪物字符串
* @param {FloorIds[]} floorIds
*/
function getRemainEnemyString(floorIds) {
export function getRemainEnemyString(floorIds) {
const enemy = checkRemainEnemy(floorIds);
const str = [];
let now = [];
@ -67,10 +64,9 @@
}
return str;
}
}
core.plugin.remainEnemy = {
core.plugin.remainEnemy = {
checkRemainEnemy,
getRemainEnemyString
};
})();
};

View File

@ -1,8 +1,6 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict';
(function () {
function removeMaps(fromId, toId, force) {
export function removeMaps(fromId, toId, force) {
toId = toId || fromId;
var fromIndex = core.floorIds.indexOf(fromId),
toIndex = core.floorIds.indexOf(toId);
@ -40,20 +38,20 @@
if (deleted && !main.replayChecking) {
core.splitArea();
}
}
}
function deleteFlags(floorId) {
export function deleteFlags(floorId) {
delete flags[`jump_${floorId}`];
delete flags[`inte_${floorId}`];
delete flags[`loop_${floorId}`];
delete flags[`melt_${floorId}`];
delete flags[`night_${floorId}`];
}
}
// 恢复楼层
// core.plugin.removeMap.resumeMaps("MT1", "MT300") 恢复MT1~MT300之间的全部层
// core.plugin.removeMap.resumeMaps("MT10") 只恢复MT10层
function resumeMaps(fromId, toId) {
// 恢复楼层
// core.plugin.removeMap.resumeMaps("MT1", "MT300") 恢复MT1~MT300之间的全部层
// core.plugin.removeMap.resumeMaps("MT10") 只恢复MT10层
export function resumeMaps(fromId, toId) {
toId = toId || fromId;
var fromIndex = core.floorIds.indexOf(fromId),
toIndex = core.floorIds.indexOf(toId);
@ -72,10 +70,10 @@
});
core.status.maps[floorId] = core.loadFloor(floorId);
}
}
}
// 分区砍层相关
var inAnyPartition = floorId => {
// 分区砍层相关
var inAnyPartition = floorId => {
var inPartition = false;
(core.floorPartitions || []).forEach(floor => {
var fromIndex = core.floorIds.indexOf(floor[0]);
@ -86,10 +84,10 @@
if (index >= fromIndex && index <= toIndex) inPartition = true;
});
return inPartition;
};
};
// 分区砍层
function autoRemoveMaps(floorId) {
// 分区砍层
export function autoRemoveMaps(floorId) {
if (main.mode != 'play' || !inAnyPartition(floorId)) return;
// 根据分区信息自动砍层与恢复
(core.floorPartitions || []).forEach(floor => {
@ -107,12 +105,11 @@
removeMaps(core.floorIds[fromIndex], core.floorIds[toIndex]);
}
});
}
}
core.plugin.removeMap = {
core.plugin.removeMap = {
removeMaps,
deleteFlags,
resumeMaps,
autoRemoveMaps
};
})();
};

View File

@ -1,12 +1,11 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict';
(function () {
const { studySkill, canStudySkill } = core.plugin.study;
const replayableSettings = ['autoSkill'];
import { studySkill, canStudySkill } from './study';
// 注册修改设置的录像操作
core.registerReplayAction('settings', name => {
const replayableSettings = ['autoSkill'];
// 注册修改设置的录像操作
core.registerReplayAction('settings', name => {
if (!name.startsWith('set:')) return false;
const [, setting, value] = name.split(':');
const v = eval(value);
@ -15,17 +14,17 @@
flags[setting] = v;
core.replay();
return true;
});
});
core.registerReplayAction('upgradeSkill', name => {
core.registerReplayAction('upgradeSkill', name => {
if (!name.startsWith('skill:')) return false;
const skill = parseInt(name.slice(6));
core.plugin.skillTree.upgradeSkill(skill);
core.replay();
return true;
});
});
core.registerReplayAction('study', name => {
core.registerReplayAction('study', name => {
if (!name.startsWith('study:')) return false;
const [num, x, y] = name
.slice(6)
@ -38,20 +37,20 @@
studySkill(enemy, num);
core.replay();
return true;
});
});
// 商店
let shopOpened = false;
let openedShopId = '';
core.registerReplayAction('openShop', name => {
// 商店
let shopOpened = false;
let openedShopId = '';
core.registerReplayAction('openShop', name => {
if (!name.startsWith('openShop:')) return false;
openedShopId = name.slice(9);
shopOpened = true;
core.replay();
return true;
});
});
core.registerReplayAction('buy', name => {
core.registerReplayAction('buy', name => {
if (!name.startsWith('buy:') && !name.startsWith('sell:')) return false;
if (!shopOpened) return false;
if (!openedShopId) return false;
@ -78,14 +77,13 @@
flags.itemShop[openedShopId][id] += type === 'buy' ? num : -num;
core.replay();
return true;
});
});
core.registerReplayAction('closeShop', name => {
core.registerReplayAction('closeShop', name => {
if (name !== 'closeShop') return false;
if (!shopOpened) return false;
shopOpened = false;
openedShopId = '';
core.replay();
return true;
});
})();
});

View File

@ -1,10 +1,8 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict';
(function () {
const { openItemShop } = core.plugin.gameUi;
const { openItemShop } = core.plugin.gameUi;
function openShop(shopId, noRoute) {
export function openShop(shopId, noRoute) {
var shop = core.status.shops[shopId];
// Step 1: 检查能否打开此商店
if (!this.canOpenShop(shopId)) {
@ -18,45 +16,45 @@
return;
}
return true;
}
}
/// 是否访问过某个快捷商店
function isShopVisited(id) {
/// 是否访问过某个快捷商店
export function isShopVisited(id) {
flags.__shops__ ??= {};
var shops = core.getFlag('__shops__');
if (!shops[id]) shops[id] = {};
return shops[id].visited;
}
}
/// 当前应当显示的快捷商店列表
function listShopIds() {
/// 当前应当显示的快捷商店列表
export function listShopIds() {
return Object.keys(core.status.shops).filter(id => {
return (
core.plugin.shop.isShopVisited(id) ||
!core.status.shops[id].mustEnable
);
});
}
}
/// 是否能够打开某个商店
function canOpenShop(id) {
/// 是否能够打开某个商店
export function canOpenShop(id) {
if (this.isShopVisited(id)) return true;
var shop = core.status.shops[id];
if (shop.item || shop.commonEvent || shop.mustEnable) return false;
return true;
}
}
/// 启用或禁用某个快捷商店
function setShopVisited(id, visited) {
/// 启用或禁用某个快捷商店
export function setShopVisited(id, visited) {
if (!core.hasFlag('__shops__')) core.setFlag('__shops__', {});
var shops = core.getFlag('__shops__');
if (!shops[id]) shops[id] = {};
if (visited) shops[id].visited = true;
else delete shops[id].visited;
}
}
/// 能否使用快捷商店
function canUseQuickShop() {
/// 能否使用快捷商店
export function canUseQuickShop() {
// 如果返回一个字符串,表示不能,字符串为不能使用的提示
// 返回null代表可以使用
@ -64,14 +62,13 @@
if (core.status.thisMap.canUseQuickShop === false)
return '当前楼层不能使用快捷商店。';
return null;
}
}
core.plugin.shop = {
core.plugin.shop = {
openShop,
isShopVisited,
listShopIds,
canOpenShop,
setShopVisited,
canUseQuickShop
};
})();
};

View File

@ -1,16 +1,14 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict';
(function () {
/**
/**
* @type {number[]}
*/
let levels = [];
let levels = [];
/**
/**
* @type {Record<Chapter, Skill[]>}
*/
const skills = {
const skills = {
chapter1: [
{
index: 0,
@ -195,26 +193,26 @@
effect: ['每打一个怪勇士造成的伤害增加1%']
}
]
};
};
core.plugin.skills = skills;
core.plugin.skills = skills;
function getSkillFromIndex(index) {
export function getSkillFromIndex(index) {
for (const [, skill] of Object.entries(skills)) {
const s = skill.find(v => v.index === index);
if (s) return s;
}
}
}
/**
/**
* 获取技能等级
* @param {number} skill
*/
function getSkillLevel(skill) {
export function getSkillLevel(skill) {
return (levels[skill] ??= 0);
}
}
function getSkillConsume(skill) {
export function getSkillConsume(skill) {
return eval(
this.getSkillFromIndex(skill).consume.replace(
/level(:\d+)?/g,
@ -224,18 +222,18 @@
}
)
);
}
}
function openTree() {
export function openTree() {
if (main.replayChecking) return;
core.plugin.skillTreeOpened.value = true;
}
}
/**
/**
* 能否升级某个技能
* @param {number} skill
*/
function canUpgrade(skill) {
export function canUpgrade(skill) {
const consume = core.plugin.skillTree.getSkillConsume(skill);
if (consume > core.status.hero.mdef) return false;
const level = core.plugin.skillTree.getSkillLevel(skill);
@ -243,17 +241,16 @@
if (level === s.max) return false;
const front = s.front;
for (const [skill, level] of front) {
if (core.plugin.skillTree.getSkillLevel(skill) < level)
return false;
if (core.plugin.skillTree.getSkillLevel(skill) < level) return false;
}
return true;
}
}
/**
/**
* 实际升级效果
* @param {number} skill
*/
function upgradeSkill(skill) {
export function upgradeSkill(skill) {
if (!canUpgrade(skill)) return false;
switch (skill) {
case 0: // 力量 +2攻击
@ -298,17 +295,17 @@
levels[skill]++;
core.updateStatusBar();
return true;
}
}
function saveSkillTree() {
export function saveSkillTree() {
return levels.slice();
}
}
function loadSkillTree(data) {
export function loadSkillTree(data) {
levels = data ?? [];
}
}
core.plugin.skillTree = {
core.plugin.skillTree = {
getSkillConsume,
getSkillFromIndex,
getSkillLevel,
@ -316,5 +313,4 @@
loadSkillTree,
upgradeSkill,
openTree
};
})();
};

View File

@ -1,9 +1,7 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict';
(function () {
// 所有的主动技能效果
var ignoreInJump = {
// 所有的主动技能效果
var ignoreInJump = {
event: ['X20007', 'X20001', 'X20006', 'X20014', 'X20010', 'X20007'],
bg: [
'X20037',
@ -19,12 +17,12 @@
'X20075',
'X20076'
]
};
};
/** @type {FloorIds[]} */
const jumpIgnoreFloor = ['MT31', 'snowTown'];
// 跳跃
function jumpSkill() {
/** @type {FloorIds[]} */
const jumpIgnoreFloor = ['MT31', 'snowTown'];
// 跳跃
export function jumpSkill() {
if (core.status.floorId.startsWith('tower'))
return core.drawTip('当无法使用该技能');
if (jumpIgnoreFloor.includes(core.status.floorId) || flags.onChase) {
@ -76,8 +74,8 @@
var noPass = core.noPass(checkLoc.x, checkLoc.y);
var id = core.getBlockId(checkLoc.x, checkLoc.y) || '';
var bgId =
core.getBlockByNumber(core.getBgNumber(checkLoc.x, checkLoc.y))
.event.id || '';
core.getBlockByNumber(core.getBgNumber(checkLoc.x, checkLoc.y)).event
.id || '';
// 可以通行
if (
!noPass ||
@ -106,12 +104,7 @@
}
// 是怪物
if (cls == 'enemys' || cls == 'enemy48') {
var firstNoPass = checkNoPass(
direction,
checkLoc.x,
checkLoc.y,
false
);
var firstNoPass = checkNoPass(direction, checkLoc.x, checkLoc.y, false);
if (!firstNoPass) return;
core.autosave();
if (flags.chapter <= 1) core.status.hero.hp -= 200 * flags.hard;
@ -160,8 +153,7 @@
var id = core.getBlockId(x, y) || '';
if (core.getBgNumber(x, y))
var bgId =
core.getBlockByNumber(core.getBgNumber(x, y)).event.id ||
'';
core.getBlockByNumber(core.getBgNumber(x, y)).event.id || '';
else var bgId = '';
if (
core.noPass(x, y) ||
@ -174,9 +166,8 @@
if (!startNo) return checkNoPass(direction, x, y, false);
return { x: x, y: y };
}
}
}
core.plugin.skillEffects = {
core.plugin.skillEffects = {
jumpSkill
};
})();
};

View File

@ -1,29 +1,27 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict';
(function () {
// 负责勇士技能:学习
const values = {
// 负责勇士技能:学习
const values = {
1: ['crit'],
6: ['n'],
7: ['hungry'],
8: ['together'],
10: ['courage'],
11: ['charge']
};
};
const cannotStudy = [9, 12, 14, 15, 24];
const cannotStudy = [9, 12, 14, 15, 24];
function canStudySkill(number) {
export function canStudySkill(number) {
const s = (core.status.hero.special ??= { num: [], last: [] });
if (core.plugin.skillTree.getSkillLevel(11) === 0) return false;
if (s.num.length >= 1) return false;
if (s.num.includes(number)) return false;
if (cannotStudy.includes(number)) return false;
return true;
}
}
function studySkill(enemy, number) {
export function studySkill(enemy, number) {
core.status.hero.special ??= { num: [], last: [] };
const s = core.status.hero.special;
const specials = core.getSpecials();
@ -41,9 +39,9 @@
for (const key of value) {
s[key] = enemy[key];
}
}
}
function forgetStudiedSkill(num, i) {
export function forgetStudiedSkill(num, i) {
const s = core.status.hero.special;
const index = i !== void 0 && i !== null ? i : s.num.indexOf(num);
if (index === -1) return;
@ -53,14 +51,14 @@
for (const key of value) {
delete s[key];
}
}
}
function declineStudiedSkill() {
export function declineStudiedSkill() {
const s = (core.status.hero.special ??= { num: [], last: [] });
s.last = s.last.map(v => v - 1);
}
}
function checkStudiedSkill() {
export function checkStudiedSkill() {
const s = core.status.hero.special;
for (let i = 0; i < s.last.length; i++) {
if (s.last[i] <= 0) {
@ -68,13 +66,12 @@
i--;
}
}
}
}
core.plugin.study = {
core.plugin.study = {
canStudySkill,
studySkill,
forgetStudiedSkill,
declineStudiedSkill,
checkStudiedSkill
};
})();
};

View File

@ -1,18 +1,16 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict';
// 1000多行改不动了
// 1000多行改不动了,原来什么样就什么样吧
(function () {
// 智慧boss
// 变量们
var stage = 1,
// 智慧boss
// 变量们
var stage = 1,
hp = 10000,
seconds = 0,
boomLocs = [], // 随机轰炸
heroHp;
// 初始化
function initTowerBoss() {
// 初始化
function initTowerBoss() {
stage = 1;
hp = 10000;
seconds = 0;
@ -21,9 +19,9 @@
autoFixRouteBoss(true);
core.insertAction([{ type: 'sleep', time: 1000, noSkip: true }]);
setTimeout(bossCore, 1000);
}
// 录像自动修正
function autoFixRouteBoss(isStart) {
}
// 录像自动修正
export function autoFixRouteBoss(isStart) {
var route = core.status.route;
if (isStart) {
// 开始修正 记录当前录像长度
@ -34,9 +32,9 @@
route.splice(flags.startFix);
route.push('choices:0');
delete flags.startFix;
}
// 血条
function healthBar(now, total) {
}
// 血条
function healthBar(now, total) {
var nowLength = (now / total) * 476; // 当前血量下绘制长度
var color = [
255 * 2 - (now / total) * 2 * 255,
@ -79,9 +77,9 @@
'#ffffff',
'16px normal'
);
}
// 血量变化
function dynamicChangeHp(from, to, total) {
}
// 血量变化
function dynamicChangeHp(from, to, total) {
var frame = 0,
speed = (to - from) / 50,
now = from;
@ -94,15 +92,14 @@
now += speed;
healthBar(now, total);
}, 20);
}
// boss说话跳字
function skipWord(words, x, y, time) {
}
// boss说话跳字
function skipWord(words, x, y, time) {
x = x || 0;
y = y || 16;
time = time || 3000;
// 创建画布
if (!core.dymCanvas.words)
core.createCanvas('words', x, y, 480, 24, 135);
if (!core.dymCanvas.words) core.createCanvas('words', x, y, 480, 24, 135);
else core.clearMap('words');
if (flags.wordsTimeOut) clearTimeout(flags.wordsTimeOut);
dynamicCurtain(y, y + 24, time / 3);
@ -145,9 +142,9 @@
}
}, 20);
}
}
// 匀变速下降背景
function dynamicCurtain(from, to, time, width) {
}
// 匀变速下降背景
function dynamicCurtain(from, to, time, width) {
width = width || 480;
if (!core.dymCanvas.wordsBg)
core.createCanvas('wordsBg', 0, from, width, 24, 130);
@ -166,14 +163,7 @@
core.clearMap('wordsBg');
style.shadowBlur = 8;
style.shadowOffsetY = 2;
core.fillRect(
'wordsBg',
0,
0,
width,
ny - from,
[180, 180, 180, 0.7]
);
core.fillRect('wordsBg', 0, 0, width, ny - from, [180, 180, 180, 0.7]);
style.shadowBlur = 3;
style.shadowOffsetY = 0;
core.strokeRect(
@ -211,9 +201,9 @@
);
}
}, 20);
}
// 攻击boss
function attackBoss() {
}
// 攻击boss
function attackBoss() {
// 每秒钟地面随机出现伤害图块 踩上去攻击boss 500血
if (flags.canAttack) return;
if (Math.random() < 0.8) return;
@ -314,9 +304,9 @@
return;
}
}, 20);
}
// 核心函数
function bossCore() {
}
// 核心函数
function bossCore() {
var interval = window.setInterval(() => {
if (stage == 1) {
if (seconds == 8) skipWord('智慧之神:果然,你和别人不一样。');
@ -340,10 +330,8 @@
}
if (stage == 2) {
if (seconds == 4) skipWord('智慧之神:你的确拥有智慧。');
if (seconds == 8)
skipWord('智慧之神:或许你就是那个未来的救星。');
if (seconds == 12)
skipWord('智慧之神:不过,这场战斗才刚刚开始');
if (seconds == 8) skipWord('智慧之神:或许你就是那个未来的救星。');
if (seconds == 12) skipWord('智慧之神:不过,这场战斗才刚刚开始');
if (seconds == 25) skipWord('提示:方形区域均为危险区域');
if (seconds == 15)
setTimeout(() => {
@ -362,8 +350,7 @@
}
if (stage >= 3) {
if (seconds == 4) skipWord('智慧之神:拥有智慧就是不一样。');
if (seconds == 8)
skipWord('智慧之神:不过,你还得再过我一关!');
if (seconds == 8) skipWord('智慧之神:不过,你还得再过我一关!');
if (seconds == 12) startStage3();
if (seconds == 15) {
flags.booming = true;
@ -419,10 +406,10 @@
}
seconds++;
}, 1000);
}
// ------ 第一阶段 10000~7000血 ------ //
// 技能1 智慧之箭 1000伤害
function intelligentArrow(fromSelf) {
}
// ------ 第一阶段 10000~7000血 ------ //
// 技能1 智慧之箭 1000伤害
function intelligentArrow(fromSelf) {
// 坐标
var loc = Math.floor(Math.random() * 13 + 1);
var direction = Math.random() > 0.5 ? 'horizon' : 'vertical';
@ -469,14 +456,7 @@
}
// 箭
if (!core.dymCanvas['inteArrow' + loc + direction])
core.createCanvas(
'inteArrow' + loc + direction,
0,
0,
544,
544,
65
);
core.createCanvas('inteArrow' + loc + direction, 0, 0, 544, 544, 65);
core.clearMap('inteArrow' + loc + direction);
if (direction == 'horizon')
core.drawImage(
@ -514,8 +494,7 @@
nloc += speed;
if (direction == 'horizon')
core.relocateCanvas('inteArrow' + loc + direction, nloc, 0);
else
core.relocateCanvas('inteArrow' + loc + direction, 0, nloc);
else core.relocateCanvas('inteArrow' + loc + direction, 0, nloc);
if (nloc < -480) {
core.deleteCanvas('inteArrow' + loc + direction);
clearInterval(skill1);
@ -558,9 +537,9 @@
}
}, 20);
}, 3000);
}
// 技能2 智慧之门 随机传送
function intelligentDoor() {
}
// 技能2 智慧之门 随机传送
function intelligentDoor() {
if (Math.random() < 0.5) return;
// 随机位置
var toX = Math.floor(Math.random() * 13) + 1,
@ -618,9 +597,9 @@
3
);
}, 20);
}
// 技能3 万冰之势 全屏随机转换滑冰 如果转换时在滑冰上造成5000点伤害
function icyMomentem() {
}
// 技能3 万冰之势 全屏随机转换滑冰 如果转换时在滑冰上造成5000点伤害
function icyMomentem() {
if (flags.haveIce) return;
if (Math.random() < 0.5) return;
var times = Math.floor(Math.random() * 100);
@ -705,10 +684,10 @@
}
}, 50);
}
}
// ------ 第二阶段 7000~3500 ------ //
// 开始第二阶段
function startStage2() {
}
// ------ 第二阶段 7000~3500 ------ //
// 开始第二阶段
function startStage2() {
// 闪烁
core.createCanvas('flash', 0, 0, 480, 480, 160);
var alpha = 0;
@ -737,10 +716,10 @@
// bgm
core.playBgm('towerBoss2.mp3');
}
}
// ----- 打雷相关 ----- //
// 随机打雷
function randomThunder() {
}
// ----- 打雷相关 ----- //
// 随机打雷
function randomThunder() {
var x = Math.floor(Math.random() * 13) + 1,
y = Math.floor(Math.random() * 13) + 1,
power = Math.ceil(Math.random() * 6);
@ -769,9 +748,9 @@
core.deleteCanvas('thunderDanger');
drawThunder(x, y, power);
}, 1000);
}
// 绘制
function drawThunder(x, y, power) {
}
// 绘制
function drawThunder(x, y, power) {
var route = getThunderRoute(x * 32 + 16, y * 32 + 16, power);
// 开始绘制
if (!core.dymCanvas.thunder)
@ -802,8 +781,7 @@
// 闪一下
var frame1 = 0,
alpha = 0.5;
if (!core.dymCanvas.flash)
core.createCanvas('flash', 0, 0, 480, 480, 160);
if (!core.dymCanvas.flash) core.createCanvas('flash', 0, 0, 480, 480, 160);
else core.clearMap('flash');
var thunderFlash = window.setInterval(() => {
alpha -= 0.05;
@ -819,9 +797,9 @@
}, 700);
}
}, 20);
}
// 获得雷电路径
function getThunderRoute(x, y, power) {
}
// 获得雷电路径
function getThunderRoute(x, y, power) {
var route = [];
for (var num = 0; num < power; num++) {
var nx = x,
@ -839,9 +817,9 @@
}
}
return route;
}
// 打雷伤害判定
function getThunderDamage(x, y, power) {
}
// 打雷伤害判定
function getThunderDamage(x, y, power) {
var hx = core.status.hero.loc.x,
hy = core.status.hero.loc.y;
if (Math.abs(hx - x) <= 1 && Math.abs(hy - y) <= 1) {
@ -855,10 +833,10 @@
return;
}
}
}
// ----- 打雷 END ----- //
// 球形闪电 横竖
function ballThunder() {
}
// ----- 打雷 END ----- //
// 球形闪电 横竖
function ballThunder() {
// 随机数量
var times = Math.ceil(Math.random() * 12) + 6;
var now = 0,
@ -1002,12 +980,10 @@
y = core.status.hero.loc.y;
if (
((Math.floor((nx - 16 - 4 * now) / 32) == x ||
Math.floor((nx - 16 + 4 * now) / 32) ==
x) &&
Math.floor((nx - 16 + 4 * now) / 32) == x) &&
locs[i][1] == y) ||
((Math.floor((ny - 16 - 4 * now) / 32) == y ||
Math.floor((ny - 16 + 4 * now) / 32) ==
y) &&
Math.floor((ny - 16 + 4 * now) / 32) == y) &&
locs[i][0] == x)
) {
damaged[i] = true;
@ -1033,9 +1009,9 @@
frame++;
}, 20);
}
}
// ------ 第三阶段 3500~0 ------ //
function startStage3() {
}
// ------ 第三阶段 3500~0 ------ //
function startStage3() {
// 闪烁
core.createCanvas('flash', 0, 0, 480, 480, 160);
var alpha = 0;
@ -1076,18 +1052,7 @@
}
core.createCanvas('tower7', 0, 0, 480, 480, 15);
// 画贴图
core.drawImage(
'tower7',
'tower7.jpeg',
360,
0,
32,
480,
0,
0,
32,
480
);
core.drawImage('tower7', 'tower7.jpeg', 360, 0, 32, 480, 0, 0, 32, 480);
core.drawImage(
'tower7',
'tower7.jpeg',
@ -1127,9 +1092,9 @@
core.setBlock('E557', 7, 2);
core.playBgm('towerBoss3.mp3');
}
}
// 进入第四阶段
function startStage4() {
}
// 进入第四阶段
function startStage4() {
// 闪烁
core.createCanvas('flash', 0, 0, 480, 480, 160);
var alpha = 0;
@ -1170,18 +1135,7 @@
}
core.createCanvas('tower7', 0, 0, 480, 480, 15);
// 画贴图
core.drawImage(
'tower7',
'tower7.jpeg',
360,
0,
64,
480,
0,
0,
64,
480
);
core.drawImage('tower7', 'tower7.jpeg', 360, 0, 64, 480, 0, 0, 64, 480);
core.drawImage(
'tower7',
'tower7.jpeg',
@ -1220,9 +1174,9 @@
);
core.setBlock('E557', 7, 3);
}
}
// 进入第五阶段
function startStage5() {
}
// 进入第五阶段
function startStage5() {
// 闪烁
core.createCanvas('flash', 0, 0, 480, 480, 160);
var alpha = 0;
@ -1263,18 +1217,7 @@
}
core.createCanvas('tower7', 0, 0, 480, 480, 15);
// 画贴图
core.drawImage(
'tower7',
'tower7.jpeg',
360,
0,
96,
480,
0,
0,
96,
480
);
core.drawImage('tower7', 'tower7.jpeg', 360, 0, 96, 480, 0, 0, 96, 480);
core.drawImage(
'tower7',
'tower7.jpeg',
@ -1313,9 +1256,9 @@
);
core.setBlock('E557', 7, 4);
}
}
// 链状闪电 随机连接 碰到勇士则受伤
function chainThunder() {
}
// 链状闪电 随机连接 碰到勇士则受伤
function chainThunder() {
// 随机次数
var times = Math.ceil(Math.random() * 6) + 3;
// 画布
@ -1360,13 +1303,12 @@
}
now++;
}, 100);
}
// 链状闪电 动画
function chainAnimate(route) {
}
// 链状闪电 动画
function chainAnimate(route) {
if (!route) return chainThunder();
// 画布
if (!core.dymCanvas.chain)
core.createCanvas('chain', 0, 0, 480, 480, 65);
if (!core.dymCanvas.chain) core.createCanvas('chain', 0, 0, 480, 480, 65);
else core.clearMap('chain');
var style = core.dymCanvas.chain;
style.shadowBlur = 3;
@ -1396,13 +1338,7 @@
);
// 节点
if (now == 0) {
core.fillCircle(
'chain',
route[0][0],
route[0][1],
7,
'#ffffff'
);
core.fillCircle('chain', route[0][0], route[0][1], 7, '#ffffff');
}
if (
(route[now + 1][0] - 16) % 32 == 0 &&
@ -1426,9 +1362,9 @@
);
now++;
}, 20);
}
// 链状闪电 获得闪电路径
function getChainRoute(locs) {
}
// 链状闪电 获得闪电路径
function getChainRoute(locs) {
// 照样用setInterval
var now = 0,
routes = [];
@ -1449,10 +1385,7 @@
nx += Math.random() * 50 * Math.cos(angle);
ny += Math.random() * 50 * Math.sin(angle);
routes.push([nx, ny]);
if (
Math.sqrt(Math.pow(ny - ty, 2) + Math.pow(nx - tx, 2)) <=
100
) {
if (Math.sqrt(Math.pow(ny - ty, 2) + Math.pow(nx - tx, 2)) <= 100) {
routes.push([tx, ty]);
break;
}
@ -1468,9 +1401,9 @@
chainAnimate(routes);
}
}, 2);
}
// 随机轰炸
function randomBoom() {
}
// 随机轰炸
function randomBoom() {
// 停止轰炸
if (!flags.booming) {
clearInterval(flags.boom);
@ -1498,9 +1431,9 @@
}, boomTime);
// 动画要在这里调用
boomingAnimate();
}
// 随机轰炸 动画
function boomingAnimate() {
}
// 随机轰炸 动画
function boomingAnimate() {
// 直接setInterval
if (!core.dymCanvas.boom) core.createCanvas('boom', 0, 0, 480, 480, 65);
else core.clearMap('boom');
@ -1525,14 +1458,7 @@
var angle = (loc[2] * Math.PI) / 50;
// 开始绘制
core.fillCircle('boom', x, y, 3, [255, 50, 50, alpha]);
core.strokeCircle(
'boom',
x,
y,
radius,
[255, 50, 50, alpha],
2
);
core.strokeCircle('boom', x, y, radius, [255, 50, 50, alpha], 2);
// 旋转的线
core.drawLine(
'boom',
@ -1556,16 +1482,11 @@
// 炸弹 下落
if (loc[2] > 70) {
var h =
y -
(20 * (85 - loc[2]) + 2.8 * Math.pow(85 - loc[2], 2));
y - (20 * (85 - loc[2]) + 2.8 * Math.pow(85 - loc[2], 2));
core.drawImage('boom', 'boom.png', x - 18, h - 80, 36, 80);
}
if (loc[2] == 85) {
core.drawAnimate(
'explosion1',
(x - 16) / 32,
(y - 16) / 32
);
core.drawAnimate('explosion1', (x - 16) / 32, (y - 16) / 32);
boomLocs.splice(index, 1);
if (boomLocs.length == 0) core.deleteCanvas('boom');
// 伤害判定
@ -1587,9 +1508,9 @@
}
});
}, 20);
}
// 直线型伤害判定
function lineDamage(x1, y1, x2, y2, damage) {
}
// 直线型伤害判定
function lineDamage(x1, y1, x2, y2, damage) {
// 获得勇士坐标
var x = core.status.hero.loc.x,
y = core.status.hero.loc.y;
@ -1608,10 +1529,8 @@
var loc1 = [x * 32 - 12, y * 32 + 16],
loc2 = [x * 32 + 12, y * 32 - 16];
// 直线方程 y == (y2 - y1) / (x2 - x1) * (x - x1) + y1
var n1 =
((y2 - y1) / (x2 - x1)) * (loc1[0] - x1) + y1 - loc1[1],
n2 =
((y2 - y1) / (x2 - x1)) * (loc2[0] - x1) + y1 - loc2[1];
var n1 = ((y2 - y1) / (x2 - x1)) * (loc1[0] - x1) + y1 - loc1[1],
n2 = ((y2 - y1) / (x2 - x1)) * (loc2[0] - x1) + y1 - loc2[1];
if (n1 * n2 <= 0) {
core.status.hero.hp -= damage;
core.addPop(x * 32 + 16, y * 32 + 16, -damage);
@ -1630,10 +1549,8 @@
var loc1 = [x * 32 - 12, y * 32 - 16],
loc2 = [x * 32 + 12, y * 32 + 16];
// 直线方程 y == (y2 - y1) / (x2 - x1) * (x - x1) + y1
var n1 =
((y2 - y1) / (x2 - x1)) * (loc1[0] - x1) + y1 - loc1[1],
n2 =
((y2 - y1) / (x2 - x1)) * (loc2[0] - x1) + y1 - loc2[1];
var n1 = ((y2 - y1) / (x2 - x1)) * (loc1[0] - x1) + y1 - loc1[1],
n2 = ((y2 - y1) / (x2 - x1)) * (loc2[0] - x1) + y1 - loc2[1];
if (n1 * n2 <= 0) {
core.status.hero.hp -= damage;
core.addPop(x * 32 + 16, y * 32 + 16, -damage);
@ -1649,10 +1566,9 @@
}
}
}
}
}
core.plugin.towerBoss = {
core.plugin.towerBoss = {
initTowerBoss,
autoFixRouteBoss
};
})();
};

View File

@ -1,5 +1,5 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict';
export {};
(function () {
if (main.replayChecking) return (core.plugin.gameUi = {});

View File

@ -1,13 +1,11 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict';
(function () {
/**
/**
* 滑动数组
* @param {any[]} arr
* @param {number} delta
*/
function slide(arr, delta) {
export function slide(arr, delta) {
if (delta === 0) return arr;
delta %= arr.length;
if (delta > 0) {
@ -18,22 +16,22 @@
arr.push(...arr.splice(0, -delta));
return arr;
}
}
}
function backDir(dir) {
export function backDir(dir) {
return {
up: 'down',
down: 'up',
left: 'right',
right: 'left'
}[dir];
}
}
function has(v) {
export function has(v) {
return v !== null && v !== void 0;
}
}
function maxGameScale(n = 0) {
export function maxGameScale(n = 0) {
const index = core.domStyle.availableScale.indexOf(core.domStyle.scale);
core.control.setDisplayScale(
core.domStyle.availableScale.length - 1 - index - n
@ -45,12 +43,11 @@
);
core.resize();
}
}
}
core.plugin.utils = {
core.plugin.utils = {
slide,
backDir,
has,
maxGameScale
};
})();
};

View File

@ -2,8 +2,8 @@ import fs from 'fs/promises';
import fss from 'fs';
import fse from 'fs-extra';
import Fontmin from 'fontmin';
import { exec } from 'child_process';
import * as babel from '@babel/core';
import * as rollup from 'rollup';
(async function () {
// 1. 去除未使用的文件
@ -40,7 +40,7 @@ import * as babel from '@babel/core';
})
);
await fse.remove('./dist/maps/');
// 编辑器需要留着吗?
// 在线查看什么都看不到,这编辑器难道还需要留着吗?
} catch {}
// 2. 压缩字体
@ -98,22 +98,23 @@ import * as babel from '@babel/core';
// 3. 压缩js插件
try {
exec(
`babel ${data.main.plugin
.map(v => `./dist/project/plugin/${v}.js`)
.join(' ')} --out-file ./dist/project/plugin.m.js`
).on('close', async () => {
const build = await rollup.rollup({
input: 'public/project/plugin/index.js'
});
const code = await build.generate({
format: 'iife',
name: 'CorePlugin'
});
const compressed = babel.transformSync(code.output[0].code)?.code!;
await fs.writeFile('./dist/project/plugin.m.js', compressed, 'utf-8');
const main = await fs.readFile('./dist/main.js', 'utf-8');
await fs.writeFile(
'./dist/main.js',
main.replace(
/this.pluginUseCompress\s*=\s*false\;/,
'this.pluginUseCompress = true;'
)
);
await fse.remove('./dist/project/plugin/');
});
} catch {
} catch (e) {
console.log('压缩插件失败');
}
@ -124,20 +125,8 @@ import * as babel from '@babel/core';
const endIndex = main.indexOf('// >>>> body end');
const nonCompress = main.slice(0, endIndex);
const needCompress = main.slice(endIndex + 17);
await fs.writeFile('./dist/temp.js', needCompress, 'utf-8');
await fs.rm('./dist/main.js');
exec('babel ./dist/temp.js --out-file ./dist/main.js').on(
'close',
async () => {
const nowMain = await fs.readFile('./dist/main.js', 'utf-8');
await fs.writeFile(
'./dist/main.js',
nonCompress + nowMain,
'utf-8'
);
await fs.rm('./dist/temp.js');
}
);
const compressed = babel.transformSync(needCompress)?.code;
await fs.writeFile('./dist/main.js', nonCompress + compressed, 'utf-8');
} catch {
console.log('main.js压缩失败');
}

View File

@ -1,5 +1,7 @@
import { ref, watch } from 'vue';
// todo 优化可以考虑改成reactive
/** 打开和关闭ui时是否展示动画 */
export const transition = ref(false);

View File

@ -1,7 +1,8 @@
import { power } from 'mutate-animate';
import { hyper, power } from 'mutate-animate';
import { Polygon } from './polygon';
import {
Light,
animateLight,
getAllLights,
moveLight,
refreshLight,
@ -27,7 +28,7 @@ export default function init() {
}
};
return { updateShadow, clearShadowCache, setCalShadow, testLight: test };
return { updateShadow, clearShadowCache, setCalShadow };
}
const shadowInfo: Partial<Record<FloorIds, Light[]>> = {
@ -35,11 +36,10 @@ const shadowInfo: Partial<Record<FloorIds, Light[]>> = {
{
id: 'mt48_1',
x: 0,
y: 0,
y: 48,
decay: 0,
r: 300,
color: '#0000',
followHero: true
color: '#0000'
}
]
};
@ -153,7 +153,3 @@ export function setCalShadow(n: boolean) {
calMapShadow = n;
updateShadow();
}
function test() {
moveLight('mt48_1', 480, 48, 2000, power(4, 'in-out'));
}