| 赞 | 16 |
| VIP | 4 |
| 好人卡 | 4 |
| 积分 | 65 |
| 经验 | 76902 |
| 最后登录 | 2026-7-21 |
| 在线时间 | 263 小时 |
Lv4.逐梦者
- 梦石
- 0
- 星屑
- 6498
- 在线时间
- 263 小时
- 注册时间
- 2010-7-17
- 帖子
- 224
|
本帖最后由 xiaolu0415 于 2026-6-29 11:14 编辑
//=============================================================================
// TimeCalendar_MZ.js
//=============================================================================
/*:
* @target MZ
* @plugindesc 七日四时时间系统|左上常驻贴图UI|新游戏仅初始化周一上午|深夜传送回床
* @author Fix
*
* @command TimePass
* @text 时间流逝一格
* @desc 推进时段,深夜自动过夜、传送睡觉点,周日深夜切换周一上午
*
* @param VarWeek
* @text 星期存储变量ID
* @type number
* @default 21
* @desc 1=周一 2=周二 3=周三 4=周四 5=周五 6=周六 7=周日
*
* @param VarTime
* @text 时段存储变量ID
* @type number
* @default 22
* @desc 1=上午 2=中午 3=晚上 4=深夜
*
* @param SleepMapId
* @text 睡觉传送地图ID
* @type number
* @default 1
* @param SleepX
* @text 睡觉点X坐标
* @type number
* @default 8
* @param SleepY
* @text 睡觉点Y坐标
* @type number
* @default 10
*
* @param UIPosX
* @text UI左上角X
* @type number
* @default 12
* @param UIPosY
* @text UI左上角Y
* @type number
* @default 12
*
* @param WeekImgW
* @text 星期图宽
* @type number
* @default 76
* @param WeekImgH
* @text 星期图高
* @type number
* @default 28
* @param TimeImgW
* @text 时段图宽
* @type number
* @default 28
* @param TimeImgH
* @text 时段图高
* @type number
* @default 28
* @param ImgGap
* @text 两张图中间间距
* @type number
* @default 6
*
* @param MonImg
* @text 周一图片(pictures,不带后缀)
* @default week_mon
* @param TueImg
* @text 周二图片
* @default week_tue
* @param WedImg
* @text 周三图片
* @default week_wed
* @param ThuImg
* @text 周四图片
* @default week_thu
* @param FriImg
* @text 周五图片
* @default week_fri
* @param SatImg
* @text 周六图片
* @default week_sat
* @param SunImg
* @text 周日图片
* @default week_sun
*
* @param MorningImg
* @text 上午图片
* @default time_morning
* @param NoonImg
* @text 中午图片
* @default time_noon
* @param EveningImg
* @text 晚上图片
* @default time_evening
* @param MidnightImg
* @text 深夜图片
* @default time_midnight
*
* @help
* 1.图片全部放入 img/pictures
* 2.仅新建游戏时初始化:变量星期=1(周一)、时段=1(上午;读档保留存档内时间)
* 3.地图左上角永久显示星期+时段贴图,实时同步变量
* 4.插件指令【时间流逝一格】切换时段;深夜执行睡觉传送+次日
* 5.周日深夜过完直接变为周一上午
*/
(() => {
const PLUGIN_NAME = "TimeCalendar_MZ";
const params = PluginManager.parameters(PLUGIN_NAME);
// 变量ID
const VAR_WEEK = Number(params.VarWeek);
const VAR_TIME = Number(params.VarTime);
// 睡觉传送配置
const SLEEP_MAP = Number(params.SleepMapId);
const SLEEP_X = Number(params.SleepX);
const SLEEP_Y = Number(params.SleepY);
// UI位置尺寸
const UI_X = Number(params.UIPosX);
const UI_Y = Number(params.UIPosY);
const W_W = Number(params.WeekImgW);
const W_H = Number(params.WeekImgH);
const T_W = Number(params.TimeImgW);
const T_H = Number(params.TimeImgH);
const GAP = Number(params.ImgGap);
// 星期贴图数组 1~7
const weekPic = ["",
params.MonImg, params.TueImg, params.WedImg,
params.ThuImg, params.FriImg, params.SatImg, params.SunImg
];
// 时段贴图数组 1~4
const timePic = ["",
params.MorningImg, params.NoonImg, params.EveningImg, params.MidnightImg
];
// 文字兜底(贴图缺失时显示)
const weekText = ["", "周一", "周二", "周三", "周四", "周五", "周六", "周日"];
const timeText = ["", "上午", "中午", "晚上", "深夜"];
// 仅新建游戏初始化周一上午,读档不覆盖
const _DataManager_createGameObjects = DataManager.createGameObjects;
DataManager.createGameObjects = function() {
_DataManager_createGameObjects.call(this);
$gameVariables.setValue(VAR_WEEK, 1);
$gameVariables.setValue(VAR_TIME, 1);
};
// 左上角悬浮透明UI窗口
class Window_TimeFloat extends Window_Base {
constructor() {
super(new Rectangle(0, 0, Graphics.width, Graphics.height));
this.opacity = 0;
this.backOpacity = 0;
}
refresh() {
this.contents.clear();
const w = $gameVariables.value(VAR_WEEK);
const t = $gameVariables.value(VAR_TIME);
const txPos = UI_X + W_W + GAP;
// 绘制星期图/兜底文字
const wName = weekPic[w];
if (wName) {
const bmpW = ImageManager.loadPicture(wName);
bmpW.addLoadListener(() => {
this.contents.blt(bmpW, 0, 0, bmpW.width, bmpW.height, UI_X, UI_Y, W_W, W_H);
});
} else {
this.drawText(weekText[w], UI_X, UI_Y, W_W, "center");
}
// 绘制时段图/兜底文字
const tName = timePic[t];
if (tName) {
const bmpT = ImageManager.loadPicture(tName);
bmpT.addLoadListener(() => {
this.contents.blt(bmpT, 0, 0, bmpT.width, bmpT.height, txPos, UI_Y, T_W, T_H);
});
} else {
this.drawText(timeText[t], txPos, UI_Y, T_W, "center");
}
}
update() {
super.update();
this.refresh();
}
}
// 地图加载生成UI
const _SceneMap_createAllWindows = Scene_Map.prototype.createAllWindows;
Scene_Map.prototype.createAllWindows = function() {
_SceneMap_createAllWindows.call(this);
this._timeUiWin = new Window_TimeFloat();
this.addWindow(this._timeUiWin);
};
// 插件指令:时间流逝
PluginManager.registerCommand(PLUGIN_NAME, "TimePass", ()=>{
let week = $gameVariables.value(VAR_WEEK);
let time = $gameVariables.value(VAR_TIME);
time += 1;
// 深夜触发过夜逻辑
if(time > 4){
// 传送睡觉点
$gamePlayer.reserveTransfer(SLEEP_MAP, SLEEP_X, SLEEP_Y, 0, 0);
time = 1;
week += 1;
// 周日转周一
if(week >7) week = 1;
}
$gameVariables.setValue(VAR_WEEK, week);
$gameVariables.setValue(VAR_TIME, time);
});
})();
比如这样写一段事件,做好星期几及时间的图片。在写触发时,设定位于变量21和22的日期及周几变量
|
|