随机排行榜系统,即时刷新自动排名
1.用AI写的一个排行榜插件2.实现401-410变量即时排行,可以带入变量名进行排名
3.即时刷新,变量变动,则自动刷新排行榜
4.玩家上榜实现:可以将其中一个变量带入玩家的某项数值,从而实现玩家同步上榜
RUBY 代码下载
/*:
* @target MZ
* @plugindesc 变量排行榜系统 v2.1(纯色版)
* @help 显示指定变量范围的排行榜(变量401-410),按数值从高到低排列
* 可在参数界面设置显示坐标和颜色
* @param posX
* @text 排行榜X坐标
* @desc 排行榜显示位置的X坐标(默认20)
* @type number
* @default20
*
* @param posY
* @text 排行榜Y坐标
* @desc 排行榜显示位置的Y坐标(默认20)
* @type number
* @default20
*
* @param bgColor
* @text 背景颜色
* @desc 排行榜背景颜色(默认#00000080)
* @typestring
* @default#00000080
*
* @param titleColor
* @text 标题颜色
* @desc 标题文字颜色(默认#FFFFFF)
* @typestring
* @default#FFFFFF
*
* @param rank1Color
* @text 第一名颜色
* @desc 第一名文字颜色(默认#FF0000)
* @typestring
* @default#FF0000
*
* @param rank2Color
* @text 第二名颜色
* @desc 第二名文字颜色(默认#FFFF00)
* @typestring
* @default#FFFF00
*
* @param rank3Color
* @text 第三名颜色
* @desc 第三名文字颜色(默认#FFFF00)
* @typestring
* @default#FFFF00
*
* @param rank4Color
* @text 第四名颜色
* @desc 第四名文字颜色(默认#FFFFFF)
* @typestring
* @default#FFFFFF
*
* @param rank5Color
* @text 第五名颜色
* @desc 第五名文字颜色(默认#FFFFFF)
* @typestring
* @default#FFFFFF
*
* @param rank6Color
* @text 第六名颜色
* @desc 第六名文字颜色(默认#FFFFFF)
* @typestring
* @default#FFFFFF
*
* @param rank7Color
* @text 第七名颜色
* @desc 第七名文字颜色(默认#FFFFFF)
* @typestring
* @default#FFFFFF
*
* @param rank8Color
* @text 第八名颜色
* @desc 第八名文字颜色(默认#FFFFFF)
* @typestring
* @default#FFFFFF
*
* @param rank9Color
* @text 第九名颜色
* @desc 第九名文字颜色(默认#FFFFFF)
* @typestring
* @default#FFFFFF
*
* @param rank10Color
* @text 第十名颜色
* @desc 第十名文字颜色(默认#FFFFFF)
* @typestring
* @default#FFFFFF
*
* @param switchId
* @text 排行榜开关ID
* @desc 控制排行榜显示的开关ID(默认0表示始终显示)
* @type switch
* @default0
*
* @author AI助手
*/
(() => {
const parameters = PluginManager.parameters('VariableRanking');
const config = {
posX: parseInt(parameters['posX'] || 20),
posY: parseInt(parameters['posY'] || 20),
bgColor: parameters['bgColor'] || '#00000080',
titleColor: parameters['titleColor'] || '#FFFFFF',
rankColors: [
parameters['rank1Color'] || '#FF0000',
parameters['rank2Color'] || '#FFFF00',
parameters['rank3Color'] || '#FFFF00',
parameters['rank4Color'] || '#FFFFFF',
parameters['rank5Color'] || '#FFFFFF',
parameters['rank6Color'] || '#FFFFFF',
parameters['rank7Color'] || '#FFFFFF',
parameters['rank8Color'] || '#FFFFFF',
parameters['rank9Color'] || '#FFFFFF',
parameters['rank10Color'] || '#FFFFFF'
],
switchId: parseInt(parameters['switchId'] || 0)
};
const _Scene_Map_update = Scene_Map.prototype.update;
Scene_Map.prototype.update = function(){
_Scene_Map_update.call(this);
// 检查开关状态(如果设置了开关ID)
if(config.switchId > 0 && !$gameSwitches.value(config.switchId)){
if(this._rankingSprite){
this._rankingSprite.removeChildren();
}
return;
}
if(!this._rankingSprite){
this._rankingSprite = new Sprite();
this._rankingSprite.z = 999;
this.addChild(this._rankingSprite);
}
// 收集变量数据(范围401-410)
const data = [];
for(let i = 401; ib.value - a.value);
// 更新排行榜显示
this._rankingSprite.removeChildren();
const bgWidth = 240;
const bgHeight = 400;
// 绘制纯色背景
const bg = new Sprite(new Bitmap(bgWidth, bgHeight));
bg.bitmap.fillAll(config.bgColor);
bg.x = config.posX;
bg.y = config.posY;
this._rankingSprite.addChild(bg);
// 绘制标题
const title = new Sprite(new Bitmap(bgWidth - 20, 40));
title.bitmap.fontSize = 24;
title.bitmap.textColor = config.titleColor;
title.bitmap.drawText('变量排行榜', 0, 0, bgWidth - 20, 40, 'center');
title.x = config.posX + 10;
title.y = config.posY + 10;
this._rankingSprite.addChild(title);
// 绘制排名条目
data.forEach((entry, rank) => {
const text = new Sprite(new Bitmap(bgWidth - 20, 32));
text.bitmap.fontSize = 20;
text.bitmap.textColor = config.rankColors || '#FFFFFF';
text.bitmap.drawText(
`${rank+1}. ${entry.name}: ${entry.value}`,
0, 0, bgWidth - 20, 32
);
text.x = config.posX + 10;
text.y = config.posY + 60 + rank * 32;
this._rankingSprite.addChild(text);
});
};
})();
本帖来自P1论坛作者l734273398,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=497472若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。
页:
[1]