插件转为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

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

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,7 +1,6 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict';
export {};
(function () {
// 创建新图层
function createCanvas(name, zIndex) {
if (!name) return;
@ -21,15 +20,7 @@
var bg2Canvas = createCanvas('bg2', 20);
var fg2Canvas = createCanvas('fg2', 63);
// 大地图适配
core.bigmap.canvas = [
'bg2',
'fg2',
'bg',
'event',
'event2',
'fg',
'damage'
];
core.bigmap.canvas = ['bg2', 'fg2', 'bg', 'event', 'event2', 'fg', 'damage'];
core.initStatus.bg2maps = {};
core.initStatus.fg2maps = {};
@ -205,4 +196,3 @@
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;
@ -54,4 +52,3 @@
core.plugin.halo = {
drawHalo
};
})();

View File

@ -1,7 +1,5 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict';
(function () {
/**
* 获取勇士在某一点的属性
* @param {keyof HeroStatus | 'all'} name
@ -9,11 +7,11 @@
* @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);
}
@ -84,4 +82,3 @@
getHeroStatusOf,
getHeroStatusOn
};
})();

View File

@ -1,7 +1,6 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict';
export {};
(function () {
['up', 'down', 'left', 'right'].forEach(one => {
// 指定中间帧动画
core.material.icons.hero[one].midFoot = 2;
@ -57,4 +56,3 @@
}
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,7 +1,6 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict';
export {};
(function () {
core.control.updateDamage = function (floorId, ctx) {
floorId = floorId || core.status.floorId;
if (!floorId || core.status.gameOver || main.mode != 'play') return;
@ -127,4 +126,3 @@
i++;
}
}
})();

View File

@ -1,8 +1,6 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict';
import { slide } from './utils';
(function () {
const { slide } = core.plugin.utils;
const list = ['tower6'];
/**
@ -28,7 +26,7 @@
setLoopMap(core.status.hero.loc.x, floorId);
}
function checkLoopMap() {
export function checkLoopMap() {
if (isLoopMap(core.status.floorId)) {
autoSetLoopMap(core.status.floorId);
}
@ -81,16 +79,10 @@
} 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) {
@ -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 = {
checkLoopMap
};
})();

View File

@ -1,7 +1,6 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict';
export {};
(function () {
// 伤害弹出
// 复写阻激夹域检测
control.prototype.checkBlock = function (forceMockery) {
@ -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();
@ -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 });
@ -121,4 +118,3 @@
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}
*/
@ -33,7 +30,7 @@
* 获取剩余怪物字符串
* @param {FloorIds[]} floorIds
*/
function getRemainEnemyString(floorIds) {
export function getRemainEnemyString(floorIds) {
const enemy = checkRemainEnemy(floorIds);
const str = [];
let now = [];
@ -73,4 +70,3 @@
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);
@ -42,7 +40,7 @@
}
}
function deleteFlags(floorId) {
export function deleteFlags(floorId) {
delete flags[`jump_${floorId}`];
delete flags[`inte_${floorId}`];
delete flags[`loop_${floorId}`];
@ -53,7 +51,7 @@
// 恢复楼层
// core.plugin.removeMap.resumeMaps("MT1", "MT300") 恢复MT1~MT300之间的全部层
// core.plugin.removeMap.resumeMaps("MT10") 只恢复MT10层
function resumeMaps(fromId, toId) {
export function resumeMaps(fromId, toId) {
toId = toId || fromId;
var fromIndex = core.floorIds.indexOf(fromId),
toIndex = core.floorIds.indexOf(toId);
@ -89,7 +87,7 @@
};
// 分区砍层
function autoRemoveMaps(floorId) {
export function autoRemoveMaps(floorId) {
if (main.mode != 'play' || !inAnyPartition(floorId)) return;
// 根据分区信息自动砍层与恢复
(core.floorPartitions || []).forEach(floor => {
@ -115,4 +113,3 @@
resumeMaps,
autoRemoveMaps
};
})();

View File

@ -1,8 +1,7 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict';
(function () {
const { studySkill, canStudySkill } = core.plugin.study;
import { studySkill, canStudySkill } from './study';
const replayableSettings = ['autoSkill'];
// 注册修改设置的录像操作
@ -88,4 +87,3 @@
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;
function openShop(shopId, noRoute) {
export function openShop(shopId, noRoute) {
var shop = core.status.shops[shopId];
// Step 1: 检查能否打开此商店
if (!this.canOpenShop(shopId)) {
@ -21,7 +19,7 @@
}
/// 是否访问过某个快捷商店
function isShopVisited(id) {
export function isShopVisited(id) {
flags.__shops__ ??= {};
var shops = core.getFlag('__shops__');
if (!shops[id]) shops[id] = {};
@ -29,7 +27,7 @@
}
/// 当前应当显示的快捷商店列表
function listShopIds() {
export function listShopIds() {
return Object.keys(core.status.shops).filter(id => {
return (
core.plugin.shop.isShopVisited(id) ||
@ -39,7 +37,7 @@
}
/// 是否能够打开某个商店
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;
@ -47,7 +45,7 @@
}
/// 启用或禁用某个快捷商店
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] = {};
@ -56,7 +54,7 @@
}
/// 能否使用快捷商店
function canUseQuickShop() {
export function canUseQuickShop() {
// 如果返回一个字符串,表示不能,字符串为不能使用的提示
// 返回null代表可以使用
@ -74,4 +72,3 @@
setShopVisited,
canUseQuickShop
};
})();

View File

@ -1,7 +1,5 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict';
(function () {
/**
* @type {number[]}
*/
@ -199,7 +197,7 @@
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;
@ -210,11 +208,11 @@
* 获取技能等级
* @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,
@ -226,7 +224,7 @@
);
}
function openTree() {
export function openTree() {
if (main.replayChecking) return;
core.plugin.skillTreeOpened.value = true;
}
@ -235,7 +233,7 @@
* 能否升级某个技能
* @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,8 +241,7 @@
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;
}
@ -253,7 +250,7 @@
* 实际升级效果
* @param {number} skill
*/
function upgradeSkill(skill) {
export function upgradeSkill(skill) {
if (!canUpgrade(skill)) return false;
switch (skill) {
case 0: // 力量 +2攻击
@ -300,11 +297,11 @@
return true;
}
function saveSkillTree() {
export function saveSkillTree() {
return levels.slice();
}
function loadSkillTree(data) {
export function loadSkillTree(data) {
levels = data ?? [];
}
@ -317,4 +314,3 @@
upgradeSkill,
openTree
};
})();

View File

@ -1,7 +1,5 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict';
(function () {
// 所有的主动技能效果
var ignoreInJump = {
event: ['X20007', 'X20001', 'X20006', 'X20014', 'X20010', 'X20007'],
@ -24,7 +22,7 @@
/** @type {FloorIds[]} */
const jumpIgnoreFloor = ['MT31', 'snowTown'];
// 跳跃
function jumpSkill() {
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) ||
@ -179,4 +171,3 @@
core.plugin.skillEffects = {
jumpSkill
};
})();

View File

@ -1,7 +1,5 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict';
(function () {
// 负责勇士技能:学习
const values = {
1: ['crit'],
@ -14,7 +12,7 @@
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;
@ -23,7 +21,7 @@
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();
@ -43,7 +41,7 @@
}
}
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;
@ -55,12 +53,12 @@
}
}
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) {
@ -77,4 +75,3 @@
declineStudiedSkill,
checkStudiedSkill
};
})();

View File

@ -1,9 +1,7 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict';
// 1000多行改不动了
// 1000多行改不动了,原来什么样就什么样吧
(function () {
// 智慧boss
// 变量们
var stage = 1,
@ -23,7 +21,7 @@
setTimeout(bossCore, 1000);
}
// 录像自动修正
function autoFixRouteBoss(isStart) {
export function autoFixRouteBoss(isStart) {
var route = core.status.route;
if (isStart) {
// 开始修正 记录当前录像长度
@ -101,8 +99,7 @@
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);
@ -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(
@ -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;
@ -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);
@ -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;
@ -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;
@ -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',
@ -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',
@ -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',
@ -1365,8 +1308,7 @@
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 &&
@ -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;
}
@ -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');
// 伤害判定
@ -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);
@ -1655,4 +1572,3 @@
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) {
@ -20,7 +18,7 @@
}
}
function backDir(dir) {
export function backDir(dir) {
return {
up: 'down',
down: 'up',
@ -29,11 +27,11 @@
}[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
@ -53,4 +51,3 @@
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'));
}