教学demo
This commit is contained in:
parent
98b10980cd
commit
00876fa43f
@ -128,6 +128,12 @@ var plugins_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
|
||||
"_type": "textarea",
|
||||
"_range": "typeof(thiseval)=='string' || thiseval==null",
|
||||
"_data": "背景音乐拼接"
|
||||
},
|
||||
"scrollingText": {
|
||||
"_leaf": true,
|
||||
"_type": "textarea",
|
||||
"_range": "typeof(thiseval)=='string' || thiseval==null",
|
||||
"_data": "接收&发送在线留言"
|
||||
}
|
||||
}
|
||||
if (obj[key]) return obj[key];
|
||||
|
@ -1520,7 +1520,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
|
||||
},
|
||||
"firstData": {
|
||||
"title": "秽翼的尤斯蒂娅",
|
||||
"name": "Eustia",
|
||||
"name": "Eustia_text",
|
||||
"version": "鸽子窝造塔小队",
|
||||
"floorId": "jiaocheng01",
|
||||
"hero": {
|
||||
@ -1935,7 +1935,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"function": "function(){\ncore.getItem('book', 1);\ncore.getItem('fly', 1);\n}"
|
||||
"function": "function(){\ncore.getItem('book', 1);\ncore.getItem('fly', 1);\ncore.getItem('postman', 1);\ncore.getItem('I369', 1);\n}"
|
||||
},
|
||||
{
|
||||
"type": "insert",
|
||||
|
@ -1,7 +1,7 @@
|
||||
main.floors.jiaocheng01=
|
||||
{
|
||||
"floorId": "jiaocheng01",
|
||||
"title": "广场",
|
||||
"title": "教程1",
|
||||
"name": "1",
|
||||
"width": 13,
|
||||
"height": 13,
|
||||
@ -70,7 +70,7 @@ main.floors.jiaocheng01=
|
||||
[129, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,129],
|
||||
[ 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1]
|
||||
],
|
||||
"areas": "牢狱",
|
||||
"areas": "教程",
|
||||
"bgmap": [
|
||||
|
||||
],
|
||||
|
@ -1,7 +1,7 @@
|
||||
main.floors.jiaocheng02=
|
||||
{
|
||||
"floorId": "jiaocheng02",
|
||||
"title": "广场",
|
||||
"title": "教程2",
|
||||
"name": "1",
|
||||
"width": 13,
|
||||
"height": 13,
|
||||
@ -82,7 +82,7 @@ main.floors.jiaocheng02=
|
||||
[ 28, 1, 30, 1, 27,129, 0,204, 0, 33, 0, 23, 0],
|
||||
[ 1, 1, 1, 1, 1, 1, 93, 1, 1, 1, 1, 1, 1]
|
||||
],
|
||||
"areas": "牢狱",
|
||||
"areas": "教程",
|
||||
"bgmap": [
|
||||
|
||||
],
|
||||
|
@ -192,6 +192,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
core.plugin.bfs();
|
||||
}
|
||||
}
|
||||
if (!core.isReplaying()) core.plugin.drawCommentSign()
|
||||
},
|
||||
"flyTo": function (toId, callback) {
|
||||
// 楼层传送器的使用,从当前楼层飞往toId
|
||||
@ -2022,6 +2023,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
nowy = core.getHeroLoc("y");
|
||||
var block = core.getBlock(nowx, nowy);
|
||||
var hasTrigger = false;
|
||||
core.showComment(nowx, nowy)
|
||||
if (
|
||||
block != null &&
|
||||
block.event.trigger == "getItem" &&
|
||||
@ -2061,7 +2063,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
core.status.hero.statistics.poisonDamage += damage;
|
||||
core.status.hero.hp -= damage;
|
||||
}
|
||||
|
||||
core.showComment(nowx, nowy)
|
||||
core.clearMap("hero");
|
||||
if (
|
||||
core.bigmap.width * 32 === core.bigmap.height * 32 &&
|
||||
|
@ -326,7 +326,8 @@ var icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1 =
|
||||
"I373": 36,
|
||||
"I374": 37,
|
||||
"I375": 38,
|
||||
"I396": 39
|
||||
"I396": 39,
|
||||
"postman": 62
|
||||
},
|
||||
"autotile": {
|
||||
"autotile": 0,
|
||||
|
@ -529,9 +529,31 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
|
||||
"canUseItemEffect": "true"
|
||||
},
|
||||
"I369": {
|
||||
"cls": "items",
|
||||
"name": "新物品",
|
||||
"canUseItemEffect": "true"
|
||||
"cls": "constants",
|
||||
"name": "动画开关",
|
||||
"canUseItemEffect": "true",
|
||||
"hideInToolbox": true,
|
||||
"hideInReplay": true,
|
||||
"useItemEvent": [
|
||||
{
|
||||
"type": "confirm",
|
||||
"text": "是否开启战斗动画",
|
||||
"yes": [
|
||||
{
|
||||
"type": "setValue",
|
||||
"name": "flag:noAnimate",
|
||||
"value": "false"
|
||||
}
|
||||
],
|
||||
"no": [
|
||||
{
|
||||
"type": "setValue",
|
||||
"name": "flag:noAnimate",
|
||||
"value": "true"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"I370": {
|
||||
"cls": "items",
|
||||
@ -576,5 +598,13 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
|
||||
"cls": "items",
|
||||
"name": "新物品",
|
||||
"canUseItemEffect": "true"
|
||||
},
|
||||
"postman": {
|
||||
"cls": "constants",
|
||||
"name": "言灵",
|
||||
"canUseItemEffect": "true",
|
||||
"text": "可以发送和接收在线留言。",
|
||||
"hideInToolbox": true,
|
||||
"hideInReplay": true
|
||||
}
|
||||
}
|
@ -295,6 +295,7 @@ var maps_90f36752_8815_4be8_b32b_d7fad1d0542e =
|
||||
"394": {"cls":"terrains","id":"T394"},
|
||||
"395": {"cls":"terrains","id":"T395"},
|
||||
"396": {"cls":"items","id":"I396"},
|
||||
"397": {"cls":"items","id":"postman"},
|
||||
"20034": {"cls":"tileset","id":"X20034","canPass":true},
|
||||
"20154": {"cls":"tileset","id":"X20154","canPass":true},
|
||||
"20216": {"cls":"tileset","id":"X20216","canPass":true},
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 22 KiB |
@ -2912,7 +2912,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
//道具栏列表
|
||||
this.itemMx = [
|
||||
//空位用‘none’填充,当前ui至多4列6行
|
||||
["book", "wand", "none", "fly"],
|
||||
["book", "postman", "I369", "fly"],
|
||||
["cross", "superPotion", "pickaxe"],
|
||||
["bomb", "centerFly", "upFly"],
|
||||
["none", "none", "none"],
|
||||
@ -2929,7 +2929,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
core.openToolbox,
|
||||
core.doSL,
|
||||
],
|
||||
[main.core.openSettings, main.core.save, main.core.load, core.doSL],
|
||||
[main.core.save, main.core.load, main.core.openSettings, core.doSL],
|
||||
];
|
||||
this.replayAction = [
|
||||
[core.triggerReplay, core.stopReplay, core.rewindReplay],
|
||||
@ -3561,7 +3561,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
["speedDown", "speedUp", "save"],
|
||||
] : [
|
||||
["keyboard", "shop", "pack", "T332"],
|
||||
["settings", "save", "load", "T331"],
|
||||
["save", "load", "settings", "T331"],
|
||||
];
|
||||
if (core.domStyle.isVertical) {
|
||||
core.clearMap(
|
||||
@ -3630,15 +3630,6 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
case "book":
|
||||
core.openBook(true);
|
||||
break;
|
||||
case "wand":
|
||||
core.insertAction({
|
||||
type: "useItem",
|
||||
id: itemId,
|
||||
});
|
||||
break;
|
||||
case "fly":
|
||||
core.useItem(itemId);
|
||||
break;
|
||||
default:
|
||||
core.useItem(itemId);
|
||||
}
|
||||
@ -5712,9 +5703,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
|
||||
var itembar_right = rightArrow_right;
|
||||
var boxName =
|
||||
core.status.event.id == "toolbox"
|
||||
? "\r[yellow]道具栏\r | 装备栏"
|
||||
: "道具栏 | \r[yellow]装备栏\r";
|
||||
core.status.event.id == "toolbox" ?
|
||||
"\r[yellow]道具栏\r | 装备栏" :
|
||||
"道具栏 | \r[yellow]装备栏\r";
|
||||
core.drawArrow(
|
||||
ctx,
|
||||
arrow_x + arrow_width,
|
||||
@ -6106,8 +6097,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
color: "white",
|
||||
align: "left",
|
||||
fontSize: itemTextFontSize,
|
||||
maxWidth:
|
||||
rightbar_width -
|
||||
maxWidth: rightbar_width -
|
||||
(itemText_x - rightbar_x) * 2 +
|
||||
itemTextFontSize / 2,
|
||||
});
|
||||
@ -6119,8 +6109,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
color: "white",
|
||||
align: "left",
|
||||
fontSize: itemTextFontSize,
|
||||
maxWidth:
|
||||
rightbar_width -
|
||||
maxWidth: rightbar_width -
|
||||
(itemText_x - rightbar_x) * 2 +
|
||||
itemTextFontSize / 2,
|
||||
});
|
||||
@ -6260,9 +6249,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
if (i === 1) name = "副手";
|
||||
var selectBorder = false;
|
||||
if (core.status.thisUIEventInfo.select.type == i) selectBorder = true;
|
||||
var borderStyle = selectBorder
|
||||
? box_selectBorderStyle
|
||||
: box_borderStyle;
|
||||
var borderStyle = selectBorder ?
|
||||
box_selectBorderStyle :
|
||||
box_borderStyle;
|
||||
drawEquipbox_drawOne(
|
||||
ctx,
|
||||
name,
|
||||
@ -6352,9 +6341,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
name = toDrawList[i];
|
||||
var selectBorder = false;
|
||||
if (core.status.thisUIEventInfo.select.type == i) selectBorder = true;
|
||||
var borderStyle = selectBorder
|
||||
? box_selectBorderStyle
|
||||
: box_borderStyle;
|
||||
var borderStyle = selectBorder ?
|
||||
box_selectBorderStyle :
|
||||
box_borderStyle;
|
||||
drawEquipbox_drawOne(
|
||||
ctx,
|
||||
name,
|
||||
@ -6586,8 +6575,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
if (
|
||||
!(
|
||||
info &&
|
||||
info.select.id &&
|
||||
["toolbox", "equipbox"].includes(core.status.event.id)
|
||||
info.select.id && ["toolbox", "equipbox"].includes(core.status.event.id)
|
||||
)
|
||||
) {
|
||||
core.drawFailTip("发生了未知错误!");
|
||||
@ -7281,7 +7269,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
core.registerReplayAction("item", core.control._replayAction_item);
|
||||
core.registerReplayAction("equip", core.control._replayAction_equip);
|
||||
core.registerReplayAction("unEquip", core.control._replayAction_unEquip);
|
||||
},
|
||||
},
|
||||
"技能树": function () {
|
||||
// 在此增加新插件
|
||||
//
|
||||
@ -23679,5 +23667,242 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
|
||||
ctx.restore(); //恢复变换前的坐标,否则将连续转置
|
||||
}
|
||||
},
|
||||
"scrollingText": function () {
|
||||
// 本插件用于绘制在线留言
|
||||
// 说明:https://h5mota.com/bbs/thread/?tid=1017
|
||||
// 目前使用core.http代替帖子中提到的axios
|
||||
////// 绘制提示同时播放成功音效 //////
|
||||
ui.prototype.drawSuccessTip = function (text, id, frame) {
|
||||
this.drawTip(text, id, frame);
|
||||
core.playSound('gem.mp3');
|
||||
}
|
||||
core.plugin.aniMap = new Map()
|
||||
////// 绘制提示同时播放错误音效 //////
|
||||
ui.prototype.drawFailTip = function (text, id, frame) {
|
||||
this.drawTip(text, id, frame);
|
||||
core.playSound('error.mp3');
|
||||
}
|
||||
/** 塔的英文名 */
|
||||
const towerName = core.firstData.name;
|
||||
|
||||
let [W, H] = [core.__SIZE__, core.__SIZE__];
|
||||
let [WIDTH, HEIGHT] = [core.__PIXELS__, core.__PIXELS__];
|
||||
|
||||
//#region 弹幕的收发
|
||||
this.getComment = function () {
|
||||
if (core.isReplaying()) return;
|
||||
let form = new FormData();
|
||||
form.append('type', 1);
|
||||
form.append('towername', towerName);
|
||||
utils.prototype.http(
|
||||
'POST',
|
||||
'https://h5mota.com/backend/tower/barrage.php',
|
||||
form,
|
||||
function (res) {
|
||||
try {
|
||||
res = JSON.parse(res);
|
||||
console.log(res);
|
||||
core.drawTip('接收成功!')
|
||||
core.playSound('item.mp3');
|
||||
let commentCollection = {};
|
||||
const commentList = res?.list;
|
||||
const isEmpty = /^\s*$/;
|
||||
for (let i = 0, l = commentList.length; i <= l - 1; i++) {
|
||||
if (isEmpty.test(commentList[i]?.comment)) continue;
|
||||
const commentTagsList = commentList[i].tags.split(',');
|
||||
const [cFloorId, cX, cY] = commentTagsList;
|
||||
if (0 <= cX && cX <= W - 1 && 0 <= cY && cY <= H - 1 && core.floorIds.includes(cFloorId)) {
|
||||
if (!commentCollection.hasOwnProperty(cFloorId)) { commentCollection[cFloorId] = {}; }
|
||||
const str = cX + ',' + cY;
|
||||
if (!commentCollection[cFloorId].hasOwnProperty(str)) { commentCollection[cFloorId][str] = []; }
|
||||
commentCollection[cFloorId][str].push(commentList[i]?.comment);
|
||||
}
|
||||
}
|
||||
core.setFlag('commentCollection', commentCollection);
|
||||
} catch (err) {
|
||||
core.drawFailTip('接收失败!' + err.message);
|
||||
}
|
||||
},
|
||||
function (err) {
|
||||
err = JSON.parse(err);
|
||||
console.error(err);
|
||||
core.drawFailTip('接收失败' + err?.message);
|
||||
},
|
||||
null, null, null, 1000
|
||||
);
|
||||
}
|
||||
|
||||
this.postComment = function (comment, tags) {
|
||||
if (core.isReplaying()) return;
|
||||
const isEmpty = /^\s*$/;
|
||||
if (isEmpty.test(comment)) {
|
||||
core.drawFailTip('您输入的消息为空,请重发!');
|
||||
return;
|
||||
}
|
||||
let form = new FormData();
|
||||
form.append('type', 2);
|
||||
form.append('towername', towerName);
|
||||
form.append('comment', comment);
|
||||
form.append('tags', tags);
|
||||
form.append('userid', 2324);
|
||||
form.append('password', '77c8fd5ff49c370342e4472ebdda5903');
|
||||
utils.prototype.http(
|
||||
'POST',
|
||||
'https://h5mota.com/backend/tower/barrage.php',
|
||||
form,
|
||||
function (res) {
|
||||
try {
|
||||
res = JSON.parse(res);
|
||||
console.log(res);
|
||||
if (res?.code === 0) {
|
||||
core.drawTip('提交成功!')
|
||||
} else {
|
||||
core.drawTip('提交失败!' + res?.message);
|
||||
}
|
||||
} catch (err) {
|
||||
core.drawFailTip('提交失败!' + err.message);
|
||||
}
|
||||
},
|
||||
function (err) {
|
||||
err = JSON.parse(err);
|
||||
console.error(err);
|
||||
core.drawFailTip('提交失败!' + err?.message);
|
||||
},
|
||||
null, null, null, 1000
|
||||
);
|
||||
}
|
||||
//#endregion
|
||||
|
||||
/** 若变量comment为真,在每层切换时在地上有弹幕的地方显示相应图标。 */
|
||||
this.drawCommentSign = function () {
|
||||
if (!core.hasFlag('comment') || core.isReplaying()) return;
|
||||
let commentCollection = core.getFlag('commentCollection', {}),
|
||||
floorId = core.status.floorId;
|
||||
core.createCanvas('sign', 0, 0, WIDTH, HEIGHT, 61);
|
||||
core.setOpacity('sign', 0.6);
|
||||
if (commentCollection.hasOwnProperty(floorId)) {
|
||||
for (let pos in commentCollection[floorId]) {
|
||||
const l = commentCollection[floorId][pos].length;
|
||||
for (let i = 0; i <= l - 1; i++) {
|
||||
const [x, y] = pos.split(',');
|
||||
core.drawIcon('sign', 'postman', 32 * x, 32 * y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 立即清除楼层的弹幕图标。关闭弹幕相关设置时调用。 */
|
||||
this.clearCommentSign = function () {
|
||||
core.deleteCanvas('sign');
|
||||
}
|
||||
|
||||
/** 默认一次显示的弹幕数 */
|
||||
const showNum = 5;
|
||||
|
||||
// 每走一步或瞬移,调用该函数,若目标点有弹幕,显示之
|
||||
this.showComment = function (x, y) {
|
||||
if (!core.getFlag('comment') || core.isReplaying()) return;
|
||||
const commentCollection = core.getFlag('commentCollection', {});
|
||||
const floorId = core.status.floorId,
|
||||
str = x + ',' + y;
|
||||
if (commentCollection.hasOwnProperty(floorId) &&
|
||||
commentCollection[floorId].hasOwnProperty(str)) {
|
||||
let commentArr = commentCollection[floorId][str].concat();
|
||||
const commentArrPicked = pickComment(commentArr, showNum);
|
||||
drawComment(commentArrPicked);
|
||||
}
|
||||
}
|
||||
|
||||
/** 返回从commentArr中挑选showNum个comment组成的数组*/
|
||||
function pickComment(commentArr, showNum) {
|
||||
let showList = [];
|
||||
if (commentArr.length <= showNum) {
|
||||
showList = commentArr;
|
||||
} else {
|
||||
for (let i = 0; i <= showNum - 1; i++) {
|
||||
const l = commentArr.length,
|
||||
n = core.plugin.dice(l - 1);
|
||||
showList.push(commentArr[n]);
|
||||
commentArr.splice(n, 1);
|
||||
}
|
||||
}
|
||||
return showList;
|
||||
}
|
||||
|
||||
function drawComment(commentArr) {
|
||||
const l = commentArr.length;
|
||||
let yList = generateCommentYList(20, HEIGHT - 20, showNum);
|
||||
if (l < showNum) yList = getRandomElements(yList, l);
|
||||
for (let i = 0; i <= l - 1; i++) {
|
||||
drawCommentStr(commentArr[i], WIDTH + 20 * Math.random(),
|
||||
yList[i], Math.random() * 0.1 + 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
/** 生成count个随机数,范围从min到max,作为弹幕的y坐标*/
|
||||
function generateCommentYList(min, max, count) {
|
||||
let yList = Array(count).fill(0);
|
||||
const distance = (max - min) / (count + 1);
|
||||
for (let i = 0; i < count; i++) {
|
||||
yList[i] = min + distance * (i + 1) + (Math.random() - 0.5) * (distance / 2);
|
||||
}
|
||||
return yList;
|
||||
}
|
||||
|
||||
function getRandomElements(arr, count) {
|
||||
let result = [...arr];
|
||||
let len = result.length;
|
||||
count = Math.min(len, count);
|
||||
|
||||
for (let i = len - 1; i > len - 1 - count; i--) {
|
||||
let j = Math.floor(Math.random() * (i + 1));
|
||||
[result[i], result[j]] = [result[j], result[i]];
|
||||
}
|
||||
|
||||
return result.slice(len - count);
|
||||
}
|
||||
|
||||
//#region 弹幕绘制部分
|
||||
const { Animation, linear, Ticker } = core.plugin.animate ?? {};
|
||||
const ctxName = 'scrollingText';
|
||||
|
||||
if (Ticker) {
|
||||
const ticker = new Ticker();
|
||||
ticker.add(() => {
|
||||
if (core.isReplaying()) return;
|
||||
core.createCanvas(ctxName, 0, 0, core.__PIXELS__, core.__PIXELS__, 136); //每帧重绘该画布
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制弹幕
|
||||
* @example
|
||||
* drawCommentStr('OK', 450, 200, 0.1);
|
||||
* @param {string} content 弹幕的内容
|
||||
* @param {number} x 弹幕的初始x坐标
|
||||
* @param {number} y 弹幕的初始y坐标
|
||||
* @param {number} vx 弹幕的横向滚动速度
|
||||
*/
|
||||
function drawCommentStr(content, x, y, vx) {
|
||||
if (core.isReplaying() || !Animation) return;
|
||||
const ani = new Animation();
|
||||
core.plugin.aniMap.set(ani, (ani) => ani.ticker.destroy());
|
||||
ani.ticker.add(() => {
|
||||
core.fillText(ctxName, content, x + ani.x, y, 'white', '16px Verdana');
|
||||
})
|
||||
// 弹幕的最大长度5600,再长属于异常数据
|
||||
const aim = 600 + Math.min(core.calWidth(ctxName, content, '16px Verdana'), 5000);
|
||||
ani.mode(linear())
|
||||
.time(aim / vx)
|
||||
.absolute()
|
||||
.move(-aim, 0)
|
||||
ani.all().then(() => {
|
||||
ani.ticker.destroy();
|
||||
});
|
||||
}
|
||||
//#endregion
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user