回合动画优化
This commit is contained in:
parent
973b546a43
commit
57a1b29310
@ -16580,14 +16580,13 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
this.hero = { hp: 1000, atk: 100, def: 100, spell: 100, speed: 10, mdef: 10 }
|
||||
this.boss = { name: "菲奥奈", id: "angel", image: "tati_050143.webp", hp: 1000, atk: 200, def: 100, speed: 10, mdef: 10, skill: ['普通攻击', '重斩'], index: 0 }
|
||||
this.enemy = [
|
||||
{ name: "小蝙蝠", id: "bat", hp: 1000, atk: 100, def: 100, speed: 10, mdef: 10, skill: ['普通攻击', '重斩'], index: 0 },
|
||||
{ name: "红蝙蝠", id: "redBat", hp: 1000, atk: 100, def: 100, speed: 10, mdef: 10, skill: ['普通攻击', '重斩'], index: 0 },
|
||||
{ name: "大蝙蝠", id: "bigBat", hp: 1000, atk: 100, def: 100, speed: 10, mdef: 10, skill: ['普通攻击', '重斩'], index: 0 },
|
||||
{ name: "绿色史莱姆", id: "greenSlime", hp: 1000, atk: 100, def: 100, speed: 10, mdef: 10, skill: ['普通攻击', '重斩'], index: 0 },
|
||||
{ name: "红色史莱姆", id: "redSlime", hp: 1000, atk: 100, def: 100, speed: 10, mdef: 10, skill: ['普通攻击', '重斩'], index: 0 },
|
||||
{ name: "黑色史莱姆", id: "blackSlime", hp: 1000, atk: 100, def: 100, speed: 10, mdef: 10, skill: ['普通攻击', '重斩'], index: 0 },
|
||||
{ name: "小蝙蝠", id: "bat", image: "tati_020125a.webp", hp: 1000, atk: 100, def: 100, speed: 10, mdef: 10, skill: ['普通攻击', '重斩'], index: 0 },
|
||||
{ name: "红蝙蝠", id: "redBat", image: "tati_050301.webp", hp: 1000, atk: 100, def: 100, speed: 10, mdef: 10, skill: ['普通攻击', '重斩'], index: 0 },
|
||||
{ name: "大蝙蝠", id: "bigBat", image: "tati_120101.webp", hp: 1000, atk: 100, def: 100, speed: 10, mdef: 10, skill: ['普通攻击', '重斩'], index: 0 },
|
||||
{ name: "绿色史莱姆", id: "greenSlime", image: "tati_340115.webp", hp: 1000, atk: 100, def: 100, speed: 10, mdef: 10, skill: ['普通攻击', '重斩'], index: 0 },
|
||||
{ name: "红色史莱姆", id: "redSlime", image: "tati_430101.webp", hp: 1000, atk: 100, def: 100, speed: 10, mdef: 10, skill: ['普通攻击', '重斩'], index: 0 },
|
||||
{ name: "黑色史莱姆", id: "blackSlime", image: "tati_440101.webp", hp: 1000, atk: 100, def: 100, speed: 10, mdef: 10, skill: ['普通攻击', '重斩'], index: 0 },
|
||||
]
|
||||
this.bossImage = "tati_050143.webp"
|
||||
this.selection = "boss"
|
||||
this.herobuff = ["sword1:1", "fly:30"]
|
||||
this.bossbuff = ["fly:2", "book:12"]
|
||||
@ -16602,8 +16601,13 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
this.skills = { //技能列表,便于调用(可通过this.skills[name]调用)
|
||||
"菲奥奈": ['普通攻击', '重斩']
|
||||
}
|
||||
this.skillShow = { //技能说明
|
||||
"普通攻击": "常规攻击形式,伤害为自身攻击-对手防御"
|
||||
}
|
||||
this.turn = 0;
|
||||
this.playingAnimate = new Set();
|
||||
this.playerTurn = false
|
||||
this.show = false
|
||||
}
|
||||
|
||||
click(px, py) {
|
||||
@ -16621,9 +16625,42 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
return sx <= x && x <= dx && sy <= y && y <= dy;
|
||||
};
|
||||
const pos = [px, py];
|
||||
if (!this.playerTurn || main.replayChecking || core.isReplaying()) return
|
||||
const enemyStatusBox = makeBox([50, 50], [1900, 200]),
|
||||
heroStatusBox = makeBox([600, 920], [900, 300]),
|
||||
bossBox = makeBox([800, 300], [100, 150]),
|
||||
enemyBox = makeBox([700, 500], [300, 300]),
|
||||
imageBox = makeBox([1500, 250], [550, 1000]);
|
||||
let enemy = true;
|
||||
this.enemy.forEach(v => { if (v.hp > 0) enemy = false })
|
||||
if (this.show) { //清除展示画面
|
||||
this.show = !this.show
|
||||
} else {
|
||||
if (inRect(pos, enemyStatusBox) && this.selection !== "" && enemy) { //绘制怪物详情
|
||||
this.show = !this.show
|
||||
|
||||
} else if (inRect(pos, enemyStatusBox) && !enemy) { //绘制boss详情
|
||||
this.show = !this.show
|
||||
|
||||
} else if (inRect(pos, heroStatusBox)) { //绘制勇士详情
|
||||
this.show = !this.show
|
||||
|
||||
} else if (inRect(pos, bossBox) && enemy) { //切换selection为boss
|
||||
this.selection = 'boss'
|
||||
this.update()
|
||||
|
||||
} else if (inRect(pos, enemyBox) && enemy) { //绘制勇士详情
|
||||
this.selection = Math.floor((px - 700) / 3) + Math.floor((py - 500) / 150) * 3
|
||||
this.update()
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
async bossStart() {
|
||||
boss.style.display = "block"
|
||||
this.selection = "boss"
|
||||
this.playerturn = false
|
||||
this.show = false
|
||||
this.turn = 0
|
||||
core.lockControl()
|
||||
await this.blackBg()
|
||||
@ -16635,6 +16672,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
}
|
||||
async bossEnd() {
|
||||
hero.hp = this.hero.hp
|
||||
this.selection = "boss"
|
||||
await this.close()
|
||||
|
||||
core.unlockControl()
|
||||
@ -16852,7 +16890,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
} else {
|
||||
posx += 100
|
||||
if (i === 2) {
|
||||
posx = 600
|
||||
posx = 700
|
||||
posy += 150
|
||||
}
|
||||
continue
|
||||
@ -16993,7 +17031,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
|
||||
if (!data) {
|
||||
|
||||
core.registerAnimationFrame("animateboss")
|
||||
core.unregisterAnimationFrame("animateboss")
|
||||
resolve()
|
||||
} else {
|
||||
data.imageList.forEach(function (image) {
|
||||
@ -17094,7 +17132,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
ctx6.restore();
|
||||
if (one.farme > data.allFarme) {
|
||||
core.clearMap(ctx6)
|
||||
core.registerAnimationFrame("animateboss")
|
||||
core.unregisterAnimationFrame("animateboss")
|
||||
resolve()
|
||||
}
|
||||
}
|
||||
@ -17117,7 +17155,11 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
ctx3.canvas.width = 2028;
|
||||
ctx3.canvas.height = 1248;
|
||||
}
|
||||
core.drawImage(ctx3, this.bossImage, 1400, 168, 750, 1080)
|
||||
if (this.selection === "boss" || this.selection === "") {
|
||||
core.drawImage(ctx3, this.boss.image, 1400, 168, 750, 1080)
|
||||
} else {
|
||||
core.drawImage(ctx3, this.enemy[this.selection].image, 1400, 168, 750, 1080)
|
||||
}
|
||||
|
||||
ctx3.restore();
|
||||
}
|
||||
@ -17141,7 +17183,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
ctx3.canvas.width = 2028;
|
||||
ctx3.canvas.height = 1248;
|
||||
}
|
||||
core.drawImage(ctx3, this.bossImage, px, 168, 750, 1080)
|
||||
core.drawImage(ctx3, this.boss.image, px, 168, 750, 1080)
|
||||
px -= 10
|
||||
ctx3.restore();
|
||||
if (px <= 1400) {
|
||||
@ -17268,7 +17310,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
posx += 80
|
||||
}
|
||||
})
|
||||
if (this.selection === "boss") {
|
||||
let enemy = true;
|
||||
this.enemy.forEach(v => { if (v.hp > 0) enemy = false })
|
||||
if (this.selection === "boss" || enemy) {
|
||||
core.drawWindowSkin("winskin.webp", ctx4, 50, 50, 1900, 200, null, null, null, 3)
|
||||
core.fillBoldText1(
|
||||
ctx4,
|
||||
@ -19538,7 +19582,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
core.plugin.playing.add(data);
|
||||
};
|
||||
core.registerAnimationFrame("animateonmap", true, function (timestamp) {
|
||||
if (timestamp - thistime > 1000 / 60) {
|
||||
if (timestamp - thistime > 1000 / 30) {
|
||||
thistime = timestamp;
|
||||
core.clearMap(anctx);
|
||||
core.plugin.playing.forEach((one) => {
|
||||
@ -19773,7 +19817,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
main.dom.replayGame.addEventListener("touchcancel", () => {
|
||||
core.dom.replayGame.style.backgroundColor = "transparent";
|
||||
});
|
||||
},
|
||||
},
|
||||
"天气叠加": function () {
|
||||
//使用方法:使用core.setWeather(天气,等级)来增加天气,使用core.setWeather()来清空天气
|
||||
// 天气叠加功能
|
||||
@ -20035,10 +20079,158 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
animateAttack.style.height = core.__PIXELS__ * core.domStyle.scale + "px";
|
||||
main.dom.animateAttack = animateAttack;
|
||||
const ctx = animateAttack.getContext("2d");
|
||||
core.plugin.playingattack = new Set()
|
||||
const ctx6 = main.dom.animate2.getContext('2d')
|
||||
|
||||
function playanimate(name, x, y, scalex = 1, scaley = 1) {
|
||||
const data = {
|
||||
name: name,
|
||||
x: x,
|
||||
y: y,
|
||||
scalex: scalex,
|
||||
scaley: scaley,
|
||||
farme: 0
|
||||
|
||||
}
|
||||
core.plugin.playingattack.add(data)
|
||||
}
|
||||
|
||||
function playinganimate() {
|
||||
let time = 0
|
||||
if (core.plugin.playingattack.size === 0) return Promise.resolve()
|
||||
return new Promise((resolve) => {
|
||||
core.registerAnimationFrame("animateenemyattack", true, (timestamp) => {
|
||||
if (timestamp - time > 1000 / 60) {
|
||||
time = timestamp;
|
||||
core.clearMap(ctx6);
|
||||
|
||||
core.plugin.playingattack.forEach((one) => {
|
||||
const data = flags["animate_" + one.name];
|
||||
|
||||
if (!data) {
|
||||
core.plugin.playingattack.delete(one);
|
||||
if (core.plugin.playingattack.size === 0) {
|
||||
core.unregisterAnimationFrame("animateenemyattack")
|
||||
resolve()
|
||||
}
|
||||
} else {
|
||||
data.imageList.forEach(function (image) {
|
||||
if (
|
||||
one.farme >= (image.beforefarme ?? 0) &&
|
||||
one.farme <= (image.afterfarme ?? data.allFarme)
|
||||
) {
|
||||
const img = core.material.images.images?.[image.image];
|
||||
if (img) {
|
||||
const gla = image.globalAlpha ?? 100;
|
||||
const agla = image.aglobalAlpha ?? gla,
|
||||
beforefarme = image.beforefarme ?? 0;
|
||||
const afterfarme = image.afterfarme ?? data.allFarme;
|
||||
|
||||
ctx6.globalAlpha =
|
||||
(gla +
|
||||
((agla - gla) * (one.farme - beforefarme)) /
|
||||
(afterfarme - beforefarme || 1)) /
|
||||
100;
|
||||
|
||||
const cx =
|
||||
(image.cx ?? 0) +
|
||||
(((image.acx ?? 0) - (image.cx ?? 0)) *
|
||||
(one.farme - beforefarme)) /
|
||||
(afterfarme - beforefarme || 1),
|
||||
cy =
|
||||
(image.cy ?? 0) +
|
||||
(((image.acy ?? 0) - (image.cy ?? 0)) *
|
||||
(one.farme - beforefarme)) /
|
||||
(afterfarme - beforefarme || 1),
|
||||
cw =
|
||||
(image.cw ?? img.width) +
|
||||
(((image.acw ?? img.width) - (image.cw ?? img.width)) *
|
||||
(one.farme - beforefarme)) /
|
||||
(afterfarme - beforefarme || 1),
|
||||
ch =
|
||||
(image.ch ?? img.height) +
|
||||
(((image.acw ?? img.height) - (image.cw ?? img.height)) *
|
||||
(one.farme - beforefarme)) /
|
||||
(afterfarme - beforefarme || 1),
|
||||
x =
|
||||
(image.x ?? 0) +
|
||||
(((image.ax ?? 0) - (image.x ?? 0)) *
|
||||
(one.farme - beforefarme)) /
|
||||
(afterfarme - beforefarme || 1),
|
||||
y =
|
||||
(image.y ?? 0) +
|
||||
(((image.ay ?? 0) - (image.y ?? 0)) *
|
||||
(one.farme - beforefarme)) /
|
||||
(afterfarme - beforefarme || 1),
|
||||
w =
|
||||
(image.w ?? one.width) +
|
||||
(((image.aw ?? one.width) - (image.w ?? one.width)) *
|
||||
(one.farme - beforefarme)) /
|
||||
(afterfarme - beforefarme || 1),
|
||||
h =
|
||||
(image.h ?? one.height) +
|
||||
(((image.aw ?? one.height) - (image.w ?? one.height)) *
|
||||
(one.farme - beforefarme)) /
|
||||
(afterfarme - beforefarme || 1),
|
||||
angle =
|
||||
(Math.PI *
|
||||
((image.image.angle ?? 0) +
|
||||
(((image.aangle ?? 0) - (image.image.angle ?? 0)) *
|
||||
(one.farme - beforefarme)) /
|
||||
(afterfarme - beforefarme || 1))) /
|
||||
180;
|
||||
|
||||
|
||||
core.drawImage(
|
||||
ctx6,
|
||||
img,
|
||||
cx,
|
||||
cy,
|
||||
cw,
|
||||
ch,
|
||||
one.x + (x - data.px) * one.scalex,
|
||||
one.y + (y - data.py) * one.scaley,
|
||||
w * one.scalex,
|
||||
h * one.scaley,
|
||||
angle
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
data.soundList.forEach(function (sound) {
|
||||
const lisen =
|
||||
sound.sound &&
|
||||
core.sounds[sound.sound] &&
|
||||
core.musicStatus.soundStatus;
|
||||
if (one.farme == sound.startfarme && lisen) {
|
||||
if (sound.stopbefore) core.stopSound();
|
||||
core.playSound(sound.sound);
|
||||
}
|
||||
});
|
||||
one.farme++;
|
||||
ctx6.restore();
|
||||
if (one.farme > data.allFarme) {
|
||||
core.clearMap(ctx6)
|
||||
core.plugin.playingattack.delete(one)
|
||||
if (core.plugin.playingattack.size === 0) {
|
||||
core.unregisterAnimationFrame("animateenemyattack")
|
||||
resolve()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
main.dom.gameDraw.appendChild(animateAttack);
|
||||
const { lcm, gcd } = core.plugin.utils
|
||||
this.drawAttackAnimate = function (
|
||||
this.drawAttackAnimate = async function (
|
||||
heroInfo,
|
||||
oneTurn,
|
||||
enemyInfo,
|
||||
@ -20369,34 +20561,51 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
}
|
||||
});
|
||||
if (!attack && nowattacking) {
|
||||
if (heroInfo.isAttack) {
|
||||
animateOnAttack("sword", true, () => {
|
||||
heroInfo.now = 0;
|
||||
heroInfo.isAttack = false;
|
||||
});
|
||||
}
|
||||
if (enemyInfo.isAttack) {
|
||||
animateOnAttack("sword", false, () => {
|
||||
enemyInfo.now = 0;
|
||||
enemyInfo.isAttack = false;
|
||||
});
|
||||
}
|
||||
if (heroInfo.isAttack) animateOnAttack('sword', true)
|
||||
if (enemyInfo.isAttack) animateOnAttack('sword', false)
|
||||
if (equipanimate.length > 0) {
|
||||
equipanimate.forEach(v => {
|
||||
animateOnAttack("sword", true, () => {
|
||||
v.now = 0;
|
||||
v.isAttack = false;
|
||||
});
|
||||
animateOnAttack('sword', true)
|
||||
})
|
||||
}
|
||||
|
||||
await Promise.all([await playinganimate(),
|
||||
new Promise(resolve => {
|
||||
if (heroInfo.isAttack) {
|
||||
heroInfo.now = 0;
|
||||
heroInfo.isAttack = false;
|
||||
}
|
||||
resolve()
|
||||
}),
|
||||
new Promise(resolve => {
|
||||
if (enemyInfo.isAttack) {
|
||||
enemyInfo.now = 0;
|
||||
enemyInfo.isAttack = false;
|
||||
}
|
||||
resolve()
|
||||
}),
|
||||
new Promise(resolve => {
|
||||
if (equipanimate.length > 0) {
|
||||
equipanimate.forEach(v => {
|
||||
v.now = 0;
|
||||
v.isAttack = false;
|
||||
})
|
||||
}
|
||||
resolve()
|
||||
})
|
||||
])
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
function animateOnAttack(name, onenemy, callback) {
|
||||
function animateOnAttack(name, onenemy) {
|
||||
if (onenemy) {
|
||||
core.playanimate(name, 290, 160, null, 1, 1, callback);
|
||||
playanimate(name, 290, 160);
|
||||
} else {
|
||||
core.playanimate(name, 130, 160, null, 1, 1, callback);
|
||||
playanimate(name, 130, 160);
|
||||
}
|
||||
}
|
||||
|
||||
@ -21084,7 +21293,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
["梅尔特", "「我忘记了」"],
|
||||
["吉克", "「骗人」"],
|
||||
];
|
||||
},
|
||||
},
|
||||
"勇士法抗乘算叠加": function () {
|
||||
// 在此增加新插件
|
||||
items.prototype.compareEquipment = function (compareEquipId, beComparedEquipId) {
|
||||
|
Loading…
Reference in New Issue
Block a user