From 9c574fc48623f1d0617991a5fae0f51f1c899b05 Mon Sep 17 00:00:00 2001 From: strawberry42271 <2806566736@qq.com> Date: Fri, 11 Apr 2025 11:51:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B8=A7=E5=8A=A8=E7=94=BB=E9=87=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/MotaAction.g4 | 96 +++- _server/MotaActionParser.js | 93 +++ project/floors/jiaocheng02.js | 23 + project/plugins.js | 1020 ++++++++++++++++----------------- 4 files changed, 719 insertions(+), 513 deletions(-) diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index d8efed5..753f0d2 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -963,6 +963,7 @@ action | addPop_s | setq_s | setcgs_s + | animationDrawable_s | over_s | overlist_s | cgtextList_s @@ -1072,6 +1073,97 @@ if (block.isCollapsed() || !block.isEnabled() || pos || Int_0 || Bool_0) { return code+',\n'; */; + +animationDrawable_s + : '帧动画' '总显示帧数' IntString '底色' ColorString? Colour '底色不透明度' IntString? BGNL?Newline + '图片序列(同一帧后面覆盖先前的,默认起始帧为0,结束帧为最后一帧)'BGNL?Newline + '(剪裁区域不填写为全图,绘制区域不填写为全画面)'BGNL?Newline + '(不透明度100为不透明,默认为不透明,结束不透明度默认与开始透明度相同)'BGNL?Newline + animationDrawableimage+? Newline + '音频序列(到达对应帧进行播放)'BGNL?Newline + animationDrawablesound+? Newline + + +/* animationDrawable_s +tooltip : animationDrawable:帧动画图片叠加 +helpUrl : /_docs/#/instruction +default : [30,"0, 0, 0",'rgb(0, 0, 0)',""] +allImages : ['EvalString_0'] +colour : this.imageColor +if (IntString_1&&(IntString_1 < 0||IntString_1>100)) throw new Error('透明度范围为0-100,0为透明,100为不透明,不填默认为不透明') + +ColorString_0 = ColorString_0 ? (', "color": ['+ColorString_0+']') : ''; +IntString_1 = IntString_1 ? (', "globalAlpha": '+IntString_1+'') : ''; +var imageList=animationDrawableimage_0?',"imageList": [\n'+animationDrawableimage_0.slice(0,-1)+'\n]':'' +var soundList=animationDrawablesound_0?',"soundList": [\n'+animationDrawablesound_0.slice(0,-1)+'\n]':'' +var code = '{"type": "animationDrawable", "allFarme": '+IntString_0+ColorString_0+IntString_1+imageList+soundList+'},\n'; +return code; +*/; + +animationDrawableList + : animationDrawableimage + | animationDrawablesound + | animationDrawabletextEmpty; + +animationDrawableimage + : '图片' EvalString? '起始帧' IntString? '起始不透明度' IntString? BGNL? Newline + '剪裁坐标cx' IntString? 'cy' IntString? '宽' IntString? '高' IntString? '绘制坐标x'IntString? 'y' IntString? '宽' IntString? '高' IntString? BGNL? Newline + '结束帧' IntString? '结束不透明度' IntString? '剪裁坐标cx' IntString? 'cy' IntString? '宽' IntString? '高' IntString? '绘制坐标x'IntString? 'y' IntString? '宽' IntString? '高' IntString? Newline +/* animationDrawableimage +tooltip : 帧动画图片列表 +helpUrl : /_docs/#/instruction +default : ["","","","","","","","","","","","","","","","","","","","",""] +colour : this.subColor +allImages : ['EvalString_0'] +if (IntString_1&&(IntString_1 < 0||IntString_1>100)) throw new Error('不透明度范围为0-100,0为透明,100为不透明,不填默认为不透明') +if (IntString_11&&(IntString_11 < 0||IntString_11>100)) throw new Error('不透明度范围为0-100,0为透明,100为不透明,不填默认为不透明') +IntString_0 = IntString_0 ? (', "beforefarme": '+IntString_0+'') : ''; +IntString_1 = IntString_1 ? (', "globalAlpha": '+IntString_1+'') : ''; +IntString_2 = IntString_2 ? (', "cx": '+IntString_2+'') : ''; +IntString_3 = IntString_3 ? (', "cy": '+IntString_3+'') : ''; +IntString_4 = IntString_4 ? (', "cw": '+IntString_4+'') : ''; +IntString_5 = IntString_5 ? (', "ch": '+IntString_5+'') : ''; +IntString_6 = IntString_6 ? (', "x": '+IntString_6+'') : ''; +IntString_7 = IntString_7 ? (', "y": '+IntString_7+'') : ''; +IntString_8 = IntString_8 ? (', "w": '+IntString_8+'') : ''; +IntString_9 = IntString_9 ? (', "h": '+IntString_9+'') : ''; + +IntString_10 = IntString_10 ? (', "afterfarme": '+IntString_10+'') : ''; +IntString_11 = IntString_11 ? (', "aglobalAlpha": '+IntString_11+'') : ''; +IntString_12 = IntString_12 ? (', "acx": '+IntString_12+'') : ''; +IntString_13 = IntString_13 ? (', "acy": '+IntString_13+'') : ''; +IntString_14 = IntString_14 ? (', "acw": '+IntString_14+'') : ''; +IntString_15 = IntString_15 ? (', "ach": '+IntString_15+'') : ''; +IntString_16 = IntString_16 ? (', "ax": '+IntString_16+'') : ''; +IntString_17 = IntString_17 ? (', "ay": '+IntString_17+'') : ''; +IntString_18 = IntString_18 ? (', "aw": '+IntString_18+'') : ''; +IntString_19 = IntString_19 ? (', "ah": '+IntString_19+'') : ''; + +return '{ "image":"'+EvalString_0+'"'+IntString_0+IntString_1+IntString_2+IntString_3+IntString_4+IntString_5+IntString_6+IntString_7+IntString_8+IntString_9+IntString_10+IntString_11+IntString_12+IntString_13+IntString_14+IntString_15+IntString_16+IntString_17+IntString_18+IntString_19+'},' +*/; + +animationDrawablesound + : '音效' EvalString? '起始帧' IntString '是否停止其他音效'Bool? Newline + +/* animationDrawablesound +tooltip : 帧动画配音 +helpUrl : /_docs/#/instruction +default : ["",0,false] +colour : this.subColor +allSounds : ['EvalString_0'] + +return '{ "sound":"'+EvalString_0+'","startfarme":'+IntString_0+',"stopbefore":'+Bool_0+'},' +*/; + +animationDrawabletextEmpty + : Newline + +/* animationDrawabletextEmpty +var code = []; +return code; +*/; + + over_s : '旁白文字' ':' EvalString BGNL? Newline '背景' EvalString? '回忆滤镜' Bool? '持续帧数' Int? '渐入渐出帧数' Int? '音频文件' EvalString? BGNL? Newline @@ -2001,10 +2093,10 @@ drawWarning_s /* drawWarning_s tooltip : drawWarning: 绘制warning警告并拉进镜头,本事件为异步事件,下一事件将在3100ms后执行 helpUrl : /_docs/#/instruction -default : [0, 0,'2',24,"这里是提示内容","绿色史莱姆",false] +default : [0, 0,2,24,"这里是提示内容","绿色史莱姆",false] colour : this.soundColor selectPoint : ["PosString_0", "PosString_1"] -if(!EvalString_1||!/^(0|([1-9][0-9]*))(\.[\d]+)?$/.test(EvalString_1))throw new Error("此项仅能填写小数或整数"); +if(!EvalString_1||!/^(0|([1-9][0-9]*))(\.[\d]+)?$/.test(EvalString_0))throw new Error("此项仅能填写小数或整数"); var code = '{"type": "drawWarning", "x": '+PosString_0+', "y": '+PosString_1+',"large":'+EvalString_0+',"size":'+Int_0+',"text": "'+EvalString_1+'", "text2": "'+EvalString_2+'", "warning": '+Bool_0+'},\n'; return code; */; diff --git a/_server/MotaActionParser.js b/_server/MotaActionParser.js index b59b6d2..5fdf9e4 100644 --- a/_server/MotaActionParser.js +++ b/_server/MotaActionParser.js @@ -1017,6 +1017,62 @@ MotaActionParser = function () { ]); } break; + case "animationDrawable": + var buildanimationDrawableimage = function (obj) { + obj = MotaActionFunctions.processanimationDrawableimage(obj || []); + var res = null; + for (var ii = obj.length - 1, one; (one = obj[ii]); ii--) { + res = MotaActionBlocks["animationDrawableimage"].xmlText([ + one[0], + one[1], + one[2], + one[3], + one[4], + one[5], + one[6], + one[7], + one[8], + one[9], + one[10], + one[11], + one[12], + one[13], + one[14], + one[15], + one[16], + one[17], + one[18], + one[19], + one[20], + res, + ]); + } + return res; + }; + var buildanimationDrawablesound = function (obj) { + obj = MotaActionFunctions.processanimationDrawablesound(obj || []); + var res = null; + for (var ii = obj.length - 1, one; (one = obj[ii]); ii--) { + res = MotaActionBlocks["animationDrawablesound"].xmlText([ + one[0], + one[1], + one[2], + res, + ]); + } + return res; + }; + this.next = MotaActionBlocks["animationDrawable_s"].xmlText([ + data.allFarme, + data.color, + "rgba(" + data.color + ")", + data.globalAlpha, + buildanimationDrawableimage(data.imageList), + buildanimationDrawablesound(data.soundList), + this.next, + ]); + break; + case "jumpHero": // 跳跃勇士 if (data.dxy) { this.next = MotaActionBlocks["jumpHero_1_s"].xmlText([ @@ -3104,6 +3160,43 @@ MotaActionParser = function () { return str; }; + MotaActionFunctions.processanimationDrawableimage = function (overList) { + var list = []; + overList.forEach(function (one) { + list.push([ + one.image, + one.beforefarme, + one.globalAlpha, + one.cx, + one.cy, + one.cw, + one.ch, + one.x, + one.y, + one.w, + one.h, + one.afterfarme, + one.aglobalAlpha, + one.acx, + one.acy, + one.acw, + one.ach, + one.ax, + one.ay, + one.aw, + one.ah, + ]); + }); + return list; + }; + MotaActionFunctions.processanimationDrawablesound = function (overList) { + var list = []; + overList.forEach(function (one) { + list.push([one.sound, one.startfarme, one.stopbefore]); + }); + return list; + }; + MotaActionFunctions.replaceFromName = function (str) { if (!str || MotaActionFunctions.disableReplace) return str; var map = {}, diff --git a/project/floors/jiaocheng02.js b/project/floors/jiaocheng02.js index 8cea02c..7990160 100644 --- a/project/floors/jiaocheng02.js +++ b/project/floors/jiaocheng02.js @@ -284,6 +284,29 @@ main.floors.jiaocheng02= "type": "hide", "remove": true } + ], + "3,8": [ + { + "type": "animationDrawable", + "allFarme": 30, + "color": [ + 0, + 0, + 0 + ], + "imageList": [ + { + "image": "" + } + ], + "soundList": [ + { + "sound": "", + "startfarme": 0, + "stopbefore": false + } + ] + } ] }, "changeFloor": { diff --git a/project/plugins.js b/project/plugins.js index 9139aab..6b6eec4 100644 --- a/project/plugins.js +++ b/project/plugins.js @@ -2774,6 +2774,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = const uictx = main.dom.outerUI.getContext("2d"); let now = 0; core.registerAnimationFrame("lightFloor", true, function (timestamp) { + if(!core.status.floorId)return if (timestamp - now > 1000 / 60) { now = timestamp; globalAlphafloor += globalAlphafloorStatus; @@ -4671,8 +4672,8 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = } }, "跳伤": function () { - // 在此增加新插件 - /** + // 在此增加新插件 + /** 函数使用说明 Dove.MorePerform.ShowDamagePop.PopDamage( 'ui', // 画布名称或画布2d上下文对象 @@ -4687,219 +4688,216 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = 0.5, // 重力 (gravity) 120 // 显示时长(帧数) */ - if (!core.registerAnimationFrame) { - throw new Error("require 2.6.1 or higher version"); - } + if (!core.registerAnimationFrame) { + throw new Error("require 2.6.1 or higher version"); + } - window.Dove = window.Dove || {}; - Dove.MorePerform = Dove.MorePerform || {}; + window.Dove = window.Dove || {}; + Dove.MorePerform = Dove.MorePerform || {}; - Dove.MorePerform.ShowDamagePop = {}; - Dove.MorePerform.ShowDamagePop.version = 1.0; + Dove.MorePerform.ShowDamagePop = {}; + Dove.MorePerform.ShowDamagePop.version = 1.0; - Dove.MorePerform.ShowDamagePop.AllPopingCanvas = []; + Dove.MorePerform.ShowDamagePop.AllPopingCanvas = []; - // 每帧的处理 - Dove.MorePerform.ShowDamagePop.Update = function () { - this.AllPopingCanvas = this.AllPopingCanvas.filter(function (spr) { - spr.update(); - return spr.isAlive(); - }); - if (!this.AllPopingCanvas.length) PopSprite._count = 0; - }; + // 每帧的处理 + Dove.MorePerform.ShowDamagePop.Update = function () { + this.AllPopingCanvas = this.AllPopingCanvas.filter(function (spr) { + spr.update(); + return spr.isAlive(); + }); + if (!this.AllPopingCanvas.length) PopSprite._count = 0; + }; - // 弹出伤害气泡 - Dove.MorePerform.ShowDamagePop.PopDamage = function ( - canvasName, - x, - y, - damageValue, - fontSize, - font, - fontColor, - outlineColor, - speedX, - speedY, - gravity, - duration - ) { - if (damageValue) { - var poper = new PopSprite( - canvasName, - x, - y, - damageValue, - fontSize, - font, - fontColor, - outlineColor, - speedX, - speedY, - gravity, - duration - ); - Dove.MorePerform.ShowDamagePop.AllPopingCanvas.push(poper); - } - }; + // 弹出伤害气泡 + Dove.MorePerform.ShowDamagePop.PopDamage = function ( + canvasName, + x, + y, + damageValue, + fontSize, + font, + fontColor, + outlineColor, + speedX, + speedY, + gravity, + duration + ) { + if (damageValue) { + var poper = new PopSprite( + canvasName, + x, + y, + damageValue, + fontSize, + font, + fontColor, + outlineColor, + speedX, + speedY, + gravity, + duration + ); + Dove.MorePerform.ShowDamagePop.AllPopingCanvas.push(poper); + } + }; - // 战斗发生前后记录生命值并处理 - Dove.MorePerform.ShowDamagePop.OnBattle = core.events.battle; - core.events.battle = function () { - var hpBeforeBattle = core.status.hero.hp; - Dove.MorePerform.ShowDamagePop.OnBattle.apply(core.events, arguments); - if (core.getFlag("noAnimate")) - Dove.MorePerform.ShowDamagePop.PopDamage( - "ui", // 默认画布名称 - core.getHeroLoc("x") * 32, // 英雄位置 x - core.getHeroLoc("y") * 32, // 英雄位置 y - Math.floor(core.status.hero.hp - hpBeforeBattle), // 伤害值 - 16, // 默认字体大小 - "Arial", //默认字体 - null, // 默认颜色 - null, // 默认描边颜色 - null, // 默认水平速度 - null, // 默认垂直速度 - null, // 默认重力 - 90 // 默认显示时长(帧数) - ); - }; - let time = 0; - // 注册每帧事件 - core.registerAnimationFrame("ShowDamagePop", true, (temptime) => { - if (temptime - time > 1000 / 60) { - time = temptime; + // 战斗发生前后记录生命值并处理 + Dove.MorePerform.ShowDamagePop.OnBattle = core.events.battle; + core.events.battle = function () { + var hpBeforeBattle = core.status.hero.hp; + Dove.MorePerform.ShowDamagePop.OnBattle.apply(core.events, arguments); + if (core.getFlag("noAnimate")) + Dove.MorePerform.ShowDamagePop.PopDamage( + "ui", // 默认画布名称 + core.getHeroLoc("x") * 32, // 英雄位置 x + core.getHeroLoc("y") * 32, // 英雄位置 y + Math.floor(core.status.hero.hp - hpBeforeBattle), // 伤害值 + 16, // 默认字体大小 + "Arial", //默认字体 + null, // 默认颜色 + null, // 默认描边颜色 + null, // 默认水平速度 + null, // 默认垂直速度 + null, // 默认重力 + 90 // 默认显示时长(帧数) + ); + }; + // 注册每帧事件 + core.registerAnimationFrame("ShowDamagePop", true, (temptime) => { - Dove.MorePerform.ShowDamagePop.Update.bind( - Dove.MorePerform.ShowDamagePop - )(); - } - }); + Dove.MorePerform.ShowDamagePop.Update.bind( + Dove.MorePerform.ShowDamagePop + )(); - // 弹出精灵类 - function PopSprite( - canvasName, - x, - y, - damage, - fontSize, - font, - fontColor, - outlineColor, - speedX, - speedY, - gravity, - duration - ) { - this.initialize.apply(this, arguments); - } + }); - PopSprite.prototype = Object.create(Object.prototype); - PopSprite.prototype.constructor = PopSprite; + // 弹出精灵类 + function PopSprite( + canvasName, + x, + y, + damage, + fontSize, + font, + fontColor, + outlineColor, + speedX, + speedY, + gravity, + duration + ) { + this.initialize.apply(this, arguments); + } - // 常量 - PopSprite._count = 0; - PopSprite._baseZOrder = 50; - PopSprite._floorDis = 20; + PopSprite.prototype = Object.create(Object.prototype); + PopSprite.prototype.constructor = PopSprite; - // 初始化 - PopSprite.prototype.initialize = function ( - canvasName, - x, - y, - damage, - fontSize, - font, - fontColor, - outlineColor, - speedX, - speedY, - gravity, - duration - ) { - this._canvasName = canvasName ?? "ui"; // 默认画布名称 - this._x = x; - this._y = y; - this._damage = damage; - this._fontSize = fontSize ?? 16; // 默认字体大小 - this._font = font ?? "Arial"; - this._fontColor = fontColor ?? (damage > 0 ? "#22FF44" : "lightcoral"); // 默认颜色 - this._outlineColor = outlineColor ?? "#FFFFFF"; // 默认描边颜色 - this._speedX = speedX ?? -1 + Math.random() * 2; // 水平速度,默认随机 - this._speedY = speedY ?? -3 - Math.random() * 4; // 垂直速度,默认随机 - this._gravity = gravity ?? 0.3; // 重力加速度,默认 0.3 - this._duration = duration ?? 180; // 显示时长(帧数),默认 180 帧 - this.initAllMembers(); - this.requestCanvas(); - }; + // 常量 + PopSprite._count = 0; + PopSprite._baseZOrder = 50; + PopSprite._floorDis = 20; - // 自更新 - PopSprite.prototype.update = function () { - if (this._timer < this._duration) { - // 使用传入的显示时长 - this._x += this._vx; - this._y += this._vy; - this._vy += this._gravity; - if (this._y >= this._floorY) { - this._y = this._floorY; - this._vy *= -0.75; // 反弹衰减 - } - core.relocateCanvas(this._symbol, this._x, this._y); - core.setOpacity(this._symbol, 1 - this._timer / this._duration); // 根据显示时长设置透明度 - } else { - this.dispose(); - } - this._timer++; - }; + // 初始化 + PopSprite.prototype.initialize = function ( + canvasName, + x, + y, + damage, + fontSize, + font, + fontColor, + outlineColor, + speedX, + speedY, + gravity, + duration + ) { + this._canvasName = canvasName ?? "ui"; // 默认画布名称 + this._x = x; + this._y = y; + this._damage = damage; + this._fontSize = fontSize ?? 16; // 默认字体大小 + this._font = font ?? "Arial"; + this._fontColor = fontColor ?? (damage > 0 ? "#22FF44" : "lightcoral"); // 默认颜色 + this._outlineColor = outlineColor ?? "#FFFFFF"; // 默认描边颜色 + this._speedX = speedX ?? -1 + Math.random() * 2; // 水平速度,默认随机 + this._speedY = speedY ?? -3 - Math.random() * 4; // 垂直速度,默认随机 + this._gravity = gravity ?? 0.3; // 重力加速度,默认 0.3 + this._duration = duration ?? 180; // 显示时长(帧数),默认 180 帧 + this.initAllMembers(); + this.requestCanvas(); + }; - // 申请并描绘canvas - PopSprite.prototype.requestCanvas = function () { - core.createCanvas( - this._symbol, - this._x, - this._y, - this._width + 4, - this._height + 4, - this._z - ); + // 自更新 + PopSprite.prototype.update = function () { + if (this._timer < this._duration) { + // 使用传入的显示时长 + this._x += this._vx; + this._y += this._vy; + this._vy += this._gravity; + if (this._y >= this._floorY) { + this._y = this._floorY; + this._vy *= -0.75; // 反弹衰减 + } + core.relocateCanvas(this._symbol, this._x, this._y); + core.setOpacity(this._symbol, 1 - this._timer / this._duration); // 根据显示时长设置透明度 + } else { + this.dispose(); + } + this._timer++; + }; - var canvas = core.getContextByName(this._symbol); - canvas.font = this._fontSize + "px " + this._font; // 动态设置字体大小 - canvas.fillStyle = this._fontColor; // 动态设置字体颜色 - canvas.strokeStyle = this._outlineColor; // 动态设置描边颜色 - canvas.strokeText(this._text, 2, this._height); - canvas.fillText(this._text, 2, this._height); - }; + // 申请并描绘canvas + PopSprite.prototype.requestCanvas = function () { + core.createCanvas( + this._symbol, + this._x, + this._y, + this._width + 4, + this._height + 4, + this._z + ); - // 初始化所有成员变量 - PopSprite.prototype.initAllMembers = function () { - this._text = String(this._damage); - var uiContext = core.ui.getContextByName(this._canvasName); // 使用指定画布 - uiContext.font = this._fontSize + "px " + this._font; // 动态设置字体大小 - var textRect = uiContext.measureText(this._text); - this._width = textRect.width + 4; - this._height = this._fontSize + 4; // 动态设置高度 - this._z = uiContext.canvas.style.zIndex - ? Number(uiContext.canvas.style.zIndex) + PopSprite._count - : PopSprite._baseZOrder + PopSprite._count; - this._symbol = "popSprite" + PopSprite._count++; - this._alive = true; - this._vx = this._speedX; // 使用传入的水平速度 - this._vy = this._speedY; // 使用传入的垂直速度 - this._floorY = this._y + PopSprite._floorDis; - this._timer = 0; - }; + var canvas = core.getContextByName(this._symbol); + canvas.font = this._fontSize + "px " + this._font; // 动态设置字体大小 + canvas.fillStyle = this._fontColor; // 动态设置字体颜色 + canvas.strokeStyle = this._outlineColor; // 动态设置描边颜色 + canvas.strokeText(this._text, 2, this._height); + canvas.fillText(this._text, 2, this._height); + }; - // 判断是否存活 - PopSprite.prototype.isAlive = function () { - return this._alive; - }; + // 初始化所有成员变量 + PopSprite.prototype.initAllMembers = function () { + this._text = String(this._damage); + var uiContext = core.ui.getContextByName(this._canvasName); // 使用指定画布 + uiContext.font = this._fontSize + "px " + this._font; // 动态设置字体大小 + var textRect = uiContext.measureText(this._text); + this._width = textRect.width + 4; + this._height = this._fontSize + 4; // 动态设置高度 + this._z = uiContext.canvas.style.zIndex ? + Number(uiContext.canvas.style.zIndex) + PopSprite._count : + PopSprite._baseZOrder + PopSprite._count; + this._symbol = "popSprite" + PopSprite._count++; + this._alive = true; + this._vx = this._speedX; // 使用传入的水平速度 + this._vy = this._speedY; // 使用传入的垂直速度 + this._floorY = this._y + PopSprite._floorDis; + this._timer = 0; + }; - // 释放 - PopSprite.prototype.dispose = function () { - this._alive = false; - core.deleteCanvas(this._symbol); - }; - }, + // 判断是否存活 + PopSprite.prototype.isAlive = function () { + return this._alive; + }; + + // 释放 + PopSprite.prototype.dispose = function () { + this._alive = false; + core.deleteCanvas(this._symbol); + }; +}, "编辑器显伤": function () { // 在此增加新插件 /////// 用户设置 /////// @@ -15303,228 +15301,225 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = }; }, "信息弹出": function () { - // 在此增加新插件 - /* 弹出显示某个内容 - * 使用方法:core.addPop(px, py, value, color, boldColor, left, jump, time, show, font, speed) - * 参数说明: - * px & py: number 弹出位置 - * value: string 显示内容 - * color: string 填充颜色 - * boldColor: string 描边颜色 - */ + // 在此增加新插件 + /* 弹出显示某个内容 + * 使用方法:core.addPop(px, py, value, color, boldColor, left, jump, time, show, font, speed) + * 参数说明: + * px & py: number 弹出位置 + * value: string 显示内容 + * color: string 填充颜色 + * boldColor: string 描边颜色 + */ - // 默认字体 - var fontD = "16px Verdana"; - // 默认颜色 - var colorD = "red"; - // 默认描边颜色 - var boldColorD = "black"; + // 默认字体 + var fontD = "16px Verdana"; + // 默认颜色 + var colorD = "red"; + // 默认描边颜色 + var boldColorD = "black"; - /** 血量弹出 */ - function pop() { - var ctx = core.getContextByName("pop"); - if (!ctx) - ctx = core.createCanvas( - "pop", - 0, - 0, - core.__PIXELS__, - core.__PIXELS__, - 90 - ); - ctx.canvas.classList.add("gameCanvas", "anti-aliasing"); - core.clearMap(ctx); - core.setTextAlign("pop", "left"); - var list = core.status.pop || []; - var count = 0; - list.forEach(function (one) { - // 由frame计算出dy - var dy = 6 - one.frame * 0.2; - var dx = one.speed; - if (one.jump) { - one.py -= dy; - } - if (!one.left) { - one.px += dx; - } else { - one.px -= dx; - } - one.frame++; - // 绘制 - if (one.frame >= one.time) - core.setAlpha(ctx, 1 - (one.frame - one.time) / one.show); - else core.setAlpha(ctx, 1); - core.fillBoldText1( - ctx, - one.value, - one.px, - one.py, - one.color || "red", - one.boldColor || "black", - 2, - one.font - ); - if (one.frame >= one.time + one.show) count++; - }); - if (count > 0) list.splice(0, count); - } - let now = 0; - if (!main.replayChecking) - core.registerAnimationFrame("pop", true, (temptime) => { - if (temptime - now > 1000 / 60) { - now = temptime; - pop(); - } - }); + /** 血量弹出 */ + function pop() { + var ctx = core.getContextByName("pop"); + if (!ctx) + ctx = core.createCanvas( + "pop", + 0, + 0, + core.__PIXELS__, + core.__PIXELS__, + 90 + ); + ctx.canvas.classList.add("gameCanvas", "anti-aliasing"); + core.clearMap(ctx); + core.setTextAlign("pop", "left"); + var list = core.status.pop || []; + var count = 0; + list.forEach(function (one) { + // 由frame计算出dy + var dy = 6 - one.frame * 0.2; + var dx = one.speed; + if (one.jump) { + one.py -= dy; + } + if (!one.left) { + one.px += dx; + } else { + one.px -= dx; + } + one.frame++; + // 绘制 + if (one.frame >= one.time) + core.setAlpha(ctx, 1 - (one.frame - one.time) / one.show); + else core.setAlpha(ctx, 1); + core.fillBoldText1( + ctx, + one.value, + one.px, + one.py, + one.color || "red", + one.boldColor || "black", + 2, + one.font + ); + if (one.frame >= one.time + one.show) count++; + }); + if (count > 0) list.splice(0, count); + } + if (!main.replayChecking) + core.registerAnimationFrame("pop", true, (temptime) => { + pop(); - /** 添加弹出内容 */ - this.addPop = function ( - value, - px, - py, - color, - boldColor, - left, - jump, - time, - show, - font, - speed - ) { - var data = { - px: px, - py: py, - value: value, - color: color || colorD, - boldColor: boldColor || boldColorD, - frame: 0, - left: left || false, - jump: jump || false, - time: time || 60, - show: show || 30, - font: font || fontD, - speed: speed || 1, - }; - if (!core.status.pop) core.status.pop = [data]; - else core.status.pop.push(data); - }; - }, + }); + + /** 添加弹出内容 */ + this.addPop = function ( + value, + px, + py, + color, + boldColor, + left, + jump, + time, + show, + font, + speed + ) { + var data = { + px: px, + py: py, + value: value, + color: color || colorD, + boldColor: boldColor || boldColorD, + frame: 0, + left: left || false, + jump: jump || false, + time: time || 60, + show: show || 30, + font: font || fontD, + speed: speed || 1, + }; + if (!core.status.pop) core.status.pop = [data]; + else core.status.pop.push(data); + }; +}, "warning": function () { - // 默认音效名 - var defaultSound = "jingbao.mp3"; - // 默认字体名 - var defaultFont = "Verdana"; + // 默认音效名 + var defaultSound = "jingbao.mp3"; + // 默认字体名 + var defaultFont = "Verdana"; - var timeout; - /** warning提示 - * @param {number} x 横坐标 - * @param {number} y 纵坐标 - * @param {string} text 显示的文字 - */ - this.drawWarning = function ( - x, - y, - text, - text2, - warning, - large = 2, - size = 36 - ) { - if (timeout) return; - x = x ?? 6; - y = y ?? 6; - text = text || "boss"; - text += "
"; - for (var i = 0; i < 10; i++) text += " "; - text += text2; - // 生成文字 - var elements = document.querySelectorAll(".gameCanvas"); - var t = document.createElement("p"); - t.innerHTML = text; - t.style.position = "absolute"; - t.style.fontSize = size * core.domStyle.scale + "px"; - t.style.left = -(300 * core.domStyle.scale) + "px"; - t.style.top = parseInt(elements[0].style.height) / 2 - 100 + "px"; - t.style.zIndex = "300"; - t.style.color = "#f11"; - t.style.fontFamily = defaultFont; - t.style.overflow = "none"; - t.style.width = "100%"; - t.classList.add("warning"); - core.dom.gameDraw.appendChild(t); - setTimeout(function () { - t.style.left = 416 * core.domStyle.scale + "px"; - }, 50); - // 计算偏移量 - var px = ((6 - x) / 12) * (100 - 100 / large + 2); - var py = ((6 - y) / 12) * (100 - 100 / large + 2); - // 修改画布的scale和transform - let time = 0; - let s = 1; - let sx = 0; - let sy = 0; - let cishu = 1; - core.registerAnimationFrame("big", true, function (temptime) { - if (temptime - time > 10) { - time = temptime; - s += (large - 1) / 30; - sx += px / 30; - sy += py / 30; - elements.forEach(function (v) { - if (v instanceof HTMLCanvasElement) { - v.style.transform = - "scale(" + s + ")translate(" + sx + "%, " + sy + "%)"; - } - }); - cishu++; - if (cishu == 30) { - core.unregisterAnimationFrame("big"); - } - } - }); - if (!warning) core.playSound(defaultSound); - // 拉回镜头 - timeout = setTimeout(function () { - // timeout = setTimeout(function () { - // timeout = void 0; - // core.dom.gameDraw.removeChild(t); - // }, 1500); - let time2 = 0; - let s2 = large - (large - 1) / 30; - let sx2 = px; - let sy2 = py; - let cishu2 = 1; - core.registerAnimationFrame("small", true, function (temptime) { - if (temptime - time2 > 10) { - time2 = temptime; - s2 -= (large - 1) / 30; - sx2 -= px / 30; - sy2 -= py / 30; - elements.forEach(function (v) { - if (v instanceof HTMLCanvasElement) { - v.style.transform = - "scale(" + s2 + ")translate(" + sx2 + "%, " + sy2 + "%)"; - } - }); - cishu2++; - if (cishu2 == 30) { - core.unregisterAnimationFrame("small"); - elements.forEach(function (v) { - if (v instanceof HTMLCanvasElement) { - v.style.transform = "none"; - } - }); - } - } - }); - // elements.forEach(function (v) { - // if (v instanceof HTMLCanvasElement) { - // v.style.transform = "none"; - // } - // }); - }, 1600); - }; - }, + var timeout; + /** warning提示 + * @param {number} x 横坐标 + * @param {number} y 纵坐标 + * @param {string} text 显示的文字 + */ + this.drawWarning = function ( + x, + y, + text, + text2, + warning, + large = 2, + size = 36 + ) { + if (timeout) return; + x = x ?? 6; + y = y ?? 6; + text = text || "boss"; + text += "
"; + for (var i = 0; i < 10; i++) text += " "; + text += text2; + // 生成文字 + var elements = document.querySelectorAll(".gameCanvas"); + var t = document.createElement("p"); + t.innerHTML = text; + t.style.position = "absolute"; + t.style.fontSize = size * core.domStyle.scale + "px"; + t.style.left = -(300 * core.domStyle.scale) + "px"; + t.style.top = parseInt(elements[0].style.height) / 2 - 100 + "px"; + t.style.zIndex = "300"; + t.style.color = "#f11"; + t.style.fontFamily = defaultFont; + t.style.overflow = "none"; + t.style.width = "100%"; + t.classList.add("warning"); + core.dom.gameDraw.appendChild(t); + setTimeout(function () { + t.style.left = 416 * core.domStyle.scale + "px"; + }, 50); + // 计算偏移量 + var px = ((6 - x) / 12) * (100 - 100 / large + 2); + var py = ((6 - y) / 12) * (100 - 100 / large + 2); + // 修改画布的scale和transform + let time = 0; + let s = 1; + let sx = 0; + let sy = 0; + let cishu = 1; + core.registerAnimationFrame("big", true, function (temptime) { + if (temptime - time > 10) { + time = temptime; + s += (large - 1) / 30; + sx += px / 30; + sy += py / 30; + elements.forEach(function (v) { + if (v instanceof HTMLCanvasElement) { + v.style.transform = + "scale(" + s + ")translate(" + sx + "%, " + sy + "%)"; + } + }); + cishu++; + if (cishu == 30) { + core.unregisterAnimationFrame("big"); + } + } + }); + if (!warning) core.playSound(defaultSound); + // 拉回镜头 + timeout = setTimeout(function () { + // timeout = setTimeout(function () { + // timeout = void 0; + // core.dom.gameDraw.removeChild(t); + // }, 1500); + let time2 = 0; + let s2 = large - (large - 1) / 30; + let sx2 = px; + let sy2 = py; + let cishu2 = 1; + core.registerAnimationFrame("small", true, function (temptime) { + if (temptime - time2 > 10) { + time2 = temptime; + s2 -= (large - 1) / 30; + sx2 -= px / 30; + sy2 -= py / 30; + elements.forEach(function (v) { + if (v instanceof HTMLCanvasElement) { + v.style.transform = + "scale(" + s2 + ")translate(" + sx2 + "%, " + sy2 + "%)"; + } + }); + cishu2++; + if (cishu2 == 30) { + core.unregisterAnimationFrame("small"); + elements.forEach(function (v) { + if (v instanceof HTMLCanvasElement) { + v.style.transform = "none"; + } + }); + } + } + }); + // elements.forEach(function (v) { + // if (v instanceof HTMLCanvasElement) { + // v.style.transform = "none"; + // } + // }); + }, 1600); + }; +}, "滑动转场": function () { // 在此增加新插件 const defaultChange = { @@ -19595,7 +19590,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = const ctx = over.getContext("2d"); over.style.display = "block"; - let farme = 0; + let now = 0; let start = 0 core.registerAnimationFrame( @@ -19603,106 +19598,109 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = "animationDrawable", true, function (timestamp) { + let frametime = timestamp - now now = timestamp; if (!imageList || imageList.length == 0) return; if (start === 0) start = now - if (timestamp - now > 1000 / 60) { - now = timestamp; - if (core.domStyle.isVertical) { - over.width = 1248; - over.height = 2028; - ctx.save(); //保存设置 - ctx.translate(1248, 0); //重新定位右上角为基准 - ctx.rotate(Math.PI / 2); //旋转90度 - } else { - over.width = 2028; - over.height = 1248; - } - farme = Math.floor((now - start) / (1000 / 60)) - core.clearMap(ctx) - ctx.globalAlpha = (globalAlpha ?? 100) / 100; - core.fillRect(ctx, 0, 0, 2028, 1248, color); - - imageList.forEach(function (one) { - if ( - farme >= (one.beforefarme ?? 0) && - farme <= (one.afterfarme ?? allFarme) - ) { - const img = core.material.images.images?.[one.image]; - if (img) { - const gla = one.globalAlpha ?? 100; - const agla = one.aglobalAlpha ?? gla, - beforefarme = one.beforefarme ?? 0; - const afterfarme = one.afterfarme ?? allFarme; - - ctx.globalAlpha = - (gla + - ((agla - gla) * (farme - beforefarme)) / - (afterfarme - beforefarme || 1)) / - 100; - - const cx = - (one.cx ?? 0) + - (((one.acx ?? 0) - (one.cx ?? 0)) * - (farme - beforefarme)) / - (afterfarme - beforefarme || 1), - cy = - (one.cy ?? 0) + - (((one.acy ?? 0) - (one.cy ?? 0)) * - (farme - beforefarme)) / - (afterfarme - beforefarme || 1), - cw = - (one.cw ?? img.width) + - (((one.acw ?? img.width) - (one.cw ?? img.width)) * - (farme - beforefarme)) / - (afterfarme - beforefarme || 1), - ch = - (one.ch ?? img.height) + - (((one.acw ?? img.height) - (one.cw ?? img.height)) * - (farme - beforefarme)) / - (afterfarme - beforefarme || 1), - x = - (one.x ?? 0) + - (((one.ax ?? 0) - (one.x ?? 0)) * (farme - beforefarme)) / - (afterfarme - beforefarme || 1), - y = - (one.y ?? 0) + - (((one.ay ?? 0) - (one.y ?? 0)) * (farme - beforefarme)) / - (afterfarme - beforefarme || 1), - w = - (one.w ?? 2028) + - (((one.aw ?? 2028) - (one.w ?? 2028)) * - (farme - beforefarme)) / - (afterfarme - beforefarme || 1), - h = - (one.h ?? 1248) + - (((one.aw ?? 1248) - (one.w ?? 1248)) * - (farme - beforefarme)) / - (afterfarme - beforefarme || 1); - ctx.drawImage(img, cx, cy, cw, ch, x, y, w, h); - } - } - }); - soundList.forEach(function (one) { - const lisen = - one.sound && - core.sounds[one.sound] && - core.musicStatus.soundStatus; - if (farme == one.startfarme && lisen) { - if (one.stopbefore) core.stopSound(); - core.playSound(one.sound); - } - }); - ctx.globalAlpha = 1; - ctx.restore(); - - if (farme > allFarme) { - core.unregisterAnimationFrame("animationDrawable"); - - core.doAction(); - } + now = timestamp; + let farme = Math.floor((now - start) / (1000 / 60)) + if (farme > allFarme) { + core.unregisterAnimationFrame("animationDrawable"); + core.doAction(); + return } + if (core.domStyle.isVertical) { + over.width = 1248; + over.height = 2028; + ctx.save(); //保存设置 + ctx.translate(1248, 0); //重新定位右上角为基准 + ctx.rotate(Math.PI / 2); //旋转90度 + } else { + over.width = 2028; + over.height = 1248; + } + + core.clearMap(ctx) + ctx.globalAlpha = (globalAlpha ?? 100) / 100; + core.fillRect(ctx, 0, 0, 2028, 1248, color); + + imageList.forEach(function (one) { + if ( + farme >= (one.beforefarme ?? 0) && + farme <= (one.afterfarme ?? allFarme) + ) { + const img = core.material.images.images?.[one.image]; + if (img) { + const gla = one.globalAlpha ?? 100; + const agla = one.aglobalAlpha ?? gla, + beforefarme = one.beforefarme ?? 0; + const afterfarme = one.afterfarme ?? allFarme; + + ctx.globalAlpha = + (gla + + ((agla - gla) * (farme - beforefarme)) / + (afterfarme - beforefarme || 1)) / + 100; + + const cx = + (one.cx ?? 0) + + (((one.acx ?? 0) - (one.cx ?? 0)) * + (farme - beforefarme)) / + (afterfarme - beforefarme || 1), + cy = + (one.cy ?? 0) + + (((one.acy ?? 0) - (one.cy ?? 0)) * + (farme - beforefarme)) / + (afterfarme - beforefarme || 1), + cw = + (one.cw ?? img.width) + + (((one.acw ?? img.width) - (one.cw ?? img.width)) * + (farme - beforefarme)) / + (afterfarme - beforefarme || 1), + ch = + (one.ch ?? img.height) + + (((one.acw ?? img.height) - (one.cw ?? img.height)) * + (farme - beforefarme)) / + (afterfarme - beforefarme || 1), + x = + (one.x ?? 0) + + (((one.ax ?? 0) - (one.x ?? 0)) * (farme - beforefarme)) / + (afterfarme - beforefarme || 1), + y = + (one.y ?? 0) + + (((one.ay ?? 0) - (one.y ?? 0)) * (farme - beforefarme)) / + (afterfarme - beforefarme || 1), + w = + (one.w ?? 2028) + + (((one.aw ?? 2028) - (one.w ?? 2028)) * + (farme - beforefarme)) / + (afterfarme - beforefarme || 1), + h = + (one.h ?? 1248) + + (((one.aw ?? 1248) - (one.w ?? 1248)) * + (farme - beforefarme)) / + (afterfarme - beforefarme || 1); + ctx.drawImage(img, cx, cy, cw, ch, x, y, w, h); + } + } + }); + soundList.forEach(function (one) { + const lisen = + one.sound && + core.sounds[one.sound] && + core.musicStatus.soundStatus; + if (farme >= one.startfarme && lisen && !one.start) { + one.start = true + if (one.stopbefore) core.stopSound(); + core.playSound(one.sound); + } + }); + ctx.globalAlpha = 1; + ctx.restore(); + + + } ); };