diff --git a/_server/table/plugins.comment.js b/_server/table/plugins.comment.js index 0ea6e33..a9cb7a1 100644 --- a/_server/table/plugins.comment.js +++ b/_server/table/plugins.comment.js @@ -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]; diff --git a/project/data.js b/project/data.js index 5326837..73092f3 100644 --- a/project/data.js +++ b/project/data.js @@ -37,7 +37,8 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "guangchang6", "guangchang5", "jiaocheng01", - "jiaocheng02" + "jiaocheng02", + "jiaocheng03" ], "floorPartitions": [], "images": [ @@ -1520,7 +1521,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = }, "firstData": { "title": "秽翼的尤斯蒂娅", - "name": "Eustia", + "name": "Eustia_text", "version": "鸽子窝造塔小队", "floorId": "jiaocheng01", "hero": { @@ -1532,10 +1533,10 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "hp": 1000, "manamax": -1, "mana": 0, - "atk": 30, - "def": 20, + "atk": 26, + "def": 16, "mdef": 100, - "speed": 20, + "speed": 16, "money": 0, "exp": 0, "equipment": [], @@ -1558,7 +1559,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "followers": [], "steps": 0, "matk": 0, - "spell": 20, + "spell": 0, "spelldef": 0, "mhp": 100 }, @@ -1916,32 +1917,26 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = ], "startText": [ { - "type": "if", - "condition": "false", - "true": [ - { - "type": "setText" - }, - { - "type": "setHeroOpacity", - "opacity": 0 - }, - { - "type": "setCurtain", - "color": [ - 0, - 0, - 0, - 1 - ], - "time": 500, - "keep": true - } - ] + "type": "setText" + }, + { + "type": "setHeroOpacity", + "opacity": 0 + }, + { + "type": "setCurtain", + "color": [ + 0, + 0, + 0, + 1 + ], + "time": 500, + "keep": true }, { "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", @@ -1952,12 +1947,21 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "name": "强制横屏" }, { - "type": "if", - "condition": "false", - "true": [ + "type": "insert", + "name": "chapter0" + }, + { + "type": "confirm", + "text": "要进行教程内容吗", + "yes": [], + "no": [ { - "type": "insert", - "name": "chapter0" + "type": "changeFloor", + "floorId": "guangchang", + "loc": [ + 6, + 10 + ] } ] } diff --git a/project/enemys.js b/project/enemys.js index 265b918..70b508b 100644 --- a/project/enemys.js +++ b/project/enemys.js @@ -2,18 +2,18 @@ var enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80 = { "greenSlime": {"name":"绿头怪","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0,"mdef":0,"spell":0,"speed":1}, "redSlime": {"name":"红头怪","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[],"value":10,"mdef":0,"spell":0,"speed":1}, - "blackSlime": {"name":"青头怪","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0,"mdef":0,"spell":0,"speed":1}, - "slimelord": {"name":"怪王","hp":790,"atk":48,"def":8,"money":10,"exp":0,"point":0,"special":[],"mdef":0,"spell":0,"speed":20}, + "blackSlime": {"name":"青头怪","hp":222,"atk":46,"def":10,"money":0,"exp":0,"point":0,"special":[],"mdef":0,"spell":0,"speed":15}, + "slimelord": {"name":"怪王","hp":790,"atk":48,"def":8,"money":0,"exp":0,"point":0,"special":[],"mdef":0,"spell":0,"speed":20}, "bat": {"name":"小蝙蝠","hp":100,"atk":50,"def":30,"money":2,"exp":0,"point":0,"special":[1],"mdef":0,"speed":15,"spell":0}, "bigBat": {"name":"大蝙蝠","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0,"mdef":0,"spell":0,"speed":1}, "redBat": {"name":"红蝙蝠","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[],"mdef":0,"spell":0,"speed":1}, "vampire": {"name":"冥灵魔王","hp":888,"atk":888,"def":888,"money":888,"exp":888,"point":0,"special":[6],"n":8,"mdef":0,"spell":0,"speed":1}, "skeleton": {"name":"骷髅人","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0,"mdef":0,"spell":0,"speed":1}, - "skeletonCaptain": {"name":"骷髅队长","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0,"mdef":0,"spell":0,"speed":1}, + "skeletonCaptain": {"name":"骷髅队长","hp":226,"atk":66,"def":1,"money":0,"exp":0,"point":0,"special":0,"mdef":0,"spell":0,"speed":18}, "zombie": {"name":"兽人","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[22],"mdef":0,"spell":0,"speed":1}, "zombieKnight": {"name":"兽人武士","hp":10000,"atk":100,"def":100,"money":0,"exp":0,"point":0,"special":[22],"speed":10,"mdef":0,"damage2":20,"spell":0}, "rock": {"name":"石头人","hp":50,"atk":50,"def":0,"money":3,"exp":0,"point":0,"special":3,"damage2":15,"mdef":0,"spell":0,"speed":1}, - "bluePriest": {"name":"初级法师","hp":100,"atk":120,"def":0,"money":3,"exp":0,"point":1,"special":[9],"mdef":0,"spell":0,"speed":1}, + "bluePriest": {"name":"初级法师","hp":108,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[9],"mdef":0,"spell":270,"speed":12}, "redPriest": {"name":"高级法师","hp":162,"atk":0,"def":1,"money":0,"exp":0,"point":0,"special":[1],"mdef":0,"spell":308,"speed":14}, "brownWizard": {"name":"初级巫师","hp":162,"atk":120,"def":1,"money":16,"exp":0,"point":0,"special":[],"value":null,"range":2,"mdef":0,"spell":66,"speed":14}, "redWizard": {"name":"高级巫师","hp":1000,"atk":1200,"def":0,"money":160,"exp":0,"point":0,"special":15,"value":200,"zoneSquare":true,"mdef":0,"spell":0,"speed":1}, @@ -45,7 +45,7 @@ var enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80 = "goldSlimelord": {"name":"金怪王","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0,"mdef":0,"spell":0,"speed":1}, "skeletonWarrior": {"name":"骷髅士兵","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0,"mdef":0,"spell":0,"speed":1}, "whiteSlimeman": {"name":"水银战士","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0,"mdef":0,"spell":0,"speed":1}, - "slimeman": {"name":"影子战士","hp":100,"atk":0,"def":0,"money":11,"exp":0,"point":0,"special":[9],"atkValue":2,"defValue":3,"mdef":0,"spell":0,"speed":1}, + "slimeman": {"name":"影子战士","hp":243,"atk":28,"def":5,"money":0,"exp":0,"point":0,"special":[],"atkValue":2,"defValue":3,"mdef":0,"spell":0,"speed":69}, "yellowGateKeeper": {"name":"初级卫兵","hp":80,"atk":25,"def":5,"money":3,"exp":1,"point":0,"special":0,"mdef":0,"spell":0,"speed":1}, "blueGateKeeper": {"name":"中级卫兵","hp":80,"atk":25,"def":5,"money":3,"exp":1,"point":0,"special":0,"mdef":0,"spell":0,"speed":1}, "redGateKeeper": {"name":"高级卫兵","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0,"mdef":0,"spell":0,"speed":1}, diff --git a/project/floors/jiaocheng01.js b/project/floors/jiaocheng01.js index 7e78739..ad7f77e 100644 --- a/project/floors/jiaocheng01.js +++ b/project/floors/jiaocheng01.js @@ -1,7 +1,7 @@ main.floors.jiaocheng01= { "floorId": "jiaocheng01", - "title": "广场", + "title": "教程1", "name": "1", "width": 13, "height": 13, @@ -11,7 +11,16 @@ main.floors.jiaocheng01= "images": [], "ratio": 1, "defaultGround": "X90078", - "firstArrive": [], + "firstArrive": [ + { + "type": "setHeroOpacity", + "opacity": 1 + }, + { + "type": "setCurtain", + "time": 1000 + } + ], "eachArrive": [], "parallelDo": "", "events": { @@ -20,6 +29,78 @@ main.floors.jiaocheng01= ], "12,11": [ "血瓶介绍:不同大小" + ], + "5,7": [ + "\t[小妖精,fairy]一种颜色的钥匙开一种颜色的门。\n一把钥匙只能开一扇门。", + { + "type": "jump", + "from": [ + 5, + 7 + ], + "to": [ + 2, + 2 + ], + "time": 500, + "keep": true + } + ], + "2,2": [ + "\t[小妖精,fairy]在这个游戏中,不同颜色的钥匙珍贵程度也不相同。", + "\t[小妖精,fairy]黄色的钥匙最为常见。", + "\t[小妖精,fairy]蓝色的钥匙有点罕见,其价值在正式游戏中略高于2把黄钥匙,但低于3把黄钥匙。", + "\t[小妖精,fairy]红色的钥匙比较稀有,在正式游戏中一般一把红钥匙可以换取3把蓝钥匙,但反之则有价无市。\n红色的钥匙在正式游戏中一般仅用于boss战相关,开启非常重要的道具,或绕过非常非常强力的怪物。", + "\t[小妖精,fairy]绿色的钥匙为剧情道具,在游戏进程中绿钥匙和不可绕过的绿门一一对应,但存在通往相同区域的二选一绿门。\n绿色的钥匙一般被重兵把守,且不参与其他钥匙的相互兑换。", + { + "type": "jump", + "to": [ + 8, + 1 + ], + "time": 500, + "keep": true + } + ], + "8,1": [ + "\t[小妖精,fairy]在地图上,偶尔会出现这种看起来白送一把蓝钥匙的房间。", + "\t[小妖精,fairy]然而,拿到这把“免费的”蓝钥匙,需要一把红钥匙作为前置。\n在教程关卡中,你肯定拥有这把红钥匙——如果你没有立即拿取旁边绿钥匙的话。", + "\t[小妖精,fairy]在正式游戏中,你可能当时没有,甚至在一时半会儿都不会有这把红钥匙。\n那样的话,这把蓝钥匙只能寄存在房间里。\n在拿到红钥匙之后,你的第一优先级行动就是回来拿上这把蓝钥匙。", + "\t[小妖精,fairy]这把红钥匙,以及用1红钥匙换取1红1蓝钥匙的操作,称为钥匙的周转。", + "\t[小妖精,fairy]当然,如果门口有怪物把守的话就另当别论——等到损失比较合适的时候再回来吧。", + { + "type": "jump", + "to": [ + 6, + 1 + ], + "time": 500, + "keep": true + }, + { + "type": "setValue", + "name": "flag:教程1", + "value": "1" + } + ], + "6,1": [ + { + "type": "if", + "condition": "(flag:教程1===1)", + "true": [ + "\t[小妖精,fairy]接下来就要开始适应本游戏的战斗系统了——", + "\t[小妖精,fairy]在此之前,让我先确认一下吧。\n你拥有黄钥匙和蓝钥匙各一把,对吗?", + "\t[小妖精,fairy]相对于其他RPG游戏来说,本作的战斗系统并不需要玩家在战斗中爆手速进行操作。\n暂停或挂机也是没问题的——怪物并不会因为现实中的你不操作而主动攻击你。\n换句话说,战斗的结果在战斗开始的一瞬间就已经确定了。", + "\t[小妖精,fairy]除此之外,通过存档读档刷取随机数的操作在本作中也是不可行的。\n本作品将不涉及任何随机数的判定。\n这意味着如果你愿意,你可以百分百精确地复制一条攻略路线。", + "\t[小妖精,fairy]换句话说,本作的战斗过程只依赖于战斗双方的各项数据。\n这包括双方的面板数值,各种技能,和多样的装备。", + "\t[小妖精,fairy]本作还有另外一个特点——地图上的资源是有限的,并不会随时间自动刷新。\n这意味着不能在低级图反复刷取资源来碾压高级的怪物,必须仔细规划资源的获取及使用。", + "\t[小妖精,fairy]在手部乘区、脸部乘区、肝部乘区都被限制住的情况下——\n请开发自己的脑部乘区,迎接后面的挑战吧!", + { + "type": "hide", + "remove": true + } + ] + } ] }, "changeFloor": { @@ -54,14 +135,14 @@ main.floors.jiaocheng01= [ 1, 0, 0, 82, 0, 1, 81, 1, 82, 1, 1, 1, 1], [ 1, 21, 1, 1, 0, 1, 22, 1, 0, 0, 21, 23, 1], [ 1, 1, 1, 1, 83, 1, 1, 1, 1, 1, 1, 1, 1], - [ 27, 0, 28, 1, 0, 0, 82, 0, 22, 1, 31, 0, 32], + [ 27, 0, 28, 1, 0,124, 82, 0, 22, 1, 31, 0, 32], [ 0, 0, 0, 1, 21, 1, 1, 1, 0, 1, 0, 0, 0], [ 29, 0, 30, 1, 23, 1, 21, 1, 0, 1, 34, 0, 33], [ 1, 1, 1, 1, 1, 1, 0, 1, 81, 1, 1, 1, 1], [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": [ ], diff --git a/project/floors/jiaocheng02.js b/project/floors/jiaocheng02.js index 9d5616e..0a2dc92 100644 --- a/project/floors/jiaocheng02.js +++ b/project/floors/jiaocheng02.js @@ -1,7 +1,7 @@ main.floors.jiaocheng02= { "floorId": "jiaocheng02", - "title": "广场", + "title": "教程2", "name": "1", "width": 13, "height": 13, @@ -15,14 +15,69 @@ main.floors.jiaocheng02= "eachArrive": [], "parallelDo": "", "events": { - "5,11": [ - "教程初始属性:\n1000HP,30攻击,20防御,20速度,20法强(*100%=20护盾)\n绿血瓶此处900,红血瓶100" + "9,10": [ + "\t[小妖精,fairy]恭喜你!开始了接触本作战斗系统的第一步!\n希望你刚才有好好看过战斗动画哦——当然没有也没关系!我们一点点教!", + "\t[小妖精,fairy]刚才我们的剑砍到敌人身上的时候,敌人身上冒出了一个“-16”的数字。\n这意味着我们砍出去的剑对敌人造成了16点伤害。\n这个“-16”是怎么来的呢?", + "\t[小妖精,fairy]打开怪物手册!", + { + "type": "callBook" + }, + "\t[小妖精,fairy]我们拥有26点攻击力——在左边的状态栏可以看到。\n敌人拥有10点防御力——在怪物手册可以看到。\n我们的每次普通攻击将对怪物造成26-10=16点伤害。", + "\t[小妖精,fairy]同理,怪物的每次普通攻击将对我们造成46-16=30点伤害。\n在战斗动画中也有体现哦!", + "\t[小妖精,fairy]一方的生命值降低到0,意味着这一方被对方击杀。\n换句话说,如果我们的生命值被怪物的攻击压低到了0,这意味着勇士在战斗中牺牲了。\n(也就是game over啦)。", + "\t[小妖精,fairy]虽然在相同的状态下,持有更多的生命值总是更好,但生命值只是一个“够用就行”的属性。\n相较于把自己的生命值把握在自我设定的“500点”“1000点”等“安全线”上,\n用这些多余的生命值换取钥匙、能力,甚至是金币等资源,对后续的游戏过程来说会更轻松。", + "\t[小妖精,fairy]话说回来。\n怪物的生命值一共有222点。\n我们想要击杀怪物需要攻击怪物——222÷16(向上取整)=14次。\n为什么是向上取整?因为哪怕怪物还剩1点生命值,没死就是没死。", + "\t[小妖精,fairy]在我们攻击怪物14次的过程中,敌人也反击了我们13次。\n我们的生命因此损失了13*30=390点。\n如果没有关闭显伤开关的话,这个”390点“的数字将会显示在在怪物的左下角。\n剩余的生命仍然足够击败第二个相同的敌人呢——但好像还有什么事需要做?", + { + "type": "jump", + "to": [ + 11, + 8 + ], + "time": 500, + "keep": true + } ], - "0,0": [ - "匕首:速度+20" + "11,8": [ + "\t[小妖精,fairy]在本作中,有一个便捷操作,叫做“自动存档”。\n具体点说,就是在我们与怪物发生战斗前,或开门前,都会进行一个存档。\n后面我们发现之前哪一步做错了,都有机会撤销,“反悔”——最多支持反悔50步之前的错误。\n读取自动存档的快捷键是“A”键。", + "\t[小妖精,fairy]红宝石可以提高角色的攻击力。\n不同形状、不同区域的红宝石,提高攻击力的程度也不一样。\n刚才黄门里的红宝石,在当前区域每一颗可以提升角色2点攻击力。", + { + "type": "if", + "condition": "(status:hp!==280)", + "true": [ + "\t[小妖精,fairy]一般来说,在地图上有无需战斗就可以获得的资源时,优先获得这些资源再进行战斗。\n获得资源提升能力,会让我们在战斗中更具有优势。\n不用为了后面保存黄钥匙!钥匙是够的!", + "\t[小妖精,fairy]所以你为什么没有拿红宝石就急匆匆地来战斗了!", + "\t[小妖精,fairy]请读取自动存档,回去拿完宝石再与敌人作战!" + ], + "false": [ + "\t[小妖精,fairy]在提升攻击力后,角色的攻击将更有力度。\n在获得2颗红宝石之后,角色每次攻击对怪物造成的伤害将由16点提升到20点。\n原本需要222÷16=14次攻击击杀的怪物,现在只需要222÷20=12次即可击杀。", + "\t[小妖精,fairy]由于怪物受到更少次数的攻击就被击杀了,角色受到的攻击次数也减少了。\n从13次减少到了11次。", + "\t[小妖精,fairy]但要注意——不是所有时候提升攻击力都能降低角色受到的攻击次数。\n如果角色的攻击力仅提升了1点,攻击伤害从16提升到17——\n击败怪物需要的攻击次数是222÷17,还是14次。这意味着战斗伤害不会有任何变化。", + "\t[小妖精,fairy]因此,能带来战斗伤害减少的攻击力提升节点特别重要——我们称之为“临界”。\n从最初的26点攻击力,16点攻击伤害,需要14次攻击击杀,开始计算——\n222÷13=17.077,这意味着我们至少要达到17.077的攻击伤害,才能减少击杀敌人的攻击次数——但由于本作的攻击力是整数,你必须达到18的攻击伤害,也就是28点攻击力,才能降低战斗伤害。", + "\t[小妖精,fairy]同理,以现在的状态开始计算。现在我们需要12次攻击击杀怪物。\n222÷11=20.182,我们需要21的攻击伤害,也就是31点攻击力。", + { + "type": "callBook" + }, + "\t[小妖精,fairy]我们的攻击力距离下一个临界点还差1点;达到临界点可以让我们受到的伤害减少30点。\n在怪物手册中记作[1,30]或\"1:30\"。\n同样地,右上角相同的怪物身上,在战斗伤害330的数字上面,显示的是距离下一个攻击临界点的距离,\n1点。", + "\t[小妖精,fairy]但请注意,有的时候用更少的攻击次数击杀怪物,并不会让自己承受怪物的伤害变少哦!\n这就与我们接下来要讲解的属性,”速度“,有关啦。", + "\t[小妖精,fairy]哎呀——生命值好像不太够了!\n捡起后面黄门里的血瓶,补充生命值继续后面的内容吧!", + { + "type": "jump", + "to": [ + 11, + 4 + ], + "time": 500, + "keep": true + } + ] + } ], - "12,0": [ - "法杖:魔攻比例10%,魔防比例0%" + "11,4": [ + { + "type": "hide", + "remove": true + } ] }, "changeFloor": { @@ -32,6 +87,13 @@ main.floors.jiaocheng02= 6, 0 ] + }, + "6,0": { + "floorId": "jiaocheng03", + "loc": [ + 6, + 12 + ] } }, "beforeBattle": {}, @@ -42,21 +104,21 @@ main.floors.jiaocheng02= "cannotMove": {}, "cannotMoveIn": {}, "map": [ - [129, 1, 27, 1, 28, 1, 91, 1, 29, 1, 30, 1,129], - [ 70, 1, 82, 1, 82, 1,236, 1, 82, 1, 82, 1,375], - [ 0, 83, 0, 29, 0, 33, 0, 31, 0, 23, 0, 83, 0], - [ 1, 1, 1, 1, 1, 1,219, 1, 1, 1, 1, 1, 1], - [ 0, 22, 0, 31, 0, 31, 0, 1, 27, 1, 30, 1, 30], - [ 81, 1, 81, 1, 81, 1, 22, 1, 27, 1, 30, 1, 27], - [ 29, 1, 31, 1, 31, 1,218, 1, 82, 1, 82, 1, 82], - [ 28, 1, 28, 1, 29, 1, 0, 81, 0, 33, 0, 21, 0], - [ 1, 1, 1, 1, 1, 1,240, 1, 1, 1, 1, 1, 1], - [ 0, 33, 0, 21, 0, 29, 0, 1, 27, 1, 28, 1, 31], - [ 83, 1, 83, 1, 83, 1,204, 1, 81, 1, 81, 1, 81], - [ 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] + [ 0, 33, 0,217, 31, 0, 91, 1, 28, 1, 30, 1,203], + [216, 1, 0, 1, 1, 1, 1, 1, 28, 1, 30, 1, 1], + [216, 1, 31, 1, 0, 0, 0, 81, 0, 1, 0, 1,211], + [211, 1, 21, 1,216, 1,216, 1, 1, 1, 81, 1, 1], + [ 0, 1, 1, 1, 0, 1, 0, 0, 0,211, 0, 0, 0], + [ 0, 1, 32, 1, 0, 1, 1, 0, 1, 1, 1, 1,211], + [ 0, 81, 0, 1, 0, 1, 21, 33, 1, 33, 0, 81, 0], + [ 31, 1, 1, 1,217, 1, 1, 1, 1, 1, 1, 1, 22], + [203, 1, 33, 0, 0, 29, 29, 29, 29, 1, 0, 0, 0], + [ 0, 1, 1, 1, 0, 1, 1, 1, 1, 1,203, 1, 82], + [ 33, 0,211, 1, 0, 1, 0,203, 0,124, 0, 1, 0], + [ 0, 81, 0, 1,217, 1, 0, 1, 1, 81, 1, 1, 21], + [216, 0, 0, 21, 0, 1, 93, 1, 27, 0, 27, 1, 21] ], - "areas": "牢狱", + "areas": "教程", "bgmap": [ ], diff --git a/project/floors/jiaocheng03.js b/project/floors/jiaocheng03.js new file mode 100644 index 0000000..80adfb2 --- /dev/null +++ b/project/floors/jiaocheng03.js @@ -0,0 +1,76 @@ +main.floors.jiaocheng03= +{ + "floorId": "jiaocheng03", + "title": "广场", + "name": "1", + "width": 13, + "height": 13, + "canFlyTo": true, + "canFlyFrom": true, + "canUseQuickShop": true, + "images": [], + "ratio": 1, + "defaultGround": "X90078", + "firstArrive": [], + "eachArrive": [], + "parallelDo": "", + "events": { + "0,0": [ + "匕首:速度+20" + ], + "12,0": [ + "法杖:魔攻比例10%,魔防比例0%" + ] + }, + "changeFloor": { + "6,12": { + "floorId": "jiaocheng02", + "loc": [ + 6, + 0 + ] + }, + "6,0": { + "floorId": "guangchang", + "loc": [ + 6, + 10 + ] + } + }, + "beforeBattle": {}, + "afterBattle": {}, + "afterGetItem": {}, + "afterOpenDoor": {}, + "autoEvent": {}, + "cannotMove": {}, + "cannotMoveIn": {}, + "map": [ + [129, 1, 27, 1, 28, 1, 91, 1, 29, 1, 30, 1,129], + [ 70, 1, 82, 1, 82, 1,236, 1, 82, 1, 82, 1,375], + [ 0, 83, 0, 29, 0, 33, 0, 31, 0, 23, 0, 83, 0], + [ 1, 1, 1, 1, 1, 1,219, 1, 1, 1, 1, 1, 1], + [ 0, 22, 0, 31, 0, 31, 0, 1, 27, 1, 30, 1, 30], + [ 81, 1, 81, 1, 81, 1, 22, 1, 27, 1, 30, 1, 27], + [ 29, 1, 31, 1, 31, 1,218, 1, 82, 1, 82, 1, 82], + [ 28, 1, 28, 1, 29, 1, 0, 81, 0, 33, 0, 21, 0], + [ 1, 1, 1, 1, 1, 1,240, 1, 1, 1, 1, 1, 1], + [ 0, 33, 0, 21, 0, 29, 0, 1, 27, 1, 28, 1, 31], + [ 83, 1, 83, 1, 83, 1,204, 1, 81, 1, 81, 1, 81], + [ 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": "牢狱", + "bgmap": [ + +], + "fgmap": [ + +], + "bg2map": [ + +], + "fg2map": [ + +] +} \ No newline at end of file diff --git a/project/functions.js b/project/functions.js index 459927d..86bb8ab 100644 --- a/project/functions.js +++ b/project/functions.js @@ -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(x, y) core.clearMap("hero"); if ( core.bigmap.width * 32 === core.bigmap.height * 32 && diff --git a/project/icons.js b/project/icons.js index 73914d5..36641a7 100644 --- a/project/icons.js +++ b/project/icons.js @@ -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, diff --git a/project/items.js b/project/items.js index aa455cd..be81f6f 100644 --- a/project/items.js +++ b/project/items.js @@ -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,67 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "cls": "items", "name": "新物品", "canUseItemEffect": "true" + }, + "postman": { + "cls": "constants", + "name": "言灵", + "canUseItemEffect": "true", + "text": "可以发送和接收在线留言。", + "hideInToolbox": true, + "hideInReplay": true, + "useItemEvent": [ + { + "type": "while", + "condition": "true", + "data": [ + { + "type": "choices", + "text": "本功能需要您在h5mota.com在线游玩并处于登录状态时使用,可以发送和接受留言。\n发言后需要选择\"获取最新留言\"才能看到自己新发的留言。", + "choices": [ + { + "text": "地图上显示在线留言:${flag:comment?'开':'关'}", + "icon": "postman", + "action": [ + { + "type": "function", + "function": "function(){\nif (core.hasFlag('comment')) {\n\tcore.setFlag('comment', false);\n\tcore.plugin.clearCommentSign();\n} else {\n\tcore.setFlag('comment', true);\n\tcore.plugin.drawCommentSign();\n}\n}" + } + ] + }, + { + "text": "写留言", + "action": [ + { + "type": "input2", + "text": "请输入要发送的评论,文明友善发言,拒绝放假、剧透。" + }, + { + "type": "function", + "function": "function(){\nconst input = core.getFlag('input', '');\nconst tags = [core.status.floorId,\n\tcore.getHeroLoc().x.toString(), core.getHeroLoc().y.toString()\n]\nif (!core.isReplaying()) {\n\tcore.plugin.postComment(input, tags);\n}\n}" + } + ] + }, + { + "text": "获取最新留言", + "action": [ + { + "type": "function", + "function": "function(){\nif (!core.isReplaying()) {\n\tcore.plugin.getComment();\n\tsetTimeout(core.plugin.drawCommentSign, 1000);\n}\n}" + } + ] + }, + { + "text": "退出", + "action": [ + { + "type": "exit" + } + ] + } + ] + } + ] + } + ] } } \ No newline at end of file diff --git a/project/maps.js b/project/maps.js index d1b42f0..dddf478 100644 --- a/project/maps.js +++ b/project/maps.js @@ -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}, diff --git a/project/materials/items.png b/project/materials/items.png index 04dc29b..2445872 100644 Binary files a/project/materials/items.png and b/project/materials/items.png differ diff --git a/project/plugins.js b/project/plugins.js index df24c93..d26f3cf 100644 --- a/project/plugins.js +++ b/project/plugins.js @@ -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); } @@ -4499,6 +4490,11 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = core.actions._sys_ondown_lockControl, 30 ); + ////// 绘制提示同时播放错误音效 ////// + ui.prototype.drawFailTip = function (text, id, frame) { + this.drawTip(text, id, frame); + core.playSound('error.opus'); + } }, "额外信息": function () { /* 宝石血瓶左下角显示数值 @@ -5605,1683 +5601,1680 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = }; }, "新道具栏/装备栏": function () { - // 这个插件有点离谱 个人觉得参数过多只会降低可读性,还不如硬编码 + // 这个插件有点离谱 个人觉得参数过多只会降低可读性,还不如硬编码 - // 注:///// *** 裹起来的区域: 该区域内参数可以随意更改调整ui绘制 不会影响总体布局 - // 请尽量修改该区域而不是其他区域 修改的时候最好可以对照现有ui修改 + // 注:///// *** 裹起来的区域: 该区域内参数可以随意更改调整ui绘制 不会影响总体布局 + // 请尽量修改该区域而不是其他区域 修改的时候最好可以对照现有ui修改 - ///// *** 道具类型 - // cls对应name - var itemClsName = { - constants: "永久道具", - tools: "消耗道具", - }; - // 一页最大放的道具数量 将把整个道具左栏分成num份 每份是一个道具项 - var itemNum = 12; - ///// *** + ///// *** 道具类型 + // cls对应name + var itemClsName = { + constants: "永久道具", + tools: "消耗道具", + }; + // 一页最大放的道具数量 将把整个道具左栏分成num份 每份是一个道具项 + var itemNum = 12; + ///// *** - // 背景设置 - function drawBoxBackground(ctx) { - core.setTextAlign(ctx, "left"); - core.clearMap(ctx); - core.deleteCanvas("_selector"); - var info = core.status.thisUIEventInfo || {}; + // 背景设置 + function drawBoxBackground(ctx) { + core.setTextAlign(ctx, "left"); + core.clearMap(ctx); + core.deleteCanvas("_selector"); + var info = core.status.thisUIEventInfo || {}; - ///// *** 背景设置 - var max = core.__PIXELS__; - var x = 2, - y = x, - w = max - x * 2, - h = w; - var borderWidth = 2, - borderRadius = 5, // radius:圆角矩形的圆角半径 - borderStyle = "#fff"; - var backgroundColor = "gray"; - // 设置背景不透明度(0.85) - var backgroundAlpha = 0.85; - ///// *** + ///// *** 背景设置 + var max = core.__PIXELS__; + var x = 2, + y = x, + w = max - x * 2, + h = w; + var borderWidth = 2, + borderRadius = 5, // radius:圆角矩形的圆角半径 + borderStyle = "#fff"; + var backgroundColor = "gray"; + // 设置背景不透明度(0.85) + var backgroundAlpha = 0.85; + ///// *** - var start_x = x + borderWidth / 2, - start_y = y + borderWidth / 2, - width = max - start_x * 2, - height = max - start_y * 2; + var start_x = x + borderWidth / 2, + start_y = y + borderWidth / 2, + width = max - start_x * 2, + height = max - start_y * 2; - // 渐变色背景的一个例子(黑色渐变白色): - // 有关渐变色的具体知识请网上搜索canvas createGradient了解 - /* + // 渐变色背景的一个例子(黑色渐变白色): + // 有关渐变色的具体知识请网上搜索canvas createGradient了解 + /* var grd = ctx.createLinearGradient(x, y, x + w, y); grd.addColorStop(0, "black"); grd.addColorStop(1, "white"); backgroundColor = grd; */ - // 使用图片背景要注释掉下面的strokeRect和fillRoundRect - // 图片背景的一个例子: - /* + // 使用图片背景要注释掉下面的strokeRect和fillRoundRect + // 图片背景的一个例子: + /* core.drawImage(ctx, "xxx.png", x, y, w, h); core.strokeRect(ctx, x, y, w, h, borderStyle, borderWidth); */ - core.setAlpha(ctx, backgroundAlpha); - core.strokeRoundRect( - ctx, - x, - y, - w, - h, - borderRadius, - borderStyle, - borderWidth - ); - core.fillRoundRect( - ctx, - start_x, - start_y, - width, - height, - borderRadius, - backgroundColor - ); - core.setAlpha(ctx, 1); - - ///// *** 左栏配置 - var leftbar_height = height; - // 左边栏宽度(width*0.6) 本身仅为坐标使用 需要与底下的rightbar_width(width*0.4)同时更改 - var leftbar_width = width * 0.6; - ///// *** - - // xxx_right参数 代表最右侧坐标 - var leftbar_right = start_x + leftbar_width - borderWidth / 2; - var leftbar_bottom = start_y + leftbar_height; - var leftbar_x = start_x; - var leftbar_y = start_y; - - ///// *** 道具栏配置 - var boxName_color = "#fff"; - var boxName_fontSize = 15; - var boxName_font = core.ui._buildFont(boxName_fontSize, true); - var arrow_x = 10 + start_x; - var arrow_y = 10 + start_y; - var arrow_width = 20; - var arrow_style = "white"; - // 暂时只能是1 否则不太行 等待新样板(2.7.3)之后对drawArrow做优化 - var arrow_lineWidth = 2; - // 右箭头 - var rightArrow_right = leftbar_right - 10; - // 道具内栏顶部坐标 本质是通过该项 控制(道具栏顶部文字和箭头)与道具内栏顶部的间隔 - var itembar_top = arrow_y + 15; - ///// *** - - var itembar_right = rightArrow_right; - var boxName = - core.status.event.id == "toolbox" - ? "\r[yellow]道具栏\r | 装备栏" - : "道具栏 | \r[yellow]装备栏\r"; - core.drawArrow( - ctx, - arrow_x + arrow_width, - arrow_y, - arrow_x, - arrow_y, - arrow_style, - arrow_lineWidth - ); - core.drawArrow( - ctx, - rightArrow_right - arrow_width, - arrow_y, - rightArrow_right, - arrow_y, - arrow_style, - arrow_lineWidth - ); - core.setTextAlign(ctx, "center"); - core.setTextBaseline(ctx, "middle"); - var changeBox = function () { - var id = core.status.event.id; - core.closePanel(); - if (id == "toolbox") core.openEquipbox(); - else core.openToolbox(); - }; - core.fillText( - ctx, - boxName, - (leftbar_right + leftbar_x) / 2, - arrow_y + 2, - boxName_color, - boxName_font - ); - - ///// *** 底栏按钮 - var pageBtn_radius = 8; - // xxx_left 最左侧坐标 - var pageBtn_left = leftbar_x + 3; - var pageBtn_right = leftbar_right - 3; - // xxx_bottom 最底部坐标 - var pageBtn_bottom = leftbar_bottom - 2; - var pageBtn_borderStyle = "#fff"; - var pageBtn_borderWidth = 2; - var pageText_color = "#fff"; - // 底部按钮与上面的道具内栏的间隔大小 - var bottomSpace = 8; - ///// *** - - drawItemListbox_setPageBtn( - ctx, - pageBtn_left, - pageBtn_right, - pageBtn_bottom, - pageBtn_radius, - pageBtn_borderStyle, - pageBtn_borderWidth - ); - var page = info.page || 1; - var pageFontSize = pageBtn_radius * 2 - 4; - var pageFont = core.ui._buildFont(pageFontSize); - setPageItems(page); - var num = itemNum; - if (core.status.event.id == "equipbox") num -= 5; - var maxPage = info.maxPage; - var pageText = page + " / " + maxPage; - core.setTextAlign(ctx, "center"); - core.setTextBaseline(ctx, "bottom"); - core.fillText( - ctx, - pageText, - (leftbar_x + leftbar_right) / 2, - pageBtn_bottom, - pageText_color, - pageFont - ); - addUIEventListener( - start_x, - start_y, - leftbar_right - start_x, - arrow_y - start_y + 13, - changeBox - ); - var itembar_height = Math.ceil( - pageBtn_bottom - - pageBtn_radius * 2 - - pageBtn_borderWidth / 2 - - bottomSpace - - itembar_top - ); - var oneItemHeight = (itembar_height - 4) / itemNum; - return { - x: start_x, - y: start_y, - width: width, - height: height, - leftbar_right: leftbar_right, - obj: { - x: arrow_x, - y: itembar_top, - width: itembar_right - arrow_x, - height: itembar_height, - oneItemHeight: oneItemHeight, - }, - }; - } - - function drawItemListbox(ctx, obj) { - ctx = ctx || core.canvas.ui; - var itembar_x = obj.x, - itembar_y = obj.y, - itembar_width = obj.width, - itembar_height = obj.height, - itemNum = obj.itemNum, - oneItemHeight = obj.oneItemHeight; - var itembar_right = itembar_x + itembar_width; - var info = core.status.thisUIEventInfo || {}; - var obj = {}; - var page = info.page || 1, - index = info.index, - select = info.select || {}; - - ///// *** 道具栏内栏配置 - var itembar_style = "black"; - var itembar_alpha = 0.7; - // 一个竖屏下减少道具显示的例子: - // if (core.domStyle.isVertical) itemNum = 10; - // 每个道具项的上下空隙占总高度的比例 - var itembar_marginHeightRatio = 0.2; - // 左右间隔空隙 - var item_marginLeft = 2; - var item_x = itembar_x + 2, - item_y = itembar_y + 2, - item_right = itembar_right - 2, - itemName_color = "#fff"; - // 修改此项以更换闪烁光标 - var item_selector = "winskin.webp"; - ///// *** - - core.setAlpha(ctx, itembar_alpha); - core.fillRect( - ctx, - itembar_x, - itembar_y, - itembar_width, - itembar_height, - itembar_style - ); - core.setAlpha(ctx, 1); - var pageItems = setPageItems(page); - var marginHeight = itembar_marginHeightRatio * oneItemHeight; - core.setTextBaseline(ctx, "middle"); - var originColor = itemName_color; - for (var i = 0; i < pageItems.length; i++) { - itemName_color = originColor; - var item = pageItems[i]; - // 设置某个的字体颜色的一个例子 - // if (item.id == "xxx") itemName_color = "green"; - drawItemListbox_drawItem( - ctx, - item_x, - item_right, - item_y, - oneItemHeight, - item_marginLeft, - marginHeight, - itemName_color, - pageItems[i] - ); - if (index == i + 1) - core.ui._drawWindowSelector( - item_selector, - item_x + 1, - item_y - 1, - item_right - item_x - 2, - oneItemHeight - 2 - ); - item_y += oneItemHeight; - } - } - - function drawToolboxRightbar(ctx, obj) { - ctx = ctx || core.canvas.ui; - var info = core.status.thisUIEventInfo || {}; - var page = info.page || 1, - index = info.index || 1, - select = info.select || {}; - var start_x = obj.x, - start_y = obj.y, - width = obj.width, - height = obj.height; - var toolboxRight = start_x + width, - toolboxBottom = start_y + height; - - ///// *** 侧边栏(rightbar)背景设置(物品介绍) - var rightbar_width = width * 0.4; - var rightbar_height = height; - var rightbar_lineWidth = 2; - var rightbar_lineStyle = "#fff"; - ///// *** - - var rightbar_x = toolboxRight - rightbar_width - rightbar_lineWidth / 2; - var rightbar_y = start_y; - core.drawLine( - ctx, - rightbar_x, - rightbar_y, - rightbar_x, - rightbar_y + rightbar_height, - rightbar_lineStyle, - rightbar_lineWidth - ); - - // 获取道具id(有可能为null) - var itemId = select.id; - var item = core.material.items[itemId]; - - ///// *** 侧边栏物品Icon信息 - var iconRect_y = rightbar_y + 10; - // space:间距 - // 这里布局设定iconRect与侧边栏左边框 itemName与工具栏右边框 itemRect与itemName的间距均为space - var space = 15; - var iconRect_x = rightbar_x + space; - var iconRect_radius = 2, - iconRect_width = 32, - iconRect_height = 32, - iconRect_style = "#fff", - iconRect_lineWidth = 2; - ///// *** - - var iconRect_bottom = iconRect_y + iconRect_height, - iconRect_right = iconRect_x + iconRect_width; - - ///// *** 侧边栏各项信息 - var itemTextFontSize = 15, - itemText_x = iconRect_x - 4, - itemText_y = Math.floor(start_y + rightbar_height * 0.25), // 坐标取整防止模糊 - itemClsFontSize = 15, - itemClsFont = core.ui._buildFont(itemClsFontSize), - itemClsColor = "#fff", - itemCls_x = itemText_x - itemClsFontSize / 2, - itemCls_middle = (iconRect_bottom + itemText_y) / 2, //_middle代表文字的中心y坐标 - itemNameFontSize = 18, - itemNameColor = "#fff", - itemNameFont = core.ui._buildFont(itemNameFontSize, true); - var itemName_x = iconRect_right + space; - var itemName_middle = - iconRect_y + iconRect_height / 2 + iconRect_lineWidth; - // 修改这里可以编辑未选中道具时的默认值 - var defaultItem = { - cls: "constants", - name: "未知道具", - text: "没有道具最永久", - }; - var defaultEquip = { - cls: "equips", - name: "未知装备", - text: "一无所有,又何尝不是一种装备", - equip: { - type: "装备", - }, - }; - ///// *** - - var originItem = item; - if (core.status.event.id == "equipbox") item = item || defaultEquip; - item = item || defaultItem; - var itemCls = item.cls, - itemName = item.name, - itemText = item.text; - itemText = core.replaceText(itemText); - if (!itemText) itemText = "该道具无描述。"; - /* 一个根据道具id修改道具名字(右栏)的例子 - * if (item.id == "xxx") itemNameColor = "red"; - */ - var itemClsName = core.getItemClsName(item); - var itemNameMaxWidth = - rightbar_width - iconRect_width - iconRect_lineWidth * 2 - space * 2; - core.strokeRoundRect( - ctx, - iconRect_x, - iconRect_y, - iconRect_width, - iconRect_height, - iconRect_radius, - iconRect_style, - iconRect_lineWidth - ); - if (item.id) - core.drawIcon( - ctx, - item.id, - iconRect_x + iconRect_lineWidth / 2, - iconRect_y + iconRect_lineWidth / 2, - iconRect_width - iconRect_lineWidth, - iconRect_height - iconRect_lineWidth - ); - core.setTextAlign(ctx, "left"); - core.setTextBaseline(ctx, "middle"); - if (itemCls === "equips" && item.id) { - itemName = "【" + item.equipCls + "】" + itemName; - } - core.fillText( - ctx, - itemName, - itemName_x, - itemName_middle, - itemNameColor, - itemNameFont, - itemNameMaxWidth - ); - if (!item.equip) - core.fillText( - ctx, - "【" + itemClsName + "】", - itemCls_x, - itemCls_middle, - itemClsColor, - itemClsFont - ); - - var statusText = ""; - if (core.status.event.id == "equipbox") { - var type = item.equip.type; - if (typeof type == "string") type = core.getEquipTypeByName(type); - var compare = core.compareEquipment(item.id, core.getEquip(type)); - var compare2; - if (item.equipCls === "双手剑") - compare2 = core.compareEquipment(null, core.getEquip(1)); - if ( - item.equipCls === "盾牌" && - core.material.items[core.getEquip(0)]?.equipCls === "双手剑" - ) - compare2 = core.compareEquipment(null, core.getEquip(0)); - if (info.select.action == "unload") - compare = core.compareEquipment(null, item.id); - // --- 变化值... - for (var name in core.status.hero) { - if (typeof core.status.hero[name] != "number") continue; - var nowValue = core.getRealStatus(name); - // 查询新值 - var newValue = Math.floor( - ((core.getStatus(name) + - (compare.value[name] || 0) + - (compare2?.value[name] || 0)) * - (core.getBuff(name) * 100 + - (compare.percentage[name] || 0) + - (compare2?.percentage[name] || 0))) / - 100 - ); - if (name === "mdef") { - var nowValue = core.getRealStatus(name); - var newValue = Math.round( - (core.getStatus(name) - - (compare.value[name] || 0) - - (compare2?.value[name] || 0)) * - (1 - - (1 - core.getBuff(name)) * - (compare.percentage[name] || 1) * - (compare2?.percentage[name] || 1)) - ); - } - if (nowValue == newValue) continue; - var color = newValue > nowValue ? "#00FF00" : "#FF0000"; - nowValue = core.formatBigNumber(nowValue); - newValue = core.formatBigNumber(newValue); - - if (name === "mdef") { - nowValue += "%"; - newValue += "%"; - } - statusText += - core.getStatusLabel(name) + - " " + - nowValue + - "->\r[" + - color + - "]" + - newValue + - "\r\n"; - } - } - itemText = statusText + itemText; - if (item.equip) { - core.drawTextContent(ctx, itemText, { - left: itemText_x, - top: itemCls_middle, - bold: false, - color: "white", - align: "left", - fontSize: itemTextFontSize, - maxWidth: - rightbar_width - - (itemText_x - rightbar_x) * 2 + - itemTextFontSize / 2, - }); - } else { - core.drawTextContent(ctx, itemText, { - left: itemText_x, - top: itemText_y, - bold: false, - color: "white", - align: "left", - fontSize: itemTextFontSize, - maxWidth: - rightbar_width - - (itemText_x - rightbar_x) * 2 + - itemTextFontSize / 2, - }); - } - - ///// *** 退出按钮设置 - var btnRadius = 10; - var btnBorderWidth = 2; - var btnRight = toolboxRight - 2; - var btnBottom = toolboxBottom - 2; - var btnBorderStyle = "#fff"; - ///// *** - - // 获取圆心位置 - var btn_x = btnRight - btnRadius - btnBorderWidth / 2; - btn_y = btnBottom - btnRadius - btnBorderWidth / 2; - drawToolbox_setExitBtn( - ctx, - btn_x, - btn_y, - btnRadius, - btnBorderStyle, - btnBorderWidth - ); - - ///// *** 使用按钮设置 - var useBtnHeight = btnRadius * 2; - // 这里不设置useBtnWidth而是根据各项数据自动得出width - var useBtnRadius = useBtnHeight / 4; - var useBtn_x = rightbar_x + 4, - useBtn_y = btnBottom - useBtnHeight; - var useBtnBorderStyle = "#fff"; - var useBtnBorderWidth = btnBorderWidth; - const batchUseBtn_x = useBtn_x + 50; // 个人觉得,搞这么多参数还不如硬编码 - const hideBtn_y = useBtn_y - useBtnHeight - 8; - ///// *** - - drawToolbox_setUseBtn( - ctx, - useBtn_x, - useBtn_y, - useBtnRadius, - useBtnHeight, - useBtnBorderStyle, - useBtnBorderWidth - ); - if (core.status.event.id === "toolbox") { - drawToolbox_setBatchUseBtn( - ctx, - batchUseBtn_x, - useBtn_y, - useBtnRadius, - useBtnHeight, - useBtnBorderStyle, - useBtnBorderWidth - ); - } - drawToolbox_setHideBtn( - ctx, - useBtn_x, - hideBtn_y, - useBtnRadius, - useBtnHeight, - useBtnBorderStyle, - useBtnBorderWidth - ); - drawToolbox_setShowHideBtn( - ctx, - rightbar_x, - useBtn_y, - useBtnHeight, - useBtnBorderStyle - ); - } - - function drawEquipbox_drawOthers(ctx, obj) { - var info = core.status.thisUIEventInfo; - - ///// *** 装备格设置 - var equipList_lineWidth = 2; - var equipList_boxSize = 32; - var equipList_borderWidth = 2; - var equipList_borderStyle = "#fff"; - var equipList_nameColor = "#fff"; - ///// *** - - var equipList_x = obj.x + 4, - equipList_bottom = obj.obj.y - equipList_lineWidth, - equipList_y = equipList_bottom - obj.obj.oneItemHeight * reduceItem - 2, - equipList_height = equipList_bottom - equipList_y; - var equipList_right = obj.leftbar_right, - equipList_width = equipList_right - equipList_x; - core.drawLine( - ctx, - obj.x, - equipList_bottom + equipList_lineWidth / 2, - equipList_right, - equipList_bottom + equipList_lineWidth / 2, - equipList_borderStyle, - equipList_lineWidth - ); - var toDrawList = core.status.globalAttribute.equipName, - len = toDrawList.length; - - ///// *** 装备格设置 - var maxItem = 2; - var box_width = 32, - box_height = 32, - box_borderStyle = "#fff", - box_selectBorderStyle = "gold", // 选中的装备格的颜色 - box_borderWidth = 2; - var boxName_fontSize = 14, - boxName_space = 2, - boxName_color = "#fff"; // 装备格名称与上面的装备格框的距离 - var maxLine = Math.ceil(len / maxItem); - ///// *** - var l = Math.sqrt(len); - if (Math.pow(l) == len && len != 4) { - if (l <= maxItem) maxItem = l; - } - maxItem = Math.min(toDrawList.length, maxItem); - info.equips = maxItem; - - var boxName_font = core.ui._buildFont(boxName_fontSize); - // 总宽高减去所有装备格宽高得到空隙大小 - var oneBoxWidth = box_width + box_borderWidth * 2; - var oneBoxHeight = - box_height + boxName_fontSize + boxName_space + 2 * box_borderWidth; - var space_y = (equipList_height - maxLine * oneBoxHeight) / (1 + maxLine), - space_x = (equipList_width - maxItem * oneBoxWidth) / (1 + maxItem); - var box_x = equipList_x + space_x, - box_y = equipList_y + space_y + 12; - for (var i = 0; i < 2; i++) { - var id = core.getEquip(i), - name = toDrawList[i]; - if (i === 0) name = "主手"; - if (i === 1) name = "副手"; - var selectBorder = false; - if (core.status.thisUIEventInfo.select.type == i) selectBorder = true; - var borderStyle = selectBorder - ? box_selectBorderStyle - : box_borderStyle; - drawEquipbox_drawOne( - ctx, - name, - id, - box_x, - box_y, - box_width, - box_height, - boxName_space, - boxName_font, - boxName_color, - borderStyle, - box_borderWidth - ); - var todo = new Function( - "core.clickOneEquipbox('" + id + "'," + i + ")" - ); - addUIEventListener( - box_x - box_borderWidth / 2, - box_y - box_borderWidth / 2, - oneBoxWidth, - oneBoxHeight, - todo - ); - box_x += space_x + oneBoxWidth; - if ((i + 1) % maxItem == 0) { - box_x = equipList_x + space_x; - box_y += space_y + oneBoxHeight; - } - } - if (core.material.items[core.getEquip(0)]?.equipCls === "双手剑") { - core.drawLine( - ctx, - equipList_x + space_x + space_x + oneBoxWidth, - equipList_y + space_y + 12, - equipList_x + - space_x + - space_x + - oneBoxWidth + - box_width + - box_borderWidth, - equipList_y + space_y + box_height + 12 - ); - core.drawLine( - ctx, - equipList_x + space_x + space_x + oneBoxWidth, - equipList_y + space_y + box_height + 12, - equipList_x + - space_x + - space_x + - oneBoxWidth + - box_width + - box_borderWidth, - equipList_y + space_y + 12 - ); - } - ///// *** 装备格设置 - var maxItem = 3; - var box_width = 32, - box_height = 32, - box_borderStyle = "#fff", - box_selectBorderStyle = "gold", // 选中的装备格的颜色 - box_borderWidth = 2; - var boxName_fontSize = 14, - boxName_space = 2, - boxName_color = "#fff"; // 装备格名称与上面的装备格框的距离 - var maxLine = Math.ceil(len / maxItem); - ///// *** - var l = Math.sqrt(len); - if (Math.pow(l) == len && len != 4) { - if (l <= maxItem) maxItem = l; - } - maxItem = Math.min(toDrawList.length, maxItem); - info.equips = maxItem; - - var boxName_font = core.ui._buildFont(boxName_fontSize); - // 总宽高减去所有装备格宽高得到空隙大小 - var oneBoxWidth = box_width + box_borderWidth * 2; - var oneBoxHeight = - box_height + boxName_fontSize + boxName_space + 2 * box_borderWidth; - var space_y = (equipList_height - maxLine * oneBoxHeight) / (1 + maxLine), - space_x = (equipList_width - maxItem * oneBoxWidth) / (1 + maxItem); - var box_x = equipList_x + space_x, - box_y = equipList_y + space_y + space_y + oneBoxHeight; - for (var i = 2; i < len; i++) { - var id = core.getEquip(i), - name = toDrawList[i]; - var selectBorder = false; - if (core.status.thisUIEventInfo.select.type == i) selectBorder = true; - var borderStyle = selectBorder - ? box_selectBorderStyle - : box_borderStyle; - drawEquipbox_drawOne( - ctx, - name, - id, - box_x, - box_y, - box_width, - box_height, - boxName_space, - boxName_font, - boxName_color, - borderStyle, - box_borderWidth - ); - var todo = new Function( - "core.clickOneEquipbox('" + id + "'," + i + ")" - ); - addUIEventListener( - box_x - box_borderWidth / 2, - box_y - box_borderWidth / 2, - oneBoxWidth, - oneBoxHeight, - todo - ); - box_x += space_x + oneBoxWidth; - } - } - - this.drawToolbox = function (ctx) { - ctx = ctx || core.canvas.ui; - core.status.thisEventClickArea = []; - - var info = drawBoxBackground(ctx); - info.itemNum = itemNum; - drawItemListbox(ctx, info.obj); - drawToolboxRightbar(ctx, info); - core.setTextBaseline(ctx, "alphabetic"); - core.setTextAlign("left"); - }; - - var reduceItem = 4; - this.drawEquipbox = function (ctx) { - ctx = ctx || core.canvas.ui; - core.status.thisEventClickArea = []; - var info = drawBoxBackground(ctx); - info.itemNum = itemNum - reduceItem; - info.obj.y += info.obj.oneItemHeight * reduceItem; - info.obj.height -= info.obj.oneItemHeight * reduceItem; - drawItemListbox(ctx, info.obj); - drawEquipbox_drawOthers(ctx, info); - drawToolboxRightbar(ctx, info); - core.setTextBaseline(ctx, "alphabetic"); - core.setTextAlign("left"); - }; - - function drawEquipbox_drawOne( - ctx, - name, - id, - x, - y, - width, - height, - space, - font, - color, - style, - lineWidth - ) { - if (id) - core.drawIcon( - ctx, - id, - x + lineWidth / 2, - y + lineWidth / 2, - width, - height - ); - core.strokeRect( - ctx, - x, - y, - width + lineWidth, - height + lineWidth, - style, - lineWidth - ); - core.setTextAlign(ctx, "center"); - core.setTextBaseline(ctx, "top"); - var tx = (x + x + lineWidth / 2 + width) / 2, - ty = y + height + (lineWidth / 2) * 3 + space; - core.fillText(ctx, name, tx, ty, color, font); - - core.setAlpha(ctx, 1); - - core.setTextBaseline(ctx, "alphabetic"); - core.setTextAlign("left"); - } - - function drawItemListbox_drawItem( - ctx, - left, - right, - top, - height, - marginLeft, - marginHeight, - style, - id - ) { - var info = core.status.thisUIEventInfo; - var nowClick = info.index; - var item = core.material.items[id] || {}; - var name = item.name || "???"; - var num = core.itemCount(id) || 0; - var fontSize = Math.floor(height - marginHeight * 2); - core.setTextAlign(ctx, "right"); - var numText = "x" + num; - core.fillText( - ctx, - numText, - right - marginLeft, - top + height / 2, - style, - core.ui._buildFont(fontSize) - ); - - const hideInfo = core.getFlag("hideInfo", {}); - if ( - item && - (hideInfo.hasOwnProperty(id) ? hideInfo[id] : item.hideInToolbox) - ) - core.setAlpha(ctx, 0.5); - - if (name != "???") - core.drawIcon( - ctx, - id, - left + marginLeft, - top + marginHeight, - fontSize, - fontSize - ); - var text_x = left + marginLeft + fontSize + 2; - var maxWidth = right - core.calWidth(ctx, numText) - text_x; - core.setTextAlign(ctx, "left"); - core.fillText( - ctx, - name, - text_x, - top + height / 2, - style, - core.ui._buildFont(fontSize), - maxWidth - ); - core.setAlpha(ctx, 1); - - var todo = new Function("core.clickItemFunc('" + id + "');"); - addUIEventListener(left, top, right - left, height, todo); - } - - function setPageItems(page) { - var num = itemNum; - if (core.status.event.id == "equipbox") num -= reduceItem; - var info = core.status.thisUIEventInfo; - if (!info) return; - page = page || info.page; - var items = core.getToolboxItems( - core.status.event.id == "toolbox" ? "all" : "equips", - core.getFlag("showHideItem", false) - ); - info.allItems = items; - var maxPage = Math.ceil(items.length / num); - info.maxPage = maxPage; - var pageItems = items.slice((page - 1) * num, page * num); - info.pageItems = pageItems; - info.maxItem = pageItems.length; - if (items.length == 0 && pageItems.length == 0) info.index = null; - if (pageItems.length == 0 && info.page > 1) { - info.page = Math.max(1, info.page - 1); - return setPageItems(info.page); - } - return pageItems; - } - - function drawToolbox_setExitBtn(ctx, x, y, r, style, lineWidth) { - core.strokeCircle(ctx, x, y, r, style, lineWidth); - ctx.textAlign = "center"; - ctx.textBaseline = "middle"; - var textSize = Math.sqrt(2) * r; - core.fillText( - ctx, - "x", - x, - y, - style, - core.ui._buildFont(textSize), - textSize - ); - core.setTextAlign(ctx, "start"); - core.setTextBaseline(ctx, "top"); - - var todo = function () { - core.closePanel(); - }; - addUIEventListener(x - r, y - r, r * 2, r * 2, todo); - } - - function drawToolbox_setUseBtn(ctx, x, y, r, h, style, lineWidth) { - core.setTextAlign(ctx, "left"); - core.setTextBaseline(ctx, "top"); - var fontSize = h - 4; - var font = core.ui._buildFont(fontSize); - var text = core.status.event.id == "toolbox" ? "使用" : "装备"; - if (core.status.thisUIEventInfo.select.action == "unload") text = "卸下"; - var w = core.calWidth(ctx, text, font) + 2 * r + lineWidth / 2; - - core.strokeRoundRect(ctx, x, y, w, h, r, style, lineWidth); - core.fillText(ctx, text, x + r, y + lineWidth / 2 + 2, style, font); - - var todo = function () { - core.useSelectItemInBox(); - }; - addUIEventListener(x, y, w, h, todo); - } - - function getSelectedItem() { - var info = core.status.thisUIEventInfo; - if ( - !( - info && - info.select.id && - ["toolbox", "equipbox"].includes(core.status.event.id) - ) - ) { - core.drawFailTip("发生了未知错误!"); - return; - } - return info.select.id; - } - - function batchUse(item, count) { - try { - const itemCount = core.itemCount(item); - if (count > itemCount) count = itemCount; - core.closePanel(); - for (let i = 0; i < count; i++) { - if (core.canUseItem(item)) core.useItem(item); - else return; - } - } catch (e) { - console.error(e); - core.drawFailTip("批量使用时出现未知错误!"); - } - } - - function drawToolbox_setBatchUseBtn(ctx, x, y, r, h, style, lineWidth) { - try { - const selectedItem = getSelectedItem(); - let canBatchUse = eval(core.material.items[selectedItem]?.canBatchUse); - if (!canBatchUse) return; - } catch (error) { - console.error(error); - return; - } - core.setTextAlign(ctx, "left"); - core.setTextBaseline(ctx, "top"); - var fontSize = h - 4; - var font = core.ui._buildFont(fontSize); - var text = "批量使用"; - var w = core.calWidth(ctx, text, font) + 2 * r + lineWidth / 2; - - core.strokeRoundRect(ctx, x, y, w, h, r, style, lineWidth); - core.fillText(ctx, text, x + r, y + lineWidth / 2 + 2, style, font); - - var todo = function () { - core.utils.myprompt("输入要使用该物品的次数(0~99)。", null, (value) => { - value = parseInt(value); - const id = getSelectedItem(); - - if (Number.isNaN(value) || value < 0 || value > 99) { - core.drawFailTip("输入不合法!"); - return; - } - if (!core.canUseItem(id)) { - core.drawFailTip("当前无法使用该道具!"); - return; - } - core.closePanel(); - batchUse(id, value); - }); - }; - addUIEventListener(x, y, w, h, todo); - } - - function drawToolbox_setHideBtn(ctx, x, y, r, h, style, lineWidth) { - core.setTextAlign(ctx, "left"); - core.setTextBaseline(ctx, "top"); - var fontSize = h - 4; - var font = core.ui._buildFont(fontSize); - var text = "显示/隐藏"; - var w = core.calWidth(ctx, text, font) + 2 * r + lineWidth / 2; - - core.strokeRoundRect(ctx, x, y, w, h, r, style, lineWidth); - core.fillText(ctx, text, x + r, y + lineWidth / 2 + 2, style, font); - - var todo = function () { - //debugger; - var id = getSelectedItem(); - let hideInfo = core.getFlag("hideInfo", {}); - console.log(id); - if (hideInfo.hasOwnProperty(id)) { - hideInfo[id] = !hideInfo[id]; - core.setFlag("hideInfo", hideInfo); - } else { - hideInfo[id] = !core.material.items[id].hideInToolbox; - core.setFlag("hideInfo", hideInfo); - } - if (core.status.event.id === "toolbox") core.plugin.drawToolbox(); - else if (core.status.event.id === "equipbox") - core.plugin.drawEquipbox(); - }; - addUIEventListener(x, y, w, h, todo); - } - - ui.prototype.getToolboxItems = function (cls, showHide) { - let list = Object.keys(core.status.hero.items[cls] || {}); - if (cls === "all") { - for (let name in core.status.hero.items) { - if (name == "equips") continue; - list = list.concat(Object.keys(core.status.hero.items[name])); - } - if (!showHide) - list = list.filter(function (id2) { - const hideInfo = core.getFlag("hideInfo", {}); - if (hideInfo.hasOwnProperty(id2)) return !hideInfo[id2]; - else return !core.material.items[id2].hideInToolbox; - }); - list = list.sort(); - return list; - } - if (cls === "equips") { - if (!showHide) - list = list.filter(function (id2) { - const hideInfo = core.getFlag("hideInfo", {}); - if (hideInfo.hasOwnProperty(id2)) return !hideInfo[id2]; - else return !core.material.items[id2].hideInToolbox; - }); - - list = list.sort(); - return list; - } - if (this.uidata.getToolboxItems) { - return this.uidata.getToolboxItems(cls, showHide); - } - if (!showHide) - list = list.filter(function (id2) { - return !core.material.items[id2].hideInToolbox; - }); - list = list.sort(); - return list; - }; - - function drawToolbox_setShowHideBtn(ctx, x, y, h, style) { - core.setTextAlign(ctx, "left"); - core.setTextBaseline(ctx, "top"); - var fontSize = h - 6; - var font = core.ui._buildFont(fontSize); - var text = "显示隐藏"; - var w = core.calWidth(ctx, text, font); - h += 4; - const squareSize = h - 6; - - x -= w + squareSize + 26; - - const border = 2; - core.fillRect(ctx, x, y, squareSize, squareSize, " #F5F5F5"); - if (core.hasFlag("showHideItem")) { - core.fillRect( - ctx, - x + border, - y + border, - squareSize - 2 * border, - squareSize - 2 * border, - "lime" - ); - } - core.fillText(ctx, text, x + squareSize + 2, y + 4, style, font); - - var todo = function () { - core.setFlag("showHideItem", !core.getFlag("showHideItem", false)); - if (core.status.event.id === "toolbox") core.plugin.drawToolbox(); - else if (core.status.event.id === "equipbox") - core.plugin.drawEquipbox(); - }; - addUIEventListener(x, y, w, h, todo); - } - - function drawItemListbox_setPageBtn( - ctx, - left, - right, - bottom, - r, - style, - lineWidth - ) { - var offset = lineWidth / 2 + r; - - var x = left + offset; - var y = bottom - offset; - var pos = (Math.sqrt(2) / 2) * (r - lineWidth / 2); - core.fillPolygon( - ctx, - [ - [x - pos, y], - [x + pos - 2, y - pos], - [x + pos - 2, y + pos], - ], - style - ); - core.strokeCircle(ctx, x, y, r, style, lineWidth); - var todo = function () { - core.addItemListboxPage(-1); - }; - addUIEventListener(x - r - 2, y - r - 2, r * 2 + 4, r * 2 + 4, todo); - - x = right - offset; - core.fillPolygon( - ctx, - [ - [x + pos, y], - [x - pos + 2, y - pos], - [x - pos + 2, y + pos], - ], - style - ); - core.strokeCircle(ctx, x, y, r, style, lineWidth); - var todo = function () { - core.addItemListboxPage(1); - }; - addUIEventListener(x - r - 2, y - r - 2, r * 2 + 4, r * 2 + 4, todo); - } - - this.clickItemFunc = function (id) { - var info = core.status.thisUIEventInfo; - if (!info) return; - if (info.select.id == id) return core.useSelectItemInBox(); - info.select = {}; - info.select.id = id; - core.setIndexAndSelect("index"); - refreshBox(); - }; - - this.clickOneEquipbox = function (id, type) { - var info = core.status.thisUIEventInfo; - if (!info) return; - if (info.select.id == id && info.select.type == type) - core.useSelectItemInBox(); - else - core.status.thisUIEventInfo.select = { - id: id, - type: type, - action: "unload", - }; - return refreshBox(); - }; - - this.useSelectItemInBox = function () { - var info = core.status.thisUIEventInfo; - if (!info) return; - if (!info.select.id) return; - var id = info.select.id; - if (core.status.event.id == "toolbox") { - core.events.tryUseItem(id); - // core.closePanel(); - } else if (core.status.event.id == "equipbox") { - var action = info.select.action || "load"; - info.index = 1; - if (action == "load") { - var type = core.getEquipTypeById(id); - let equipClsid = core.material.items[id]?.equipCls; - let equipCls0 = core.material.items[core.getEquip(0)]?.equipCls; - let equipCls1 = core.material.items[core.getEquip(1)]?.equipCls; - if (equipClsid === "双手剑") { - core.unloadEquip(0, function () { - core.status.route.push("unEquip:" + 0); - }); - core.unloadEquip(1, function () { - core.status.route.push("unEquip:" + 1); - }); - } - if ( - equipCls0 === "双手剑" && - !(equipClsid === "饰品" || equipClsid === "护具") - ) { - core.unloadEquip(0, function () { - core.status.route.push("unEquip:" + 0); - }); - } - core.loadEquip(id, function () { - core.status.route.push("equip:" + id); - info.select.type = type; - core.setIndexAndSelect("select"); - core.drawEquipbox(); - }); - } else { - var type = info.select.type; - core.unloadEquip(type, function () { - core.status.route.push("unEquip:" + type); - info.select.type = type; - info.select.action = "load"; - core.setIndexAndSelect("select"); - core.drawEquipbox(); - }); - } - } - core.updateStatusBar(); - }; - - this.setIndexAndSelect = function (toChange) { - var info = core.status.thisUIEventInfo; - if (!info) return; - setPageItems(info.page); - var index = info.index || 1; - var items = info.pageItems; - - info.select.action = null; - info.select.type = null; - if (toChange == "index") info.index = items.indexOf(info.select.id) + 1; - info.select.id = items[info.index - 1]; - }; - - this.addItemListboxPage = function (num) { - var info = core.status.thisUIEventInfo; - if (!info) return; - var maxPage = info.maxPage || 1; - info.page = info.page || 1; - info.page += num; - if (info.page <= 0) info.page = maxPage; - if (info.page > maxPage) info.page = 1; - info.index = 1; - setPageItems(info.page); - core.setIndexAndSelect("select"); - refreshBox(); - }; - - this.addItemListboxIndex = function (num) { - var info = core.status.thisUIEventInfo; - if (!info) return; - var maxItem = info.maxItem || 0; - info.index = info.index || 0; - info.index += num; - if (info.index <= 0) info.index = 1; - if (info.index > maxItem) info.index = maxItem; - core.setIndexAndSelect("select"); - refreshBox(); - }; - - this.addEquipboxType = function (num) { - var info = core.status.thisUIEventInfo; - var type = info.select.type; - if (type == null && num > 0) info.select.type = 0; - else info.select.type = type + num; - var max = core.status.globalAttribute.equipName.length; - if (info.select.type >= max) { - info.select = {}; - core.setIndexAndSelect("select"); - return core.addItemListboxPage(0); - } else { - var m = Math.abs(info.select.type); - if (info.select.type < 0) info.select.type = max - m; - core.setIndexAndSelect("select"); - refreshBox(); - return; - } - }; - - core.actions._keyDownToolbox = function (keycode) { - if (!core.status.thisEventClickArea) return; - if (keycode == 37) { - // left - core.addItemListboxPage(-1); - return; - } - if (keycode == 38) { - // up - core.addItemListboxIndex(-1); - return; - } - if (keycode == 39) { - // right - core.addItemListboxPage(1); - return; - } - if (keycode == 40) { - // down - core.addItemListboxIndex(1); - return; - } - }; - - ////// 工具栏界面时,放开某个键的操作 ////// - core.actions._keyUpToolbox = function (keycode) { - if (keycode == 81) { - core.ui.closePanel(); - if (core.isReplaying()) core.control._replay_equipbox(); - else core.openEquipbox(); - return; - } - if (keycode == 84 || keycode == 27 || keycode == 88) { - core.closePanel(); - return; - } - if (keycode == 13 || keycode == 32 || keycode == 67) { - var info = core.status.thisUIEventInfo; - if (info.select) { - core.useSelectItemInBox(); - } - return; - } - }; - - core.actions._keyDownEquipbox = function (keycode) { - if (!core.status.thisEventClickArea) return; - if (keycode == 37) { - // left - var info = core.status.thisUIEventInfo; - if (info.index != null) return core.addItemListboxPage(-1); - return core.addEquipboxType(-1); - } - if (keycode == 38) { - // up - var info = core.status.thisUIEventInfo; - if (info.index == 1) { - info.select.type = core.status.globalAttribute.equipName.length - 1; - core.setIndexAndSelect(); - return refreshBox(); - } - if (info.index) return core.addItemListboxIndex(-1); - return core.addEquipboxType(-1 * info.equips); - } - if (keycode == 39) { - // right - var info = core.status.thisUIEventInfo; - if (info.index != null) return core.addItemListboxPage(1); - return core.addEquipboxType(1); - } - if (keycode == 40) { - // down - var info = core.status.thisUIEventInfo; - if (info.index) return core.addItemListboxIndex(1); - return core.addEquipboxType(info.equips); - } - }; - - core.actions._keyUpEquipbox = function (keycode, altKey) { - if (altKey && keycode >= 48 && keycode <= 57) { - core.items.quickSaveEquip(keycode - 48); - return; - } - if (keycode == 84) { - core.ui.closePanel(); - if (core.isReplaying()) core.control._replay_toolbox(); - else core.openToolbox(); - return; - } - if (keycode == 81 || keycode == 27 || keycode == 88) { - core.closePanel(); - return; - } - if (keycode == 13 || keycode == 32 || keycode == 67) { - var info = core.status.thisUIEventInfo; - if (info.select) core.useSelectItemInBox(); - return; - } - }; - - core.registerAction( - "ondown", - "inEventClickAction", - function (x, y, px, py) { - if (!core.status.thisEventClickArea) return false; - var info = core.status.thisEventClickArea; - for (var i = 0; i < info.length; i++) { - var obj = info[i]; - if ( - px >= obj.x && - px <= obj.x + obj.width && - py > obj.y && - py < obj.y + obj.height - ) { - if (obj.todo) obj.todo(); - break; - } - } - return true; - }, - 51 - ); - core.registerAction( - "onclick", - "stopClick", - function () { - if (core.status.thisEventClickArea) return true; - }, - 51 - ); - - function addUIEventListener(x, y, width, height, todo) { - if (!core.status.thisEventClickArea) return; - var obj = { - x: x, - y: y, - width: width, - height: height, - todo: todo, - }; - core.status.thisEventClickArea.push(obj); - } - - this.initThisEventInfo = function () { - core.status.thisUIEventInfo = { - page: 1, - select: {}, - }; - core.status.thisEventClickArea = []; - }; - - function refreshBox() { - if (!core.status.event.id) return; - if (core.status.event.id == "toolbox") core.drawToolbox(); - else core.drawEquipbox(); - } - - core.ui.closePanel = function () { - if (core.status.hero && core.status.hero.flags) { - // 清除全部临时变量 - Object.keys(core.status.hero.flags).forEach(function (name) { - if (name.startsWith("@temp@") || /^arg\d+$/.test(name)) { - delete core.status.hero.flags[name]; - } - }); - } - this.clearUI(); - core.maps.generateGroundPattern(); - core.updateStatusBar(true); - core.unlockControl(); - core.status.event.data = null; - core.status.event.id = null; - core.status.event.selection = null; - core.status.event.ui = null; - core.status.event.interval = null; - core.status.thisUIEventInfo = null; - core.status.thisEventClickArea = null; - }; - - this.getItemClsName = function (item) { - if (item == null) return itemClsName; - if (item.cls == "equips") { - if (typeof item.equip.type == "string") return item.equip.type; - var type = core.getEquipTypeById(item.id); - return core.status.globalAttribute.equipName[type]; - } else return itemClsName[item.cls] || item.cls; - }; - - core.events.openToolbox = function (fromUserAction) { - if (core.isReplaying()) return; - if (!this._checkStatus("toolbox", fromUserAction)) return; - core.initThisEventInfo(); - let info = core.status.thisUIEventInfo; - info.index = 1; - core.setIndexAndSelect("select"); - core.drawToolbox(); - }; - - core.events.openEquipbox = function (fromUserAction) { - if (core.isReplaying()) return; - if (!this._checkStatus("equipbox", fromUserAction)) return; - core.initThisEventInfo(); - let info = core.status.thisUIEventInfo; - info.select.type = 0; - core.setIndexAndSelect("select"); - core.drawEquipbox(); - }; - - core.control._replay_toolbox = function () { - if (!core.isPlaying() || !core.isReplaying()) return; - if (!core.status.replay.pausing) return core.drawTip("请先暂停录像"); - if (core.isMoving() || core.status.replay.animate || core.status.event.id) - return core.drawTip("请等待当前事件的处理结束"); - - core.lockControl(); - core.status.event.id = "toolbox"; - core.drawToolbox(); - }; - - core.control._replay_equipbox = function () { - if (!core.isPlaying() || !core.isReplaying()) return; - if (!core.status.replay.pausing) return core.drawTip("请先暂停录像"); - if (core.isMoving() || core.status.replay.animate || core.status.event.id) - return core.drawTip("请等待当前事件的处理结束"); - - core.lockControl(); - core.status.event.id = "equipbox"; - core.drawEquipbox(); - }; - - core.control._replayAction_item = function (action) { - if (action.indexOf("item:") != 0) return false; - var itemId = action.substring(5); - if (!core.canUseItem(itemId)) return false; - if ( - core.material.items[itemId].hideInReplay || - core.status.replay.speed == 24 - ) { - core.useItem(itemId, false, core.replay); - return true; - } - core.status.event.id = "toolbox"; - core.initThisEventInfo(); - var info = core.status.thisUIEventInfo; - var items = core.getToolboxItems( - "all", - core.getFlag("showHideItem", false) - ); - setPageItems(1); - var index = items.indexOf(itemId) + 1; - info.page = Math.ceil(index / info.maxItem); - info.index = index % info.maxItem || info.maxItem; - core.setIndexAndSelect("select"); - setPageItems(info.page); - core.drawToolbox(); - setTimeout(function () { - core.ui.closePanel(); - core.useItem(itemId, false, core.replay); - }, core.control.__replay_getTimeout()); - return true; - }; - - core.control._replayAction_equip = function (action) { - if (action.indexOf("equip:") != 0) return false; - var itemId = action.substring(6); - var items = core.getToolboxItems( - "equips", - core.getFlag("showHideItem", false) - ); - var index = items.indexOf(itemId) + 1; - if (index < 1) { - core.removeFlag("__doNotCheckAutoEvents__"); - return false; - } - - var cb = function () { - var next = core.status.replay.toReplay[0] || ""; - if (!next.startsWith("equip:") && !next.startsWith("unEquip:")) { - core.removeFlag("__doNotCheckAutoEvents__"); - core.checkAutoEvents(); - } - core.replay(); - }; - core.setFlag("__doNotCheckAutoEvents__", true); - - core.status.route.push(action); - if ( - core.material.items[itemId].hideInReplay || - core.status.replay.speed == 24 - ) { - core.loadEquip(itemId, cb); - return true; - } - core.status.event.id = "equipbox"; - core.initThisEventInfo(); - var info = core.status.thisUIEventInfo; - setPageItems(1); - info.page = Math.ceil(index / info.maxItem); - info.index = index % info.maxItem || info.maxItem; - core.setIndexAndSelect("select"); - setPageItems(info.page); - core.drawEquipbox(); - setTimeout(function () { - core.ui.closePanel(); - core.loadEquip(itemId, cb); - }, core.control.__replay_getTimeout()); - return true; - }; - - core.control._replayAction_unEquip = function (action) { - if (action.indexOf("unEquip:") != 0) return false; - var equipType = parseInt(action.substring(8)); - if (!core.isset(equipType)) { - core.removeFlag("__doNotCheckAutoEvents__"); - return false; - } - - var cb = function () { - var next = core.status.replay.toReplay[0] || ""; - if (!next.startsWith("equip:") && !next.startsWith("unEquip:")) { - core.removeFlag("__doNotCheckAutoEvents__"); - core.checkAutoEvents(); - } - core.replay(); - }; - core.setFlag("__doNotCheckAutoEvents__", true); - - core.status.route.push(action); - if (core.status.replay.speed == 24) { - core.unloadEquip(equipType, cb); - return true; - } - core.status.event.id = "equipbox"; - core.initThisEventInfo(); - var info = core.status.thisUIEventInfo; - setPageItems(1); - info.select.type = equipType; - core.setIndexAndSelect(); - core.drawEquipbox(); - setTimeout(function () { - core.ui.closePanel(); - core.unloadEquip(equipType, cb); - }, core.control.__replay_getTimeout()); - return true; - }; - core.registerReplayAction("item", core.control._replayAction_item); - core.registerReplayAction("equip", core.control._replayAction_equip); - core.registerReplayAction("unEquip", core.control._replayAction_unEquip); - }, + core.setAlpha(ctx, backgroundAlpha); + core.strokeRoundRect( + ctx, + x, + y, + w, + h, + borderRadius, + borderStyle, + borderWidth + ); + core.fillRoundRect( + ctx, + start_x, + start_y, + width, + height, + borderRadius, + backgroundColor + ); + core.setAlpha(ctx, 1); + + ///// *** 左栏配置 + var leftbar_height = height; + // 左边栏宽度(width*0.6) 本身仅为坐标使用 需要与底下的rightbar_width(width*0.4)同时更改 + var leftbar_width = width * 0.6; + ///// *** + + // xxx_right参数 代表最右侧坐标 + var leftbar_right = start_x + leftbar_width - borderWidth / 2; + var leftbar_bottom = start_y + leftbar_height; + var leftbar_x = start_x; + var leftbar_y = start_y; + + ///// *** 道具栏配置 + var boxName_color = "#fff"; + var boxName_fontSize = 15; + var boxName_font = core.ui._buildFont(boxName_fontSize, true); + var arrow_x = 10 + start_x; + var arrow_y = 10 + start_y; + var arrow_width = 20; + var arrow_style = "white"; + // 暂时只能是1 否则不太行 等待新样板(2.7.3)之后对drawArrow做优化 + var arrow_lineWidth = 2; + // 右箭头 + var rightArrow_right = leftbar_right - 10; + // 道具内栏顶部坐标 本质是通过该项 控制(道具栏顶部文字和箭头)与道具内栏顶部的间隔 + var itembar_top = arrow_y + 15; + ///// *** + + var itembar_right = rightArrow_right; + var boxName = + core.status.event.id == "toolbox" ? + "\r[yellow]道具栏\r | 装备栏" : + "道具栏 | \r[yellow]装备栏\r"; + core.drawArrow( + ctx, + arrow_x + arrow_width, + arrow_y, + arrow_x, + arrow_y, + arrow_style, + arrow_lineWidth + ); + core.drawArrow( + ctx, + rightArrow_right - arrow_width, + arrow_y, + rightArrow_right, + arrow_y, + arrow_style, + arrow_lineWidth + ); + core.setTextAlign(ctx, "center"); + core.setTextBaseline(ctx, "middle"); + var changeBox = function () { + var id = core.status.event.id; + core.closePanel(); + if (id == "toolbox") core.openEquipbox(); + else core.openToolbox(); + }; + core.fillText( + ctx, + boxName, + (leftbar_right + leftbar_x) / 2, + arrow_y + 2, + boxName_color, + boxName_font + ); + + ///// *** 底栏按钮 + var pageBtn_radius = 8; + // xxx_left 最左侧坐标 + var pageBtn_left = leftbar_x + 3; + var pageBtn_right = leftbar_right - 3; + // xxx_bottom 最底部坐标 + var pageBtn_bottom = leftbar_bottom - 2; + var pageBtn_borderStyle = "#fff"; + var pageBtn_borderWidth = 2; + var pageText_color = "#fff"; + // 底部按钮与上面的道具内栏的间隔大小 + var bottomSpace = 8; + ///// *** + + drawItemListbox_setPageBtn( + ctx, + pageBtn_left, + pageBtn_right, + pageBtn_bottom, + pageBtn_radius, + pageBtn_borderStyle, + pageBtn_borderWidth + ); + var page = info.page || 1; + var pageFontSize = pageBtn_radius * 2 - 4; + var pageFont = core.ui._buildFont(pageFontSize); + setPageItems(page); + var num = itemNum; + if (core.status.event.id == "equipbox") num -= 5; + var maxPage = info.maxPage; + var pageText = page + " / " + maxPage; + core.setTextAlign(ctx, "center"); + core.setTextBaseline(ctx, "bottom"); + core.fillText( + ctx, + pageText, + (leftbar_x + leftbar_right) / 2, + pageBtn_bottom, + pageText_color, + pageFont + ); + addUIEventListener( + start_x, + start_y, + leftbar_right - start_x, + arrow_y - start_y + 13, + changeBox + ); + var itembar_height = Math.ceil( + pageBtn_bottom - + pageBtn_radius * 2 - + pageBtn_borderWidth / 2 - + bottomSpace - + itembar_top + ); + var oneItemHeight = (itembar_height - 4) / itemNum; + return { + x: start_x, + y: start_y, + width: width, + height: height, + leftbar_right: leftbar_right, + obj: { + x: arrow_x, + y: itembar_top, + width: itembar_right - arrow_x, + height: itembar_height, + oneItemHeight: oneItemHeight, + }, + }; + } + + function drawItemListbox(ctx, obj) { + ctx = ctx || core.canvas.ui; + var itembar_x = obj.x, + itembar_y = obj.y, + itembar_width = obj.width, + itembar_height = obj.height, + itemNum = obj.itemNum, + oneItemHeight = obj.oneItemHeight; + var itembar_right = itembar_x + itembar_width; + var info = core.status.thisUIEventInfo || {}; + var obj = {}; + var page = info.page || 1, + index = info.index, + select = info.select || {}; + + ///// *** 道具栏内栏配置 + var itembar_style = "black"; + var itembar_alpha = 0.7; + // 一个竖屏下减少道具显示的例子: + // if (core.domStyle.isVertical) itemNum = 10; + // 每个道具项的上下空隙占总高度的比例 + var itembar_marginHeightRatio = 0.2; + // 左右间隔空隙 + var item_marginLeft = 2; + var item_x = itembar_x + 2, + item_y = itembar_y + 2, + item_right = itembar_right - 2, + itemName_color = "#fff"; + // 修改此项以更换闪烁光标 + var item_selector = "winskin.webp"; + ///// *** + + core.setAlpha(ctx, itembar_alpha); + core.fillRect( + ctx, + itembar_x, + itembar_y, + itembar_width, + itembar_height, + itembar_style + ); + core.setAlpha(ctx, 1); + var pageItems = setPageItems(page); + var marginHeight = itembar_marginHeightRatio * oneItemHeight; + core.setTextBaseline(ctx, "middle"); + var originColor = itemName_color; + for (var i = 0; i < pageItems.length; i++) { + itemName_color = originColor; + var item = pageItems[i]; + // 设置某个的字体颜色的一个例子 + // if (item.id == "xxx") itemName_color = "green"; + drawItemListbox_drawItem( + ctx, + item_x, + item_right, + item_y, + oneItemHeight, + item_marginLeft, + marginHeight, + itemName_color, + pageItems[i] + ); + if (index == i + 1) + core.ui._drawWindowSelector( + item_selector, + item_x + 1, + item_y - 1, + item_right - item_x - 2, + oneItemHeight - 2 + ); + item_y += oneItemHeight; + } + } + + function drawToolboxRightbar(ctx, obj) { + ctx = ctx || core.canvas.ui; + var info = core.status.thisUIEventInfo || {}; + var page = info.page || 1, + index = info.index || 1, + select = info.select || {}; + var start_x = obj.x, + start_y = obj.y, + width = obj.width, + height = obj.height; + var toolboxRight = start_x + width, + toolboxBottom = start_y + height; + + ///// *** 侧边栏(rightbar)背景设置(物品介绍) + var rightbar_width = width * 0.4; + var rightbar_height = height; + var rightbar_lineWidth = 2; + var rightbar_lineStyle = "#fff"; + ///// *** + + var rightbar_x = toolboxRight - rightbar_width - rightbar_lineWidth / 2; + var rightbar_y = start_y; + core.drawLine( + ctx, + rightbar_x, + rightbar_y, + rightbar_x, + rightbar_y + rightbar_height, + rightbar_lineStyle, + rightbar_lineWidth + ); + + // 获取道具id(有可能为null) + var itemId = select.id; + var item = core.material.items[itemId]; + + ///// *** 侧边栏物品Icon信息 + var iconRect_y = rightbar_y + 10; + // space:间距 + // 这里布局设定iconRect与侧边栏左边框 itemName与工具栏右边框 itemRect与itemName的间距均为space + var space = 15; + var iconRect_x = rightbar_x + space; + var iconRect_radius = 2, + iconRect_width = 32, + iconRect_height = 32, + iconRect_style = "#fff", + iconRect_lineWidth = 2; + ///// *** + + var iconRect_bottom = iconRect_y + iconRect_height, + iconRect_right = iconRect_x + iconRect_width; + + ///// *** 侧边栏各项信息 + var itemTextFontSize = 15, + itemText_x = iconRect_x - 4, + itemText_y = Math.floor(start_y + rightbar_height * 0.25), // 坐标取整防止模糊 + itemClsFontSize = 15, + itemClsFont = core.ui._buildFont(itemClsFontSize), + itemClsColor = "#fff", + itemCls_x = itemText_x - itemClsFontSize / 2, + itemCls_middle = (iconRect_bottom + itemText_y) / 2, //_middle代表文字的中心y坐标 + itemNameFontSize = 18, + itemNameColor = "#fff", + itemNameFont = core.ui._buildFont(itemNameFontSize, true); + var itemName_x = iconRect_right + space; + var itemName_middle = + iconRect_y + iconRect_height / 2 + iconRect_lineWidth; + // 修改这里可以编辑未选中道具时的默认值 + var defaultItem = { + cls: "constants", + name: "未知道具", + text: "没有道具最永久", + }; + var defaultEquip = { + cls: "equips", + name: "未知装备", + text: "一无所有,又何尝不是一种装备", + equip: { + type: "装备", + }, + }; + ///// *** + + var originItem = item; + if (core.status.event.id == "equipbox") item = item || defaultEquip; + item = item || defaultItem; + var itemCls = item.cls, + itemName = item.name, + itemText = item.text; + itemText = core.replaceText(itemText); + if (!itemText) itemText = "该道具无描述。"; + /* 一个根据道具id修改道具名字(右栏)的例子 + * if (item.id == "xxx") itemNameColor = "red"; + */ + var itemClsName = core.getItemClsName(item); + var itemNameMaxWidth = + rightbar_width - iconRect_width - iconRect_lineWidth * 2 - space * 2; + core.strokeRoundRect( + ctx, + iconRect_x, + iconRect_y, + iconRect_width, + iconRect_height, + iconRect_radius, + iconRect_style, + iconRect_lineWidth + ); + if (item.id) + core.drawIcon( + ctx, + item.id, + iconRect_x + iconRect_lineWidth / 2, + iconRect_y + iconRect_lineWidth / 2, + iconRect_width - iconRect_lineWidth, + iconRect_height - iconRect_lineWidth + ); + core.setTextAlign(ctx, "left"); + core.setTextBaseline(ctx, "middle"); + if (itemCls === "equips" && item.id) { + itemName = "【" + item.equipCls + "】" + itemName; + } + core.fillText( + ctx, + itemName, + itemName_x, + itemName_middle, + itemNameColor, + itemNameFont, + itemNameMaxWidth + ); + if (!item.equip) + core.fillText( + ctx, + "【" + itemClsName + "】", + itemCls_x, + itemCls_middle, + itemClsColor, + itemClsFont + ); + + var statusText = ""; + if (core.status.event.id == "equipbox") { + var type = item.equip.type; + if (typeof type == "string") type = core.getEquipTypeByName(type); + var compare = core.compareEquipment(item.id, core.getEquip(type)); + var compare2; + if (item.equipCls === "双手剑") + compare2 = core.compareEquipment(null, core.getEquip(1)); + if ( + item.equipCls === "盾牌" && + core.material.items[core.getEquip(0)]?.equipCls === "双手剑" + ) + compare2 = core.compareEquipment(null, core.getEquip(0)); + if (info.select.action == "unload") + compare = core.compareEquipment(null, item.id); + // --- 变化值... + for (var name in core.status.hero) { + if (typeof core.status.hero[name] != "number") continue; + var nowValue = core.getRealStatus(name); + // 查询新值 + var newValue = Math.floor( + ((core.getStatus(name) + + (compare.value[name] || 0) + + (compare2?.value[name] || 0)) * + (core.getBuff(name) * 100 + + (compare.percentage[name] || 0) + + (compare2?.percentage[name] || 0))) / + 100 + ); + if (name === "mdef") { + var nowValue = core.getRealStatus(name); + var newValue = Math.round( + (core.getStatus(name) - + (compare.value[name] || 0) - + (compare2?.value[name] || 0)) * + (1 - + (1 - core.getBuff(name)) * + (compare.percentage[name] || 1) * + (compare2?.percentage[name] || 1)) + ); + } + if (nowValue == newValue) continue; + var color = newValue > nowValue ? "#00FF00" : "#FF0000"; + nowValue = core.formatBigNumber(nowValue); + newValue = core.formatBigNumber(newValue); + + if (name === "mdef") { + nowValue += "%"; + newValue += "%"; + } + statusText += + core.getStatusLabel(name) + + " " + + nowValue + + "->\r[" + + color + + "]" + + newValue + + "\r\n"; + } + } + itemText = statusText + itemText; + if (item.equip) { + core.drawTextContent(ctx, itemText, { + left: itemText_x, + top: itemCls_middle, + bold: false, + color: "white", + align: "left", + fontSize: itemTextFontSize, + maxWidth: rightbar_width - + (itemText_x - rightbar_x) * 2 + + itemTextFontSize / 2, + }); + } else { + core.drawTextContent(ctx, itemText, { + left: itemText_x, + top: itemText_y, + bold: false, + color: "white", + align: "left", + fontSize: itemTextFontSize, + maxWidth: rightbar_width - + (itemText_x - rightbar_x) * 2 + + itemTextFontSize / 2, + }); + } + + ///// *** 退出按钮设置 + var btnRadius = 10; + var btnBorderWidth = 2; + var btnRight = toolboxRight - 2; + var btnBottom = toolboxBottom - 2; + var btnBorderStyle = "#fff"; + ///// *** + + // 获取圆心位置 + var btn_x = btnRight - btnRadius - btnBorderWidth / 2; + btn_y = btnBottom - btnRadius - btnBorderWidth / 2; + drawToolbox_setExitBtn( + ctx, + btn_x, + btn_y, + btnRadius, + btnBorderStyle, + btnBorderWidth + ); + + ///// *** 使用按钮设置 + var useBtnHeight = btnRadius * 2; + // 这里不设置useBtnWidth而是根据各项数据自动得出width + var useBtnRadius = useBtnHeight / 4; + var useBtn_x = rightbar_x + 4, + useBtn_y = btnBottom - useBtnHeight; + var useBtnBorderStyle = "#fff"; + var useBtnBorderWidth = btnBorderWidth; + const batchUseBtn_x = useBtn_x + 50; // 个人觉得,搞这么多参数还不如硬编码 + const hideBtn_y = useBtn_y - useBtnHeight - 8; + ///// *** + + drawToolbox_setUseBtn( + ctx, + useBtn_x, + useBtn_y, + useBtnRadius, + useBtnHeight, + useBtnBorderStyle, + useBtnBorderWidth + ); + if (core.status.event.id === "toolbox") { + drawToolbox_setBatchUseBtn( + ctx, + batchUseBtn_x, + useBtn_y, + useBtnRadius, + useBtnHeight, + useBtnBorderStyle, + useBtnBorderWidth + ); + } + drawToolbox_setHideBtn( + ctx, + useBtn_x, + hideBtn_y, + useBtnRadius, + useBtnHeight, + useBtnBorderStyle, + useBtnBorderWidth + ); + drawToolbox_setShowHideBtn( + ctx, + rightbar_x, + useBtn_y, + useBtnHeight, + useBtnBorderStyle + ); + } + + function drawEquipbox_drawOthers(ctx, obj) { + var info = core.status.thisUIEventInfo; + + ///// *** 装备格设置 + var equipList_lineWidth = 2; + var equipList_boxSize = 32; + var equipList_borderWidth = 2; + var equipList_borderStyle = "#fff"; + var equipList_nameColor = "#fff"; + ///// *** + + var equipList_x = obj.x + 4, + equipList_bottom = obj.obj.y - equipList_lineWidth, + equipList_y = equipList_bottom - obj.obj.oneItemHeight * reduceItem - 2, + equipList_height = equipList_bottom - equipList_y; + var equipList_right = obj.leftbar_right, + equipList_width = equipList_right - equipList_x; + core.drawLine( + ctx, + obj.x, + equipList_bottom + equipList_lineWidth / 2, + equipList_right, + equipList_bottom + equipList_lineWidth / 2, + equipList_borderStyle, + equipList_lineWidth + ); + var toDrawList = core.status.globalAttribute.equipName, + len = toDrawList.length; + + ///// *** 装备格设置 + var maxItem = 2; + var box_width = 32, + box_height = 32, + box_borderStyle = "#fff", + box_selectBorderStyle = "gold", // 选中的装备格的颜色 + box_borderWidth = 2; + var boxName_fontSize = 14, + boxName_space = 2, + boxName_color = "#fff"; // 装备格名称与上面的装备格框的距离 + var maxLine = Math.ceil(len / maxItem); + ///// *** + var l = Math.sqrt(len); + if (Math.pow(l) == len && len != 4) { + if (l <= maxItem) maxItem = l; + } + maxItem = Math.min(toDrawList.length, maxItem); + info.equips = maxItem; + + var boxName_font = core.ui._buildFont(boxName_fontSize); + // 总宽高减去所有装备格宽高得到空隙大小 + var oneBoxWidth = box_width + box_borderWidth * 2; + var oneBoxHeight = + box_height + boxName_fontSize + boxName_space + 2 * box_borderWidth; + var space_y = (equipList_height - maxLine * oneBoxHeight) / (1 + maxLine), + space_x = (equipList_width - maxItem * oneBoxWidth) / (1 + maxItem); + var box_x = equipList_x + space_x, + box_y = equipList_y + space_y + 12; + for (var i = 0; i < 2; i++) { + var id = core.getEquip(i), + name = toDrawList[i]; + if (i === 0) name = "主手"; + if (i === 1) name = "副手"; + var selectBorder = false; + if (core.status.thisUIEventInfo.select.type == i) selectBorder = true; + var borderStyle = selectBorder ? + box_selectBorderStyle : + box_borderStyle; + drawEquipbox_drawOne( + ctx, + name, + id, + box_x, + box_y, + box_width, + box_height, + boxName_space, + boxName_font, + boxName_color, + borderStyle, + box_borderWidth + ); + var todo = new Function( + "core.clickOneEquipbox('" + id + "'," + i + ")" + ); + addUIEventListener( + box_x - box_borderWidth / 2, + box_y - box_borderWidth / 2, + oneBoxWidth, + oneBoxHeight, + todo + ); + box_x += space_x + oneBoxWidth; + if ((i + 1) % maxItem == 0) { + box_x = equipList_x + space_x; + box_y += space_y + oneBoxHeight; + } + } + if (core.material.items[core.getEquip(0)]?.equipCls === "双手剑") { + core.drawLine( + ctx, + equipList_x + space_x + space_x + oneBoxWidth, + equipList_y + space_y + 12, + equipList_x + + space_x + + space_x + + oneBoxWidth + + box_width + + box_borderWidth, + equipList_y + space_y + box_height + 12 + ); + core.drawLine( + ctx, + equipList_x + space_x + space_x + oneBoxWidth, + equipList_y + space_y + box_height + 12, + equipList_x + + space_x + + space_x + + oneBoxWidth + + box_width + + box_borderWidth, + equipList_y + space_y + 12 + ); + } + ///// *** 装备格设置 + var maxItem = 3; + var box_width = 32, + box_height = 32, + box_borderStyle = "#fff", + box_selectBorderStyle = "gold", // 选中的装备格的颜色 + box_borderWidth = 2; + var boxName_fontSize = 14, + boxName_space = 2, + boxName_color = "#fff"; // 装备格名称与上面的装备格框的距离 + var maxLine = Math.ceil(len / maxItem); + ///// *** + var l = Math.sqrt(len); + if (Math.pow(l) == len && len != 4) { + if (l <= maxItem) maxItem = l; + } + maxItem = Math.min(toDrawList.length, maxItem); + info.equips = maxItem; + + var boxName_font = core.ui._buildFont(boxName_fontSize); + // 总宽高减去所有装备格宽高得到空隙大小 + var oneBoxWidth = box_width + box_borderWidth * 2; + var oneBoxHeight = + box_height + boxName_fontSize + boxName_space + 2 * box_borderWidth; + var space_y = (equipList_height - maxLine * oneBoxHeight) / (1 + maxLine), + space_x = (equipList_width - maxItem * oneBoxWidth) / (1 + maxItem); + var box_x = equipList_x + space_x, + box_y = equipList_y + space_y + space_y + oneBoxHeight; + for (var i = 2; i < len; i++) { + var id = core.getEquip(i), + name = toDrawList[i]; + var selectBorder = false; + if (core.status.thisUIEventInfo.select.type == i) selectBorder = true; + var borderStyle = selectBorder ? + box_selectBorderStyle : + box_borderStyle; + drawEquipbox_drawOne( + ctx, + name, + id, + box_x, + box_y, + box_width, + box_height, + boxName_space, + boxName_font, + boxName_color, + borderStyle, + box_borderWidth + ); + var todo = new Function( + "core.clickOneEquipbox('" + id + "'," + i + ")" + ); + addUIEventListener( + box_x - box_borderWidth / 2, + box_y - box_borderWidth / 2, + oneBoxWidth, + oneBoxHeight, + todo + ); + box_x += space_x + oneBoxWidth; + } + } + + this.drawToolbox = function (ctx) { + ctx = ctx || core.canvas.ui; + core.status.thisEventClickArea = []; + + var info = drawBoxBackground(ctx); + info.itemNum = itemNum; + drawItemListbox(ctx, info.obj); + drawToolboxRightbar(ctx, info); + core.setTextBaseline(ctx, "alphabetic"); + core.setTextAlign("left"); + }; + + var reduceItem = 4; + this.drawEquipbox = function (ctx) { + ctx = ctx || core.canvas.ui; + core.status.thisEventClickArea = []; + var info = drawBoxBackground(ctx); + info.itemNum = itemNum - reduceItem; + info.obj.y += info.obj.oneItemHeight * reduceItem; + info.obj.height -= info.obj.oneItemHeight * reduceItem; + drawItemListbox(ctx, info.obj); + drawEquipbox_drawOthers(ctx, info); + drawToolboxRightbar(ctx, info); + core.setTextBaseline(ctx, "alphabetic"); + core.setTextAlign("left"); + }; + + function drawEquipbox_drawOne( + ctx, + name, + id, + x, + y, + width, + height, + space, + font, + color, + style, + lineWidth + ) { + if (id) + core.drawIcon( + ctx, + id, + x + lineWidth / 2, + y + lineWidth / 2, + width, + height + ); + core.strokeRect( + ctx, + x, + y, + width + lineWidth, + height + lineWidth, + style, + lineWidth + ); + core.setTextAlign(ctx, "center"); + core.setTextBaseline(ctx, "top"); + var tx = (x + x + lineWidth / 2 + width) / 2, + ty = y + height + (lineWidth / 2) * 3 + space; + core.fillText(ctx, name, tx, ty, color, font); + + core.setAlpha(ctx, 1); + + core.setTextBaseline(ctx, "alphabetic"); + core.setTextAlign("left"); + } + + function drawItemListbox_drawItem( + ctx, + left, + right, + top, + height, + marginLeft, + marginHeight, + style, + id + ) { + var info = core.status.thisUIEventInfo; + var nowClick = info.index; + var item = core.material.items[id] || {}; + var name = item.name || "???"; + var num = core.itemCount(id) || 0; + var fontSize = Math.floor(height - marginHeight * 2); + core.setTextAlign(ctx, "right"); + var numText = "x" + num; + core.fillText( + ctx, + numText, + right - marginLeft, + top + height / 2, + style, + core.ui._buildFont(fontSize) + ); + + const hideInfo = core.getFlag("hideInfo", {}); + if ( + item && + (hideInfo.hasOwnProperty(id) ? hideInfo[id] : item.hideInToolbox) + ) + core.setAlpha(ctx, 0.5); + + if (name != "???") + core.drawIcon( + ctx, + id, + left + marginLeft, + top + marginHeight, + fontSize, + fontSize + ); + var text_x = left + marginLeft + fontSize + 2; + var maxWidth = right - core.calWidth(ctx, numText) - text_x; + core.setTextAlign(ctx, "left"); + core.fillText( + ctx, + name, + text_x, + top + height / 2, + style, + core.ui._buildFont(fontSize), + maxWidth + ); + core.setAlpha(ctx, 1); + + var todo = new Function("core.clickItemFunc('" + id + "');"); + addUIEventListener(left, top, right - left, height, todo); + } + + function setPageItems(page) { + var num = itemNum; + if (core.status.event.id == "equipbox") num -= reduceItem; + var info = core.status.thisUIEventInfo; + if (!info) return; + page = page || info.page; + var items = core.getToolboxItems( + core.status.event.id == "toolbox" ? "all" : "equips", + core.getFlag("showHideItem", false) + ); + info.allItems = items; + var maxPage = Math.ceil(items.length / num); + info.maxPage = maxPage; + var pageItems = items.slice((page - 1) * num, page * num); + info.pageItems = pageItems; + info.maxItem = pageItems.length; + if (items.length == 0 && pageItems.length == 0) info.index = null; + if (pageItems.length == 0 && info.page > 1) { + info.page = Math.max(1, info.page - 1); + return setPageItems(info.page); + } + return pageItems; + } + + function drawToolbox_setExitBtn(ctx, x, y, r, style, lineWidth) { + core.strokeCircle(ctx, x, y, r, style, lineWidth); + ctx.textAlign = "center"; + ctx.textBaseline = "middle"; + var textSize = Math.sqrt(2) * r; + core.fillText( + ctx, + "x", + x, + y, + style, + core.ui._buildFont(textSize), + textSize + ); + core.setTextAlign(ctx, "start"); + core.setTextBaseline(ctx, "top"); + + var todo = function () { + core.closePanel(); + }; + addUIEventListener(x - r, y - r, r * 2, r * 2, todo); + } + + function drawToolbox_setUseBtn(ctx, x, y, r, h, style, lineWidth) { + core.setTextAlign(ctx, "left"); + core.setTextBaseline(ctx, "top"); + var fontSize = h - 4; + var font = core.ui._buildFont(fontSize); + var text = core.status.event.id == "toolbox" ? "使用" : "装备"; + if (core.status.thisUIEventInfo.select.action == "unload") text = "卸下"; + var w = core.calWidth(ctx, text, font) + 2 * r + lineWidth / 2; + + core.strokeRoundRect(ctx, x, y, w, h, r, style, lineWidth); + core.fillText(ctx, text, x + r, y + lineWidth / 2 + 2, style, font); + + var todo = function () { + core.useSelectItemInBox(); + }; + addUIEventListener(x, y, w, h, todo); + } + + function getSelectedItem() { + var info = core.status.thisUIEventInfo; + if ( + !( + info && + info.select.id && ["toolbox", "equipbox"].includes(core.status.event.id) + ) + ) { + core.drawFailTip("发生了未知错误!"); + return; + } + return info.select.id; + } + + function batchUse(item, count) { + try { + const itemCount = core.itemCount(item); + if (count > itemCount) count = itemCount; + core.closePanel(); + for (let i = 0; i < count; i++) { + if (core.canUseItem(item)) core.useItem(item); + else return; + } + } catch (e) { + console.error(e); + core.drawFailTip("批量使用时出现未知错误!"); + } + } + + function drawToolbox_setBatchUseBtn(ctx, x, y, r, h, style, lineWidth) { + try { + const selectedItem = getSelectedItem(); + let canBatchUse = eval(core.material.items[selectedItem]?.canBatchUse); + if (!canBatchUse) return; + } catch (error) { + console.error(error); + return; + } + core.setTextAlign(ctx, "left"); + core.setTextBaseline(ctx, "top"); + var fontSize = h - 4; + var font = core.ui._buildFont(fontSize); + var text = "批量使用"; + var w = core.calWidth(ctx, text, font) + 2 * r + lineWidth / 2; + + core.strokeRoundRect(ctx, x, y, w, h, r, style, lineWidth); + core.fillText(ctx, text, x + r, y + lineWidth / 2 + 2, style, font); + + var todo = function () { + core.utils.myprompt("输入要使用该物品的次数(0~99)。", null, (value) => { + value = parseInt(value); + const id = getSelectedItem(); + + if (Number.isNaN(value) || value < 0 || value > 99) { + core.drawFailTip("输入不合法!"); + return; + } + if (!core.canUseItem(id)) { + core.drawFailTip("当前无法使用该道具!"); + return; + } + core.closePanel(); + batchUse(id, value); + }); + }; + addUIEventListener(x, y, w, h, todo); + } + + function drawToolbox_setHideBtn(ctx, x, y, r, h, style, lineWidth) { + core.setTextAlign(ctx, "left"); + core.setTextBaseline(ctx, "top"); + var fontSize = h - 4; + var font = core.ui._buildFont(fontSize); + var text = "显示/隐藏"; + var w = core.calWidth(ctx, text, font) + 2 * r + lineWidth / 2; + + core.strokeRoundRect(ctx, x, y, w, h, r, style, lineWidth); + core.fillText(ctx, text, x + r, y + lineWidth / 2 + 2, style, font); + + var todo = function () { + //debugger; + var id = getSelectedItem(); + let hideInfo = core.getFlag("hideInfo", {}); + console.log(id); + if (hideInfo.hasOwnProperty(id)) { + hideInfo[id] = !hideInfo[id]; + core.setFlag("hideInfo", hideInfo); + } else { + hideInfo[id] = !core.material.items[id].hideInToolbox; + core.setFlag("hideInfo", hideInfo); + } + if (core.status.event.id === "toolbox") core.plugin.drawToolbox(); + else if (core.status.event.id === "equipbox") + core.plugin.drawEquipbox(); + }; + addUIEventListener(x, y, w, h, todo); + } + + ui.prototype.getToolboxItems = function (cls, showHide) { + let list = Object.keys(core.status.hero.items[cls] || {}); + if (cls === "all") { + for (let name in core.status.hero.items) { + if (name == "equips") continue; + list = list.concat(Object.keys(core.status.hero.items[name])); + } + if (!showHide) + list = list.filter(function (id2) { + const hideInfo = core.getFlag("hideInfo", {}); + if (hideInfo.hasOwnProperty(id2)) return !hideInfo[id2]; + else return !core.material.items[id2].hideInToolbox; + }); + list = list.sort(); + return list; + } + if (cls === "equips") { + if (!showHide) + list = list.filter(function (id2) { + const hideInfo = core.getFlag("hideInfo", {}); + if (hideInfo.hasOwnProperty(id2)) return !hideInfo[id2]; + else return !core.material.items[id2].hideInToolbox; + }); + + list = list.sort(); + return list; + } + if (this.uidata.getToolboxItems) { + return this.uidata.getToolboxItems(cls, showHide); + } + if (!showHide) + list = list.filter(function (id2) { + return !core.material.items[id2].hideInToolbox; + }); + list = list.sort(); + return list; + }; + + function drawToolbox_setShowHideBtn(ctx, x, y, h, style) { + core.setTextAlign(ctx, "left"); + core.setTextBaseline(ctx, "top"); + var fontSize = h - 6; + var font = core.ui._buildFont(fontSize); + var text = "显示隐藏"; + var w = core.calWidth(ctx, text, font); + h += 4; + const squareSize = h - 6; + + x -= w + squareSize + 26; + + const border = 2; + core.fillRect(ctx, x, y, squareSize, squareSize, " #F5F5F5"); + if (core.hasFlag("showHideItem")) { + core.fillRect( + ctx, + x + border, + y + border, + squareSize - 2 * border, + squareSize - 2 * border, + "lime" + ); + } + core.fillText(ctx, text, x + squareSize + 2, y + 4, style, font); + + var todo = function () { + core.setFlag("showHideItem", !core.getFlag("showHideItem", false)); + if (core.status.event.id === "toolbox") core.plugin.drawToolbox(); + else if (core.status.event.id === "equipbox") + core.plugin.drawEquipbox(); + }; + addUIEventListener(x, y, w, h, todo); + } + + function drawItemListbox_setPageBtn( + ctx, + left, + right, + bottom, + r, + style, + lineWidth + ) { + var offset = lineWidth / 2 + r; + + var x = left + offset; + var y = bottom - offset; + var pos = (Math.sqrt(2) / 2) * (r - lineWidth / 2); + core.fillPolygon( + ctx, + [ + [x - pos, y], + [x + pos - 2, y - pos], + [x + pos - 2, y + pos], + ], + style + ); + core.strokeCircle(ctx, x, y, r, style, lineWidth); + var todo = function () { + core.addItemListboxPage(-1); + }; + addUIEventListener(x - r - 2, y - r - 2, r * 2 + 4, r * 2 + 4, todo); + + x = right - offset; + core.fillPolygon( + ctx, + [ + [x + pos, y], + [x - pos + 2, y - pos], + [x - pos + 2, y + pos], + ], + style + ); + core.strokeCircle(ctx, x, y, r, style, lineWidth); + var todo = function () { + core.addItemListboxPage(1); + }; + addUIEventListener(x - r - 2, y - r - 2, r * 2 + 4, r * 2 + 4, todo); + } + + this.clickItemFunc = function (id) { + var info = core.status.thisUIEventInfo; + if (!info) return; + if (info.select.id == id) return core.useSelectItemInBox(); + info.select = {}; + info.select.id = id; + core.setIndexAndSelect("index"); + refreshBox(); + }; + + this.clickOneEquipbox = function (id, type) { + var info = core.status.thisUIEventInfo; + if (!info) return; + if (info.select.id == id && info.select.type == type) + core.useSelectItemInBox(); + else + core.status.thisUIEventInfo.select = { + id: id, + type: type, + action: "unload", + }; + return refreshBox(); + }; + + this.useSelectItemInBox = function () { + var info = core.status.thisUIEventInfo; + if (!info) return; + if (!info.select.id) return; + var id = info.select.id; + if (core.status.event.id == "toolbox") { + core.events.tryUseItem(id); + // core.closePanel(); + } else if (core.status.event.id == "equipbox") { + var action = info.select.action || "load"; + info.index = 1; + if (action == "load") { + var type = core.getEquipTypeById(id); + let equipClsid = core.material.items[id]?.equipCls; + let equipCls0 = core.material.items[core.getEquip(0)]?.equipCls; + let equipCls1 = core.material.items[core.getEquip(1)]?.equipCls; + if (equipClsid === "双手剑") { + core.unloadEquip(0, function () { + core.status.route.push("unEquip:" + 0); + }); + core.unloadEquip(1, function () { + core.status.route.push("unEquip:" + 1); + }); + } + if ( + equipCls0 === "双手剑" && + !(equipClsid === "饰品" || equipClsid === "护具") + ) { + core.unloadEquip(0, function () { + core.status.route.push("unEquip:" + 0); + }); + } + core.loadEquip(id, function () { + core.status.route.push("equip:" + id); + info.select.type = type; + core.setIndexAndSelect("select"); + core.drawEquipbox(); + }); + } else { + var type = info.select.type; + core.unloadEquip(type, function () { + core.status.route.push("unEquip:" + type); + info.select.type = type; + info.select.action = "load"; + core.setIndexAndSelect("select"); + core.drawEquipbox(); + }); + } + } + core.updateStatusBar(); + }; + + this.setIndexAndSelect = function (toChange) { + var info = core.status.thisUIEventInfo; + if (!info) return; + setPageItems(info.page); + var index = info.index || 1; + var items = info.pageItems; + + info.select.action = null; + info.select.type = null; + if (toChange == "index") info.index = items.indexOf(info.select.id) + 1; + info.select.id = items[info.index - 1]; + }; + + this.addItemListboxPage = function (num) { + var info = core.status.thisUIEventInfo; + if (!info) return; + var maxPage = info.maxPage || 1; + info.page = info.page || 1; + info.page += num; + if (info.page <= 0) info.page = maxPage; + if (info.page > maxPage) info.page = 1; + info.index = 1; + setPageItems(info.page); + core.setIndexAndSelect("select"); + refreshBox(); + }; + + this.addItemListboxIndex = function (num) { + var info = core.status.thisUIEventInfo; + if (!info) return; + var maxItem = info.maxItem || 0; + info.index = info.index || 0; + info.index += num; + if (info.index <= 0) info.index = 1; + if (info.index > maxItem) info.index = maxItem; + core.setIndexAndSelect("select"); + refreshBox(); + }; + + this.addEquipboxType = function (num) { + var info = core.status.thisUIEventInfo; + var type = info.select.type; + if (type == null && num > 0) info.select.type = 0; + else info.select.type = type + num; + var max = core.status.globalAttribute.equipName.length; + if (info.select.type >= max) { + info.select = {}; + core.setIndexAndSelect("select"); + return core.addItemListboxPage(0); + } else { + var m = Math.abs(info.select.type); + if (info.select.type < 0) info.select.type = max - m; + core.setIndexAndSelect("select"); + refreshBox(); + return; + } + }; + + core.actions._keyDownToolbox = function (keycode) { + if (!core.status.thisEventClickArea) return; + if (keycode == 37) { + // left + core.addItemListboxPage(-1); + return; + } + if (keycode == 38) { + // up + core.addItemListboxIndex(-1); + return; + } + if (keycode == 39) { + // right + core.addItemListboxPage(1); + return; + } + if (keycode == 40) { + // down + core.addItemListboxIndex(1); + return; + } + }; + + ////// 工具栏界面时,放开某个键的操作 ////// + core.actions._keyUpToolbox = function (keycode) { + if (keycode == 81) { + core.ui.closePanel(); + if (core.isReplaying()) core.control._replay_equipbox(); + else core.openEquipbox(); + return; + } + if (keycode == 84 || keycode == 27 || keycode == 88) { + core.closePanel(); + return; + } + if (keycode == 13 || keycode == 32 || keycode == 67) { + var info = core.status.thisUIEventInfo; + if (info.select) { + core.useSelectItemInBox(); + } + return; + } + }; + + core.actions._keyDownEquipbox = function (keycode) { + if (!core.status.thisEventClickArea) return; + if (keycode == 37) { + // left + var info = core.status.thisUIEventInfo; + if (info.index != null) return core.addItemListboxPage(-1); + return core.addEquipboxType(-1); + } + if (keycode == 38) { + // up + var info = core.status.thisUIEventInfo; + if (info.index == 1) { + info.select.type = core.status.globalAttribute.equipName.length - 1; + core.setIndexAndSelect(); + return refreshBox(); + } + if (info.index) return core.addItemListboxIndex(-1); + return core.addEquipboxType(-1 * info.equips); + } + if (keycode == 39) { + // right + var info = core.status.thisUIEventInfo; + if (info.index != null) return core.addItemListboxPage(1); + return core.addEquipboxType(1); + } + if (keycode == 40) { + // down + var info = core.status.thisUIEventInfo; + if (info.index) return core.addItemListboxIndex(1); + return core.addEquipboxType(info.equips); + } + }; + + core.actions._keyUpEquipbox = function (keycode, altKey) { + if (altKey && keycode >= 48 && keycode <= 57) { + core.items.quickSaveEquip(keycode - 48); + return; + } + if (keycode == 84) { + core.ui.closePanel(); + if (core.isReplaying()) core.control._replay_toolbox(); + else core.openToolbox(); + return; + } + if (keycode == 81 || keycode == 27 || keycode == 88) { + core.closePanel(); + return; + } + if (keycode == 13 || keycode == 32 || keycode == 67) { + var info = core.status.thisUIEventInfo; + if (info.select) core.useSelectItemInBox(); + return; + } + }; + + core.registerAction( + "ondown", + "inEventClickAction", + function (x, y, px, py) { + if (!core.status.thisEventClickArea) return false; + var info = core.status.thisEventClickArea; + for (var i = 0; i < info.length; i++) { + var obj = info[i]; + if ( + px >= obj.x && + px <= obj.x + obj.width && + py > obj.y && + py < obj.y + obj.height + ) { + if (obj.todo) obj.todo(); + break; + } + } + return true; + }, + 51 + ); + core.registerAction( + "onclick", + "stopClick", + function () { + if (core.status.thisEventClickArea) return true; + }, + 51 + ); + + function addUIEventListener(x, y, width, height, todo) { + if (!core.status.thisEventClickArea) return; + var obj = { + x: x, + y: y, + width: width, + height: height, + todo: todo, + }; + core.status.thisEventClickArea.push(obj); + } + + this.initThisEventInfo = function () { + core.status.thisUIEventInfo = { + page: 1, + select: {}, + }; + core.status.thisEventClickArea = []; + }; + + function refreshBox() { + if (!core.status.event.id) return; + if (core.status.event.id == "toolbox") core.drawToolbox(); + else core.drawEquipbox(); + } + + core.ui.closePanel = function () { + if (core.status.hero && core.status.hero.flags) { + // 清除全部临时变量 + Object.keys(core.status.hero.flags).forEach(function (name) { + if (name.startsWith("@temp@") || /^arg\d+$/.test(name)) { + delete core.status.hero.flags[name]; + } + }); + } + this.clearUI(); + core.maps.generateGroundPattern(); + core.updateStatusBar(true); + core.unlockControl(); + core.status.event.data = null; + core.status.event.id = null; + core.status.event.selection = null; + core.status.event.ui = null; + core.status.event.interval = null; + core.status.thisUIEventInfo = null; + core.status.thisEventClickArea = null; + }; + + this.getItemClsName = function (item) { + if (item == null) return itemClsName; + if (item.cls == "equips") { + if (typeof item.equip.type == "string") return item.equip.type; + var type = core.getEquipTypeById(item.id); + return core.status.globalAttribute.equipName[type]; + } else return itemClsName[item.cls] || item.cls; + }; + + core.events.openToolbox = function (fromUserAction) { + if (core.isReplaying()) return; + if (!this._checkStatus("toolbox", fromUserAction)) return; + core.initThisEventInfo(); + let info = core.status.thisUIEventInfo; + info.index = 1; + core.setIndexAndSelect("select"); + core.drawToolbox(); + }; + + core.events.openEquipbox = function (fromUserAction) { + if (core.isReplaying()) return; + if (!this._checkStatus("equipbox", fromUserAction)) return; + core.initThisEventInfo(); + let info = core.status.thisUIEventInfo; + info.select.type = 0; + core.setIndexAndSelect("select"); + core.drawEquipbox(); + }; + + core.control._replay_toolbox = function () { + if (!core.isPlaying() || !core.isReplaying()) return; + if (!core.status.replay.pausing) return core.drawTip("请先暂停录像"); + if (core.isMoving() || core.status.replay.animate || core.status.event.id) + return core.drawTip("请等待当前事件的处理结束"); + + core.lockControl(); + core.status.event.id = "toolbox"; + core.drawToolbox(); + }; + + core.control._replay_equipbox = function () { + if (!core.isPlaying() || !core.isReplaying()) return; + if (!core.status.replay.pausing) return core.drawTip("请先暂停录像"); + if (core.isMoving() || core.status.replay.animate || core.status.event.id) + return core.drawTip("请等待当前事件的处理结束"); + + core.lockControl(); + core.status.event.id = "equipbox"; + core.drawEquipbox(); + }; + + core.control._replayAction_item = function (action) { + if (action.indexOf("item:") != 0) return false; + var itemId = action.substring(5); + if (!core.canUseItem(itemId)) return false; + if ( + core.material.items[itemId].hideInReplay || + core.status.replay.speed == 24 + ) { + core.useItem(itemId, false, core.replay); + return true; + } + core.status.event.id = "toolbox"; + core.initThisEventInfo(); + var info = core.status.thisUIEventInfo; + var items = core.getToolboxItems( + "all", + core.getFlag("showHideItem", false) + ); + setPageItems(1); + var index = items.indexOf(itemId) + 1; + info.page = Math.ceil(index / info.maxItem); + info.index = index % info.maxItem || info.maxItem; + core.setIndexAndSelect("select"); + setPageItems(info.page); + core.drawToolbox(); + setTimeout(function () { + core.ui.closePanel(); + core.useItem(itemId, false, core.replay); + }, core.control.__replay_getTimeout()); + return true; + }; + + core.control._replayAction_equip = function (action) { + if (action.indexOf("equip:") != 0) return false; + var itemId = action.substring(6); + var items = core.getToolboxItems( + "equips", + core.getFlag("showHideItem", false) + ); + var index = items.indexOf(itemId) + 1; + if (index < 1) { + core.removeFlag("__doNotCheckAutoEvents__"); + return false; + } + + var cb = function () { + var next = core.status.replay.toReplay[0] || ""; + if (!next.startsWith("equip:") && !next.startsWith("unEquip:")) { + core.removeFlag("__doNotCheckAutoEvents__"); + core.checkAutoEvents(); + } + core.replay(); + }; + core.setFlag("__doNotCheckAutoEvents__", true); + + core.status.route.push(action); + if ( + core.material.items[itemId].hideInReplay || + core.status.replay.speed == 24 + ) { + core.loadEquip(itemId, cb); + return true; + } + core.status.event.id = "equipbox"; + core.initThisEventInfo(); + var info = core.status.thisUIEventInfo; + setPageItems(1); + info.page = Math.ceil(index / info.maxItem); + info.index = index % info.maxItem || info.maxItem; + core.setIndexAndSelect("select"); + setPageItems(info.page); + core.drawEquipbox(); + setTimeout(function () { + core.ui.closePanel(); + core.loadEquip(itemId, cb); + }, core.control.__replay_getTimeout()); + return true; + }; + + core.control._replayAction_unEquip = function (action) { + if (action.indexOf("unEquip:") != 0) return false; + var equipType = parseInt(action.substring(8)); + if (!core.isset(equipType)) { + core.removeFlag("__doNotCheckAutoEvents__"); + return false; + } + + var cb = function () { + var next = core.status.replay.toReplay[0] || ""; + if (!next.startsWith("equip:") && !next.startsWith("unEquip:")) { + core.removeFlag("__doNotCheckAutoEvents__"); + core.checkAutoEvents(); + } + core.replay(); + }; + core.setFlag("__doNotCheckAutoEvents__", true); + + core.status.route.push(action); + if (core.status.replay.speed == 24) { + core.unloadEquip(equipType, cb); + return true; + } + core.status.event.id = "equipbox"; + core.initThisEventInfo(); + var info = core.status.thisUIEventInfo; + setPageItems(1); + info.select.type = equipType; + core.setIndexAndSelect(); + core.drawEquipbox(); + setTimeout(function () { + core.ui.closePanel(); + core.unloadEquip(equipType, cb); + }, core.control.__replay_getTimeout()); + return true; + }; + core.registerReplayAction("item", core.control._replayAction_item); + core.registerReplayAction("equip", core.control._replayAction_equip); + core.registerReplayAction("unEquip", core.control._replayAction_unEquip); +}, "技能树": function () { // 在此增加新插件 // @@ -13665,1130 +13658,1130 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = }; }, "楼传": function () { - // 在此增加新插件 + // 在此增加新插件 - core.canMoveFloor = function () { - let canmove = false; - core.status.thisMap.blocks.forEach((block) => { - if ( - !block.disable && - (block.event.id == "upFloor" || block.event.id == "downFloor") - ) { - let automaticRoute = core.automaticRoute(block.x, block.y); - if (!core.flags.flyNearStair || automaticRoute.length > 0) { - let loc = automaticRoute.pop(); - loc = automaticRoute.pop(); - if (core.canMoveDirectly(loc?.x, loc?.y) >= 0 || !loc) { - canmove = true; - } - } - } - }); - return canmove; - }; - ui.prototype._drawViewMaps_drawHint = function () { - core.playSound("打开界面"); - }; + core.canMoveFloor = function () { + let canmove = false; + core.status.thisMap.blocks.forEach((block) => { + if ( + !block.disable && + (block.event.id == "upFloor" || block.event.id == "downFloor") + ) { + let automaticRoute = core.automaticRoute(block.x, block.y); + if (!core.flags.flyNearStair || automaticRoute.length > 0) { + let loc = automaticRoute.pop(); + loc = automaticRoute.pop(); + if (core.canMoveDirectly(loc?.x, loc?.y) >= 0 || !loc) { + canmove = true; + } + } + } + }); + return canmove; + }; + ui.prototype._drawViewMaps_drawHint = function () { + core.playSound("打开界面"); + }; - ////// 绘制浏览地图界面 ////// - ui.prototype._drawViewMaps = function (index, x, y) { - core.lockControl(); + ////// 绘制浏览地图界面 ////// + ui.prototype._drawViewMaps = function (index, x, y) { + core.lockControl(); - core.clearMap("data"); - core.status.event.id = "viewMaps"; - this.clearUI(); - //console.log(index) - if (index == null) index = core.floorIds.indexOf(core.status.floorId); - core.animateFrame.tip = null; - core.status.checkBlock.cache = {}; - let data = this._drawViewMaps_buildData(index, x, y); - core.drawWindowSkin("winskin1.webp", "ui", 0, 0, 416, 416); - let page = core.status.event.data.index; - let floorId = core.status.event.data.floorId; - core.ui.statusBar._update_map(floorId); - const bfs = core.plugin.bfsSearch(floorId, 1, true); - const mapdir = bfs.mapdir[floorId]; - core.setTextAlign("ui", "center"); - let size = (core.__PIXELS__ * 3) / 4; //312 - const areas = core.getFlag("areas"); + core.clearMap("data"); + core.status.event.id = "viewMaps"; + this.clearUI(); + //console.log(index) + if (index == null) index = core.floorIds.indexOf(core.status.floorId); + core.animateFrame.tip = null; + core.status.checkBlock.cache = {}; + let data = this._drawViewMaps_buildData(index, x, y); + core.drawWindowSkin("winskin1.webp", "ui", 0, 0, 416, 416); + let page = core.status.event.data.index; + let floorId = core.status.event.data.floorId; + core.ui.statusBar._update_map(floorId); + const bfs = core.plugin.bfsSearch(floorId, 1, true); + const mapdir = bfs.mapdir[floorId]; + core.setTextAlign("ui", "center"); + let size = (core.__PIXELS__ * 3) / 4; //312 + const areas = core.getFlag("areas"); - let i = areas.findIndex((v) => v.maps.includes(floorId)); - core.fillRoundRect("ui", 15 - 2, 15 - 2, 35 + 4, 35 + 4, 4, "#444444"); - core.strokeRoundRect( - "ui", - 15 - 4, - 15 - 4, - 35 + 8, - 35 + 8, - 4, - "#444444", - 1 - ); - core.fillBoldText1( - "ui", - "当前", - 13 + 20, - 17 + 20, - "#FFFFFF", - "#000000", - 2, - this._buildFont(18, true) - ); + let i = areas.findIndex((v) => v.maps.includes(floorId)); + core.fillRoundRect("ui", 15 - 2, 15 - 2, 35 + 4, 35 + 4, 4, "#444444"); + core.strokeRoundRect( + "ui", + 15 - 4, + 15 - 4, + 35 + 8, + 35 + 8, + 4, + "#444444", + 1 + ); + core.fillBoldText1( + "ui", + "当前", + 13 + 20, + 17 + 20, + "#FFFFFF", + "#000000", + 2, + this._buildFont(18, true) + ); - core.fillRoundRect( - "ui", - 15 - 2, - 15 - 2 + 35 + 8 + size + 8 - 54, - 35 + 4, - 35 + 4, - 4, - "#444444" - ); - core.strokeRoundRect( - "ui", - 15 - 4, - 15 - 4 + 35 + 8 + size + 8 - 54, - 35 + 8, - 35 + 8, - 4, - "#444444", - 1 - ); - if ( - !core.status.maps[core.floorIds[page]].canFlyTo || - !core.hasVisitedFloor(core.floorIds[page]) - ) { - core.fillBoldText1( - "ui", - "预览", - 13 + 20, - 17 + 20 + 35 + 8 + size + 8 - 54, - "#909090", - "#000000", - 2, - this._buildFont(18, true) - ); - } else { - core.fillBoldText1( - "ui", - "传送", - 13 + 20, - 17 + 20 + 35 + 8 + size + 8 - 54, - "#909090", - "#000000", - 2, - this._buildFont(18, true) - ); - } - core.fillRoundRect( - "ui", - 15 - 4 + size - 2 + 45, - 15 - 2 + size - 4 + 45, - 35 + 4, - 35 + 4, - 4, - "#444444" - ); - core.strokeRoundRect( - "ui", - 15 - 4 + size - 4 + 45, - 15 - 4 + size - 4 + 45, - 35 + 8, - 35 + 8, - 4, - "#444444", - 1 - ); - core.fillBoldText1( - "ui", - "离开", - 15 - 4 + size - 4 + 45 + 22, - 15 - 4 + size - 4 + 45 + 26, - "#FFFFFF", - "#000000", - 2, - this._buildFont(18, true) - ); + core.fillRoundRect( + "ui", + 15 - 2, + 15 - 2 + 35 + 8 + size + 8 - 54, + 35 + 4, + 35 + 4, + 4, + "#444444" + ); + core.strokeRoundRect( + "ui", + 15 - 4, + 15 - 4 + 35 + 8 + size + 8 - 54, + 35 + 8, + 35 + 8, + 4, + "#444444", + 1 + ); + if ( + !core.status.maps[core.floorIds[page]].canFlyTo || + !core.hasVisitedFloor(core.floorIds[page]) + ) { + core.fillBoldText1( + "ui", + "预览", + 13 + 20, + 17 + 20 + 35 + 8 + size + 8 - 54, + "#909090", + "#000000", + 2, + this._buildFont(18, true) + ); + } else { + core.fillBoldText1( + "ui", + "传送", + 13 + 20, + 17 + 20 + 35 + 8 + size + 8 - 54, + "#909090", + "#000000", + 2, + this._buildFont(18, true) + ); + } + core.fillRoundRect( + "ui", + 15 - 4 + size - 2 + 45, + 15 - 2 + size - 4 + 45, + 35 + 4, + 35 + 4, + 4, + "#444444" + ); + core.strokeRoundRect( + "ui", + 15 - 4 + size - 4 + 45, + 15 - 4 + size - 4 + 45, + 35 + 8, + 35 + 8, + 4, + "#444444", + 1 + ); + core.fillBoldText1( + "ui", + "离开", + 15 - 4 + size - 4 + 45 + 22, + 15 - 4 + size - 4 + 45 + 26, + "#FFFFFF", + "#000000", + 2, + this._buildFont(18, true) + ); - core.fillRoundRect( - "ui", - 15 + 44 - 2, - 15 - 2, - size + 4 - 58, - 35 + 4, - 4, - "#444444" - ); - core.strokeRoundRect( - "ui", - 15 + 44 - 4, - 15 - 4, - size + 8 - 58, - 35 + 8, - 4, - "#444444", - 1 - ); - if (mapdir.includes("up")) { - core.fillBoldText1( - "ui", - "北▲", - 30 + 145 + 10, - 17 + 20, - "#FFFFFF", - "#000000", - 2, - this._buildFont(18, true) - ); - } else { - core.fillBoldText1( - "ui", - "北▲", - 30 + 145 + 10, - 17 + 20, - "#909090", - "#000000", - 2, - this._buildFont(18, true) - ); - } + core.fillRoundRect( + "ui", + 15 + 44 - 2, + 15 - 2, + size + 4 - 58, + 35 + 4, + 4, + "#444444" + ); + core.strokeRoundRect( + "ui", + 15 + 44 - 4, + 15 - 4, + size + 8 - 58, + 35 + 8, + 4, + "#444444", + 1 + ); + if (mapdir.includes("up")) { + core.fillBoldText1( + "ui", + "北▲", + 30 + 145 + 10, + 17 + 20, + "#FFFFFF", + "#000000", + 2, + this._buildFont(18, true) + ); + } else { + core.fillBoldText1( + "ui", + "北▲", + 30 + 145 + 10, + 17 + 20, + "#909090", + "#000000", + 2, + this._buildFont(18, true) + ); + } - core.fillRoundRect( - "ui", - 15 - 2, - 59 - 2, - 35 + 4, - size + 4 - 58, - 4, - "#444444" - ); - core.strokeRoundRect( - "ui", - 15 - 4, - 59 - 4, - 35 + 8, - size + 8 - 58, - 4, - "#444444", - 1 - ); - if (mapdir.includes("left")) { - core.fillBoldText1( - "ui", - "西", - 15 + 17, - 25 + 150, - "#FFFFFF", - "#000000", - 2, - this._buildFont(18, true) - ); - core.fillBoldText1( - "ui", - "◀", - 15 + 17, - 45 + 150, - "#FFFFFF", - "#000000", - 2, - this._buildFont(18, true) - ); - } else { - core.fillBoldText1( - "ui", - "西", - 15 + 17, - 25 + 150, - "#909090", - "#000000", - 2, - this._buildFont(18, true) - ); - core.fillBoldText1( - "ui", - "◀", - 15 + 17, - 45 + 150, - "#909090", - "#000000", - 2, - this._buildFont(18, true) - ); - } - core.fillRoundRect( - "ui", - 15 + 44 - 2, - 15 - 2 + size - 4, - size + 4 - 58, - 35 + 4, - 4, - "#444444" - ); - core.strokeRoundRect( - "ui", - 15 + 44 - 4, - 15 - 4 + size - 4, - size + 8 - 58, - 35 + 8, - 4, - "#444444", - 1 - ); - if (mapdir.includes("down")) { - core.fillBoldText1( - "ui", - "南▼", - 30 + 145 + 10, - 17 + 20 + size - 4, - "#FFFFFF", - "#000000", - 2, - this._buildFont(18, true) - ); - } else { - core.fillBoldText1( - "ui", - "南▼", - 30 + 145 + 10, - 17 + 20 + size - 4, - "#909090", - "#000000", - 2, - this._buildFont(18, true) - ); - } + core.fillRoundRect( + "ui", + 15 - 2, + 59 - 2, + 35 + 4, + size + 4 - 58, + 4, + "#444444" + ); + core.strokeRoundRect( + "ui", + 15 - 4, + 59 - 4, + 35 + 8, + size + 8 - 58, + 4, + "#444444", + 1 + ); + if (mapdir.includes("left")) { + core.fillBoldText1( + "ui", + "西", + 15 + 17, + 25 + 150, + "#FFFFFF", + "#000000", + 2, + this._buildFont(18, true) + ); + core.fillBoldText1( + "ui", + "◀", + 15 + 17, + 45 + 150, + "#FFFFFF", + "#000000", + 2, + this._buildFont(18, true) + ); + } else { + core.fillBoldText1( + "ui", + "西", + 15 + 17, + 25 + 150, + "#909090", + "#000000", + 2, + this._buildFont(18, true) + ); + core.fillBoldText1( + "ui", + "◀", + 15 + 17, + 45 + 150, + "#909090", + "#000000", + 2, + this._buildFont(18, true) + ); + } + core.fillRoundRect( + "ui", + 15 + 44 - 2, + 15 - 2 + size - 4, + size + 4 - 58, + 35 + 4, + 4, + "#444444" + ); + core.strokeRoundRect( + "ui", + 15 + 44 - 4, + 15 - 4 + size - 4, + size + 8 - 58, + 35 + 8, + 4, + "#444444", + 1 + ); + if (mapdir.includes("down")) { + core.fillBoldText1( + "ui", + "南▼", + 30 + 145 + 10, + 17 + 20 + size - 4, + "#FFFFFF", + "#000000", + 2, + this._buildFont(18, true) + ); + } else { + core.fillBoldText1( + "ui", + "南▼", + 30 + 145 + 10, + 17 + 20 + size - 4, + "#909090", + "#000000", + 2, + this._buildFont(18, true) + ); + } - core.fillRoundRect( - "ui", - 15 - 2 + size - 4, - 59 - 2, - 35 + 4, - size + 4 - 58, - 4, - "#444444" - ); - core.strokeRoundRect( - "ui", - 15 - 4 + size - 4, - 59 - 4, - 35 + 8, - size + 8 - 58, - 4, - "#444444", - 1 - ); - if (mapdir.includes("right")) { - core.fillBoldText1( - "ui", - "东", - 15 + 17 + size - 4, - 25 + 150, - "#FFFFFF", - "#000000", - 2, - this._buildFont(18, true) - ); - core.fillBoldText1( - "ui", - "▶", - 15 + 17 + size - 4, - 45 + 150, - "#FFFFFF", - "#000000", - 2, - this._buildFont(18, true) - ); - } else { - core.fillBoldText1( - "ui", - "东", - 15 + 17 + size - 4, - 25 + 150, - "#909090", - "#000000", - 2, - this._buildFont(18, true) - ); - core.fillBoldText1( - "ui", - "▶", - 15 + 17 + size - 4, - 45 + 150, - "#909090", - "#000000", - 2, - this._buildFont(18, true) - ); - } - core.fillRoundRect( - "ui", - 60 - 2, - 60 - 2, - size - 58 + 4, - size - 58 + 4, - 4, - "#444444" - ); - core.strokeRoundRect( - "ui", - 60 - 4, - 60 - 4, - size - 58 + 8, - size - 58 + 8, - 4, - "#444444", - 1 - ); - core.drawThumbnail(floorId, null, { - damage: data.damage, - ctx: "ui", - x: 58, - y: 58, - size: 0.62, - all: data.all, - }); - if ( - !core.status.maps[core.floorIds[page]].canFlyTo || - !core.hasVisitedFloor(core.floorIds[page]) - ) { - /*core.fillRect("ui", 58, + core.fillRoundRect( + "ui", + 15 - 2 + size - 4, + 59 - 2, + 35 + 4, + size + 4 - 58, + 4, + "#444444" + ); + core.strokeRoundRect( + "ui", + 15 - 4 + size - 4, + 59 - 4, + 35 + 8, + size + 8 - 58, + 4, + "#444444", + 1 + ); + if (mapdir.includes("right")) { + core.fillBoldText1( + "ui", + "东", + 15 + 17 + size - 4, + 25 + 150, + "#FFFFFF", + "#000000", + 2, + this._buildFont(18, true) + ); + core.fillBoldText1( + "ui", + "▶", + 15 + 17 + size - 4, + 45 + 150, + "#FFFFFF", + "#000000", + 2, + this._buildFont(18, true) + ); + } else { + core.fillBoldText1( + "ui", + "东", + 15 + 17 + size - 4, + 25 + 150, + "#909090", + "#000000", + 2, + this._buildFont(18, true) + ); + core.fillBoldText1( + "ui", + "▶", + 15 + 17 + size - 4, + 45 + 150, + "#909090", + "#000000", + 2, + this._buildFont(18, true) + ); + } + core.fillRoundRect( + "ui", + 60 - 2, + 60 - 2, + size - 58 + 4, + size - 58 + 4, + 4, + "#444444" + ); + core.strokeRoundRect( + "ui", + 60 - 4, + 60 - 4, + size - 58 + 8, + size - 58 + 8, + 4, + "#444444", + 1 + ); + core.drawThumbnail(floorId, null, { + damage: data.damage, + ctx: "ui", + x: 58, + y: 58, + size: 0.62, + all: data.all, + }); + if ( + !core.status.maps[core.floorIds[page]].canFlyTo || + !core.hasVisitedFloor(core.floorIds[page]) + ) { + /*core.fillRect("ui", 58, 58, size - 50, size - 50, "rgba(0,0,0,0.5)")*/ - core.getContextByName("ui").globalAlpha = 0.7; + core.getContextByName("ui").globalAlpha = 0.7; - core.drawImage( - "ui", - "miwu.webp", - 0, - 0, - size, - size, - 58, - 58, - size - 50, - size - 50 - ); - core.getContextByName("ui").globalAlpha = 1; - /*core.fillText("ui", '?', 188, + core.drawImage( + "ui", + "miwu.webp", + 0, + 0, + size, + size, + 58, + 58, + size - 50, + size - 50 + ); + core.getContextByName("ui").globalAlpha = 1; + /*core.fillText("ui", '?', 188, 278, "rgba(255,255,255,0.2)", this._buildFont(250, true))*/ - } - core.fillRoundRect( - "ui", - 15 + 44 - 2, - 60 - 2 + size - 4, - size + 4 - 58, - 35 + 4, - 4, - "#444444" - ); - core.strokeRoundRect( - "ui", - 15 + 44 - 4, - 60 - 4 + size - 4, - size + 8 - 58, - 35 + 8, - 4, - "#444444", - 1 - ); - core.fillBoldText1( - "ui", - core.status.maps[floorId].areas, - 30 + 145 + 10, - 17 + 65 + size - 4, - "#FFFFFF", - "#000000", - 2, - this._buildFont(18, true) - ); - core.fillRoundRect( - "ui", - 15 - 2, - 60 - 2 + size - 4, - 35 + 4, - 35 + 4, - 4, - "#444444" - ); - core.strokeRoundRect( - "ui", - 15 - 4, - 60 - 4 + size - 4, - 35 + 8, - 35 + 8, - 4, - "#444444", - 1 - ); - if (i === 0) { - core.fillBoldText1( - "ui", - "◀", - 30, - 17 + 65 + size - 4, - "#909090", - "#000000", - 2, - this._buildFont(18, true) - ); - } else { - core.fillBoldText1( - "ui", - "◀", - 30, - 17 + 65 + size - 4, - "#FFFFFF", - "#000000", - 2, - this._buildFont(18, true) - ); - } - core.fillRoundRect( - "ui", - 15 - 2 + size - 4, - 60 - 2 + size - 4, - 35 + 4, - 35 + 4, - 4, - "#444444" - ); - core.strokeRoundRect( - "ui", - 15 - 4 + size - 4, - 60 - 4 + size - 4, - 35 + 8, - 35 + 8, - 4, - "#444444", - 1 - ); - if (i === areas.length - 1) { - core.fillBoldText1( - "ui", - "▶", - 30 + 300 + 10, - 17 + 65 + size - 4, - "#909090", - "#000000", - 2, - this._buildFont(18, true) - ); - } else { - core.fillBoldText1( - "ui", - "▶", - 30 + 300 + 10, - 17 + 65 + size - 4, - "#FFFFFF", - "#000000", - 2, - this._buildFont(18, true) - ); - } + } + core.fillRoundRect( + "ui", + 15 + 44 - 2, + 60 - 2 + size - 4, + size + 4 - 58, + 35 + 4, + 4, + "#444444" + ); + core.strokeRoundRect( + "ui", + 15 + 44 - 4, + 60 - 4 + size - 4, + size + 8 - 58, + 35 + 8, + 4, + "#444444", + 1 + ); + core.fillBoldText1( + "ui", + core.status.maps[floorId].areas, + 30 + 145 + 10, + 17 + 65 + size - 4, + "#FFFFFF", + "#000000", + 2, + this._buildFont(18, true) + ); + core.fillRoundRect( + "ui", + 15 - 2, + 60 - 2 + size - 4, + 35 + 4, + 35 + 4, + 4, + "#444444" + ); + core.strokeRoundRect( + "ui", + 15 - 4, + 60 - 4 + size - 4, + 35 + 8, + 35 + 8, + 4, + "#444444", + 1 + ); + if (i === 0) { + core.fillBoldText1( + "ui", + "◀", + 30, + 17 + 65 + size - 4, + "#909090", + "#000000", + 2, + this._buildFont(18, true) + ); + } else { + core.fillBoldText1( + "ui", + "◀", + 30, + 17 + 65 + size - 4, + "#FFFFFF", + "#000000", + 2, + this._buildFont(18, true) + ); + } + core.fillRoundRect( + "ui", + 15 - 2 + size - 4, + 60 - 2 + size - 4, + 35 + 4, + 35 + 4, + 4, + "#444444" + ); + core.strokeRoundRect( + "ui", + 15 - 4 + size - 4, + 60 - 4 + size - 4, + 35 + 8, + 35 + 8, + 4, + "#444444", + 1 + ); + if (i === areas.length - 1) { + core.fillBoldText1( + "ui", + "▶", + 30 + 300 + 10, + 17 + 65 + size - 4, + "#909090", + "#000000", + 2, + this._buildFont(18, true) + ); + } else { + core.fillBoldText1( + "ui", + "▶", + 30 + 300 + 10, + 17 + 65 + size - 4, + "#FFFFFF", + "#000000", + 2, + this._buildFont(18, true) + ); + } - core.fillRoundRect( - "ui", - 15 - 2 + size - 4, - 15 - 2, - 80 + 4, - 35 + 4, - 4, - "#444444" - ); - core.strokeRoundRect( - "ui", - 15 - 4 + size - 4, - 15 - 4, - 80 + 8, - 35 + 8, - 4, - "#444444", - 1 - ); - if (mapdir.includes("upFloor")) { - core.fillBoldText1( - "ui", - "上楼", - 30 + 320 + 10, - 17 + 20, - "#FFFFFF", - "#000000", - 2, - this._buildFont(18, true) - ); - } else { - core.fillBoldText1( - "ui", - "上楼", - 30 + 320 + 10, - 17 + 20, - "#909090", - "#000000", - 2, - this._buildFont(18, true) - ); - } - core.fillRoundRect( - "ui", - 15 - 2 + size - 4, - 15 - 2 + size - 4, - 80 + 4, - 35 + 4, - 4, - "#444444" - ); - core.strokeRoundRect( - "ui", - 15 - 4 + size - 4, - 15 - 4 + size - 4, - 80 + 8, - 35 + 8, - 4, - "#444444", - 1 - ); - if (mapdir.includes("downFloor")) { - core.fillBoldText1( - "ui", - "下楼", - 30 + 320 + 10, - 17 + 20 + size - 4, - "#FFFFFF", - "#000000", - 2, - this._buildFont(18, true) - ); - } else { - core.fillBoldText1( - "ui", - "下楼", - 30 + 320 + 10, - 17 + 20 + size - 4, - "#909090", - "#000000", - 2, - this._buildFont(18, true) - ); - } + core.fillRoundRect( + "ui", + 15 - 2 + size - 4, + 15 - 2, + 80 + 4, + 35 + 4, + 4, + "#444444" + ); + core.strokeRoundRect( + "ui", + 15 - 4 + size - 4, + 15 - 4, + 80 + 8, + 35 + 8, + 4, + "#444444", + 1 + ); + if (mapdir.includes("upFloor")) { + core.fillBoldText1( + "ui", + "上楼", + 30 + 320 + 10, + 17 + 20, + "#FFFFFF", + "#000000", + 2, + this._buildFont(18, true) + ); + } else { + core.fillBoldText1( + "ui", + "上楼", + 30 + 320 + 10, + 17 + 20, + "#909090", + "#000000", + 2, + this._buildFont(18, true) + ); + } + core.fillRoundRect( + "ui", + 15 - 2 + size - 4, + 15 - 2 + size - 4, + 80 + 4, + 35 + 4, + 4, + "#444444" + ); + core.strokeRoundRect( + "ui", + 15 - 4 + size - 4, + 15 - 4 + size - 4, + 80 + 8, + 35 + 8, + 4, + "#444444", + 1 + ); + if (mapdir.includes("downFloor")) { + core.fillBoldText1( + "ui", + "下楼", + 30 + 320 + 10, + 17 + 20 + size - 4, + "#FFFFFF", + "#000000", + 2, + this._buildFont(18, true) + ); + } else { + core.fillBoldText1( + "ui", + "下楼", + 30 + 320 + 10, + 17 + 20 + size - 4, + "#909090", + "#000000", + 2, + this._buildFont(18, true) + ); + } - core.fillRoundRect( - "ui", - 15 - 2 + size - 4 + 35 + 8, - 59 - 2, - 37 + 4, - (size - 58) / 2 + 4, - 4, - "#444444" - ); - core.strokeRoundRect( - "ui", - 15 - 4 + size - 4 + 35 + 8, - 59 - 4, - 37 + 8, - (size - 58) / 2 + 8, - 4, - "#444444", - 1 - ); - const title = core.status.maps[floorId].title; - //const length = title.length - fillTextVertical( - "ui", - title, - 15 - 4 + size - 4 + 45, - 85, - core.hasVisitedFloor(floorId) ? "#FFFFFF" : "#444444", - "#000000", - 18 - ); - //const uictx = main.dom.gameCanvas.ui.getContext('2d') - core.fillRoundRect( - "ui", - 15 - 2 + size - 4 + 35 + 8, - 59 - 2 + (size - 58) / 2 + 8, - 37 + 4, - 119 + 4, - 4, - "#444444" - ); - core.strokeRoundRect( - "ui", - 15 - 4 + size - 4 + 35 + 8, - 59 - 4 + (size - 58) / 2 + 8, - 37 + 8, - 119 + 8, - 4, - "#444444", - 1 - ); - if (core.getFlag("showEnemy")) { - fillTextVertical( - "ui", - "关闭漏怪检测", - 15 - 4 + size - 4 + 45, - 220, - "#FFFFFF", - "#000000", - 18 - ); - } else { - fillTextVertical( - "ui", - "开启漏怪检测", - 15 - 4 + size - 4 + 45, - 220, - "#FFFFFF", - "#000000", - 18 - ); - } + core.fillRoundRect( + "ui", + 15 - 2 + size - 4 + 35 + 8, + 59 - 2, + 37 + 4, + (size - 58) / 2 + 4, + 4, + "#444444" + ); + core.strokeRoundRect( + "ui", + 15 - 4 + size - 4 + 35 + 8, + 59 - 4, + 37 + 8, + (size - 58) / 2 + 8, + 4, + "#444444", + 1 + ); + const title = core.status.maps[floorId].title; + //const length = title.length + fillTextVertical( + "ui", + title, + 15 - 4 + size - 4 + 45, + 85, + core.hasVisitedFloor(floorId) ? "#FFFFFF" : "#444444", + "#000000", + 18 + ); + //const uictx = main.dom.gameCanvas.ui.getContext('2d') + core.fillRoundRect( + "ui", + 15 - 2 + size - 4 + 35 + 8, + 59 - 2 + (size - 58) / 2 + 8, + 37 + 4, + 119 + 4, + 4, + "#444444" + ); + core.strokeRoundRect( + "ui", + 15 - 4 + size - 4 + 35 + 8, + 59 - 4 + (size - 58) / 2 + 8, + 37 + 8, + 119 + 8, + 4, + "#444444", + 1 + ); + if (core.getFlag("showEnemy")) { + fillTextVertical( + "ui", + "关闭漏怪检测", + 15 - 4 + size - 4 + 45, + 220, + "#FFFFFF", + "#000000", + 18 + ); + } else { + fillTextVertical( + "ui", + "开启漏怪检测", + 15 - 4 + size - 4 + 45, + 220, + "#FFFFFF", + "#000000", + 18 + ); + } - //uictx.fillTextVertical(title, 15 - 4 + size - 4 + 35 + 29, 25 + 150) - //fillTextVertical('ui', title, 15 - 4 + size - 4 + 35 + 29, 25 + 150, '#FFFFFF', this._buildFont(18, true)) - }; + //uictx.fillTextVertical(title, 15 - 4 + size - 4 + 35 + 29, 25 + 150) + //fillTextVertical('ui', title, 15 - 4 + size - 4 + 35 + 29, 25 + 150, '#FFFFFF', this._buildFont(18, true)) + }; - function fillTextVertical(name, text, x, y, style, boldstyle, fontsize) { - //竖向文字绘制 + function fillTextVertical(name, text, x, y, style, boldstyle, fontsize) { + //竖向文字绘制 - const ctx = core.ui.getContextByName(name); - if (!ctx) return; - const canvas = document.createElement("canvas"); - const context = canvas.getContext("2d"); - fontsize *= 3; - const length = text.length; - canvas.width = fontsize * 2; - canvas.height = fontsize * length * 2; - if (style) context.fillStyle = core.arrayToRGBA(style); - if (boldstyle) context.strokeStyle = core.arrayToRGBA(boldstyle); - context.lineWidth = 2; - if (fontsize) context.font = core.ui._buildFont(fontsize, true); - let arrText = text.split(""); + const ctx = core.ui.getContextByName(name); + if (!ctx) return; + const canvas = document.createElement("canvas"); + const context = canvas.getContext("2d"); + fontsize *= 3; + const length = text.length; + canvas.width = fontsize * 2; + canvas.height = fontsize * length * 2; + if (style) context.fillStyle = core.arrayToRGBA(style); + if (boldstyle) context.strokeStyle = core.arrayToRGBA(boldstyle); + context.lineWidth = 2; + if (fontsize) context.font = core.ui._buildFont(fontsize, true); + let arrText = text.split(""); - let arrWidth = arrText.map(function (letter) { - return context.measureText(letter).width; - }); + let arrWidth = arrText.map(function (letter) { + return context.measureText(letter).width; + }); - let align = context.textAlign; + let align = context.textAlign; - let baseline = context.textBaseline; - let sx = fontsize, - sy = fontsize * length; - if (align == "left") { - sx = sx + Math.max.apply(null, arrWidth) / 2; - } else if (align == "right") { - sx = sx - Math.max.apply(null, arrWidth) / 2; - } + let baseline = context.textBaseline; + let sx = fontsize, + sy = fontsize * length; + if (align == "left") { + sx = sx + Math.max.apply(null, arrWidth) / 2; + } else if (align == "right") { + sx = sx - Math.max.apply(null, arrWidth) / 2; + } - if ( - baseline == "bottom" || - baseline == "alphabetic" || - baseline == "ideographic" - ) { - sy = sy - arrWidth[0] / 2; - } else if (baseline == "top" || baseline == "hanging") { - sy = sy + arrWidth[0] / 2; - } + if ( + baseline == "bottom" || + baseline == "alphabetic" || + baseline == "ideographic" + ) { + sy = sy - arrWidth[0] / 2; + } else if (baseline == "top" || baseline == "hanging") { + sy = sy + arrWidth[0] / 2; + } - context.textAlign = "center"; + context.textAlign = "center"; - context.textBaseline = "middle"; - context.lineWidth = 6; + context.textBaseline = "middle"; + context.lineWidth = 6; - // 开始逐字绘制 + // 开始逐字绘制 - arrText.forEach(function (letter, index) { - // 确定下一个字符的纵坐标位置 + arrText.forEach(function (letter, index) { + // 确定下一个字符的纵坐标位置 - context.strokeText(letter, sx, sy); - context.fillText(letter, sx, sy); - // 旋转坐标系还原成初始态 + context.strokeText(letter, sx, sy); + context.fillText(letter, sx, sy); + // 旋转坐标系还原成初始态 - context.setTransform(1, 0, 0, 1, 0, 0); + context.setTransform(1, 0, 0, 1, 0, 0); - // 确定下一个字符的纵坐标位置 + // 确定下一个字符的纵坐标位置 - var letterWidth = 54; + var letterWidth = 54; - sy = sy + letterWidth; - }); + sy = sy + letterWidth; + }); - // 水平垂直对齐方式还原 + // 水平垂直对齐方式还原 - context.textAlign = align; + context.textAlign = align; - context.textBaseline = baseline; + context.textBaseline = baseline; - //绘制到目标位置 - ctx.drawImage( - canvas, - x, - y - (fontsize / 3) * length, - canvas.width / 3, - canvas.height / 3 - ); - } + //绘制到目标位置 + ctx.drawImage( + canvas, + x, + y - (fontsize / 3) * length, + canvas.width / 3, + canvas.height / 3 + ); + } - ////// 点击楼层传送器时的打开操作 ////// - events.prototype.useFly = function (fromUserAction) { - if (!core.isPlaying()) return; - if (!core.status.maps[core.status.floorId].canFlyFrom) { - core.drawTip(core.material.items["fly"].name + "好像失效了", "fly"); - return; - } - // 从“浏览地图”页面:尝试直接传送到该层 - if (core.status.event.id == "viewMaps") { - if (!core.hasItem("fly")) { - core.playSound("操作失败"); - core.drawTip("你没有" + core.material.items["fly"].name, "fly"); - } else if ( - core.flags.flyNearStair && - !core.nearStair() && - !flags.canMoveFloor - ) { - core.playSound("操作失败"); - core.drawTip( - "无法到达楼梯边使用" + core.material.items["fly"].name, - "fly" - ); - } else { - core.flyTo(core.status.event.data.floorId); - core.updateStatusBar(); - } - return; - } + ////// 点击楼层传送器时的打开操作 ////// + events.prototype.useFly = function (fromUserAction) { + if (!core.isPlaying()) return; + if (!core.status.maps[core.status.floorId].canFlyFrom) { + core.drawTip(core.material.items["fly"].name + "好像失效了", "fly"); + return; + } + // 从“浏览地图”页面:尝试直接传送到该层 + if (core.status.event.id == "viewMaps") { + if (!core.hasItem("fly")) { + core.playSound("操作失败"); + core.drawTip("你没有" + core.material.items["fly"].name, "fly"); + } else if ( + core.flags.flyNearStair && + !core.nearStair() && + !flags.canMoveFloor + ) { + core.playSound("操作失败"); + core.drawTip( + "无法到达楼梯边使用" + core.material.items["fly"].name, + "fly" + ); + } else { + core.flyTo(core.status.event.data.floorId); + core.updateStatusBar(); + } + return; + } - if (!this._checkStatus("fly", fromUserAction, true)) return; - //if (core.flags.flyNearStair && !core.nearStair()) + if (!this._checkStatus("fly", fromUserAction, true)) return; + //if (core.flags.flyNearStair && !core.nearStair()) - if ( - (core.flags.flyNearStair && !core.nearStair()) || - !flags.canMoveFloor - ) { - core.playSound("操作失败"); - core.drawTip( - "无法到达楼梯边使用" + core.material.items["fly"].name, - "fly" - ); - core.unlockControl(); - core.status.event.data = null; - core.status.event.id = null; - return; - } - if (!core.canUseItem("fly")) { - core.playSound("操作失败"); - core.drawTip(core.material.items["fly"].name + "好像失效了", "fly"); - core.unlockControl(); - core.status.event.data = null; - core.status.event.id = null; - return; - } - core.playSound("打开界面"); - core.useItem("fly", true); - core.updateStatusBar(); - return; - }; - ////// 系统菜单栏界面时的点击操作 ////// - actions.prototype._clickSettings = function (x, y) { - if (this._out(x)) return; - var choices = core.status.event.ui.choices; - var topIndex = this._getChoicesTopIndex(choices.length); - if (y >= topIndex && y < topIndex + choices.length) { - var selection = y - topIndex; - core.status.event.selection = selection; - switch (selection) { - case 0: - core.status.event.selection = 0; - core.playSound("确定"); - core.ui._drawSwitchs(); - break; - case 1: - // core.playSound('确定'); - core.ui._drawKeyBoard(); - break; - case 2: - // core.playSound('确定'); - core.clearUI(); - core.useItem("fly"); - break; - case 3: - core.status.event.selection = 0; - core.playSound("确定"); - core.ui._drawNotes(); - break; - case 4: - core.status.event.selection = 0; - core.playSound("确定"); - core.ui._drawSyncSave(); - break; - case 5: - core.status.event.selection = 0; - core.playSound("确定"); - core.ui._drawGameInfo(); - break; - case 6: - return core.confirmRestart(); - case 7: - core.playSound("取消"); - core.ui.closePanel(); - break; - } - } - return; - }; - ////// 查看地图界面时的点击操作 ////// - actions.prototype._clickViewMaps = function (x, y, px, py) { - if (core.status.event.data == null) { - core.ui._drawViewMaps(core.floorIds.indexOf(core.status.floorId)); - return; - } - let now = core.floorIds.indexOf(core.status.floorId); - let index = core.status.event.data.index; - let cx = core.status.event.data.x, - cy = core.status.event.data.y; - let floorId = core.floorIds[index], - mw = core.floors[floorId].width, - mh = core.floors[floorId].height; - let perpx = core.__PIXELS__ / 5, - cornerpx = (perpx * 3) / 4; - const bfs = core.plugin.bfsSearch(floorId, 1, true); - const mapdir = bfs.mapdir[floorId]; - const res = bfs.res; - const formto = {}; - for (let from in res) { - const to = res[from]; - const [fromfloorId, fromsx, fromsy, dir] = from.split("_"); - const [tofloorId, tosx, tosy] = to.split("_"); - if (!formto[fromfloorId]) formto[fromfloorId] = {}; - if (!formto[fromfloorId][dir]) formto[fromfloorId][dir] = tofloorId; - } - const areas = core.getFlag("areas"); - let i = areas.findIndex((v) => v.maps.includes(floorId)); + if ( + (core.flags.flyNearStair && !core.nearStair()) || + !flags.canMoveFloor + ) { + core.playSound("操作失败"); + core.drawTip( + "无法到达楼梯边使用" + core.material.items["fly"].name, + "fly" + ); + core.unlockControl(); + core.status.event.data = null; + core.status.event.id = null; + return; + } + if (!core.canUseItem("fly")) { + core.playSound("操作失败"); + core.drawTip(core.material.items["fly"].name + "好像失效了", "fly"); + core.unlockControl(); + core.status.event.data = null; + core.status.event.id = null; + return; + } + core.playSound("打开界面"); + core.useItem("fly", true); + core.updateStatusBar(); + return; + }; + ////// 系统菜单栏界面时的点击操作 ////// + actions.prototype._clickSettings = function (x, y) { + if (this._out(x)) return; + var choices = core.status.event.ui.choices; + var topIndex = this._getChoicesTopIndex(choices.length); + if (y >= topIndex && y < topIndex + choices.length) { + var selection = y - topIndex; + core.status.event.selection = selection; + switch (selection) { + case 0: + core.status.event.selection = 0; + core.playSound("确定"); + core.ui._drawSwitchs(); + break; + case 1: + // core.playSound('确定'); + core.ui._drawKeyBoard(); + break; + case 2: + // core.playSound('确定'); + core.clearUI(); + core.useItem("fly"); + break; + case 3: + core.status.event.selection = 0; + core.playSound("确定"); + core.ui._drawNotes(); + break; + case 4: + core.status.event.selection = 0; + core.playSound("确定"); + core.ui._drawSyncSave(); + break; + case 5: + core.status.event.selection = 0; + core.playSound("确定"); + core.ui._drawGameInfo(); + break; + case 6: + return core.confirmRestart(); + case 7: + core.playSound("取消"); + core.ui.closePanel(); + break; + } + } + return; + }; + ////// 查看地图界面时的点击操作 ////// + actions.prototype._clickViewMaps = function (x, y, px, py) { + if (core.status.event.data == null) { + core.ui._drawViewMaps(core.floorIds.indexOf(core.status.floorId)); + return; + } + let now = core.floorIds.indexOf(core.status.floorId); + let index = core.status.event.data.index; + let cx = core.status.event.data.x, + cy = core.status.event.data.y; + let floorId = core.floorIds[index], + mw = core.floors[floorId].width, + mh = core.floors[floorId].height; + let perpx = core.__PIXELS__ / 5, + cornerpx = (perpx * 3) / 4; + const bfs = core.plugin.bfsSearch(floorId, 1, true); + const mapdir = bfs.mapdir[floorId]; + const res = bfs.res; + const formto = {}; + for (let from in res) { + const to = res[from]; + const [fromfloorId, fromsx, fromsy, dir] = from.split("_"); + const [tofloorId, tosx, tosy] = to.split("_"); + if (!formto[fromfloorId]) formto[fromfloorId] = {}; + if (!formto[fromfloorId][dir]) formto[fromfloorId][dir] = tofloorId; + } + const areas = core.getFlag("areas"); + let i = areas.findIndex((v) => v.maps.includes(floorId)); - if (px >= 11 && px <= 54 && py >= 11 && py <= 54) { - core.ui._drawViewMaps(core.floorIds.indexOf(core.status.floorId)); - } else if (px >= 362 && px <= 407 && py >= 191 && py <= 318) { - flags.showEnemy = !flags.showEnemy; - core.ui._drawViewMaps(index); - } else if (px >= 364 && px <= 407 && py >= 364 && py <= 407) { - core.clearMap("data"); - core.playSound("取消"); - core.ui.closePanel(); - core.getItemDetail(); - core.redrawMap(); - core.updateStatusBar(); - core.ui.statusBar._update_map(); - return; - } else if (px >= 55 && px <= 317 && py >= 11 && py <= 54) { - if (mapdir.includes("up")) - core.ui._drawViewMaps(core.floorIds.indexOf(formto[floorId].up)); - } else if (px >= 55 && px <= 317 && py >= 319 && py <= 362) { - if (mapdir.includes("down")) - core.ui._drawViewMaps(core.floorIds.indexOf(formto[floorId].down)); - } else if (px >= 11 && px <= 54 && py >= 55 && py <= 317) { - if (mapdir.includes("left")) - core.ui._drawViewMaps(core.floorIds.indexOf(formto[floorId].left)); - } else if (px >= 319 && px <= 362 && py >= 55 && py <= 317) { - if (mapdir.includes("right")) - core.ui._drawViewMaps(core.floorIds.indexOf(formto[floorId].right)); - } else if (px >= 319 && px <= 407 && py >= 11 && py <= 54) { - if (mapdir.includes("upFloor")) - core.ui._drawViewMaps(core.floorIds.indexOf(formto[floorId].upFloor)); - } else if (px >= 319 && px <= 407 && py >= 319 && py <= 362) { - if (mapdir.includes("downFloor")) - core.ui._drawViewMaps( - core.floorIds.indexOf(formto[floorId].downFloor) - ); - } else if ( - px >= 55 && - px <= 317 && - py >= 55 && - py <= 317 && - core.isPlaying() - ) { - core.useFly(false); - return; - } else if (px >= 11 && px <= 54 && py >= 364 && py <= 407) { - if (i > 0) { - i -= 1; - core.ui._drawViewMaps(core.floorIds.indexOf(areas[i].maps[0])); - } - } else if (px >= 319 && px <= 362 && py >= 364 && py <= 407) { - if (i < areas.length - 1) { - i += 1; - core.ui._drawViewMaps(core.floorIds.indexOf(areas[i].maps[0])); - } - } - }; - const replayAction_fly = function (action) { - //楼层传送的录像操作 - if (action.indexOf("fly:") != 0) return false; - var floorId = action.substring(4); - var toIndex = core.floorIds.indexOf(floorId); - if ( - !core.canUseItem("fly") || - (core.flags.flyNearStair && !core.nearStair() && !flags.canMoveFloor) - ) - return false; - core.ui._drawViewMaps(toIndex); - if (core.status.replay.speed == 24) { - if (!core.flyTo(floorId, core.replay)) - core.control._replay_error(action); - return true; - } - setTimeout(function () { - if (!core.flyTo(floorId, core.replay)) - core.control._replay_error(action); - }, core.control.__replay_getTimeout()); - return true; - }; - core.registerReplayAction("fly", replayAction_fly); - ////// 查看地图界面时,放开某个键的操作 ////// + if (px >= 11 && px <= 54 && py >= 11 && py <= 54) { + core.ui._drawViewMaps(core.floorIds.indexOf(core.status.floorId)); + } else if (px >= 362 && px <= 407 && py >= 191 && py <= 318) { + flags.showEnemy = !flags.showEnemy; + core.ui._drawViewMaps(index); + } else if (px >= 364 && px <= 407 && py >= 364 && py <= 407) { + core.clearMap("data"); + core.playSound("取消"); + core.ui.closePanel(); + core.getItemDetail(); + core.redrawMap(); + core.updateStatusBar(); + core.ui.statusBar._update_map(); + return; + } else if (px >= 55 && px <= 317 && py >= 11 && py <= 54) { + if (mapdir.includes("up")) + core.ui._drawViewMaps(core.floorIds.indexOf(formto[floorId].up)); + } else if (px >= 55 && px <= 317 && py >= 319 && py <= 362) { + if (mapdir.includes("down")) + core.ui._drawViewMaps(core.floorIds.indexOf(formto[floorId].down)); + } else if (px >= 11 && px <= 54 && py >= 55 && py <= 317) { + if (mapdir.includes("left")) + core.ui._drawViewMaps(core.floorIds.indexOf(formto[floorId].left)); + } else if (px >= 319 && px <= 362 && py >= 55 && py <= 317) { + if (mapdir.includes("right")) + core.ui._drawViewMaps(core.floorIds.indexOf(formto[floorId].right)); + } else if (px >= 319 && px <= 407 && py >= 11 && py <= 54) { + if (mapdir.includes("upFloor")) + core.ui._drawViewMaps(core.floorIds.indexOf(formto[floorId].upFloor)); + } else if (px >= 319 && px <= 407 && py >= 319 && py <= 362) { + if (mapdir.includes("downFloor")) + core.ui._drawViewMaps( + core.floorIds.indexOf(formto[floorId].downFloor) + ); + } else if ( + px >= 55 && + px <= 317 && + py >= 55 && + py <= 317 && + core.isPlaying() + ) { + core.useFly(false); + return; + } else if (px >= 11 && px <= 54 && py >= 364 && py <= 407) { + if (i > 0) { + i -= 1; + core.ui._drawViewMaps(core.floorIds.indexOf(areas[i].maps[0])); + } + } else if (px >= 319 && px <= 362 && py >= 364 && py <= 407) { + if (i < areas.length - 1) { + i += 1; + core.ui._drawViewMaps(core.floorIds.indexOf(areas[i].maps[0])); + } + } + }; + const replayAction_fly = function (action) { + //楼层传送的录像操作 + if (action.indexOf("fly:") != 0) return false; + var floorId = action.substring(4); + var toIndex = core.floorIds.indexOf(floorId); + if ( + !core.canUseItem("fly") || + (core.flags.flyNearStair && !core.nearStair() && !flags.canMoveFloor) + ) + return false; + core.ui._drawViewMaps(toIndex); + if (core.status.replay.speed == 24) { + if (!core.flyTo(floorId, core.replay)) + core.control._replay_error(action); + return true; + } + setTimeout(function () { + if (!core.flyTo(floorId, core.replay)) + core.control._replay_error(action); + }, core.control.__replay_getTimeout()); + return true; + }; + core.registerReplayAction("fly", replayAction_fly); + ////// 查看地图界面时,放开某个键的操作 ////// - actions.prototype._keyUpViewMaps = function (keycode) { - if (core.status.event.data == null) { - core.ui._drawViewMaps(core.floorIds.indexOf(core.status.floorId)); - return; - } - var floorId = core.floorIds[core.status.event.data.index]; + actions.prototype._keyUpViewMaps = function (keycode) { + if (core.status.event.data == null) { + core.ui._drawViewMaps(core.floorIds.indexOf(core.status.floorId)); + return; + } + var floorId = core.floorIds[core.status.event.data.index]; - if (keycode == 27 || keycode == 71) { - core.clearMap("data"); - core.playSound("取消"); - core.ui.closePanel(); - core.getItemDetail(); - core.redrawMap(); - core.ui.statusBar._update_map(); - core.updateStatusBar(); - return; - } + if (keycode == 27 || keycode == 71) { + core.clearMap("data"); + core.playSound("取消"); + core.ui.closePanel(); + core.getItemDetail(); + core.redrawMap(); + core.ui.statusBar._update_map(); + core.updateStatusBar(); + return; + } - if (keycode == 86) { - core.status.event.data.damage = !core.status.event.data.damage; - core.playSound("光标移动"); - core.ui._drawViewMaps(core.status.event.data); - return; - } - if (keycode == 66 || keycode == 88) { - if (core.isReplaying()) { - core.control._replay_book(); - } else { - core.openBook(false); - } - return; - } - if ( - (keycode == 13 || keycode == 32 || keycode == 67) && - !core.isReplaying() - ) { - core.useFly(false); - return; - } - return; - }; - actions.prototype._keyDownViewMaps = function (keycode) { - if (core.status.event.data == null) return; + if (keycode == 86) { + core.status.event.data.damage = !core.status.event.data.damage; + core.playSound("光标移动"); + core.ui._drawViewMaps(core.status.event.data); + return; + } + if (keycode == 66 || keycode == 88) { + if (core.isReplaying()) { + core.control._replay_book(); + } else { + core.openBook(false); + } + return; + } + if ( + (keycode == 13 || keycode == 32 || keycode == 67) && + !core.isReplaying() + ) { + core.useFly(false); + return; + } + return; + }; + actions.prototype._keyDownViewMaps = function (keycode) { + if (core.status.event.data == null) return; - var floorId = core.floorIds[core.status.event.data.index], - mh = core.floors[floorId].height; + var floorId = core.floorIds[core.status.event.data.index], + mh = core.floors[floorId].height; - if (keycode == 39) this._clickViewMaps(9, 1, 330, 250); - if (keycode == 37) this._clickViewMaps(9, 8, 25, 200); - if (keycode == 40) this._clickViewMaps(9, 6, 250, 330); - if (keycode == 38) this._clickViewMaps(9, 3, 200, 25); - if (keycode == 34) this._clickViewMaps(9, 3, 350, 330); - if (keycode == 33) this._clickViewMaps(9, 3, 350, 25); - return; - }; + if (keycode == 39) this._clickViewMaps(9, 1, 330, 250); + if (keycode == 37) this._clickViewMaps(9, 8, 25, 200); + if (keycode == 40) this._clickViewMaps(9, 6, 250, 330); + if (keycode == 38) this._clickViewMaps(9, 3, 200, 25); + if (keycode == 34) this._clickViewMaps(9, 3, 350, 330); + if (keycode == 33) this._clickViewMaps(9, 3, 350, 25); + return; + }; - actions.prototype._sys_onmousewheel = function (direct) { - // 向下滚动是 -1 ,向上是 1 + actions.prototype._sys_onmousewheel = function (direct) { + // 向下滚动是 -1 ,向上是 1 - if (this._checkReplaying()) { - // 滚轮控制速度 - if (direct == 1) core.speedUpReplay(); - if (direct == -1) core.speedDownReplay(); - return; - } + if (this._checkReplaying()) { + // 滚轮控制速度 + if (direct == 1) core.speedUpReplay(); + if (direct == -1) core.speedDownReplay(); + return; + } - // 楼层飞行器 - if (core.status.lockControl && core.status.event.id == "fly") { - if (direct == 1) core.ui.drawFly(this._getNextFlyFloor(1)); - if (direct == -1) core.ui.drawFly(this._getNextFlyFloor(-1)); - return; - } + // 楼层飞行器 + if (core.status.lockControl && core.status.event.id == "fly") { + if (direct == 1) core.ui.drawFly(this._getNextFlyFloor(1)); + if (direct == -1) core.ui.drawFly(this._getNextFlyFloor(-1)); + return; + } - // 怪物手册 - if (core.status.lockControl && core.status.event.id == "book") { - var pageinfo = core.ui._drawBook_pageinfo(); - if (direct == 1) - core.ui.drawBook(core.status.event.data - pageinfo.per_page); - if (direct == -1) - core.ui.drawBook(core.status.event.data + pageinfo.per_page); - return; - } + // 怪物手册 + if (core.status.lockControl && core.status.event.id == "book") { + var pageinfo = core.ui._drawBook_pageinfo(); + if (direct == 1) + core.ui.drawBook(core.status.event.data - pageinfo.per_page); + if (direct == -1) + core.ui.drawBook(core.status.event.data + pageinfo.per_page); + return; + } - // 存读档 - if ( - core.status.lockControl && - (core.status.event.id == "save" || core.status.event.id == "load") - ) { - var index = - core.status.event.data.page * 10 + core.status.event.data.offset; - if (direct == 1) core.ui._drawSLPanel(index - 10); - if (direct == -1) core.ui._drawSLPanel(index + 10); - return; - } + // 存读档 + if ( + core.status.lockControl && + (core.status.event.id == "save" || core.status.event.id == "load") + ) { + var index = + core.status.event.data.page * 10 + core.status.event.data.offset; + if (direct == 1) core.ui._drawSLPanel(index - 10); + if (direct == -1) core.ui._drawSLPanel(index + 10); + return; + } - // 浏览地图 - if (core.status.lockControl && core.status.event.id == "viewMaps") { - let floorId = core.floorIds[core.status.event.data.index]; - if (!flags.__visited__[floorId]) floorId = core.status.floorId; - const visit = Object.keys(flags.__visited__); - let index = visit.indexOf(floorId); - if (direct == 1) { - if (index > 0) - core.ui._drawViewMaps(core.floorIds.indexOf(visit[index - 1])); - } - if (direct == -1) { - if (index < visit.length - 1) - core.ui._drawViewMaps(core.floorIds.indexOf(visit[index + 1])); - } - return; - } + // 浏览地图 + if (core.status.lockControl && core.status.event.id == "viewMaps") { + let floorId = core.floorIds[core.status.event.data.index]; + if (!flags.__visited__[floorId]) floorId = core.status.floorId; + const visit = Object.keys(flags.__visited__); + let index = visit.indexOf(floorId); + if (direct == 1) { + if (index > 0) + core.ui._drawViewMaps(core.floorIds.indexOf(visit[index - 1])); + } + if (direct == -1) { + if (index < visit.length - 1) + core.ui._drawViewMaps(core.floorIds.indexOf(visit[index + 1])); + } + return; + } - // wait事件 - if ( - core.status.lockControl && - core.status.event.id == "action" && - core.status.event.data.type == "wait" - ) { - var timeout = - Math.max(0, core.status.event.timeout - new Date().getTime()) || 0; - core.setFlag("type", 0); - var keycode = direct == 1 ? 33 : 34; - core.setFlag("keycode", keycode); - core.setFlag("timeout", timeout); - var executed = core.events.__action_wait_afterGet( - core.status.event.data.current - ); - if (executed || !core.status.event.data.current.forceChild) { - core.status.route.push("input:" + (1e8 * timeout + keycode)); - clearTimeout(core.status.event.interval); - delete core.status.event.timeout; - core.doAction(); - } - return; - } - }; - core.registerAction( - "onmousewheel", - "_sys_onmousewheel", - actions.prototype._sys_onmousewheel, - 0 - ); - }, + // wait事件 + if ( + core.status.lockControl && + core.status.event.id == "action" && + core.status.event.data.type == "wait" + ) { + var timeout = + Math.max(0, core.status.event.timeout - new Date().getTime()) || 0; + core.setFlag("type", 0); + var keycode = direct == 1 ? 33 : 34; + core.setFlag("keycode", keycode); + core.setFlag("timeout", timeout); + var executed = core.events.__action_wait_afterGet( + core.status.event.data.current + ); + if (executed || !core.status.event.data.current.forceChild) { + core.status.route.push("input:" + (1e8 * timeout + keycode)); + clearTimeout(core.status.event.interval); + delete core.status.event.timeout; + core.doAction(); + } + return; + } + }; + core.registerAction( + "onmousewheel", + "_sys_onmousewheel", + actions.prototype._sys_onmousewheel, + 0 + ); +}, "CG回廊": function () { // 在此增加新插件 const CGUI = document.createElement("canvas"); //CGui画布设置 @@ -15556,197 +15549,197 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = }; }, "滑动转场": function () { - // 在此增加新插件 - const defaultChange = { - left: "leftPortal", // 左箭头 - up: "upPortal", // 上箭头 - right: "rightPortal", // 右箭头 - down: "downPortal", // 下箭头 - upFloor: "upFloor", // 上楼 - downFloor: "downFloor", // 下楼 - }; - const dirData = { - //方向坐标 - up: [-1, 0], - down: [1, 0], - left: [0, -1], - right: [0, 1], - upFloor: [0, 0], - downFloor: [0, 0], - }; - let allChangeEntries = Object.entries(defaultChange); - const move = document.createElement("canvas"); - const speed = 12; - let modedata = 0; + // 在此增加新插件 + const defaultChange = { + left: "leftPortal", // 左箭头 + up: "upPortal", // 上箭头 + right: "rightPortal", // 右箭头 + down: "downPortal", // 下箭头 + upFloor: "upFloor", // 上楼 + downFloor: "downFloor", // 下楼 + }; + const dirData = { + //方向坐标 + up: [-1, 0], + down: [1, 0], + left: [0, -1], + right: [0, 1], + upFloor: [0, 0], + downFloor: [0, 0], + }; + let allChangeEntries = Object.entries(defaultChange); + const move = document.createElement("canvas"); + const speed = 12; + let modedata = 0; - move.width = 1248; - move.height = 1248; + move.width = 1248; + move.height = 1248; - const ctx = move.getContext("2d"); + const ctx = move.getContext("2d"); - events.prototype.changeFloor = function ( - floorId, - stair, - heroLoc, - time, - callback - ) { - let block = core.getBlock(hero.loc.x, hero.loc.y); - var info = this._changeFloor_getInfo(floorId, stair, heroLoc, time); + events.prototype.changeFloor = function ( + floorId, + stair, + heroLoc, + time, + callback + ) { + let block = core.getBlock(hero.loc.x, hero.loc.y); + var info = this._changeFloor_getInfo(floorId, stair, heroLoc, time); - if (info == null) { - if (callback) callback(); - return; - } - floorId = info.floorId; - info.locked = core.status.lockControl; + if (info == null) { + if (callback) callback(); + return; + } + floorId = info.floorId; + info.locked = core.status.lockControl; - core.dom.floorNameLabel.innerText = core.status.maps[floorId].title; - core.lockControl(); - core.stopAutomaticRoute(); - core.clearContinueAutomaticRoute(); - core.status.replay.animate = true; - clearInterval(core.interval.onDownInterval); - delete core.animateFrame.tip; - core.interval.onDownInterval = "tmp"; + core.dom.floorNameLabel.innerText = core.status.maps[floorId].title; + core.lockControl(); + core.stopAutomaticRoute(); + core.clearContinueAutomaticRoute(); + core.status.replay.animate = true; + clearInterval(core.interval.onDownInterval); + delete core.animateFrame.tip; + core.interval.onDownInterval = "tmp"; - this._changeFloor_beforeChange(info, block, callback); - }; - events.prototype._changeFloor_beforeChange = function ( - info, - block, - callback - ) { - this._changeFloor_playSound(); - if ( - block && - block?.event && - !main.replayChecking && - !core.isReplaying() && - !core.getFlag("__isFlying__", false) - ) { - const dirEntries = allChangeEntries.find( - (v) => v[1] === block.event.id - ); - if (block?.event?.trigger === "changeFloor" && dirEntries) { - const toFloorId = block.event.data.floorId; - const dir = dirEntries[0]; + this._changeFloor_beforeChange(info, block, callback); + }; + events.prototype._changeFloor_beforeChange = function ( + info, + block, + callback + ) { + this._changeFloor_playSound(); + if ( + block && + block?.event && + !main.replayChecking && + !core.isReplaying() && + !core.hasFlag("__isFlying__") && !core.hasFlag("__fromLoad__") + ) { + const dirEntries = allChangeEntries.find( + (v) => v[1] === block.event.id + ); + if (block?.event?.trigger === "changeFloor" && dirEntries) { + const toFloorId = block.event.data.floorId; + const dir = dirEntries[0]; - const data = core.ui._drawViewMaps_buildData( - core.floorIds.indexOf(core.status.floorId) - ); - const dataTo = core.ui._drawViewMaps_buildData( - core.floorIds.indexOf(toFloorId) - ); - const v = dirData[dir][1], // 水平数值 - h = dirData[dir][0]; //竖直数值 - ctx.clearRect(0, 0, 1248, 1248); - core.drawThumbnail(core.status.floorId, null, { - damage: data.damage, - ctx: ctx, - x: 416, - y: 416, - size: 1, - all: data.all, - }); - if (dir !== "upFloor" && dir !== "downFloor") { - core.drawThumbnail(toFloorId, null, { - damage: dataTo.damage, - ctx: ctx, - x: 416 + 416 * v, - y: 416 + 416 * h, - size: 1, - all: dataTo.all, - }); + const data = core.ui._drawViewMaps_buildData( + core.floorIds.indexOf(core.status.floorId) + ); + const dataTo = core.ui._drawViewMaps_buildData( + core.floorIds.indexOf(toFloorId) + ); + const v = dirData[dir][1], // 水平数值 + h = dirData[dir][0]; //竖直数值 + ctx.clearRect(0, 0, 1248, 1248); + core.drawThumbnail(core.status.floorId, null, { + damage: data.damage, + ctx: ctx, + x: 416, + y: 416, + size: 1, + all: data.all, + }); + if (dir !== "upFloor" && dir !== "downFloor") { + core.drawThumbnail(toFloorId, null, { + damage: dataTo.damage, + ctx: ctx, + x: 416 + 416 * v, + y: 416 + 416 * h, + size: 1, + all: dataTo.all, + }); - var _run = function () { - var cb = function () { - modedata = 0; - core.clearUI(); - core.clearMap("data"); - core.events._changeFloor_changing(info, callback); - }; + var _run = function () { + var cb = function () { + modedata = 0; + core.clearUI(); + core.clearMap("data"); + core.events._changeFloor_changing(info, callback); + }; - var animate = window.setInterval( - function () { - if (modedata >= 416) { - delete core.animateFrame.asyncId[animate]; - clearInterval(animate); - cb(); - } else { - core.clearUI(); - core.clearMap("data"); + var animate = window.setInterval( + function () { + if (modedata >= 416) { + delete core.animateFrame.asyncId[animate]; + clearInterval(animate); + cb(); + } else { + core.clearUI(); + core.clearMap("data"); - core.canvas.data.drawImage( - move, - 416 + modedata * v, - 416 + modedata * h, - 416, - 416, - 0, - 0, - 416, - 416 - ); - let status = "leftFoot"; + core.canvas.data.drawImage( + move, + 416 + modedata * v, + 416 + modedata * h, + 416, + 416, + 0, + 0, + 416, + 416 + ); + let status = "leftFoot"; - if (modedata > 208) { - status = "rightFoot"; - } - const img = core.material.images.hero; - const heroIconArr = core.material.icons.hero; - const width = core.material.icons.hero.width || 32; - const height = core.material.icons.hero.height; - const heroIcon = heroIconArr[dir]; + if (modedata > 208) { + status = "rightFoot"; + } + const img = core.material.images.hero; + const heroIconArr = core.material.icons.hero; + const width = core.material.icons.hero.width || 32; + const height = core.material.icons.hero.height; + const heroIcon = heroIconArr[dir]; - core.canvas.data.drawImage( - img, - (heroIcon[status] % 4) * width, - heroIcon.loc * height, - width, - height, - core.status.hero.loc.x * 32 - - core.bigmap.offsetX - - (modedata - (modedata * 32) / 416) * v, - core.status.hero.loc.y * 32 - - 16 - - (modedata - (modedata * 32) / 416) * h, - width, - height - ); - modedata += speed; - clearInterval(animate); - delete core.animateFrame.asyncId[animate]; - _run(); - } - }, - core.status.replay.speed == 24 - ? 1 - : 10 / core.status.replay.speed - ); + core.canvas.data.drawImage( + img, + (heroIcon[status] % 4) * width, + heroIcon.loc * height, + width, + height, + core.status.hero.loc.x * 32 - + core.bigmap.offsetX - + (modedata - (modedata * 32) / 416) * v, + core.status.hero.loc.y * 32 - + 16 - + (modedata - (modedata * 32) / 416) * h, + width, + height + ); + modedata += speed; + clearInterval(animate); + delete core.animateFrame.asyncId[animate]; + _run(); + } + }, + core.status.replay.speed == 24 ? + 1 : + 10 / core.status.replay.speed + ); - core.animateFrame.lastAsyncId = animate; - core.animateFrame.asyncId[animate] = cb; - }; - _run(); - return; - } - } - } - // 需要 setTimeout 执行,不然会出错 - window.setTimeout(function () { - if (info.time == 0) core.events._changeFloor_changing(info, callback); - else - core.showWithAnimate( - core.dom.floorMsgGroup, - info.time / 2, - function () { - core.events._changeFloor_changing(info, callback); - } - ); - }, 25); - }; - }, + core.animateFrame.lastAsyncId = animate; + core.animateFrame.asyncId[animate] = cb; + }; + _run(); + return; + } + } + } + // 需要 setTimeout 执行,不然会出错 + window.setTimeout(function () { + if (info.time == 0) core.events._changeFloor_changing(info, callback); + else + core.showWithAnimate( + core.dom.floorMsgGroup, + info.time / 2, + function () { + core.events._changeFloor_changing(info, callback); + } + ); + }, 25); + }; +}, "剧情cg": function () { // 在此增加新插件 // 在此增加新插件 @@ -21658,7 +21651,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = let max = heroInfo.speed if (enemyInfo.speed > max) max = enemyInfo.speed equipInfo.forEach(v => { if (v.speed > max) max = v.speed }) - let i = 0 + let i = 1 while (oneTurn * i / max < 15) { i++ } @@ -21666,7 +21659,6 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = if (enemyInfo.onAttack) enemyInfo.now *= i equipInfo.forEach(v => { if (v.onAttack) v.now *= i }) oneTurn *= i - console.log([oneTurn, heroInfo.now, enemyInfo.now]) let time = 0, farme = 0; return new Promise((res) => { @@ -21696,11 +21688,8 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = (inRect(pos, easyclosebox) && easy) || (inRect(pos, uneasyclosebox) && !easy) ) { - core.status.event.id = ""; - core.unregisterAnimationFrame("attackAnimate"); - core.clearMap(ctx); - core.closePanel(); - res(); + flags.qukly = !flags.qukly + } }; async function drawAttackAnimate( @@ -21730,7 +21719,28 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = if (v.onAttack) onAttack = true; }); core.clearMap(ctx); - let animate = Math.floor(farme / 30); + let animate = Math.floor(farme / 15); + + if (flags.qukly) { + while (true) { + let goattack = false + equipInfo.forEach(v => { + if (v.now >= oneTurn) goattack = true + + }); + if (enemyInfo.now >= oneTurn) goattack = true + if (heroInfo.now >= oneTurn) goattack = true + + if (goattack) break; + enemyInfo.now += enemyInfo.speed + heroInfo.now += heroInfo.speed + equipInfo.forEach(function (v) { + v.now += v.speed + + }); + + } + } if (easy) { core.fillRect(ctx, 64, 52, 288, 212, "rgba(0,0,0,0.5)"); core.strokeRect(ctx, 64, 52, 288, 212, "rgba(255,255,255,0.5)", 4); @@ -21861,7 +21871,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = ); core.fillBoldText( ctx, - "跳过", + flags.qukly ? "正常" : "极速", 330, 250, "#FFFF60", @@ -21888,7 +21898,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = "bold 36px pala" ); - if (!attack && !onAttack) enemyInfo.now += enemyInfo.speed; + if (!attack && !onAttack && !flags.qukly) enemyInfo.now += enemyInfo.speed; let enemynow = Math.min(100 + (enemyInfo.now / oneTurn) * 215, 315); ctx.fillStyle = "#FFFFFF"; ctx.beginPath(); @@ -21939,7 +21949,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = core.drawIcon(ctx, v.id, vnow - 16, 54, 32, 32); }); - if (!attack && !onAttack) heroInfo.now += hero.speed; + if (!attack && !onAttack && !flags.qukly) heroInfo.now += hero.speed; let heronow = Math.min(100 + (heroInfo.now / oneTurn) * 215, 315); ctx.beginPath(); ctx.moveTo(heronow, 120); @@ -22209,7 +22219,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = ); core.fillBoldText( ctx, - "跳过", + flags.qukly ? "正常" : "极速", 330, 365, "#FFFF60", @@ -22236,7 +22246,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = "bold 36px pala" ); - if (!attack && !onAttack) enemyInfo.now += enemyInfo.speed; + if (!attack && !onAttack & !flags.qukly) enemyInfo.now += enemyInfo.speed; let enemynow = Math.min(100 + (enemyInfo.now / oneTurn) * 215, 315); ctx.fillStyle = "#FFFFFF"; ctx.beginPath(); @@ -22287,7 +22297,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = core.drawIcon(ctx, v.id, vnow - 16, 54, 32, 32); }); - if (!attack && !onAttack) heroInfo.now += hero.speed; + if (!attack && !onAttack && !flags.qukly) heroInfo.now += hero.speed; let heronow = Math.min(100 + (heroInfo.now / oneTurn) * 215, 315); ctx.beginPath(); ctx.moveTo(heronow, 120); @@ -23679,5 +23689,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 + } } \ No newline at end of file