设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 52|回复: 0
打印 上一主题 下一主题

[原创发布] 随机排行榜系统,即时刷新自动排名

[复制链接]

Lv3.寻梦者

梦石
0
星屑
4637
在线时间
1389 小时
注册时间
2018-1-16
帖子
394
跳转到指定楼层
1

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
1.用AI写的一个排行榜插件
2.实现401-410变量即时排行,可以带入变量名进行排名
3.即时刷新,变量变动,则自动刷新排行榜
4.玩家上榜实现:可以将其中一个变量带入玩家的某项数值,从而实现玩家同步上榜

RUBY 代码复制下载
  1. /*:
  2. * @target MZ
  3. * @plugindesc 变量排行榜系统 v2.1(纯色版)
  4. * @help 显示指定变量范围的排行榜(变量401-410),按数值从高到低排列
  5. * 可在参数界面设置显示坐标和颜色
  6. * @param posX
  7. * @text 排行榜X坐标
  8. * @desc 排行榜显示位置的X坐标(默认20
  9. * @type number
  10. * @default 20
  11. *
  12. * @param posY
  13. * @text 排行榜Y坐标
  14. * @desc 排行榜显示位置的Y坐标(默认20
  15. * @type number
  16. * @default 20
  17. *
  18. * @param bgColor
  19. * @text 背景颜色
  20. * @desc 排行榜背景颜色(默认#00000080)
  21. * @type string
  22. * @default #00000080
  23. *
  24. * @param titleColor
  25. * @text 标题颜色
  26. * @desc 标题文字颜色(默认#FFFFFF)
  27. * @type string
  28. * @default #FFFFFF
  29. *
  30. * @param rank1Color
  31. * @text 第一名颜色
  32. * @desc 第一名文字颜色(默认#FF0000)
  33. * @type string
  34. * @default #FF0000
  35. *
  36. * @param rank2Color
  37. * @text 第二名颜色
  38. * @desc 第二名文字颜色(默认#FFFF00)
  39. * @type string
  40. * @default #FFFF00
  41. *
  42. * @param rank3Color
  43. * @text 第三名颜色
  44. * @desc 第三名文字颜色(默认#FFFF00)
  45. * @type string
  46. * @default #FFFF00
  47. *
  48. * @param rank4Color
  49. * @text 第四名颜色
  50. * @desc 第四名文字颜色(默认#FFFFFF)
  51. * @type string
  52. * @default #FFFFFF
  53. *
  54. * @param rank5Color
  55. * @text 第五名颜色
  56. * @desc 第五名文字颜色(默认#FFFFFF)
  57. * @type string
  58. * @default #FFFFFF
  59. *
  60. * @param rank6Color
  61. * @text 第六名颜色
  62. * @desc 第六名文字颜色(默认#FFFFFF)
  63. * @type string
  64. * @default #FFFFFF
  65. *
  66. * @param rank7Color
  67. * @text 第七名颜色
  68. * @desc 第七名文字颜色(默认#FFFFFF)
  69. * @type string
  70. * @default #FFFFFF
  71. *
  72. * @param rank8Color
  73. * @text 第八名颜色
  74. * @desc 第八名文字颜色(默认#FFFFFF)
  75. * @type string
  76. * @default #FFFFFF
  77. *
  78. * @param rank9Color
  79. * @text 第九名颜色
  80. * @desc 第九名文字颜色(默认#FFFFFF)
  81. * @type string
  82. * @default #FFFFFF
  83. *
  84. * @param rank10Color
  85. * @text 第十名颜色
  86. * @desc 第十名文字颜色(默认#FFFFFF)
  87. * @type string
  88. * @default #FFFFFF
  89. *
  90. * @param switchId
  91. * @text 排行榜开关ID
  92. * @desc 控制排行榜显示的开关ID(默认0表示始终显示)
  93. * @type switch
  94. * @default 0
  95. *
  96. * @author AI助手
  97. */
  98.  
  99. (() => {
  100.     const parameters = PluginManager.parameters('VariableRanking');
  101.     const config = {
  102.         posX: parseInt(parameters['posX'] || 20),
  103.         posY: parseInt(parameters['posY'] || 20),
  104.         bgColor: parameters['bgColor'] || '#00000080',
  105.         titleColor: parameters['titleColor'] || '#FFFFFF',
  106.         rankColors: [
  107.             parameters['rank1Color'] || '#FF0000',
  108.             parameters['rank2Color'] || '#FFFF00',
  109.             parameters['rank3Color'] || '#FFFF00',
  110.             parameters['rank4Color'] || '#FFFFFF',
  111.             parameters['rank5Color'] || '#FFFFFF',
  112.             parameters['rank6Color'] || '#FFFFFF',
  113.             parameters['rank7Color'] || '#FFFFFF',
  114.             parameters['rank8Color'] || '#FFFFFF',
  115.             parameters['rank9Color'] || '#FFFFFF',
  116.             parameters['rank10Color'] || '#FFFFFF'
  117.         ],
  118.         switchId: parseInt(parameters['switchId'] || 0)
  119.     };
  120.  
  121.     const _Scene_Map_update = Scene_Map.prototype.update;
  122.     Scene_Map.prototype.update = function() {
  123.         _Scene_Map_update.call(this);
  124.  
  125.         // 检查开关状态(如果设置了开关ID)
  126.         if (config.switchId > 0 && !$gameSwitches.value(config.switchId)) {
  127.             if (this._rankingSprite) {
  128.                 this._rankingSprite.removeChildren();
  129.             }
  130.             return;
  131.         }
  132.  
  133.         if (!this._rankingSprite) {
  134.             this._rankingSprite = new Sprite();
  135.             this._rankingSprite.z = 999;
  136.             this.addChild(this._rankingSprite);
  137.         }
  138.  
  139.         // 收集变量数据(范围401-410
  140.         const data = [];
  141.         for (let i = 401; i <= 410; i++) {
  142.             data.push({
  143.                 value: $gameVariables.value(i),
  144.                 id: i,
  145.                 name: $dataSystem.variables[i] || `变量${i}` // 获取变量名(含默认值)
  146.             });
  147.         }
  148.  
  149.         // 按数值降序排序
  150.         data.sort((a, b) => b.value - a.value);
  151.  
  152.         // 更新排行榜显示
  153.         this._rankingSprite.removeChildren();
  154.         const bgWidth = 240;
  155.         const bgHeight = 400;
  156.  
  157.         // 绘制纯色背景
  158.         const bg = new Sprite(new Bitmap(bgWidth, bgHeight));
  159.         bg.bitmap.fillAll(config.bgColor);
  160.         bg.x = config.posX;
  161.         bg.y = config.posY;
  162.         this._rankingSprite.addChild(bg);
  163.  
  164.         // 绘制标题
  165.         const title = new Sprite(new Bitmap(bgWidth - 20, 40));
  166.         title.bitmap.fontSize = 24;
  167.         title.bitmap.textColor = config.titleColor;
  168.         title.bitmap.drawText('变量排行榜', 0, 0, bgWidth - 20, 40, 'center');
  169.         title.x = config.posX + 10;
  170.         title.y = config.posY + 10;
  171.         this._rankingSprite.addChild(title);
  172.  
  173.         // 绘制排名条目
  174.         data.forEach((entry, rank) => {
  175.             const text = new Sprite(new Bitmap(bgWidth - 20, 32));
  176.             text.bitmap.fontSize = 20;
  177.             text.bitmap.textColor = config.rankColors[rank] || '#FFFFFF';
  178.  
  179.             text.bitmap.drawText(
  180.                 `${rank+1}. ${entry.name}: ${entry.value}`,
  181.                 0, 0, bgWidth - 20, 32
  182.             );
  183.             text.x = config.posX + 10;
  184.             text.y = config.posY + 60 + rank * 32;
  185.             this._rankingSprite.addChild(text);
  186.         });
  187.     };
  188. })();

$3S7J13M]95Q89CDAD[ZNLS.png (349.01 KB, 下载次数: 0)

$3S7J13M]95Q89CDAD[ZNLS.png

7V$T47}B{CYAQ7HY}4`SEDA.png (112.02 KB, 下载次数: 0)

7V$T47}B{CYAQ7HY}4`SEDA.png

C)R0[7OVRSZK$86O4SV(PAL.png (328.37 KB, 下载次数: 0)

C)R0[7OVRSZK$86O4SV(PAL.png

I[~U@$`)0Z\0__O9LT`[email protected] (154.39 KB, 下载次数: 0)

I[~U@$`)0Z\0__O9LT`E@X.png
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2025-6-3 01:41

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表