扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 60|回复: 0

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

[复制链接]
累计送礼:
0 个
累计收礼:
0 个
  • TA的每日心情
    开心
    昨天 00:43
  • 签到天数: 144 天

    连续签到: 3 天

    [LV.7]常住居民III

    2396

    主题

    461

    回帖

    1万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    6
    卡币
    12389
    OK点
    16
    推广点
    0
    同能卷
    0
    积分
    15274

    灌水之王

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





                本帖来自P1论坛作者l734273398,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=497472  若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2025-6-7 00:37 , Processed in 0.124875 second(s), 54 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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