普通回合战特效表现优化

This commit is contained in:
草莓 2025-02-26 11:33:40 +08:00
parent ea950830d5
commit c0617ac80f

View File

@ -4712,9 +4712,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
this._y = y;
this._damage = damage;
this._fontSize = fontSize ?? 16; // 默认字体大小
this._font = font ?? "宋体"
this._fontColor = fontColor ?? (damage > 0 ? '#22FF44' : '#FF2244'); // 默认颜色
this._outlineColor = outlineColor ?? '#000000'; // 默认描边颜色
this._font = font ?? "Arial"
this._fontColor = fontColor ?? (damage > 0 ? '#22FF44' : 'lightcoral'); // 默认颜色
this._outlineColor = outlineColor ?? '#FFFFFF'; // 默认描边颜色
this._speedX = speedX ?? (-2 + Math.random() * 3); // 水平速度,默认随机
this._speedY = speedY ?? (-3 - Math.random() * 4); // 垂直速度,默认随机
this._gravity = gravity ?? 0.3; // 重力加速度,默认 0.5
@ -4756,10 +4756,10 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
PopSprite.prototype.initAllMembers = function () {
this._text = String(this._damage);
var uiContext = core.ui.getContextByName(this._canvasName); // 使用指定画布
uiContext.font = this._fontSize + 'px 宋体'; // 动态设置字体大小
uiContext.font = this._fontSize + 'px ' + this._font; // 动态设置字体大小
var textRect = uiContext.measureText(this._text);
this._width = Math.round(textRect.width + 4);
this._height = this._fontSize + 4; // 动态设置高度
this._width = textRect.width + 4;
this._height = this._fontSize * 1.4 + 4; // 动态设置高度
this._z = uiContext.canvas.style.zIndex ? uiContext.canvas.style.zIndex + PopSprite._count : PopSprite._baseZOrder + PopSprite._count;
this._symbol = 'popSprite' + PopSprite._count++;
this._alive = true;
@ -8644,7 +8644,44 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
return arr;
}
}
/**
* 图片叠加滤镜
* @param {img} image 需要叠加的图片
* @param {color} style 需要叠加的颜色
*/
function imagelighter(image, style) {
// 创建一个canvas元素
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
// 设置canvas的尺寸与图片相同
canvas.width = image.width;
canvas.height = image.height;
ctx.drawImage(image, 0, 0);
// 创建一个临时canvas用于红色滤镜
const tempCanvas = document.createElement('canvas');
const tempCtx = tempCanvas.getContext('2d');
tempCanvas.width = image.width;
tempCanvas.height = image.height;
// 在临时canvas上绘制红色滤镜
tempCtx.fillStyle = style ?? 'rgba(255, 0, 0, 0.5)'; // 半透明红色
tempCtx.fillRect(0, 0, tempCanvas.width, tempCanvas.height);
// 使用lighter混合模式叠加红色滤镜
ctx.globalCompositeOperation = 'lighter';
ctx.drawImage(tempCanvas, 0, 0);
// 使用destination-in混合模式保留原始图片的透明度
ctx.globalCompositeOperation = 'destination-in';
ctx.drawImage(image, 0, 0);
// 恢复默认混合模式
ctx.globalCompositeOperation = 'source-over';
// 返回处理后的canvas
return canvas;
}
/**
* 获取一个方向的反方向
* @example backDir('up'); // 'down'
@ -9034,6 +9071,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
);
}
core.plugin.utils = {
imagelighter,
gcdOfTwo,
lcmOfTwo,
gcd,
@ -20358,6 +20396,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
core.plugin.playingattack = new Set()
const ctx6 = main.dom.animate2.getContext('2d')
let easy = false
const { imagelighter } = core.plugin.utils
function playanimate(name, x, y, scalex = 1, scaley = 1) {
const data = {
@ -20567,7 +20606,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
128,
"#FFFFFF",
"#000000",
"bold 14px pala"
"bold 14px Verdana"
);
core.setTextAlign(ctx, "left");
core.drawIcon(ctx, "hp", 70, 190, 16, 16);
@ -20578,7 +20617,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
205,
"#FFFFFF",
"#000000",
"bold 14px pala"
"bold 14px Arial"
);
core.fillBoldText(
@ -20588,14 +20627,15 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
230,
"#FFFF60",
"#000000",
"bold 18px pala"
"bold 18px Verdana"
);
core.strokeRect(ctx, 112, 139, 32, 48, "rgba(255,255,255,1)", 1);
let img = heroInfo.inAttack ? imagelighter(core.material.images.images["hero.webp"]) : core.material.images.images["hero.webp"]
core.drawImage(
ctx,
"hero.webp",
img,
32 * (animate % 4),
0,
32,
@ -20614,16 +20654,16 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
128,
"#FFFFFF",
"#000000",
"bold 14px pala"
"bold 14px Verdana"
);
core.setTextAlign(ctx, "right");
if (enemyInfo.cls === "enemys") {
core.strokeRect(ctx, 272, 155, 32, 32, "rgba(255,255,255,1)", 1);
let img = enemyInfo.inAttack ? imagelighter(core.getBlockInfo(enemyInfo.id).image) : core.getBlockInfo(enemyInfo.id).image
core.drawImage(
ctx,
core.getBlockInfo(enemyInfo.id).image,
img,
32 * (animate % 2),
core.getBlockInfo(enemyInfo.id).posY * 32,
32,
@ -20635,10 +20675,10 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
);
} else {
core.strokeRect(ctx, 272, 139, 32, 48, "rgba(255,255,255,1)", 1);
let img = enemyInfo.inAttack ? imagelighter(core.getBlockInfo(enemyInfo.id).image) : core.getBlockInfo(enemyInfo.id).image
core.drawImage(
ctx,
core.getBlockInfo(enemyInfo.id).image,
img,
32 * (animate % 4),
core.getBlockInfo(enemyInfo.id).posY * 48,
32,
@ -20658,7 +20698,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
205,
"#FFFFFF",
"#000000",
"bold 14px pala"
"bold 14px Verdana"
);
core.fillBoldText(
ctx,
@ -20667,7 +20707,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
230,
"#FFFF60",
"#000000",
"bold 18px pala"
"bold 18px Verdana"
);
core.fillBoldText(
@ -20761,7 +20801,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
128,
"#FFFFFF",
"#000000",
"bold 14px pala"
"bold 14px Verdana"
);
core.setTextAlign(ctx, "left");
core.drawIcon(ctx, "hp", 70, 190, 16, 16);
@ -20779,7 +20819,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
205,
"#FFFFFF",
"#000000",
"bold 14px pala"
"bold 14px Arial"
);
core.fillBoldText(
@ -20789,7 +20829,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
225,
"#FFFFFF",
"#000000",
"bold 14px pala"
"bold 14px Arial"
);
core.fillBoldText(
ctx,
@ -20798,7 +20838,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
245,
"#FFFFFF",
"#000000",
"bold 14px pala"
"bold 14px Arial"
);
core.fillBoldText(
ctx,
@ -20807,7 +20847,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
265,
"#FFFFFF",
"#000000",
"bold 14px pala"
"bold 14px Arial"
);
core.fillBoldText(
ctx,
@ -20820,7 +20860,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
285,
"#FFFFFF",
"#000000",
"bold 14px pala"
"bold 14px Arial"
);
core.fillBoldText(
ctx,
@ -20833,7 +20873,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
305,
"#FFFFFF",
"#000000",
"bold 14px pala"
"bold 14px Arial"
);
core.fillBoldText(
ctx,
@ -20842,7 +20882,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
325,
"#FFFFFF",
"#000000",
"bold 14px pala"
"bold 14px Arial"
);
core.fillBoldText(
ctx,
@ -20851,13 +20891,14 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
345,
"#FFFFFF",
"#000000",
"bold 14px pala"
"bold 14px Arial"
);
core.strokeRect(ctx, 112, 139, 32, 48, "rgba(255,255,255,1)", 1);
let img = heroInfo.inAttack ? imagelighter(core.material.images.images["hero.webp"]) : core.material.images.images["hero.webp"]
core.drawImage(
ctx,
"hero.webp",
img,
32 * (animate % 4),
0,
32,
@ -20876,16 +20917,16 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
128,
"#FFFFFF",
"#000000",
"bold 14px pala"
"bold 14px Verdana"
);
core.setTextAlign(ctx, "right");
if (enemyInfo.cls === "enemys") {
core.strokeRect(ctx, 272, 155, 32, 32, "rgba(255,255,255,1)", 1);
let img = enemyInfo.inAttack ? imagelighter(core.getBlockInfo(enemyInfo.id).image) : core.getBlockInfo(enemyInfo.id).image
core.drawImage(
ctx,
core.getBlockInfo(enemyInfo.id).image,
img,
32 * (animate % 2),
core.getBlockInfo(enemyInfo.id).posY * 32,
32,
@ -20897,10 +20938,10 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
);
} else {
core.strokeRect(ctx, 272, 139, 32, 48, "rgba(255,255,255,1)", 1);
let img = enemyInfo.inAttack ? imagelighter(core.getBlockInfo(enemyInfo.id).image) : core.getBlockInfo(enemyInfo.id).image
core.drawImage(
ctx,
core.getBlockInfo(enemyInfo.id).image,
img,
32 * (animate % 4),
core.getBlockInfo(enemyInfo.id).posY * 48,
32,
@ -20923,7 +20964,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
205,
"#FFFFFF",
"#000000",
"bold 14px pala"
"bold 14px Arial"
);
core.fillBoldText(
ctx,
@ -20932,7 +20973,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
225,
"#FFFFFF",
"#000000",
"bold 14px pala"
"bold 14px Arial"
);
core.fillBoldText(
ctx,
@ -20941,7 +20982,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
245,
"#FFFFFF",
"#000000",
"bold 14px pala"
"bold 14px Arial"
);
core.fillBoldText(
@ -20951,7 +20992,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
265,
"#FFFFFF",
"#000000",
"bold 14px pala"
"bold 14px Arial"
);
core.fillBoldText(
ctx,
@ -20960,7 +21001,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
285,
"#FFFFFF",
"#000000",
"bold 14px pala"
"bold 14px Arial"
);
core.fillBoldText(
ctx,
@ -20969,7 +21010,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
315,
"#FFFF60",
"#000000",
"bold 18px pala"
"bold 18px Verdana"
);
core.fillBoldText(
ctx,
@ -20978,7 +21019,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
340,
"#FFFF60",
"#000000",
"bold 18px pala"
"bold 18px Verdana"
);
core.fillBoldText(
@ -21087,14 +21128,15 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
if (!attack && nowattacking) {
if (heroInfo.isAttack) {
enemyInfo.inAttack = true
const herodamage = -Math.max(heroInfo.atk - enemyInfo.def, 0)
Dove.MorePerform.ShowDamagePop.PopDamage(
ctx, // 默认画布名称
270, // 英雄位置 x
140, // 英雄位置 y
herodamage, // 伤害值
16, // 默认字体大小
null, //默认字体
18, // 默认字体大小
"Arial", //默认字体
null, // 默认颜色
null, // 默认描边颜色
0, // 默认水平速度
@ -21107,14 +21149,15 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
animateOnAttack('sword', true)
}
if (enemyInfo.isAttack) {
heroInfo.inAttack = true
const enemydamage = -Math.max(enemyInfo.atk - heroInfo.def, 0)
Dove.MorePerform.ShowDamagePop.PopDamage(
ctx, // 默认画布名称
115, // 英雄位置 x
110, // 英雄位置 x
140, // 英雄位置 y
enemydamage, // 伤害值
16, // 默认字体大小
null, //默认字体
18, // 默认字体大小
"Arial", //默认字体
null, // 默认颜色
null, // 默认描边颜色
0, // 默认水平速度
@ -21135,6 +21178,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
await Promise.all([await playinganimate(),
new Promise(resolve => {
if (heroInfo.isAttack) {
enemyInfo.inAttack = false
heroInfo.now = 0;
heroInfo.isAttack = false;
}
@ -21142,6 +21186,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
}),
new Promise(resolve => {
if (enemyInfo.isAttack) {
heroInfo.inAttack = false
enemyInfo.now = 0;
enemyInfo.isAttack = false;
}