1 Star 0 Fork 5

flanpan/RMMZ脚本框架中文注释

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
rmmz_scenes.js 116.04 KB
一键复制 编辑 原始数据 按行查看 历史
9梦菌 提交于 2023-05-06 01:54 . 更新
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107
//=============================================================================
// rmmz_scenes.js v1.0.2
//=============================================================================
//-----------------------------------------------------------------------------
// 场景_基础
// Scene_Base
//
// 游戏中所有场景的父类。
// The superclass of all scenes within the game.
function Scene_Base() {
this.initialize(...arguments);
}
Scene_Base.prototype = Object.create(Stage.prototype);
Scene_Base.prototype.constructor = Scene_Base;
/* 初始化 */
Scene_Base.prototype.initialize = function() {
Stage.prototype.initialize.call(this);
this._started = false;
this._active = false;
this._fadeSign = 0;
this._fadeDuration = 0;
this._fadeWhite = 0;
this._fadeOpacity = 0;
this.createColorFilter();
};
/* 创建 */
Scene_Base.prototype.create = function() {
//
};
/* 是否活动的 */
Scene_Base.prototype.isActive = function() {
return this._active;
};
/* 是否准备好 */
Scene_Base.prototype.isReady = function() {
return (
ImageManager.isReady() &&
EffectManager.isReady() &&
FontManager.isReady()
);
};
/* 开始 */
Scene_Base.prototype.start = function() {
this._started = true;
this._active = true;
};
/* 更新 */
Scene_Base.prototype.update = function() {
this.updateFade();
this.updateColorFilter();
this.updateChildren();
AudioManager.checkErrors();
};
/* 停止 */
Scene_Base.prototype.stop = function() {
this._active = false;
};
/* 是否开始了 */
Scene_Base.prototype.isStarted = function() {
return this._started;
};
/* 是否忙碌 */
Scene_Base.prototype.isBusy = function() {
return this.isFading();
};
/* 是否渐变中 */
Scene_Base.prototype.isFading = function() {
return this._fadeDuration > 0;
};
/* 结束 */
Scene_Base.prototype.terminate = function() {
//
};
/* 创建窗口图层 */
Scene_Base.prototype.createWindowLayer = function() {
this._windowLayer = new WindowLayer();
this._windowLayer.x = (Graphics.width - Graphics.boxWidth) / 2;
this._windowLayer.y = (Graphics.height - Graphics.boxHeight) / 2;
this.addChild(this._windowLayer);
};
/* 添加窗口 */
Scene_Base.prototype.addWindow = function(window) {
this._windowLayer.addChild(window);
};
/* 开始淡入 */
Scene_Base.prototype.startFadeIn = function(duration, white) {
this._fadeSign = 1;
this._fadeDuration = duration || 30;
this._fadeWhite = white;
this._fadeOpacity = 255;
this.updateColorFilter();
};
/* 开始淡出 */
Scene_Base.prototype.startFadeOut = function(duration, white) {
this._fadeSign = -1;
this._fadeDuration = duration || 30;
this._fadeWhite = white;
this._fadeOpacity = 0;
this.updateColorFilter();
};
/* 创建颜色过滤器 */
Scene_Base.prototype.createColorFilter = function() {
this._colorFilter = new ColorFilter();
this.filters = [this._colorFilter];
};
/* 更新颜色过滤器 */
Scene_Base.prototype.updateColorFilter = function() {
const c = this._fadeWhite ? 255 : 0;
const blendColor = [c, c, c, this._fadeOpacity];
this._colorFilter.setBlendColor(blendColor);
};
/* 更新渐变 */
Scene_Base.prototype.updateFade = function() {
if (this._fadeDuration > 0) {
const d = this._fadeDuration;
if (this._fadeSign > 0) {
this._fadeOpacity -= this._fadeOpacity / d;
} else {
this._fadeOpacity += (255 - this._fadeOpacity) / d;
}
this._fadeDuration--;
}
};
/* 更新子元素 */
Scene_Base.prototype.updateChildren = function() {
for (const child of this.children) {
if (child.update) {
child.update();
}
}
};
/* 场景入栈 */
Scene_Base.prototype.popScene = function() {
SceneManager.pop();
};
/* 检测游戏结束 */
Scene_Base.prototype.checkGameover = function() {
if ($gameParty.isAllDead()) {
SceneManager.goto(Scene_Gameover);
}
};
/* 所有淡出 */
Scene_Base.prototype.fadeOutAll = function() {
const time = this.slowFadeSpeed() / 60;
AudioManager.fadeOutBgm(time);
AudioManager.fadeOutBgs(time);
AudioManager.fadeOutMe(time);
this.startFadeOut(this.slowFadeSpeed());
};
/* 渐变速度 */
Scene_Base.prototype.fadeSpeed = function() {
return 24;
};
/* 缓慢的渐变速度 */
Scene_Base.prototype.slowFadeSpeed = function() {
return this.fadeSpeed() * 2;
};
/* 缩放精灵
* 根据精灵与画面的长宽比例来放大精灵。
*/
Scene_Base.prototype.scaleSprite = function(sprite) {
const ratioX = Graphics.width / sprite.bitmap.width;
const ratioY = Graphics.height / sprite.bitmap.height;
const scale = Math.max(ratioX, ratioY, 1.0);
sprite.scale.x = scale;
sprite.scale.y = scale;
};
/* 中心精灵
* 将精灵放置在画面中心。
*/
Scene_Base.prototype.centerSprite = function(sprite) {
sprite.x = Graphics.width / 2;
sprite.y = Graphics.height / 2;
sprite.anchor.x = 0.5;
sprite.anchor.y = 0.5;
};
/* 是否帮助窗口位于底下的模式 */
Scene_Base.prototype.isBottomHelpMode = function() {
return true;
};
/* 是否按键位于底下的模式 */
Scene_Base.prototype.isBottomButtonMode = function() {
return false;
};
/* 是否输入位于右边的模式 */
Scene_Base.prototype.isRightInputMode = function() {
return true;
};
/* 主指令宽度 */
Scene_Base.prototype.mainCommandWidth = function() {
return 240;
};
/* 按键区域顶部位置 */
Scene_Base.prototype.buttonAreaTop = function() {
if (this.isBottomButtonMode()) {
return Graphics.boxHeight - this.buttonAreaHeight();
} else {
return 0;
}
};
/* 按键区域底部位置 */
Scene_Base.prototype.buttonAreaBottom = function() {
return this.buttonAreaTop() + this.buttonAreaHeight();
};
/* 按键区域高 */
Scene_Base.prototype.buttonAreaHeight = function() {
return 52;
};
/* 按键 Y 坐标 */
Scene_Base.prototype.buttonY = function() {
const offsetY = Math.floor((this.buttonAreaHeight() - 48) / 2);
return this.buttonAreaTop() + offsetY;
};
/* 计算窗口高度 */
Scene_Base.prototype.calcWindowHeight = function(numLines, selectable) {
if (selectable) {
return Window_Selectable.prototype.fittingHeight(numLines);
} else {
return Window_Base.prototype.fittingHeight(numLines);
}
};
/* 请求自动保存 */
Scene_Base.prototype.requestAutosave = function() {
if (this.isAutosaveEnabled()) {
this.executeAutosave();
}
};
/* 是否自动保存启用 */
Scene_Base.prototype.isAutosaveEnabled = function() {
return (
!DataManager.isBattleTest() &&
!DataManager.isEventTest() &&
$gameSystem.isAutosaveEnabled() &&
$gameSystem.isSaveEnabled()
);
};
/* 执行自动保存 */
Scene_Base.prototype.executeAutosave = function() {
$gameSystem.onBeforeSave();
DataManager.saveGame(0)
.then(() => this.onAutosaveSuccess())
.catch(() => this.onAutosaveFailure());
};
/* 当自动保存成功 */
Scene_Base.prototype.onAutosaveSuccess = function() {
//
};
/* 当自动保存失败 */
Scene_Base.prototype.onAutosaveFailure = function() {
//
};
//-----------------------------------------------------------------------------
// 场景_启动
// Scene_Boot
//
// 初始化整个游戏的场景类。
// The scene class for initializing the entire game.
function Scene_Boot() {
this.initialize(...arguments);
}
Scene_Boot.prototype = Object.create(Scene_Base.prototype);
Scene_Boot.prototype.constructor = Scene_Boot;
/* 初始化 */
Scene_Boot.prototype.initialize = function() {
Scene_Base.prototype.initialize.call(this);
this._databaseLoaded = false;
};
/* 创建 */
Scene_Boot.prototype.create = function() {
Scene_Base.prototype.create.call(this);
DataManager.loadDatabase();
StorageManager.updateForageKeys();
};
/* 是否准备好 */
Scene_Boot.prototype.isReady = function() {
if (!this._databaseLoaded) {
if (
DataManager.isDatabaseLoaded() &&
StorageManager.forageKeysUpdated()
) {
this._databaseLoaded = true;
this.onDatabaseLoaded();
}
return false;
}
return Scene_Base.prototype.isReady.call(this) && this.isPlayerDataLoaded();
};
/* 当数据库加载完 */
Scene_Boot.prototype.onDatabaseLoaded = function() {
this.setEncryptionInfo();
this.loadSystemImages();
this.loadPlayerData();
this.loadGameFonts();
};
/* 设置加密信息 */
Scene_Boot.prototype.setEncryptionInfo = function() {
const hasImages = $dataSystem.hasEncryptedImages;
const hasAudio = $dataSystem.hasEncryptedAudio;
const key = $dataSystem.encryptionKey;
Utils.setEncryptionInfo(hasImages, hasAudio, key);
};
/* 加载系统图像 */
Scene_Boot.prototype.loadSystemImages = function() {
ColorManager.loadWindowskin();
ImageManager.loadSystem("IconSet");
};
/* 加载玩家数据 */
Scene_Boot.prototype.loadPlayerData = function() {
DataManager.loadGlobalInfo();
ConfigManager.load();
};
/* 加载游戏字体 */
Scene_Boot.prototype.loadGameFonts = function() {
const advanced = $dataSystem.advanced;
FontManager.load("rmmz-mainfont", advanced.mainFontFilename);
FontManager.load("rmmz-numberfont", advanced.numberFontFilename);
};
/* 是否玩家数据加载了 */
Scene_Boot.prototype.isPlayerDataLoaded = function() {
return DataManager.isGlobalInfoLoaded() && ConfigManager.isLoaded();
};
/* 开始 */
Scene_Boot.prototype.start = function() {
Scene_Base.prototype.start.call(this);
SoundManager.preloadImportantSounds();
if (DataManager.isBattleTest()) {
DataManager.setupBattleTest();
SceneManager.goto(Scene_Battle);
} else if (DataManager.isEventTest()) {
DataManager.setupEventTest();
SceneManager.goto(Scene_Map);
} else {
this.startNormalGame();
}
this.resizeScreen();
this.updateDocumentTitle();
};
/* 开始普通游戏 */
Scene_Boot.prototype.startNormalGame = function() {
this.checkPlayerLocation();
DataManager.setupNewGame();
SceneManager.goto(Scene_Title);
Window_TitleCommand.initCommandPosition();
};
/* 改变画面大小 */
Scene_Boot.prototype.resizeScreen = function() {
const screenWidth = $dataSystem.advanced.screenWidth;
const screenHeight = $dataSystem.advanced.screenHeight;
Graphics.resize(screenWidth, screenHeight);
this.adjustBoxSize();
this.adjustWindow();
};
/* 自适应框尺寸 */
Scene_Boot.prototype.adjustBoxSize = function() {
const uiAreaWidth = $dataSystem.advanced.uiAreaWidth;
const uiAreaHeight = $dataSystem.advanced.uiAreaHeight;
const boxMargin = 4;
Graphics.boxWidth = uiAreaWidth - boxMargin * 2;
Graphics.boxHeight = uiAreaHeight - boxMargin * 2;
};
/* 自适应窗口*/
Scene_Boot.prototype.adjustWindow = function() {
if (Utils.isNwjs()) {
const xDelta = Graphics.width - window.innerWidth;
const yDelta = Graphics.height - window.innerHeight;
window.moveBy(-xDelta / 2, -yDelta / 2);
window.resizeBy(xDelta, yDelta);
}
};
/* 更新文档标题 */
Scene_Boot.prototype.updateDocumentTitle = function() {
document.title = $dataSystem.gameTitle;
};
/* 检测玩家位置 */
Scene_Boot.prototype.checkPlayerLocation = function() {
if ($dataSystem.startMapId === 0) {
throw new Error("Player's starting position is not set");
}
};
//-----------------------------------------------------------------------------
// 场景_标题
// Scene_Title
//
// 标题场景的场景类。
// The scene class of the title screen.
function Scene_Title() {
this.initialize(...arguments);
}
Scene_Title.prototype = Object.create(Scene_Base.prototype);
Scene_Title.prototype.constructor = Scene_Title;
/* 初始化 */
Scene_Title.prototype.initialize = function() {
Scene_Base.prototype.initialize.call(this);
};
/* 创建 */
Scene_Title.prototype.create = function() {
Scene_Base.prototype.create.call(this);
this.createBackground();
this.createForeground();
this.createWindowLayer();
this.createCommandWindow();
};
/* 开始 */
Scene_Title.prototype.start = function() {
Scene_Base.prototype.start.call(this);
SceneManager.clearStack();
this.adjustBackground();
this.playTitleMusic();
this.startFadeIn(this.fadeSpeed(), false);
};
/* 更新 */
Scene_Title.prototype.update = function() {
if (!this.isBusy()) {
this._commandWindow.open();
}
Scene_Base.prototype.update.call(this);
};
/* 是否繁忙 */
Scene_Title.prototype.isBusy = function() {
return (
this._commandWindow.isClosing() ||
Scene_Base.prototype.isBusy.call(this)
);
};
/* 结束 */
Scene_Title.prototype.terminate = function() {
Scene_Base.prototype.terminate.call(this);
SceneManager.snapForBackground();
if (this._gameTitleSprite) {
this._gameTitleSprite.bitmap.destroy();
}
};
/* 创建背景 */
Scene_Title.prototype.createBackground = function() {
this._backSprite1 = new Sprite(
ImageManager.loadTitle1($dataSystem.title1Name)
);
this._backSprite2 = new Sprite(
ImageManager.loadTitle2($dataSystem.title2Name)
);
this.addChild(this._backSprite1);
this.addChild(this._backSprite2);
};
/* 创建前景 */
Scene_Title.prototype.createForeground = function() {
this._gameTitleSprite = new Sprite(
new Bitmap(Graphics.width, Graphics.height)
);
this.addChild(this._gameTitleSprite);
if ($dataSystem.optDrawTitle) {
this.drawGameTitle();
}
};
/* 绘制游戏标题 */
Scene_Title.prototype.drawGameTitle = function() {
const x = 20;
const y = Graphics.height / 4;
const maxWidth = Graphics.width - x * 2;
const text = $dataSystem.gameTitle;
const bitmap = this._gameTitleSprite.bitmap;
bitmap.fontFace = $gameSystem.mainFontFace();
bitmap.outlineColor = "black";
bitmap.outlineWidth = 8;
bitmap.fontSize = 72;
bitmap.drawText(text, x, y, maxWidth, 48, "center");
};
/* 自适应背景 */
Scene_Title.prototype.adjustBackground = function() {
this.scaleSprite(this._backSprite1);
this.scaleSprite(this._backSprite2);
this.centerSprite(this._backSprite1);
this.centerSprite(this._backSprite2);
};
/* 创建指令窗口 */
Scene_Title.prototype.createCommandWindow = function() {
const background = $dataSystem.titleCommandWindow.background;
const rect = this.commandWindowRect();
this._commandWindow = new Window_TitleCommand(rect);
this._commandWindow.setBackgroundType(background);
this._commandWindow.setHandler("newGame", this.commandNewGame.bind(this));
this._commandWindow.setHandler("continue", this.commandContinue.bind(this));
this._commandWindow.setHandler("options", this.commandOptions.bind(this));
this.addWindow(this._commandWindow);
};
/* 指令窗口矩形区域 */
Scene_Title.prototype.commandWindowRect = function() {
const offsetX = $dataSystem.titleCommandWindow.offsetX;
const offsetY = $dataSystem.titleCommandWindow.offsetY;
const ww = this.mainCommandWidth();
const wh = this.calcWindowHeight(3, true);
const wx = (Graphics.boxWidth - ww) / 2 + offsetX;
const wy = Graphics.boxHeight - wh - 96 + offsetY;
return new Rectangle(wx, wy, ww, wh);
};
/* 重新开始的指令 */
Scene_Title.prototype.commandNewGame = function() {
DataManager.setupNewGame();
this._commandWindow.close();
this.fadeOutAll();
SceneManager.goto(Scene_Map);
};
/* 继续游戏的指令 */
Scene_Title.prototype.commandContinue = function() {
this._commandWindow.close();
SceneManager.push(Scene_Load);
};
/* 选项的指令 */
Scene_Title.prototype.commandOptions = function() {
this._commandWindow.close();
SceneManager.push(Scene_Options);
};
/* 播放标题音乐 */
Scene_Title.prototype.playTitleMusic = function() {
AudioManager.playBgm($dataSystem.titleBgm);
AudioManager.stopBgs();
AudioManager.stopMe();
};
//-----------------------------------------------------------------------------
// 游戏信息
// Scene_Message
//
// Scene_Map 和 Scene_Battle 的父类。
// The superclass of Scene_Map and Scene_Battle.
function Scene_Message() {
this.initialize(...arguments);
}
Scene_Message.prototype = Object.create(Scene_Base.prototype);
Scene_Message.prototype.constructor = Scene_Message;
/* 初始化 */
Scene_Message.prototype.initialize = function() {
Scene_Base.prototype.initialize.call(this);
};
/* 是否信息窗口关闭中 */
Scene_Message.prototype.isMessageWindowClosing = function() {
return this._messageWindow.isClosing();
};
/* 创建所有窗口 */
Scene_Message.prototype.createAllWindows = function() {
this.createMessageWindow();
this.createScrollTextWindow();
this.createGoldWindow();
this.createNameBoxWindow();
this.createChoiceListWindow();
this.createNumberInputWindow();
this.createEventItemWindow();
this.associateWindows();
};
/* 创建信息窗口 */
Scene_Message.prototype.createMessageWindow = function() {
const rect = this.messageWindowRect();
this._messageWindow = new Window_Message(rect);
this.addWindow(this._messageWindow);
};
/* 信息窗口矩形区域 */
Scene_Message.prototype.messageWindowRect = function() {
const ww = Graphics.boxWidth;
const wh = this.calcWindowHeight(4, false) + 8;
const wx = (Graphics.boxWidth - ww) / 2;
const wy = 0;
return new Rectangle(wx, wy, ww, wh);
};
/* 创建滚动文本窗口 */
Scene_Message.prototype.createScrollTextWindow = function() {
const rect = this.scrollTextWindowRect();
this._scrollTextWindow = new Window_ScrollText(rect);
this.addWindow(this._scrollTextWindow);
};
/* 滚动文本窗口矩形区域 */
Scene_Message.prototype.scrollTextWindowRect = function() {
const wx = 0;
const wy = 0;
const ww = Graphics.boxWidth;
const wh = Graphics.boxHeight;
return new Rectangle(wx, wy, ww, wh);
};
/* 创建金钱窗口 */
Scene_Message.prototype.createGoldWindow = function() {
const rect = this.goldWindowRect();
this._goldWindow = new Window_Gold(rect);
this._goldWindow.openness = 0;
this.addWindow(this._goldWindow);
};
/* 金钱窗口矩形区域 */
Scene_Message.prototype.goldWindowRect = function() {
const ww = this.mainCommandWidth();
const wh = this.calcWindowHeight(1, true);
const wx = Graphics.boxWidth - ww;
const wy = 0;
return new Rectangle(wx, wy, ww, wh);
};
/* 创建名字框窗口 */
Scene_Message.prototype.createNameBoxWindow = function() {
this._nameBoxWindow = new Window_NameBox();
this.addWindow(this._nameBoxWindow);
};
/* 创建选项列表窗口 */
Scene_Message.prototype.createChoiceListWindow = function() {
this._choiceListWindow = new Window_ChoiceList();
this.addWindow(this._choiceListWindow);
};
/* 创建数值输入窗口 */
Scene_Message.prototype.createNumberInputWindow = function() {
this._numberInputWindow = new Window_NumberInput();
this.addWindow(this._numberInputWindow);
};
/* 创建事件物品窗口 */
Scene_Message.prototype.createEventItemWindow = function() {
const rect = this.eventItemWindowRect();
this._eventItemWindow = new Window_EventItem(rect);
this.addWindow(this._eventItemWindow);
};
/* 事件物品表窗口矩形区域 */
Scene_Message.prototype.eventItemWindowRect = function() {
const wx = 0;
const wy = 0;
const ww = Graphics.boxWidth;
const wh = this.calcWindowHeight(4, true);
return new Rectangle(wx, wy, ww, wh);
};
/* 关联窗口 */
Scene_Message.prototype.associateWindows = function() {
const messageWindow = this._messageWindow;
messageWindow.setGoldWindow(this._goldWindow);
messageWindow.setNameBoxWindow(this._nameBoxWindow);
messageWindow.setChoiceListWindow(this._choiceListWindow);
messageWindow.setNumberInputWindow(this._numberInputWindow);
messageWindow.setEventItemWindow(this._eventItemWindow);
this._nameBoxWindow.setMessageWindow(messageWindow);
this._choiceListWindow.setMessageWindow(messageWindow);
this._numberInputWindow.setMessageWindow(messageWindow);
this._eventItemWindow.setMessageWindow(messageWindow);
};
//-----------------------------------------------------------------------------
// 场景_地图
// Scene_Map
//
// 地图场景的场景类。
// The scene class of the map screen.
function Scene_Map() {
this.initialize(...arguments);
}
Scene_Map.prototype = Object.create(Scene_Message.prototype);
Scene_Map.prototype.constructor = Scene_Map;
/* 初始化 */
Scene_Map.prototype.initialize = function() {
Scene_Message.prototype.initialize.call(this);
this._waitCount = 0;
this._encounterEffectDuration = 0;
this._mapLoaded = false;
this._touchCount = 0;
this._menuEnabled = false;
};
/* 创建 */
Scene_Map.prototype.create = function() {
Scene_Message.prototype.create.call(this);
this._transfer = $gamePlayer.isTransferring();
this._lastMapWasNull = !$dataMap;
if (this._transfer) {
DataManager.loadMapData($gamePlayer.newMapId());
this.onTransfer();
} else if (!$dataMap || $dataMap.id !== $gameMap.mapId()) {
DataManager.loadMapData($gameMap.mapId());
}
};
/* 是否准备好 */
Scene_Map.prototype.isReady = function() {
if (!this._mapLoaded && DataManager.isMapLoaded()) {
this.onMapLoaded();
this._mapLoaded = true;
}
return this._mapLoaded && Scene_Message.prototype.isReady.call(this);
};
/* 当地图加载完 */
Scene_Map.prototype.onMapLoaded = function() {
if (this._transfer) {
$gamePlayer.performTransfer();
}
this.createDisplayObjects();
};
/* 当传送 */
Scene_Map.prototype.onTransfer = function() {
ImageManager.clear();
EffectManager.clear();
};
/* 开始 */
Scene_Map.prototype.start = function() {
Scene_Message.prototype.start.call(this);
SceneManager.clearStack();
if (this._transfer) {
this.fadeInForTransfer();
this.onTransferEnd();
} else if (this.needsFadeIn()) {
this.startFadeIn(this.fadeSpeed(), false);
}
this.menuCalling = false;
};
/* 当传送完 */
Scene_Map.prototype.onTransferEnd = function() {
this._mapNameWindow.open();
$gameMap.autoplay();
if (this.shouldAutosave()) {
this.requestAutosave();
}
};
/* 是否应该自动保存 */
Scene_Map.prototype.shouldAutosave = function() {
return !this._lastMapWasNull;
};
/* 更新 */
Scene_Map.prototype.update = function() {
Scene_Message.prototype.update.call(this);
this.updateDestination();
this.updateMenuButton();
this.updateMapNameWindow();
this.updateMainMultiply();
if (this.isSceneChangeOk()) {
this.updateScene();
} else if (SceneManager.isNextScene(Scene_Battle)) {
this.updateEncounterEffect();
}
this.updateWaitCount();
};
/* 加倍更新主函数
* 一帧内执行两次,即帧率翻倍。
*/
Scene_Map.prototype.updateMainMultiply = function() {
if (this.isFastForward()) {
this.updateMain();
}
this.updateMain();
};
/* 更新主函数 */
Scene_Map.prototype.updateMain = function() {
$gameMap.update(this.isActive());
$gamePlayer.update(this.isPlayerActive());
$gameTimer.update(this.isActive());
$gameScreen.update();
};
/* 是否玩家活动的 */
Scene_Map.prototype.isPlayerActive = function() {
return this.isActive() && !this.isFading();
};
/* 是否快进 */
Scene_Map.prototype.isFastForward = function() {
return (
$gameMap.isEventRunning() &&
!SceneManager.isSceneChanging() &&
(Input.isLongPressed("ok") || TouchInput.isLongPressed())
);
};
/* 停止 */
Scene_Map.prototype.stop = function() {
Scene_Message.prototype.stop.call(this);
$gamePlayer.straighten();
this._mapNameWindow.close();
if (this.needsSlowFadeOut()) {
this.startFadeOut(this.slowFadeSpeed(), false);
} else if (SceneManager.isNextScene(Scene_Map)) {
this.fadeOutForTransfer();
} else if (SceneManager.isNextScene(Scene_Battle)) {
this.launchBattle();
}
};
/* 是否繁忙 */
Scene_Map.prototype.isBusy = function() {
return (
this.isMessageWindowClosing() ||
this._waitCount > 0 ||
this._encounterEffectDuration > 0 ||
Scene_Message.prototype.isBusy.call(this)
);
};
/* 结束 */
Scene_Map.prototype.terminate = function() {
Scene_Message.prototype.terminate.call(this);
if (!SceneManager.isNextScene(Scene_Battle)) {
this._spriteset.update();
this._mapNameWindow.hide();
this.hideMenuButton();
SceneManager.snapForBackground();
}
$gameScreen.clearZoom();
};
/* 是否需要淡入 */
Scene_Map.prototype.needsFadeIn = function() {
return (
SceneManager.isPreviousScene(Scene_Battle) ||
SceneManager.isPreviousScene(Scene_Load)
);
};
/* 是否需要缓慢淡出 */
Scene_Map.prototype.needsSlowFadeOut = function() {
return (
SceneManager.isNextScene(Scene_Title) ||
SceneManager.isNextScene(Scene_Gameover)
);
};
/* 更新等待计数 */
Scene_Map.prototype.updateWaitCount = function() {
if (this._waitCount > 0) {
this._waitCount--;
return true;
}
return false;
};
/* 更新目的地 */
Scene_Map.prototype.updateDestination = function() {
if (this.isMapTouchOk()) {
this.processMapTouch();
} else {
$gameTemp.clearDestination();
this._touchCount = 0;
}
};
/* 更新菜单按钮 */
Scene_Map.prototype.updateMenuButton = function() {
if (this._menuButton) {
const menuEnabled = this.isMenuEnabled();
if (menuEnabled === this._menuEnabled) {
this._menuButton.visible = this._menuEnabled;
} else {
this._menuEnabled = menuEnabled;
}
}
};
/* 隐藏菜单按钮 */
Scene_Map.prototype.hideMenuButton = function() {
if (this._menuButton) {
this._menuButton.visible = false;
this._menuEnabled = false;
}
};
/* 更新地图名字窗口 */
Scene_Map.prototype.updateMapNameWindow = function() {
if ($gameMessage.isBusy()) {
this._mapNameWindow.close();
}
};
/* 是否菜单启用 */
Scene_Map.prototype.isMenuEnabled = function() {
return $gameSystem.isMenuEnabled() && !$gameMap.isEventRunning();
};
/* 是否地图可以触摸 */
Scene_Map.prototype.isMapTouchOk = function() {
return this.isActive() && $gamePlayer.canMove();
};
/* 处理地图触摸 */
Scene_Map.prototype.processMapTouch = function() {
if (TouchInput.isTriggered() || this._touchCount > 0) {
if (TouchInput.isPressed() && !this.isAnyButtonPressed()) {
if (this._touchCount === 0 || this._touchCount >= 15) {
this.onMapTouch();
}
this._touchCount++;
} else {
this._touchCount = 0;
}
}
};
/* 是否有按钮按下 */
Scene_Map.prototype.isAnyButtonPressed = function() {
return this._menuButton && this._menuButton.isPressed();
};
/* 当地图触摸 */
Scene_Map.prototype.onMapTouch = function() {
const x = $gameMap.canvasToMapX(TouchInput.x);
const y = $gameMap.canvasToMapY(TouchInput.y);
$gameTemp.setDestination(x, y);
};
/* 是否场景切换好了 */
Scene_Map.prototype.isSceneChangeOk = function() {
return this.isActive() && !$gameMessage.isBusy();
};
/* 更新场景 */
Scene_Map.prototype.updateScene = function() {
this.checkGameover();
if (!SceneManager.isSceneChanging()) {
this.updateTransferPlayer();
}
if (!SceneManager.isSceneChanging()) {
this.updateEncounter();
}
if (!SceneManager.isSceneChanging()) {
this.updateCallMenu();
}
if (!SceneManager.isSceneChanging()) {
this.updateCallDebug();
}
};
/* 创建显示对象 */
Scene_Map.prototype.createDisplayObjects = function() {
this.createSpriteset();
this.createWindowLayer();
this.createAllWindows();
this.createButtons();
};
/* 创建精灵组 */
Scene_Map.prototype.createSpriteset = function() {
this._spriteset = new Spriteset_Map();
this.addChild(this._spriteset);
this._spriteset.update();
};
/* 创建所有窗口 */
Scene_Map.prototype.createAllWindows = function() {
this.createMapNameWindow();
Scene_Message.prototype.createAllWindows.call(this);
};
/* 创建地图名字窗口 */
Scene_Map.prototype.createMapNameWindow = function() {
const rect = this.mapNameWindowRect();
this._mapNameWindow = new Window_MapName(rect);
this.addWindow(this._mapNameWindow);
};
/* 地图名字窗口矩形区域 */
Scene_Map.prototype.mapNameWindowRect = function() {
const wx = 0;
const wy = 0;
const ww = 360;
const wh = this.calcWindowHeight(1, false);
return new Rectangle(wx, wy, ww, wh);
};
/* 创建按钮 */
Scene_Map.prototype.createButtons = function() {
if (ConfigManager.touchUI) {
this.createMenuButton();
}
};
/* 创建菜单按钮 */
Scene_Map.prototype.createMenuButton = function() {
this._menuButton = new Sprite_Button("menu");
this._menuButton.x = Graphics.boxWidth - this._menuButton.width - 4;
this._menuButton.y = this.buttonY();
this._menuButton.visible = false;
this.addWindow(this._menuButton);
};
/* 更新传送玩家 */
Scene_Map.prototype.updateTransferPlayer = function() {
if ($gamePlayer.isTransferring()) {
SceneManager.goto(Scene_Map);
}
};
/* 更新遇敌 */
Scene_Map.prototype.updateEncounter = function() {
if ($gamePlayer.executeEncounter()) {
SceneManager.push(Scene_Battle);
}
};
/* 更新呼叫菜单 */
Scene_Map.prototype.updateCallMenu = function() {
if (this.isMenuEnabled()) {
if (this.isMenuCalled()) {
this.menuCalling = true;
}
if (this.menuCalling && !$gamePlayer.isMoving()) {
this.callMenu();
}
} else {
this.menuCalling = false;
}
};
/* 是否菜单被呼叫 */
Scene_Map.prototype.isMenuCalled = function() {
return Input.isTriggered("menu") || TouchInput.isCancelled();
};
/* 呼叫菜单 */
Scene_Map.prototype.callMenu = function() {
SoundManager.playOk();
SceneManager.push(Scene_Menu);
Window_MenuCommand.initCommandPosition();
$gameTemp.clearDestination();
this._mapNameWindow.hide();
this._waitCount = 2;
};
/* 更新呼叫调式 */
Scene_Map.prototype.updateCallDebug = function() {
if (this.isDebugCalled()) {
SceneManager.push(Scene_Debug);
}
};
/* 是否调式被呼叫 */
Scene_Map.prototype.isDebugCalled = function() {
return Input.isTriggered("debug") && $gameTemp.isPlaytest();
};
/* 淡入传送 */
Scene_Map.prototype.fadeInForTransfer = function() {
const fadeType = $gamePlayer.fadeType();
switch (fadeType) {
case 0:
case 1:
this.startFadeIn(this.fadeSpeed(), fadeType === 1);
break;
}
};
/* 淡出传送 */
Scene_Map.prototype.fadeOutForTransfer = function() {
const fadeType = $gamePlayer.fadeType();
switch (fadeType) {
case 0:
case 1:
this.startFadeOut(this.fadeSpeed(), fadeType === 1);
break;
}
};
/* 发起战斗 */
Scene_Map.prototype.launchBattle = function() {
BattleManager.saveBgmAndBgs();
this.stopAudioOnBattleStart();
SoundManager.playBattleStart();
this.startEncounterEffect();
this._mapNameWindow.hide();
};
/* 当战斗开始停止音频 */
Scene_Map.prototype.stopAudioOnBattleStart = function() {
if (!AudioManager.isCurrentBgm($gameSystem.battleBgm())) {
AudioManager.stopBgm();
}
AudioManager.stopBgs();
AudioManager.stopMe();
AudioManager.stopSe();
};
/* 开始遇敌效果 */
Scene_Map.prototype.startEncounterEffect = function() {
this._spriteset.hideCharacters();
this._encounterEffectDuration = this.encounterEffectSpeed();
};
/* 更新遇敌效果 */
Scene_Map.prototype.updateEncounterEffect = function() {
if (this._encounterEffectDuration > 0) {
this._encounterEffectDuration--;
const speed = this.encounterEffectSpeed();
const n = speed - this._encounterEffectDuration;
const p = n / speed;
const q = ((p - 1) * 20 * p + 5) * p + 1;
const zoomX = $gamePlayer.screenX();
const zoomY = $gamePlayer.screenY() - 24;
if (n === 2) {
$gameScreen.setZoom(zoomX, zoomY, 1);
this.snapForBattleBackground();
this.startFlashForEncounter(speed / 2);
}
$gameScreen.setZoom(zoomX, zoomY, q);
if (n === Math.floor(speed / 6)) {
this.startFlashForEncounter(speed / 2);
}
if (n === Math.floor(speed / 2)) {
BattleManager.playBattleBgm();
this.startFadeOut(this.fadeSpeed());
}
}
};
/* 快照作为战斗背景 */
Scene_Map.prototype.snapForBattleBackground = function() {
this._windowLayer.visible = false;
SceneManager.snapForBackground();
this._windowLayer.visible = true;
};
/* 遇敌开始闪烁 */
Scene_Map.prototype.startFlashForEncounter = function(duration) {
const color = [255, 255, 255, 255];
$gameScreen.startFlash(color, duration);
};
/* 遇敌效果速度 */
Scene_Map.prototype.encounterEffectSpeed = function() {
return 60;
};
//-----------------------------------------------------------------------------
// 场景_菜单基础
// Scene_MenuBase
//
// 所有菜单类型场景的父类。
// The superclass of all the menu-type scenes.
function Scene_MenuBase() {
this.initialize(...arguments);
}
Scene_MenuBase.prototype = Object.create(Scene_Base.prototype);
Scene_MenuBase.prototype.constructor = Scene_MenuBase;
/* 初始化 */
Scene_MenuBase.prototype.initialize = function() {
Scene_Base.prototype.initialize.call(this);
};
/* 创建 */
Scene_MenuBase.prototype.create = function() {
Scene_Base.prototype.create.call(this);
this.createBackground();
this.updateActor();
this.createWindowLayer();
this.createButtons();
};
/* 更新 */
Scene_MenuBase.prototype.update = function() {
Scene_Base.prototype.update.call(this);
this.updatePageButtons();
};
/* 帮助区域顶部 */
Scene_MenuBase.prototype.helpAreaTop = function() {
if (this.isBottomHelpMode()) {
return this.mainAreaBottom();
} else if (this.isBottomButtonMode()) {
return 0;
} else {
return this.buttonAreaBottom();
}
};
/* 帮助区域底部 */
Scene_MenuBase.prototype.helpAreaBottom = function() {
return this.helpAreaTop() + this.helpAreaHeight();
};
/* 帮助区域高度 */
Scene_MenuBase.prototype.helpAreaHeight = function() {
return this.calcWindowHeight(2, false);
};
/* 主区域顶部 */
Scene_MenuBase.prototype.mainAreaTop = function() {
if (!this.isBottomHelpMode()) {
return this.helpAreaBottom();
} else if (this.isBottomButtonMode()) {
return 0;
} else {
return this.buttonAreaBottom();
}
};
/* 主区域底部 */
Scene_MenuBase.prototype.mainAreaBottom = function() {
return this.mainAreaTop() + this.mainAreaHeight();
};
/* 主区域高度 */
Scene_MenuBase.prototype.mainAreaHeight = function() {
return Graphics.boxHeight - this.buttonAreaHeight() - this.helpAreaHeight();
};
/* 角色 */
Scene_MenuBase.prototype.actor = function() {
return this._actor;
};
/* 更新角色 */
Scene_MenuBase.prototype.updateActor = function() {
this._actor = $gameParty.menuActor();
};
/* 创建背景 */
Scene_MenuBase.prototype.createBackground = function() {
this._backgroundFilter = new PIXI.filters.BlurFilter();
this._backgroundSprite = new Sprite();
this._backgroundSprite.bitmap = SceneManager.backgroundBitmap();
this._backgroundSprite.filters = [this._backgroundFilter];
this.addChild(this._backgroundSprite);
this.setBackgroundOpacity(192);
};
/* 设置背景不透明度 */
Scene_MenuBase.prototype.setBackgroundOpacity = function(opacity) {
this._backgroundSprite.opacity = opacity;
};
/* 创建帮助窗口 */
Scene_MenuBase.prototype.createHelpWindow = function() {
const rect = this.helpWindowRect();
this._helpWindow = new Window_Help(rect);
this.addWindow(this._helpWindow);
};
/* 帮助窗口矩形区域 */
Scene_MenuBase.prototype.helpWindowRect = function() {
const wx = 0;
const wy = this.helpAreaTop();
const ww = Graphics.boxWidth;
const wh = this.helpAreaHeight();
return new Rectangle(wx, wy, ww, wh);
};
/* 创建按钮 */
Scene_MenuBase.prototype.createButtons = function() {
if (ConfigManager.touchUI) {
if (this.needsCancelButton()) {
this.createCancelButton();
}
if (this.needsPageButtons()) {
this.createPageButtons();
}
}
};
/* 是否需要取消按钮 */
Scene_MenuBase.prototype.needsCancelButton = function() {
return true;
};
/* 创建取消按钮 */
Scene_MenuBase.prototype.createCancelButton = function() {
this._cancelButton = new Sprite_Button("cancel");
this._cancelButton.x = Graphics.boxWidth - this._cancelButton.width - 4;
this._cancelButton.y = this.buttonY();
this.addWindow(this._cancelButton);
};
/* 是否需要翻页按钮 */
Scene_MenuBase.prototype.needsPageButtons = function() {
return false;
};
/* 创建翻页按钮 */
Scene_MenuBase.prototype.createPageButtons = function() {
this._pageupButton = new Sprite_Button("pageup");
this._pageupButton.x = 4;
this._pageupButton.y = this.buttonY();
const pageupRight = this._pageupButton.x + this._pageupButton.width;
this._pagedownButton = new Sprite_Button("pagedown");
this._pagedownButton.x = pageupRight + 4;
this._pagedownButton.y = this.buttonY();
this.addWindow(this._pageupButton);
this.addWindow(this._pagedownButton);
this._pageupButton.setClickHandler(this.previousActor.bind(this));
this._pagedownButton.setClickHandler(this.nextActor.bind(this));
};
/* 更新翻页按钮 */
Scene_MenuBase.prototype.updatePageButtons = function() {
if (this._pageupButton && this._pagedownButton) {
const enabled = this.arePageButtonsEnabled();
this._pageupButton.visible = enabled;
this._pagedownButton.visible = enabled;
}
};
/* 是否翻页按钮启用 */
Scene_MenuBase.prototype.arePageButtonsEnabled = function() {
return true;
};
/* 下一个角色 */
Scene_MenuBase.prototype.nextActor = function() {
$gameParty.makeMenuActorNext();
this.updateActor();
this.onActorChange();
};
/* 上一个角色 */
Scene_MenuBase.prototype.previousActor = function() {
$gameParty.makeMenuActorPrevious();
this.updateActor();
this.onActorChange();
};
/* 当角色改变 */
Scene_MenuBase.prototype.onActorChange = function() {
SoundManager.playCursor();
};
//-----------------------------------------------------------------------------
// 场景_菜单
// Scene_Menu
//
// 菜单画面的场景类。
// The scene class of the menu screen.
function Scene_Menu() {
this.initialize(...arguments);
}
Scene_Menu.prototype = Object.create(Scene_MenuBase.prototype);
Scene_Menu.prototype.constructor = Scene_Menu;
/* 初始化 */
Scene_Menu.prototype.initialize = function() {
Scene_MenuBase.prototype.initialize.call(this);
};
/* 帮助区域高度 */
Scene_Menu.prototype.helpAreaHeight = function() {
return 0;
};
/* 创建 */
Scene_Menu.prototype.create = function() {
Scene_MenuBase.prototype.create.call(this);
this.createCommandWindow();
this.createGoldWindow();
this.createStatusWindow();
};
/* 开始 */
Scene_Menu.prototype.start = function() {
Scene_MenuBase.prototype.start.call(this);
this._statusWindow.refresh();
};
/* 创建指令窗口 */
Scene_Menu.prototype.createCommandWindow = function() {
const rect = this.commandWindowRect();
const commandWindow = new Window_MenuCommand(rect);
commandWindow.setHandler("item", this.commandItem.bind(this));
commandWindow.setHandler("skill", this.commandPersonal.bind(this));
commandWindow.setHandler("equip", this.commandPersonal.bind(this));
commandWindow.setHandler("status", this.commandPersonal.bind(this));
commandWindow.setHandler("formation", this.commandFormation.bind(this));
commandWindow.setHandler("options", this.commandOptions.bind(this));
commandWindow.setHandler("save", this.commandSave.bind(this));
commandWindow.setHandler("gameEnd", this.commandGameEnd.bind(this));
commandWindow.setHandler("cancel", this.popScene.bind(this));
this.addWindow(commandWindow);
this._commandWindow = commandWindow;
};
/* 指令窗口矩形区域 */
Scene_Menu.prototype.commandWindowRect = function() {
const ww = this.mainCommandWidth();
const wh = this.mainAreaHeight() - this.goldWindowRect().height;
const wx = this.isRightInputMode() ? Graphics.boxWidth - ww : 0;
const wy = this.mainAreaTop();
return new Rectangle(wx, wy, ww, wh);
};
/* 创建金钱窗口 */
Scene_Menu.prototype.createGoldWindow = function() {
const rect = this.goldWindowRect();
this._goldWindow = new Window_Gold(rect);
this.addWindow(this._goldWindow);
};
/* 金钱窗口矩形区域 */
Scene_Menu.prototype.goldWindowRect = function() {
const ww = this.mainCommandWidth();
const wh = this.calcWindowHeight(1, true);
const wx = this.isRightInputMode() ? Graphics.boxWidth - ww : 0;
const wy = this.mainAreaBottom() - wh;
return new Rectangle(wx, wy, ww, wh);
};
/* 创建状态窗口 */
Scene_Menu.prototype.createStatusWindow = function() {
const rect = this.statusWindowRect();
this._statusWindow = new Window_MenuStatus(rect);
this.addWindow(this._statusWindow);
};
/* 状态窗口矩形区域 */
Scene_Menu.prototype.statusWindowRect = function() {
const ww = Graphics.boxWidth - this.mainCommandWidth();
const wh = this.mainAreaHeight();
const wx = this.isRightInputMode() ? 0 : Graphics.boxWidth - ww;
const wy = this.mainAreaTop();
return new Rectangle(wx, wy, ww, wh);
};
/* 物品的指令 */
Scene_Menu.prototype.commandItem = function() {
SceneManager.push(Scene_Item);
};
/* 个人的指令 */
Scene_Menu.prototype.commandPersonal = function() {
this._statusWindow.setFormationMode(false);
this._statusWindow.selectLast();
this._statusWindow.activate();
this._statusWindow.setHandler("ok", this.onPersonalOk.bind(this));
this._statusWindow.setHandler("cancel", this.onPersonalCancel.bind(this));
};
/* 整队的指令 */
Scene_Menu.prototype.commandFormation = function() {
this._statusWindow.setFormationMode(true);
this._statusWindow.selectLast();
this._statusWindow.activate();
this._statusWindow.setHandler("ok", this.onFormationOk.bind(this));
this._statusWindow.setHandler("cancel", this.onFormationCancel.bind(this));
};
/* 选项的指令 */
Scene_Menu.prototype.commandOptions = function() {
SceneManager.push(Scene_Options);
};
/* 存档的指令 */
Scene_Menu.prototype.commandSave = function() {
SceneManager.push(Scene_Save);
};
/* 游戏结束的指令 */
Scene_Menu.prototype.commandGameEnd = function() {
SceneManager.push(Scene_GameEnd);
};
/* 当个人确定 */
Scene_Menu.prototype.onPersonalOk = function() {
switch (this._commandWindow.currentSymbol()) {
case "skill":
SceneManager.push(Scene_Skill);
break;
case "equip":
SceneManager.push(Scene_Equip);
break;
case "status":
SceneManager.push(Scene_Status);
break;
}
};
/* 当个人取消 */
Scene_Menu.prototype.onPersonalCancel = function() {
this._statusWindow.deselect();
this._commandWindow.activate();
};
/* 当整队确定 */
Scene_Menu.prototype.onFormationOk = function() {
const index = this._statusWindow.index();
const pendingIndex = this._statusWindow.pendingIndex();
if (pendingIndex >= 0) {
$gameParty.swapOrder(index, pendingIndex);
this._statusWindow.setPendingIndex(-1);
this._statusWindow.redrawItem(index);
} else {
this._statusWindow.setPendingIndex(index);
}
this._statusWindow.activate();
};
/* 当整队取消 */
Scene_Menu.prototype.onFormationCancel = function() {
if (this._statusWindow.pendingIndex() >= 0) {
this._statusWindow.setPendingIndex(-1);
this._statusWindow.activate();
} else {
this._statusWindow.deselect();
this._commandWindow.activate();
}
};
//-----------------------------------------------------------------------------
// 场景_项目基础
// Scene_ItemBase
//
// Scene_Item 和 Scene_Skill 的父类。
// The superclass of Scene_Item and Scene_Skill.
function Scene_ItemBase() {
this.initialize(...arguments);
}
Scene_ItemBase.prototype = Object.create(Scene_MenuBase.prototype);
Scene_ItemBase.prototype.constructor = Scene_ItemBase;
/* 初始化 */
Scene_ItemBase.prototype.initialize = function() {
Scene_MenuBase.prototype.initialize.call(this);
};
/* 创建 */
Scene_ItemBase.prototype.create = function() {
Scene_MenuBase.prototype.create.call(this);
};
/* 创建角色窗口 */
Scene_ItemBase.prototype.createActorWindow = function() {
const rect = this.actorWindowRect();
this._actorWindow = new Window_MenuActor(rect);
this._actorWindow.setHandler("ok", this.onActorOk.bind(this));
this._actorWindow.setHandler("cancel", this.onActorCancel.bind(this));
this.addWindow(this._actorWindow);
};
/* 角色窗口矩形区域 */
Scene_ItemBase.prototype.actorWindowRect = function() {
const wx = 0;
const wy = Math.min(this.mainAreaTop(), this.helpAreaTop());
const ww = Graphics.boxWidth - this.mainCommandWidth();
const wh = this.mainAreaHeight() + this.helpAreaHeight();
return new Rectangle(wx, wy, ww, wh);
};
/* 项目 */
Scene_ItemBase.prototype.item = function() {
return this._itemWindow.item();
};
/* 使用者 */
Scene_ItemBase.prototype.user = function() {
return null;
};
/* 是否光标在左边
* 物品场景和技能插件只有两列,所以光标不是左边就是右边,影响使用物品/技能后的角色窗口位置。
*/
Scene_ItemBase.prototype.isCursorLeft = function() {
return this._itemWindow.index() % 2 === 0;
};
/* 显示角色窗口 */
Scene_ItemBase.prototype.showActorWindow = function() {
if (this.isCursorLeft()) {
this._actorWindow.x = Graphics.boxWidth - this._actorWindow.width;
} else {
this._actorWindow.x = 0;
}
this._actorWindow.show();
this._actorWindow.activate();
};
/* 隐藏角色窗口 */
Scene_ItemBase.prototype.hideActorWindow = function() {
this._actorWindow.hide();
this._actorWindow.deactivate();
};
/* 是否角色窗口活动的 */
Scene_ItemBase.prototype.isActorWindowActive = function() {
return this._actorWindow && this._actorWindow.active;
};
/* 当角色确定 */
Scene_ItemBase.prototype.onActorOk = function() {
if (this.canUse()) {
this.useItem();
} else {
SoundManager.playBuzzer();
}
};
/* 当角色取消 */
Scene_ItemBase.prototype.onActorCancel = function() {
this.hideActorWindow();
this.activateItemWindow();
};
/* 确定项目 */
Scene_ItemBase.prototype.determineItem = function() {
const action = new Game_Action(this.user());
const item = this.item();
action.setItemObject(item);
if (action.isForFriend()) {
this.showActorWindow();
this._actorWindow.selectForItem(this.item());
} else {
this.useItem();
this.activateItemWindow();
}
};
/* 使用项目 */
Scene_ItemBase.prototype.useItem = function() {
this.playSeForItem();
this.user().useItem(this.item());
this.applyItem();
this.checkCommonEvent();
this.checkGameover();
this._actorWindow.refresh();
};
/* 激活项目窗口 */
Scene_ItemBase.prototype.activateItemWindow = function() {
this._itemWindow.refresh();
this._itemWindow.activate();
};
/* 项目的目标角色 */
Scene_ItemBase.prototype.itemTargetActors = function() {
const action = new Game_Action(this.user());
action.setItemObject(this.item());
if (!action.isForFriend()) {
return [];
} else if (action.isForAll()) {
return $gameParty.members();
} else {
return [$gameParty.members()[this._actorWindow.index()]];
}
};
/* 是否能使用 */
Scene_ItemBase.prototype.canUse = function() {
const user = this.user();
return user && user.canUse(this.item()) && this.isItemEffectsValid();
};
/* 是否项目效果有效 */
Scene_ItemBase.prototype.isItemEffectsValid = function() {
const action = new Game_Action(this.user());
action.setItemObject(this.item());
return this.itemTargetActors().some(target => action.testApply(target));
};
/* 执行项目 */
Scene_ItemBase.prototype.applyItem = function() {
const action = new Game_Action(this.user());
action.setItemObject(this.item());
for (const target of this.itemTargetActors()) {
for (let i = 0; i < action.numRepeats(); i++) {
action.apply(target);
}
}
action.applyGlobal();
};
/* 检测公共事件 */
Scene_ItemBase.prototype.checkCommonEvent = function() {
if ($gameTemp.isCommonEventReserved()) {
SceneManager.goto(Scene_Map);
}
};
//-----------------------------------------------------------------------------
// 场景_物品
// Scene_Item
//
// 物品画面的场景类。
// The scene class of the item screen.
function Scene_Item() {
this.initialize(...arguments);
}
Scene_Item.prototype = Object.create(Scene_ItemBase.prototype);
Scene_Item.prototype.constructor = Scene_Item;
/* 初始化 */
Scene_Item.prototype.initialize = function() {
Scene_ItemBase.prototype.initialize.call(this);
};
/* 创建 */
Scene_Item.prototype.create = function() {
Scene_ItemBase.prototype.create.call(this);
this.createHelpWindow();
this.createCategoryWindow();
this.createItemWindow();
this.createActorWindow();
};
/* 创建类型窗口 */
Scene_Item.prototype.createCategoryWindow = function() {
const rect = this.categoryWindowRect();
this._categoryWindow = new Window_ItemCategory(rect);
this._categoryWindow.setHelpWindow(this._helpWindow);
this._categoryWindow.setHandler("ok", this.onCategoryOk.bind(this));
this._categoryWindow.setHandler("cancel", this.popScene.bind(this));
this.addWindow(this._categoryWindow);
};
/* 类型窗口矩形区域 */
Scene_Item.prototype.categoryWindowRect = function() {
const wx = 0;
const wy = this.mainAreaTop();
const ww = Graphics.boxWidth;
const wh = this.calcWindowHeight(1, true);
return new Rectangle(wx, wy, ww, wh);
};
/* 创建项目窗口 */
Scene_Item.prototype.createItemWindow = function() {
const rect = this.itemWindowRect();
this._itemWindow = new Window_ItemList(rect);
this._itemWindow.setHelpWindow(this._helpWindow);
this._itemWindow.setHandler("ok", this.onItemOk.bind(this));
this._itemWindow.setHandler("cancel", this.onItemCancel.bind(this));
this.addWindow(this._itemWindow);
this._categoryWindow.setItemWindow(this._itemWindow);
if (!this._categoryWindow.needsSelection()) {
this._itemWindow.y -= this._categoryWindow.height;
this._itemWindow.height += this._categoryWindow.height;
this._categoryWindow.hide();
this._categoryWindow.deactivate();
this.onCategoryOk();
}
};
/* 项目窗口矩形区域 */
Scene_Item.prototype.itemWindowRect = function() {
const wx = 0;
const wy = this._categoryWindow.y + this._categoryWindow.height;
const ww = Graphics.boxWidth;
const wh = this.mainAreaBottom() - wy;
return new Rectangle(wx, wy, ww, wh);
};
/* 使用者 */
Scene_Item.prototype.user = function() {
const members = $gameParty.movableMembers();
const bestPha = Math.max(...members.map(member => member.pha));
return members.find(member => member.pha === bestPha);
};
/* 当类型确定 */
Scene_Item.prototype.onCategoryOk = function() {
this._itemWindow.activate();
this._itemWindow.selectLast();
};
/* 当项目确定 */
Scene_Item.prototype.onItemOk = function() {
$gameParty.setLastItem(this.item());
this.determineItem();
};
/* 当项目取消 */
Scene_Item.prototype.onItemCancel = function() {
if (this._categoryWindow.needsSelection()) {
this._itemWindow.deselect();
this._categoryWindow.activate();
} else {
this.popScene();
}
};
/* 播放项目的音效 */
Scene_Item.prototype.playSeForItem = function() {
SoundManager.playUseItem();
};
/* 使用项目 */
Scene_Item.prototype.useItem = function() {
Scene_ItemBase.prototype.useItem.call(this);
this._itemWindow.redrawCurrentItem();
};
//-----------------------------------------------------------------------------
// 场景_技能
// Scene_Skill
//
// 技能画面的场景类。
// The scene class of the skill screen.
function Scene_Skill() {
this.initialize(...arguments);
}
Scene_Skill.prototype = Object.create(Scene_ItemBase.prototype);
Scene_Skill.prototype.constructor = Scene_Skill;
/* 初始化 */
Scene_Skill.prototype.initialize = function() {
Scene_ItemBase.prototype.initialize.call(this);
};
/* 创建 */
Scene_Skill.prototype.create = function() {
Scene_ItemBase.prototype.create.call(this);
this.createHelpWindow();
this.createSkillTypeWindow();
this.createStatusWindow();
this.createItemWindow();
this.createActorWindow();
};
/* 开始 */
Scene_Skill.prototype.start = function() {
Scene_ItemBase.prototype.start.call(this);
this.refreshActor();
};
/* 创建技能类型窗口 */
Scene_Skill.prototype.createSkillTypeWindow = function() {
const rect = this.skillTypeWindowRect();
this._skillTypeWindow = new Window_SkillType(rect);
this._skillTypeWindow.setHelpWindow(this._helpWindow);
this._skillTypeWindow.setHandler("skill", this.commandSkill.bind(this));
this._skillTypeWindow.setHandler("cancel", this.popScene.bind(this));
this._skillTypeWindow.setHandler("pagedown", this.nextActor.bind(this));
this._skillTypeWindow.setHandler("pageup", this.previousActor.bind(this));
this.addWindow(this._skillTypeWindow);
};
/* 技能类型窗口矩形区域 */
Scene_Skill.prototype.skillTypeWindowRect = function() {
const ww = this.mainCommandWidth();
const wh = this.calcWindowHeight(3, true);
const wx = this.isRightInputMode() ? Graphics.boxWidth - ww : 0;
const wy = this.mainAreaTop();
return new Rectangle(wx, wy, ww, wh);
};
/* 创建状态窗口 */
Scene_Skill.prototype.createStatusWindow = function() {
const rect = this.statusWindowRect();
this._statusWindow = new Window_SkillStatus(rect);
this.addWindow(this._statusWindow);
};
/* 状态窗口矩形区域 */
Scene_Skill.prototype.statusWindowRect = function() {
const ww = Graphics.boxWidth - this.mainCommandWidth();
const wh = this._skillTypeWindow.height;
const wx = this.isRightInputMode() ? 0 : Graphics.boxWidth - ww;
const wy = this.mainAreaTop();
return new Rectangle(wx, wy, ww, wh);
};
/* 创建项目窗口 */
Scene_Skill.prototype.createItemWindow = function() {
const rect = this.itemWindowRect();
this._itemWindow = new Window_SkillList(rect);
this._itemWindow.setHelpWindow(this._helpWindow);
this._itemWindow.setHandler("ok", this.onItemOk.bind(this));
this._itemWindow.setHandler("cancel", this.onItemCancel.bind(this));
this._skillTypeWindow.setSkillWindow(this._itemWindow);
this.addWindow(this._itemWindow);
};
/* 项目窗口矩形区域 */
Scene_Skill.prototype.itemWindowRect = function() {
const wx = 0;
const wy = this._statusWindow.y + this._statusWindow.height;
const ww = Graphics.boxWidth;
const wh = this.mainAreaHeight() - this._statusWindow.height;
return new Rectangle(wx, wy, ww, wh);
};
/* 是否需要翻页按钮 */
Scene_Skill.prototype.needsPageButtons = function() {
return true;
};
/* 是否翻页按钮启用 */
Scene_Skill.prototype.arePageButtonsEnabled = function() {
return !this.isActorWindowActive();
};
/* 刷新角色 */
Scene_Skill.prototype.refreshActor = function() {
const actor = this.actor();
this._skillTypeWindow.setActor(actor);
this._statusWindow.setActor(actor);
this._itemWindow.setActor(actor);
};
/* 使用者 */
Scene_Skill.prototype.user = function() {
return this.actor();
};
/* 技能的指令 */
Scene_Skill.prototype.commandSkill = function() {
this._itemWindow.activate();
this._itemWindow.selectLast();
};
/* 当项目确定 */
Scene_Skill.prototype.onItemOk = function() {
this.actor().setLastMenuSkill(this.item());
this.determineItem();
};
/* 当项目取消 */
Scene_Skill.prototype.onItemCancel = function() {
this._itemWindow.deselect();
this._skillTypeWindow.activate();
};
/* 播放项目的音效 */
Scene_Skill.prototype.playSeForItem = function() {
SoundManager.playUseSkill();
};
/* 使用项目 */
Scene_Skill.prototype.useItem = function() {
Scene_ItemBase.prototype.useItem.call(this);
this._statusWindow.refresh();
this._itemWindow.refresh();
};
/* 当角色改变 */
Scene_Skill.prototype.onActorChange = function() {
Scene_MenuBase.prototype.onActorChange.call(this);
this.refreshActor();
this._itemWindow.deselect();
this._skillTypeWindow.activate();
};
//-----------------------------------------------------------------------------
// 场景_装备
// Scene_Equip
//
// 装备画面的场景类。
// The scene class of the equipment screen.
function Scene_Equip() {
this.initialize(...arguments);
}
Scene_Equip.prototype = Object.create(Scene_MenuBase.prototype);
Scene_Equip.prototype.constructor = Scene_Equip;
/* 初始化 */
Scene_Equip.prototype.initialize = function() {
Scene_MenuBase.prototype.initialize.call(this);
};
/* 创建 */
Scene_Equip.prototype.create = function() {
Scene_MenuBase.prototype.create.call(this);
this.createHelpWindow();
this.createStatusWindow();
this.createCommandWindow();
this.createSlotWindow();
this.createItemWindow();
this.refreshActor();
};
/* 创建状态窗口 */
Scene_Equip.prototype.createStatusWindow = function() {
const rect = this.statusWindowRect();
this._statusWindow = new Window_EquipStatus(rect);
this.addWindow(this._statusWindow);
};
/* 状态窗口矩形区域 */
Scene_Equip.prototype.statusWindowRect = function() {
const wx = 0;
const wy = this.mainAreaTop();
const ww = this.statusWidth();
const wh = this.mainAreaHeight();
return new Rectangle(wx, wy, ww, wh);
};
/* 创建指令窗口 */
Scene_Equip.prototype.createCommandWindow = function() {
const rect = this.commandWindowRect();
this._commandWindow = new Window_EquipCommand(rect);
this._commandWindow.setHelpWindow(this._helpWindow);
this._commandWindow.setHandler("equip", this.commandEquip.bind(this));
this._commandWindow.setHandler("optimize", this.commandOptimize.bind(this));
this._commandWindow.setHandler("clear", this.commandClear.bind(this));
this._commandWindow.setHandler("cancel", this.popScene.bind(this));
this._commandWindow.setHandler("pagedown", this.nextActor.bind(this));
this._commandWindow.setHandler("pageup", this.previousActor.bind(this));
this.addWindow(this._commandWindow);
};
/* 指令窗口矩形区域 */
Scene_Equip.prototype.commandWindowRect = function() {
const wx = this.statusWidth();
const wy = this.mainAreaTop();
const ww = Graphics.boxWidth - this.statusWidth();
const wh = this.calcWindowHeight(1, true);
return new Rectangle(wx, wy, ww, wh);
};
/* 创建插槽窗口 */
Scene_Equip.prototype.createSlotWindow = function() {
const rect = this.slotWindowRect();
this._slotWindow = new Window_EquipSlot(rect);
this._slotWindow.setHelpWindow(this._helpWindow);
this._slotWindow.setStatusWindow(this._statusWindow);
this._slotWindow.setHandler("ok", this.onSlotOk.bind(this));
this._slotWindow.setHandler("cancel", this.onSlotCancel.bind(this));
this.addWindow(this._slotWindow);
};
/* 插槽窗口矩形区域 */
Scene_Equip.prototype.slotWindowRect = function() {
const commandWindowRect = this.commandWindowRect();
const wx = this.statusWidth();
const wy = commandWindowRect.y + commandWindowRect.height;
const ww = Graphics.boxWidth - this.statusWidth();
const wh = this.mainAreaHeight() - commandWindowRect.height;
return new Rectangle(wx, wy, ww, wh);
};
/* 创建项目窗口 */
Scene_Equip.prototype.createItemWindow = function() {
const rect = this.itemWindowRect();
this._itemWindow = new Window_EquipItem(rect);
this._itemWindow.setHelpWindow(this._helpWindow);
this._itemWindow.setStatusWindow(this._statusWindow);
this._itemWindow.setHandler("ok", this.onItemOk.bind(this));
this._itemWindow.setHandler("cancel", this.onItemCancel.bind(this));
this._itemWindow.hide();
this._slotWindow.setItemWindow(this._itemWindow);
this.addWindow(this._itemWindow);
};
/* 项目窗口矩形区域 */
Scene_Equip.prototype.itemWindowRect = function() {
return this.slotWindowRect();
};
/* 状态宽度 */
Scene_Equip.prototype.statusWidth = function() {
return 312;
};
/* 是否需要翻页按钮 */
Scene_Equip.prototype.needsPageButtons = function() {
return true;
};
/* 是否翻页按钮启用 */
Scene_Equip.prototype.arePageButtonsEnabled = function() {
return !(this._itemWindow && this._itemWindow.active);
};
/* 刷新角色 */
Scene_Equip.prototype.refreshActor = function() {
const actor = this.actor();
this._statusWindow.setActor(actor);
this._slotWindow.setActor(actor);
this._itemWindow.setActor(actor);
};
/* 装备的指令 */
Scene_Equip.prototype.commandEquip = function() {
this._slotWindow.activate();
this._slotWindow.select(0);
};
/* 最强装备的指令 */
Scene_Equip.prototype.commandOptimize = function() {
SoundManager.playEquip();
this.actor().optimizeEquipments();
this._statusWindow.refresh();
this._slotWindow.refresh();
this._commandWindow.activate();
};
/* 清空的指令 */
Scene_Equip.prototype.commandClear = function() {
SoundManager.playEquip();
this.actor().clearEquipments();
this._statusWindow.refresh();
this._slotWindow.refresh();
this._commandWindow.activate();
};
/* 当插槽确定 */
Scene_Equip.prototype.onSlotOk = function() {
this._slotWindow.hide();
this._itemWindow.show();
this._itemWindow.activate();
this._itemWindow.select(0);
};
/* 当插槽取消 */
Scene_Equip.prototype.onSlotCancel = function() {
this._slotWindow.deselect();
this._commandWindow.activate();
};
/* 当项目确定 */
Scene_Equip.prototype.onItemOk = function() {
SoundManager.playEquip();
this.executeEquipChange();
this.hideItemWindow();
this._slotWindow.refresh();
this._itemWindow.refresh();
this._statusWindow.refresh();
};
/* 执行装备更换 */
Scene_Equip.prototype.executeEquipChange = function() {
const actor = this.actor();
const slotId = this._slotWindow.index();
const item = this._itemWindow.item();
actor.changeEquip(slotId, item);
};
/* 当项目取消 */
Scene_Equip.prototype.onItemCancel = function() {
this.hideItemWindow();
};
/* 当角色改变 */
Scene_Equip.prototype.onActorChange = function() {
Scene_MenuBase.prototype.onActorChange.call(this);
this.refreshActor();
this.hideItemWindow();
this._slotWindow.deselect();
this._slotWindow.deactivate();
this._commandWindow.activate();
};
/* 隐藏项目窗口 */
Scene_Equip.prototype.hideItemWindow = function() {
this._slotWindow.show();
this._slotWindow.activate();
this._itemWindow.hide();
this._itemWindow.deselect();
};
//-----------------------------------------------------------------------------
// 场景_状态
// Scene_Status
//
// 状态画面的场景类。
// The scene class of the status screen.
function Scene_Status() {
this.initialize(...arguments);
}
Scene_Status.prototype = Object.create(Scene_MenuBase.prototype);
Scene_Status.prototype.constructor = Scene_Status;
/* 初始化 */
Scene_Status.prototype.initialize = function() {
Scene_MenuBase.prototype.initialize.call(this);
};
/* 创建 */
Scene_Status.prototype.create = function() {
Scene_MenuBase.prototype.create.call(this);
this.createProfileWindow();
this.createStatusWindow();
this.createStatusParamsWindow();
this.createStatusEquipWindow();
};
/* 帮助区域高度 */
Scene_Status.prototype.helpAreaHeight = function() {
return 0;
};
/* 创建简介窗口 */
Scene_Status.prototype.createProfileWindow = function() {
const rect = this.profileWindowRect();
this._profileWindow = new Window_Help(rect);
this.addWindow(this._profileWindow);
};
/* 简介窗口矩形区域 */
Scene_Status.prototype.profileWindowRect = function() {
const ww = Graphics.boxWidth;
const wh = this.profileHeight();
const wx = 0;
const wy = this.mainAreaBottom() - wh;
return new Rectangle(wx, wy, ww, wh);
};
/* 创建状态窗口 */
Scene_Status.prototype.createStatusWindow = function() {
const rect = this.statusWindowRect();
this._statusWindow = new Window_Status(rect);
this._statusWindow.setHandler("cancel", this.popScene.bind(this));
this._statusWindow.setHandler("pagedown", this.nextActor.bind(this));
this._statusWindow.setHandler("pageup", this.previousActor.bind(this));
this.addWindow(this._statusWindow);
};
/* 状态窗口矩形窗口 */
Scene_Status.prototype.statusWindowRect = function() {
const wx = 0;
const wy = this.mainAreaTop();
const ww = Graphics.boxWidth;
const wh = this.statusParamsWindowRect().y - wy;
return new Rectangle(wx, wy, ww, wh);
};
/* 创建状态能力值窗口 */
Scene_Status.prototype.createStatusParamsWindow = function() {
const rect = this.statusParamsWindowRect();
this._statusParamsWindow = new Window_StatusParams(rect);
this.addWindow(this._statusParamsWindow);
};
/* 状态能力值窗口矩形区域 */
Scene_Status.prototype.statusParamsWindowRect = function() {
const ww = this.statusParamsWidth();
const wh = this.statusParamsHeight();
const wx = 0;
const wy = this.mainAreaBottom() - this.profileHeight() - wh;
return new Rectangle(wx, wy, ww, wh);
};
/* 创建状态装备窗口 */
Scene_Status.prototype.createStatusEquipWindow = function() {
const rect = this.statusEquipWindowRect();
this._statusEquipWindow = new Window_StatusEquip(rect);
this.addWindow(this._statusEquipWindow);
};
/* 状态装备窗口矩形区域 */
Scene_Status.prototype.statusEquipWindowRect = function() {
const ww = Graphics.boxWidth - this.statusParamsWidth();
const wh = this.statusParamsHeight();
const wx = this.statusParamsWidth();
const wy = this.mainAreaBottom() - this.profileHeight() - wh;
return new Rectangle(wx, wy, ww, wh);
};
/* 状态能力值宽度 */
Scene_Status.prototype.statusParamsWidth = function() {
return 300;
};
/* 状态能力值高度 */
Scene_Status.prototype.statusParamsHeight = function() {
return this.calcWindowHeight(6, false);
};
/* 简介高度 */
Scene_Status.prototype.profileHeight = function() {
return this.calcWindowHeight(2, false);
};
/* 开始 */
Scene_Status.prototype.start = function() {
Scene_MenuBase.prototype.start.call(this);
this.refreshActor();
};
/* 是否需要翻页按钮 */
Scene_Status.prototype.needsPageButtons = function() {
return true;
};
/* 刷新角色 */
Scene_Status.prototype.refreshActor = function() {
const actor = this.actor();
this._profileWindow.setText(actor.profile());
this._statusWindow.setActor(actor);
this._statusParamsWindow.setActor(actor);
this._statusEquipWindow.setActor(actor);
};
/* 当角色改变 */
Scene_Status.prototype.onActorChange = function() {
Scene_MenuBase.prototype.onActorChange.call(this);
this.refreshActor();
this._statusWindow.activate();
};
//-----------------------------------------------------------------------------
// 场景_选项
// Scene_Options
//
// 选项画面的场景类。
// The scene class of the options screen.
function Scene_Options() {
this.initialize(...arguments);
}
Scene_Options.prototype = Object.create(Scene_MenuBase.prototype);
Scene_Options.prototype.constructor = Scene_Options;
/* 初始化 */
Scene_Options.prototype.initialize = function() {
Scene_MenuBase.prototype.initialize.call(this);
};
/* 创建 */
Scene_Options.prototype.create = function() {
Scene_MenuBase.prototype.create.call(this);
this.createOptionsWindow();
};
/* 结束 */
Scene_Options.prototype.terminate = function() {
Scene_MenuBase.prototype.terminate.call(this);
ConfigManager.save();
};
/* 创建选项窗口 */
Scene_Options.prototype.createOptionsWindow = function() {
const rect = this.optionsWindowRect();
this._optionsWindow = new Window_Options(rect);
this._optionsWindow.setHandler("cancel", this.popScene.bind(this));
this.addWindow(this._optionsWindow);
};
/* 选项窗口矩形区域 */
Scene_Options.prototype.optionsWindowRect = function() {
const n = Math.min(this.maxCommands(), this.maxVisibleCommands());
const ww = 400;
const wh = this.calcWindowHeight(n, true);
const wx = (Graphics.boxWidth - ww) / 2;
const wy = (Graphics.boxHeight - wh) / 2;
return new Rectangle(wx, wy, ww, wh);
};
/* 最大指令数 */
Scene_Options.prototype.maxCommands = function() {
// 在添加选项项目时增加此值。
// Increase this value when adding option items.
return 7;
};
/* 最大可见的指令数 */
Scene_Options.prototype.maxVisibleCommands = function() {
return 12;
};
//-----------------------------------------------------------------------------
// 场景_文件
// Scene_File
//
// Scene_Save 和 Scene_Load 的父类。
// The superclass of Scene_Save and Scene_Load.
function Scene_File() {
this.initialize(...arguments);
}
Scene_File.prototype = Object.create(Scene_MenuBase.prototype);
Scene_File.prototype.constructor = Scene_File;
/* 初始化 */
Scene_File.prototype.initialize = function() {
Scene_MenuBase.prototype.initialize.call(this);
};
/* 创建 */
Scene_File.prototype.create = function() {
Scene_MenuBase.prototype.create.call(this);
DataManager.loadAllSavefileImages();
this.createHelpWindow();
this.createListWindow();
this._helpWindow.setText(this.helpWindowText());
};
/* 帮助区域高度 */
Scene_File.prototype.helpAreaHeight = function() {
return 0;
};
/* 开始 */
Scene_File.prototype.start = function() {
Scene_MenuBase.prototype.start.call(this);
this._listWindow.refresh();
};
/* 存档 ID */
Scene_File.prototype.savefileId = function() {
return this._listWindow.savefileId();
};
/* 是否存档启用 */
Scene_File.prototype.isSavefileEnabled = function(savefileId) {
return this._listWindow.isEnabled(savefileId);
};
/* 创建帮助窗口 */
Scene_File.prototype.createHelpWindow = function() {
const rect = this.helpWindowRect();
this._helpWindow = new Window_Help(rect);
this.addWindow(this._helpWindow);
};
/* 帮助窗口矩形区域 */
Scene_File.prototype.helpWindowRect = function() {
const wx = 0;
const wy = this.mainAreaTop();
const ww = Graphics.boxWidth;
const wh = this.calcWindowHeight(1, false);
return new Rectangle(wx, wy, ww, wh);
};
/* 创建列表窗口 */
Scene_File.prototype.createListWindow = function() {
const rect = this.listWindowRect();
this._listWindow = new Window_SavefileList(rect);
this._listWindow.setHandler("ok", this.onSavefileOk.bind(this));
this._listWindow.setHandler("cancel", this.popScene.bind(this));
this._listWindow.setMode(this.mode(), this.needsAutosave());
this._listWindow.selectSavefile(this.firstSavefileId());
this._listWindow.refresh();
this.addWindow(this._listWindow);
};
/* 列表窗口矩形区域 */
Scene_File.prototype.listWindowRect = function() {
const wx = 0;
const wy = this.mainAreaTop() + this._helpWindow.height;
const ww = Graphics.boxWidth;
const wh = this.mainAreaHeight() - this._helpWindow.height;
return new Rectangle(wx, wy, ww, wh);
};
/* 模式 */
Scene_File.prototype.mode = function() {
return null;
};
/* 是否需要自动保存 */
Scene_File.prototype.needsAutosave = function() {
return $gameSystem.isAutosaveEnabled();
};
/* 激活列表窗口 */
Scene_File.prototype.activateListWindow = function() {
this._listWindow.activate();
};
/* 帮助窗口文本 */
Scene_File.prototype.helpWindowText = function() {
return "";
};
/* 第一个存档 ID */
Scene_File.prototype.firstSavefileId = function() {
return 0;
};
/* 当存档确定 */
Scene_File.prototype.onSavefileOk = function() {
//
};
//-----------------------------------------------------------------------------
// 场景_存档
// Scene_Save
//
// 存档画面的场景类。
// The scene class of the save screen.
function Scene_Save() {
this.initialize(...arguments);
}
Scene_Save.prototype = Object.create(Scene_File.prototype);
Scene_Save.prototype.constructor = Scene_Save;
/* 初始化 */
Scene_Save.prototype.initialize = function() {
Scene_File.prototype.initialize.call(this);
};
/* 模式 */
Scene_Save.prototype.mode = function() {
return "save";
};
/* 帮助窗口文本 */
Scene_Save.prototype.helpWindowText = function() {
return TextManager.saveMessage;
};
/* 第一个存档 ID */
Scene_Save.prototype.firstSavefileId = function() {
return $gameSystem.savefileId();
};
/* 当存档确定 */
Scene_Save.prototype.onSavefileOk = function() {
Scene_File.prototype.onSavefileOk.call(this);
const savefileId = this.savefileId();
if (this.isSavefileEnabled(savefileId)) {
this.executeSave(savefileId);
} else {
this.onSaveFailure();
}
};
/* 执行保存 */
Scene_Save.prototype.executeSave = function(savefileId) {
$gameSystem.setSavefileId(savefileId);
$gameSystem.onBeforeSave();
DataManager.saveGame(savefileId)
.then(() => this.onSaveSuccess())
.catch(() => this.onSaveFailure());
};
/* 当保存成功 */
Scene_Save.prototype.onSaveSuccess = function() {
SoundManager.playSave();
this.popScene();
};
/* 当保存失败 */
Scene_Save.prototype.onSaveFailure = function() {
SoundManager.playBuzzer();
this.activateListWindow();
};
//-----------------------------------------------------------------------------
// 场景_读档
// Scene_Load
//
// 读档画面的场景类。
// The scene class of the load screen.
function Scene_Load() {
this.initialize(...arguments);
}
Scene_Load.prototype = Object.create(Scene_File.prototype);
Scene_Load.prototype.constructor = Scene_Load;
/* 初始化 */
Scene_Load.prototype.initialize = function() {
Scene_File.prototype.initialize.call(this);
this._loadSuccess = false;
};
/* 结束 */
Scene_Load.prototype.terminate = function() {
Scene_File.prototype.terminate.call(this);
if (this._loadSuccess) {
$gameSystem.onAfterLoad();
}
};
/* 模式 */
Scene_Load.prototype.mode = function() {
return "load";
};
/* 帮助窗口文本 */
Scene_Load.prototype.helpWindowText = function() {
return TextManager.loadMessage;
};
/* 第一个存档 ID */
Scene_Load.prototype.firstSavefileId = function() {
return DataManager.latestSavefileId();
};
/* 当存档确定 */
Scene_Load.prototype.onSavefileOk = function() {
Scene_File.prototype.onSavefileOk.call(this);
const savefileId = this.savefileId();
if (this.isSavefileEnabled(savefileId)) {
this.executeLoad(savefileId);
} else {
this.onLoadFailure();
}
};
/* 执行加载 */
Scene_Load.prototype.executeLoad = function(savefileId) {
DataManager.loadGame(savefileId)
.then(() => this.onLoadSuccess())
.catch(() => this.onLoadFailure());
};
/* 当加载成功 */
Scene_Load.prototype.onLoadSuccess = function() {
SoundManager.playLoad();
this.fadeOutAll();
this.reloadMapIfUpdated();
SceneManager.goto(Scene_Map);
this._loadSuccess = true;
};
/* 当加载失败 */
Scene_Load.prototype.onLoadFailure = function() {
SoundManager.playBuzzer();
this.activateListWindow();
};
/* 如果更新则重载地图 */
Scene_Load.prototype.reloadMapIfUpdated = function() {
if ($gameSystem.versionId() !== $dataSystem.versionId) {
const mapId = $gameMap.mapId();
const x = $gamePlayer.x;
const y = $gamePlayer.y;
$gamePlayer.reserveTransfer(mapId, x, y);
$gamePlayer.requestMapReload();
}
};
//-----------------------------------------------------------------------------
// 场景_游戏结束
// Scene_GameEnd
//
// 游戏结束画面的场景类。
// The scene class of the game end screen.
function Scene_GameEnd() {
this.initialize(...arguments);
}
Scene_GameEnd.prototype = Object.create(Scene_MenuBase.prototype);
Scene_GameEnd.prototype.constructor = Scene_GameEnd;
/* 初始化 */
Scene_GameEnd.prototype.initialize = function() {
Scene_MenuBase.prototype.initialize.call(this);
};
/* 创建 */
Scene_GameEnd.prototype.create = function() {
Scene_MenuBase.prototype.create.call(this);
this.createCommandWindow();
};
/* 停止 */
Scene_GameEnd.prototype.stop = function() {
Scene_MenuBase.prototype.stop.call(this);
this._commandWindow.close();
};
/* 创建背景 */
Scene_GameEnd.prototype.createBackground = function() {
Scene_MenuBase.prototype.createBackground.call(this);
this.setBackgroundOpacity(128);
};
/* 创建指令窗口 */
Scene_GameEnd.prototype.createCommandWindow = function() {
const rect = this.commandWindowRect();
this._commandWindow = new Window_GameEnd(rect);
this._commandWindow.setHandler("toTitle", this.commandToTitle.bind(this));
this._commandWindow.setHandler("cancel", this.popScene.bind(this));
this.addWindow(this._commandWindow);
};
/* 指令窗口矩形区域 */
Scene_GameEnd.prototype.commandWindowRect = function() {
const ww = this.mainCommandWidth();
const wh = this.calcWindowHeight(2, true);
const wx = (Graphics.boxWidth - ww) / 2;
const wy = (Graphics.boxHeight - wh) / 2;
return new Rectangle(wx, wy, ww, wh);
};
/* 回到标题的指令 */
Scene_GameEnd.prototype.commandToTitle = function() {
this.fadeOutAll();
SceneManager.goto(Scene_Title);
Window_TitleCommand.initCommandPosition();
};
//-----------------------------------------------------------------------------
// 场景_商店
// Scene_Shop
//
// 商店画面的场景类。
// The scene class of the shop screen.
function Scene_Shop() {
this.initialize(...arguments);
}
Scene_Shop.prototype = Object.create(Scene_MenuBase.prototype);
Scene_Shop.prototype.constructor = Scene_Shop;
/* 初始化 */
Scene_Shop.prototype.initialize = function() {
Scene_MenuBase.prototype.initialize.call(this);
};
/* 准备 */
Scene_Shop.prototype.prepare = function(goods, purchaseOnly) {
this._goods = goods;
this._purchaseOnly = purchaseOnly;
this._item = null;
};
/* 创建 */
Scene_Shop.prototype.create = function() {
Scene_MenuBase.prototype.create.call(this);
this.createHelpWindow();
this.createGoldWindow();
this.createCommandWindow();
this.createDummyWindow();
this.createNumberWindow();
this.createStatusWindow();
this.createBuyWindow();
this.createCategoryWindow();
this.createSellWindow();
};
/* 创建金钱窗口 */
Scene_Shop.prototype.createGoldWindow = function() {
const rect = this.goldWindowRect();
this._goldWindow = new Window_Gold(rect);
this.addWindow(this._goldWindow);
};
/* 金钱窗口矩形区域 */
Scene_Shop.prototype.goldWindowRect = function() {
const ww = this.mainCommandWidth();
const wh = this.calcWindowHeight(1, true);
const wx = Graphics.boxWidth - ww;
const wy = this.mainAreaTop();
return new Rectangle(wx, wy, ww, wh);
};
/* 创建指令窗口 */
Scene_Shop.prototype.createCommandWindow = function() {
const rect = this.commandWindowRect();
this._commandWindow = new Window_ShopCommand(rect);
this._commandWindow.setPurchaseOnly(this._purchaseOnly);
this._commandWindow.y = this.mainAreaTop();
this._commandWindow.setHandler("buy", this.commandBuy.bind(this));
this._commandWindow.setHandler("sell", this.commandSell.bind(this));
this._commandWindow.setHandler("cancel", this.popScene.bind(this));
this.addWindow(this._commandWindow);
};
/* 指令窗口矩形区域 */
Scene_Shop.prototype.commandWindowRect = function() {
const wx = 0;
const wy = this.mainAreaTop();
const ww = this._goldWindow.x;
const wh = this.calcWindowHeight(1, true);
return new Rectangle(wx, wy, ww, wh);
};
/* 创建样品窗口 */
Scene_Shop.prototype.createDummyWindow = function() {
const rect = this.dummyWindowRect();
this._dummyWindow = new Window_Base(rect);
this.addWindow(this._dummyWindow);
};
/* 样品窗口矩形区域 */
Scene_Shop.prototype.dummyWindowRect = function() {
const wx = 0;
const wy = this._commandWindow.y + this._commandWindow.height;
const ww = Graphics.boxWidth;
const wh = this.mainAreaHeight() - this._commandWindow.height;
return new Rectangle(wx, wy, ww, wh);
};
/* 创建数值窗口 */
Scene_Shop.prototype.createNumberWindow = function() {
const rect = this.numberWindowRect();
this._numberWindow = new Window_ShopNumber(rect);
this._numberWindow.hide();
this._numberWindow.setHandler("ok", this.onNumberOk.bind(this));
this._numberWindow.setHandler("cancel", this.onNumberCancel.bind(this));
this.addWindow(this._numberWindow);
};
/* 数值窗口矩形区域 */
Scene_Shop.prototype.numberWindowRect = function() {
const wx = 0;
const wy = this._dummyWindow.y;
const ww = Graphics.boxWidth - this.statusWidth();
const wh = this._dummyWindow.height;
return new Rectangle(wx, wy, ww, wh);
};
/* 创建状态窗口 */
Scene_Shop.prototype.createStatusWindow = function() {
const rect = this.statusWindowRect();
this._statusWindow = new Window_ShopStatus(rect);
this._statusWindow.hide();
this.addWindow(this._statusWindow);
};
/* 状态窗口矩形区域 */
Scene_Shop.prototype.statusWindowRect = function() {
const ww = this.statusWidth();
const wh = this._dummyWindow.height;
const wx = Graphics.boxWidth - ww;
const wy = this._dummyWindow.y;
return new Rectangle(wx, wy, ww, wh);
};
/* 创建购买窗口 */
Scene_Shop.prototype.createBuyWindow = function() {
const rect = this.buyWindowRect();
this._buyWindow = new Window_ShopBuy(rect);
this._buyWindow.setupGoods(this._goods);
this._buyWindow.setHelpWindow(this._helpWindow);
this._buyWindow.setStatusWindow(this._statusWindow);
this._buyWindow.hide();
this._buyWindow.setHandler("ok", this.onBuyOk.bind(this));
this._buyWindow.setHandler("cancel", this.onBuyCancel.bind(this));
this.addWindow(this._buyWindow);
};
/* 购买窗口矩形区域 */
Scene_Shop.prototype.buyWindowRect = function() {
const wx = 0;
const wy = this._dummyWindow.y;
const ww = Graphics.boxWidth - this.statusWidth();
const wh = this._dummyWindow.height;
return new Rectangle(wx, wy, ww, wh);
};
/* 创建类型窗口 */
Scene_Shop.prototype.createCategoryWindow = function() {
const rect = this.categoryWindowRect();
this._categoryWindow = new Window_ItemCategory(rect);
this._categoryWindow.setHelpWindow(this._helpWindow);
this._categoryWindow.hide();
this._categoryWindow.deactivate();
this._categoryWindow.setHandler("ok", this.onCategoryOk.bind(this));
this._categoryWindow.setHandler("cancel", this.onCategoryCancel.bind(this));
this.addWindow(this._categoryWindow);
};
/* 类型窗口矩形区域 */
Scene_Shop.prototype.categoryWindowRect = function() {
const wx = 0;
const wy = this._dummyWindow.y;
const ww = Graphics.boxWidth;
const wh = this.calcWindowHeight(1, true);
return new Rectangle(wx, wy, ww, wh);
};
/* 创建出售窗口 */
Scene_Shop.prototype.createSellWindow = function() {
const rect = this.sellWindowRect();
this._sellWindow = new Window_ShopSell(rect);
this._sellWindow.setHelpWindow(this._helpWindow);
this._sellWindow.hide();
this._sellWindow.setHandler("ok", this.onSellOk.bind(this));
this._sellWindow.setHandler("cancel", this.onSellCancel.bind(this));
this._categoryWindow.setItemWindow(this._sellWindow);
this.addWindow(this._sellWindow);
if (!this._categoryWindow.needsSelection()) {
this._sellWindow.y -= this._categoryWindow.height;
this._sellWindow.height += this._categoryWindow.height;
}
};
/* 出售窗口矩形区域 */
Scene_Shop.prototype.sellWindowRect = function() {
const wx = 0;
const wy = this._categoryWindow.y + this._categoryWindow.height;
const ww = Graphics.boxWidth;
const wh =
this.mainAreaHeight() -
this._commandWindow.height -
this._categoryWindow.height;
return new Rectangle(wx, wy, ww, wh);
};
/* 状态宽度 */
Scene_Shop.prototype.statusWidth = function() {
return 352;
};
/* 激活购买窗口 */
Scene_Shop.prototype.activateBuyWindow = function() {
this._buyWindow.setMoney(this.money());
this._buyWindow.show();
this._buyWindow.activate();
this._statusWindow.show();
};
/* 激活出售窗口 */
Scene_Shop.prototype.activateSellWindow = function() {
if (this._categoryWindow.needsSelection()) {
this._categoryWindow.show();
}
this._sellWindow.refresh();
this._sellWindow.show();
this._sellWindow.activate();
this._statusWindow.hide();
};
/* 购买的指令 */
Scene_Shop.prototype.commandBuy = function() {
this._dummyWindow.hide();
this.activateBuyWindow();
};
/* 出售的指令 */
Scene_Shop.prototype.commandSell = function() {
this._dummyWindow.hide();
this._sellWindow.show();
this._sellWindow.deselect();
this._sellWindow.refresh();
if (this._categoryWindow.needsSelection()) {
this._categoryWindow.show();
this._categoryWindow.activate();
} else {
this.onCategoryOk();
}
};
/* 当购买确定 */
Scene_Shop.prototype.onBuyOk = function() {
this._item = this._buyWindow.item();
this._buyWindow.hide();
this._numberWindow.setup(this._item, this.maxBuy(), this.buyingPrice());
this._numberWindow.setCurrencyUnit(this.currencyUnit());
this._numberWindow.show();
this._numberWindow.activate();
};
/* 当购买取消 */
Scene_Shop.prototype.onBuyCancel = function() {
this._commandWindow.activate();
this._dummyWindow.show();
this._buyWindow.hide();
this._statusWindow.hide();
this._statusWindow.setItem(null);
this._helpWindow.clear();
};
/* 当类型确定 */
Scene_Shop.prototype.onCategoryOk = function() {
this.activateSellWindow();
this._sellWindow.select(0);
};
/* 当类型取消 */
Scene_Shop.prototype.onCategoryCancel = function() {
this._commandWindow.activate();
this._dummyWindow.show();
this._categoryWindow.hide();
this._sellWindow.hide();
};
/* 当出售确定 */
Scene_Shop.prototype.onSellOk = function() {
this._item = this._sellWindow.item();
this._categoryWindow.hide();
this._sellWindow.hide();
this._numberWindow.setup(this._item, this.maxSell(), this.sellingPrice());
this._numberWindow.setCurrencyUnit(this.currencyUnit());
this._numberWindow.show();
this._numberWindow.activate();
this._statusWindow.setItem(this._item);
this._statusWindow.show();
};
/* 当出售取消 */
Scene_Shop.prototype.onSellCancel = function() {
this._sellWindow.deselect();
this._statusWindow.setItem(null);
this._helpWindow.clear();
if (this._categoryWindow.needsSelection()) {
this._categoryWindow.activate();
} else {
this.onCategoryCancel();
}
};
/* 当数值确定 */
Scene_Shop.prototype.onNumberOk = function() {
SoundManager.playShop();
switch (this._commandWindow.currentSymbol()) {
case "buy":
this.doBuy(this._numberWindow.number());
break;
case "sell":
this.doSell(this._numberWindow.number());
break;
}
this.endNumberInput();
this._goldWindow.refresh();
this._statusWindow.refresh();
};
/* 当数值取消 */
Scene_Shop.prototype.onNumberCancel = function() {
SoundManager.playCancel();
this.endNumberInput();
};
/* 进行购买 */
Scene_Shop.prototype.doBuy = function(number) {
$gameParty.loseGold(number * this.buyingPrice());
$gameParty.gainItem(this._item, number);
};
/* 进行出售 */
Scene_Shop.prototype.doSell = function(number) {
$gameParty.gainGold(number * this.sellingPrice());
$gameParty.loseItem(this._item, number);
};
/* 结束数值输入 */
Scene_Shop.prototype.endNumberInput = function() {
this._numberWindow.hide();
switch (this._commandWindow.currentSymbol()) {
case "buy":
this.activateBuyWindow();
break;
case "sell":
this.activateSellWindow();
break;
}
};
/* 最多购买数 */
Scene_Shop.prototype.maxBuy = function() {
const num = $gameParty.numItems(this._item);
const max = $gameParty.maxItems(this._item) - num;
const price = this.buyingPrice();
if (price > 0) {
return Math.min(max, Math.floor(this.money() / price));
} else {
return max;
}
};
/* 最多出售数 */
Scene_Shop.prototype.maxSell = function() {
return $gameParty.numItems(this._item);
};
/* 金钱 */
Scene_Shop.prototype.money = function() {
return this._goldWindow.value();
};
/* 货币单位 */
Scene_Shop.prototype.currencyUnit = function() {
return this._goldWindow.currencyUnit();
};
/* 购买价格 */
Scene_Shop.prototype.buyingPrice = function() {
return this._buyWindow.price(this._item);
};
/* 出售价格 */
Scene_Shop.prototype.sellingPrice = function() {
return Math.floor(this._item.price / 2);
};
//-----------------------------------------------------------------------------
// 场景_名字
// Scene_Name
//
// 名字输入画面的场景类。
// The scene class of the name input screen.
function Scene_Name() {
this.initialize(...arguments);
}
Scene_Name.prototype = Object.create(Scene_MenuBase.prototype);
Scene_Name.prototype.constructor = Scene_Name;
/* 初始化 */
Scene_Name.prototype.initialize = function() {
Scene_MenuBase.prototype.initialize.call(this);
};
/* 准备 */
Scene_Name.prototype.prepare = function(actorId, maxLength) {
this._actorId = actorId;
this._maxLength = maxLength;
};
/* 创建 */
Scene_Name.prototype.create = function() {
Scene_MenuBase.prototype.create.call(this);
this._actor = $gameActors.actor(this._actorId);
this.createEditWindow();
this.createInputWindow();
};
/* 开始 */
Scene_Name.prototype.start = function() {
Scene_MenuBase.prototype.start.call(this);
this._editWindow.refresh();
};
/* 创建编辑窗口 */
Scene_Name.prototype.createEditWindow = function() {
const rect = this.editWindowRect();
this._editWindow = new Window_NameEdit(rect);
this._editWindow.setup(this._actor, this._maxLength);
this.addWindow(this._editWindow);
};
/* 编辑窗口矩形区域 */
Scene_Name.prototype.editWindowRect = function() {
const inputWindowHeight = this.calcWindowHeight(9, true);
const padding = $gameSystem.windowPadding();
const ww = 600;
const wh = ImageManager.faceHeight + padding * 2;
const wx = (Graphics.boxWidth - ww) / 2;
const wy = (Graphics.boxHeight - (wh + inputWindowHeight + 8)) / 2;
return new Rectangle(wx, wy, ww, wh);
};
/* 创建输入窗口 */
Scene_Name.prototype.createInputWindow = function() {
const rect = this.inputWindowRect();
this._inputWindow = new Window_NameInput(rect);
this._inputWindow.setEditWindow(this._editWindow);
this._inputWindow.setHandler("ok", this.onInputOk.bind(this));
this.addWindow(this._inputWindow);
};
/* 输入窗口矩形区域 */
Scene_Name.prototype.inputWindowRect = function() {
const wx = this._editWindow.x;
const wy = this._editWindow.y + this._editWindow.height + 8;
const ww = this._editWindow.width;
const wh = this.calcWindowHeight(9, true);
return new Rectangle(wx, wy, ww, wh);
};
/* 当输入确定 */
Scene_Name.prototype.onInputOk = function() {
this._actor.setName(this._editWindow.name());
this.popScene();
};
//-----------------------------------------------------------------------------
// 场景_调试
// Scene_Debug
//
// 调试画面的场景类。
// The scene class of the debug screen.
function Scene_Debug() {
this.initialize(...arguments);
}
Scene_Debug.prototype = Object.create(Scene_MenuBase.prototype);
Scene_Debug.prototype.constructor = Scene_Debug;
/* 初始化 */
Scene_Debug.prototype.initialize = function() {
Scene_MenuBase.prototype.initialize.call(this);
};
/* 创建 */
Scene_Debug.prototype.create = function() {
Scene_MenuBase.prototype.create.call(this);
this.createRangeWindow();
this.createEditWindow();
this.createDebugHelpWindow();
};
/* 是否需求取消按钮 */
Scene_Debug.prototype.needsCancelButton = function() {
return false;
};
/* 创建范围窗口 */
Scene_Debug.prototype.createRangeWindow = function() {
const rect = this.rangeWindowRect();
this._rangeWindow = new Window_DebugRange(rect);
this._rangeWindow.setHandler("ok", this.onRangeOk.bind(this));
this._rangeWindow.setHandler("cancel", this.popScene.bind(this));
this.addWindow(this._rangeWindow);
};
/* 范围窗口矩形区域 */
Scene_Debug.prototype.rangeWindowRect = function() {
const wx = 0;
const wy = 0;
const ww = 246;
const wh = Graphics.boxHeight;
return new Rectangle(wx, wy, ww, wh);
};
/* 创建编辑窗口 */
Scene_Debug.prototype.createEditWindow = function() {
const rect = this.editWindowRect();
this._editWindow = new Window_DebugEdit(rect);
this._editWindow.setHandler("cancel", this.onEditCancel.bind(this));
this._rangeWindow.setEditWindow(this._editWindow);
this.addWindow(this._editWindow);
};
/* 编辑窗口矩形区域 */
Scene_Debug.prototype.editWindowRect = function() {
const wx = this._rangeWindow.width;
const wy = 0;
const ww = Graphics.boxWidth - wx;
const wh = this.calcWindowHeight(10, true);
return new Rectangle(wx, wy, ww, wh);
};
/* 创建调试帮助窗口 */
Scene_Debug.prototype.createDebugHelpWindow = function() {
const rect = this.debugHelpWindowRect();
this._debugHelpWindow = new Window_Base(rect);
this.addWindow(this._debugHelpWindow);
};
/* 调试帮助窗口矩形区域 */
Scene_Debug.prototype.debugHelpWindowRect = function() {
const wx = this._editWindow.x;
const wy = this._editWindow.height;
const ww = this._editWindow.width;
const wh = Graphics.boxHeight - wy;
return new Rectangle(wx, wy, ww, wh);
};
/* 当范围确定 */
Scene_Debug.prototype.onRangeOk = function() {
this._editWindow.activate();
this._editWindow.select(0);
this.refreshHelpWindow();
};
/* 当编辑取消 */
Scene_Debug.prototype.onEditCancel = function() {
this._rangeWindow.activate();
this._editWindow.deselect();
this.refreshHelpWindow();
};
/* 刷新帮助窗口 */
Scene_Debug.prototype.refreshHelpWindow = function() {
const helpWindow = this._debugHelpWindow;
helpWindow.contents.clear();
if (this._editWindow.active) {
const rect = helpWindow.baseTextRect();
helpWindow.drawTextEx(this.helpText(), rect.x, rect.y, rect.width);
}
};
/* 帮助文本 */
Scene_Debug.prototype.helpText = function() {
if (this._rangeWindow.mode() === "switch") {
return "Enter : ON / OFF";
} else {
return (
"Left : -1 Pageup : -10\n" +
"Right : +1 Pagedown : +10"
);
}
};
//-----------------------------------------------------------------------------
// 场景_战斗
// Scene_Battle
//
// 战斗画面的场景类。
// The scene class of the battle screen.
function Scene_Battle() {
this.initialize(...arguments);
}
Scene_Battle.prototype = Object.create(Scene_Message.prototype);
Scene_Battle.prototype.constructor = Scene_Battle;
/* 初始化 */
Scene_Battle.prototype.initialize = function() {
Scene_Message.prototype.initialize.call(this);
};
/* 创建 */
Scene_Battle.prototype.create = function() {
Scene_Message.prototype.create.call(this);
this.createDisplayObjects();
};
/* 开始 */
Scene_Battle.prototype.start = function() {
Scene_Message.prototype.start.call(this);
BattleManager.playBattleBgm();
BattleManager.startBattle();
this._statusWindow.refresh();
this.startFadeIn(this.fadeSpeed(), false);
};
/* 更新 */
Scene_Battle.prototype.update = function() {
const active = this.isActive();
$gameTimer.update(active);
$gameScreen.update();
this.updateVisibility();
if (active && !this.isBusy()) {
this.updateBattleProcess();
}
Scene_Message.prototype.update.call(this);
};
/* 更新可见性 */
Scene_Battle.prototype.updateVisibility = function() {
this.updateLogWindowVisibility();
this.updateStatusWindowVisibility();
this.updateInputWindowVisibility();
this.updateCancelButton();
};
/* 更新战斗流程 */
Scene_Battle.prototype.updateBattleProcess = function() {
BattleManager.update(this.isTimeActive());
};
/* 是否时间即时 */
Scene_Battle.prototype.isTimeActive = function() {
if (BattleManager.isActiveTpb()) {
return !this._skillWindow.active && !this._itemWindow.active;
} else {
return !this.isAnyInputWindowActive();
}
};
/* 是否有任何输入窗口处于活动状态 */
Scene_Battle.prototype.isAnyInputWindowActive = function() {
return (
this._partyCommandWindow.active ||
this._actorCommandWindow.active ||
this._skillWindow.active ||
this._itemWindow.active ||
this._actorWindow.active ||
this._enemyWindow.active
);
};
/* 改变输入窗口 */
Scene_Battle.prototype.changeInputWindow = function() {
this.hideSubInputWindows();
if (BattleManager.isInputting()) {
if (BattleManager.actor()) {
this.startActorCommandSelection();
} else {
this.startPartyCommandSelection();
}
} else {
this.endCommandSelection();
}
};
/* 停止 */
Scene_Battle.prototype.stop = function() {
Scene_Message.prototype.stop.call(this);
if (this.needsSlowFadeOut()) {
this.startFadeOut(this.slowFadeSpeed(), false);
} else {
this.startFadeOut(this.fadeSpeed(), false);
}
this._statusWindow.close();
this._partyCommandWindow.close();
this._actorCommandWindow.close();
};
/* 结束 */
Scene_Battle.prototype.terminate = function() {
Scene_Message.prototype.terminate.call(this);
$gameParty.onBattleEnd();
$gameTroop.onBattleEnd();
AudioManager.stopMe();
if (this.shouldAutosave()) {
this.requestAutosave();
}
};
Scene_Battle.prototype.shouldAutosave = function() {
return SceneManager.isNextScene(Scene_Map);
};
/* 是否需要缓慢淡出 */
Scene_Battle.prototype.needsSlowFadeOut = function() {
return (
SceneManager.isNextScene(Scene_Title) ||
SceneManager.isNextScene(Scene_Gameover)
);
};
/* 更新日志窗口可见性 */
Scene_Battle.prototype.updateLogWindowVisibility = function() {
this._logWindow.visible = !this._helpWindow.visible;
};
/* 更新状态窗口可见性 */
Scene_Battle.prototype.updateStatusWindowVisibility = function() {
if ($gameMessage.isBusy()) {
this._statusWindow.close();
} else if (this.shouldOpenStatusWindow()) {
this._statusWindow.open();
}
this.updateStatusWindowPosition();
};
/* 是否需要打开状态窗口 */
Scene_Battle.prototype.shouldOpenStatusWindow = function() {
return (
this.isActive() &&
!this.isMessageWindowClosing() &&
!BattleManager.isBattleEnd()
);
};
/* 更新状态窗口位置 */
Scene_Battle.prototype.updateStatusWindowPosition = function() {
const statusWindow = this._statusWindow;
const targetX = this.statusWindowX();
if (statusWindow.x < targetX) {
statusWindow.x = Math.min(statusWindow.x + 16, targetX);
}
if (statusWindow.x > targetX) {
statusWindow.x = Math.max(statusWindow.x - 16, targetX);
}
};
/* 状态窗口坐标 X */
Scene_Battle.prototype.statusWindowX = function() {
if (this.isAnyInputWindowActive()) {
return this.statusWindowRect().x;
} else {
return this._partyCommandWindow.width / 2;
}
};
/* 更新输入窗口可见性 */
Scene_Battle.prototype.updateInputWindowVisibility = function() {
if ($gameMessage.isBusy()) {
this.closeCommandWindows();
this.hideSubInputWindows();
} else if (this.needsInputWindowChange()) {
this.changeInputWindow();
}
};
/* 是否需要输入窗口更改 */
Scene_Battle.prototype.needsInputWindowChange = function() {
const windowActive = this.isAnyInputWindowActive();
const inputting = BattleManager.isInputting();
if (windowActive && inputting) {
return this._actorCommandWindow.actor() !== BattleManager.actor();
}
return windowActive !== inputting;
};
/* 更新取消按钮 */
Scene_Battle.prototype.updateCancelButton = function() {
if (this._cancelButton) {
this._cancelButton.visible =
this.isAnyInputWindowActive() && !this._partyCommandWindow.active;
}
};
/* 创建显示对象 */
Scene_Battle.prototype.createDisplayObjects = function() {
this.createSpriteset();
this.createWindowLayer();
this.createAllWindows();
this.createButtons();
BattleManager.setLogWindow(this._logWindow);
BattleManager.setSpriteset(this._spriteset);
this._logWindow.setSpriteset(this._spriteset);
};
/* 创建精灵组 */
Scene_Battle.prototype.createSpriteset = function() {
this._spriteset = new Spriteset_Battle();
this.addChild(this._spriteset);
};
/* 创建所有窗口 */
Scene_Battle.prototype.createAllWindows = function() {
this.createLogWindow();
this.createStatusWindow();
this.createPartyCommandWindow();
this.createActorCommandWindow();
this.createHelpWindow();
this.createSkillWindow();
this.createItemWindow();
this.createActorWindow();
this.createEnemyWindow();
Scene_Message.prototype.createAllWindows.call(this);
};
/* 创建日志窗口 */
Scene_Battle.prototype.createLogWindow = function() {
const rect = this.logWindowRect();
this._logWindow = new Window_BattleLog(rect);
this.addWindow(this._logWindow);
};
/* 日志窗口矩形区域 */
Scene_Battle.prototype.logWindowRect = function() {
const wx = 0;
const wy = 0;
const ww = Graphics.boxWidth;
const wh = this.calcWindowHeight(10, false);
return new Rectangle(wx, wy, ww, wh);
};
/* 创建状态窗口 */
Scene_Battle.prototype.createStatusWindow = function() {
const rect = this.statusWindowRect();
const statusWindow = new Window_BattleStatus(rect);
this.addWindow(statusWindow);
this._statusWindow = statusWindow;
};
/* 状态窗口矩形区域 */
Scene_Battle.prototype.statusWindowRect = function() {
const extra = 10;
const ww = Graphics.boxWidth - 192;
const wh = this.windowAreaHeight() + extra;
const wx = this.isRightInputMode() ? 0 : Graphics.boxWidth - ww;
const wy = Graphics.boxHeight - wh + extra - 4;
return new Rectangle(wx, wy, ww, wh);
};
/* 创建队伍指令窗口 */
Scene_Battle.prototype.createPartyCommandWindow = function() {
const rect = this.partyCommandWindowRect();
const commandWindow = new Window_PartyCommand(rect);
commandWindow.setHandler("fight", this.commandFight.bind(this));
commandWindow.setHandler("escape", this.commandEscape.bind(this));
commandWindow.deselect();
this.addWindow(commandWindow);
this._partyCommandWindow = commandWindow;
};
/* 队伍指令窗口矩形区域 */
Scene_Battle.prototype.partyCommandWindowRect = function() {
const ww = 192;
const wh = this.windowAreaHeight();
const wx = this.isRightInputMode() ? Graphics.boxWidth - ww : 0;
const wy = Graphics.boxHeight - wh;
return new Rectangle(wx, wy, ww, wh);
};
/* 创建角色指令窗口 */
Scene_Battle.prototype.createActorCommandWindow = function() {
const rect = this.actorCommandWindowRect();
const commandWindow = new Window_ActorCommand(rect);
commandWindow.y = Graphics.boxHeight - commandWindow.height;
commandWindow.setHandler("attack", this.commandAttack.bind(this));
commandWindow.setHandler("skill", this.commandSkill.bind(this));
commandWindow.setHandler("guard", this.commandGuard.bind(this));
commandWindow.setHandler("item", this.commandItem.bind(this));
commandWindow.setHandler("cancel", this.commandCancel.bind(this));
this.addWindow(commandWindow);
this._actorCommandWindow = commandWindow;
};
/* 角色指令窗口矩形区域 */
Scene_Battle.prototype.actorCommandWindowRect = function() {
const ww = 192;
const wh = this.windowAreaHeight();
const wx = this.isRightInputMode() ? Graphics.boxWidth - ww : 0;
const wy = Graphics.boxHeight - wh;
return new Rectangle(wx, wy, ww, wh);
};
/* 创建帮助窗口 */
Scene_Battle.prototype.createHelpWindow = function() {
const rect = this.helpWindowRect();
this._helpWindow = new Window_Help(rect);
this._helpWindow.hide();
this.addWindow(this._helpWindow);
};
/* 帮助窗口矩形区域 */
Scene_Battle.prototype.helpWindowRect = function() {
const wx = 0;
const wy = this.helpAreaTop();
const ww = Graphics.boxWidth;
const wh = this.helpAreaHeight();
return new Rectangle(wx, wy, ww, wh);
};
/* 创建技能窗口 */
Scene_Battle.prototype.createSkillWindow = function() {
const rect = this.skillWindowRect();
this._skillWindow = new Window_BattleSkill(rect);
this._skillWindow.setHelpWindow(this._helpWindow);
this._skillWindow.setHandler("ok", this.onSkillOk.bind(this));
this._skillWindow.setHandler("cancel", this.onSkillCancel.bind(this));
this.addWindow(this._skillWindow);
};
/* 技能窗口矩形区域 */
Scene_Battle.prototype.skillWindowRect = function() {
const ww = Graphics.boxWidth;
const wh = this.windowAreaHeight();
const wx = 0;
const wy = Graphics.boxHeight - wh;
return new Rectangle(wx, wy, ww, wh);
};
/* 创建物品窗口 */
Scene_Battle.prototype.createItemWindow = function() {
const rect = this.itemWindowRect();
this._itemWindow = new Window_BattleItem(rect);
this._itemWindow.setHelpWindow(this._helpWindow);
this._itemWindow.setHandler("ok", this.onItemOk.bind(this));
this._itemWindow.setHandler("cancel", this.onItemCancel.bind(this));
this.addWindow(this._itemWindow);
};
/* 物品窗口矩形区域 */
Scene_Battle.prototype.itemWindowRect = function() {
return this.skillWindowRect();
};
/* 创建角色窗口 */
Scene_Battle.prototype.createActorWindow = function() {
const rect = this.actorWindowRect();
this._actorWindow = new Window_BattleActor(rect);
this._actorWindow.setHandler("ok", this.onActorOk.bind(this));
this._actorWindow.setHandler("cancel", this.onActorCancel.bind(this));
this.addWindow(this._actorWindow);
};
/* 角色窗口矩形区域 */
Scene_Battle.prototype.actorWindowRect = function() {
return this.statusWindowRect();
};
/* 创建敌人窗口 */
Scene_Battle.prototype.createEnemyWindow = function() {
const rect = this.enemyWindowRect();
this._enemyWindow = new Window_BattleEnemy(rect);
this._enemyWindow.setHandler("ok", this.onEnemyOk.bind(this));
this._enemyWindow.setHandler("cancel", this.onEnemyCancel.bind(this));
this.addWindow(this._enemyWindow);
};
/* 敌人窗口矩形区域 */
Scene_Battle.prototype.enemyWindowRect = function() {
const wx = this._statusWindow.x;
const ww = this._statusWindow.width;
const wh = this.windowAreaHeight();
const wy = Graphics.boxHeight - wh;
return new Rectangle(wx, wy, ww, wh);
};
/* 帮助区域顶部 */
Scene_Battle.prototype.helpAreaTop = function() {
return 0;
};
/* 帮助区域底部 */
Scene_Battle.prototype.helpAreaBottom = function() {
return this.helpAreaTop() + this.helpAreaHeight();
};
/* 帮助区域高度 */
Scene_Battle.prototype.helpAreaHeight = function() {
return this.calcWindowHeight(2, false);
};
/* 按钮区域顶部 */
Scene_Battle.prototype.buttonAreaTop = function() {
return this.helpAreaBottom();
};
/* 窗口区域高度 */
Scene_Battle.prototype.windowAreaHeight = function() {
return this.calcWindowHeight(4, true);
};
/* 创建按钮 */
Scene_Battle.prototype.createButtons = function() {
if (ConfigManager.touchUI) {
this.createCancelButton();
}
};
/* 创建取消按钮 */
Scene_Battle.prototype.createCancelButton = function() {
this._cancelButton = new Sprite_Button("cancel");
this._cancelButton.x = Graphics.boxWidth - this._cancelButton.width - 4;
this._cancelButton.y = this.buttonY();
this.addWindow(this._cancelButton);
};
/* 关闭指令窗口 */
Scene_Battle.prototype.closeCommandWindows = function() {
this._partyCommandWindow.deactivate();
this._actorCommandWindow.deactivate();
this._partyCommandWindow.close();
this._actorCommandWindow.close();
};
/* 隐藏子输入窗口 */
Scene_Battle.prototype.hideSubInputWindows = function() {
this._actorWindow.deactivate();
this._enemyWindow.deactivate();
this._skillWindow.deactivate();
this._itemWindow.deactivate();
this._actorWindow.hide();
this._enemyWindow.hide();
this._skillWindow.hide();
this._itemWindow.hide();
};
/* 开始队伍指令选择 */
Scene_Battle.prototype.startPartyCommandSelection = function() {
this._statusWindow.deselect();
this._statusWindow.show();
this._statusWindow.open();
this._actorCommandWindow.setup(null);
this._actorCommandWindow.close();
this._partyCommandWindow.setup();
};
/* 战斗的指令 */
Scene_Battle.prototype.commandFight = function() {
this.selectNextCommand();
};
/* 逃跑的指令 */
Scene_Battle.prototype.commandEscape = function() {
BattleManager.processEscape();
this.changeInputWindow();
};
/* 开始角色指令选择 */
Scene_Battle.prototype.startActorCommandSelection = function() {
this._statusWindow.show();
this._statusWindow.selectActor(BattleManager.actor());
this._partyCommandWindow.close();
this._actorCommandWindow.show();
this._actorCommandWindow.setup(BattleManager.actor());
};
/* 攻击的指令 */
Scene_Battle.prototype.commandAttack = function() {
const action = BattleManager.inputtingAction();
action.setAttack();
this.onSelectAction();
};
/* 技能的指令 */
Scene_Battle.prototype.commandSkill = function() {
this._skillWindow.setActor(BattleManager.actor());
this._skillWindow.setStypeId(this._actorCommandWindow.currentExt());
this._skillWindow.refresh();
this._skillWindow.show();
this._skillWindow.activate();
this._statusWindow.hide();
this._actorCommandWindow.hide();
};
/* 防御的指令 */
Scene_Battle.prototype.commandGuard = function() {
const action = BattleManager.inputtingAction();
action.setGuard();
this.onSelectAction();
};
/* 物品的指令 */
Scene_Battle.prototype.commandItem = function() {
this._itemWindow.refresh();
this._itemWindow.show();
this._itemWindow.activate();
this._statusWindow.hide();
this._actorCommandWindow.hide();
};
/* 取消的指令 */
Scene_Battle.prototype.commandCancel = function() {
this.selectPreviousCommand();
};
/* 选择下一个指令 */
Scene_Battle.prototype.selectNextCommand = function() {
BattleManager.selectNextCommand();
this.changeInputWindow();
};
/* 选择上一个指令 */
Scene_Battle.prototype.selectPreviousCommand = function() {
BattleManager.selectPreviousCommand();
this.changeInputWindow();
};
/* 开始角色选择 */
Scene_Battle.prototype.startActorSelection = function() {
this._actorWindow.refresh();
this._actorWindow.show();
this._actorWindow.activate();
};
/* 当角色确定 */
Scene_Battle.prototype.onActorOk = function() {
const action = BattleManager.inputtingAction();
action.setTarget(this._actorWindow.index());
this.hideSubInputWindows();
this.selectNextCommand();
};
/* 当角色取消 */
Scene_Battle.prototype.onActorCancel = function() {
this._actorWindow.hide();
switch (this._actorCommandWindow.currentSymbol()) {
case "skill":
this._skillWindow.show();
this._skillWindow.activate();
break;
case "item":
this._itemWindow.show();
this._itemWindow.activate();
break;
}
};
/* 开始敌人选择 */
Scene_Battle.prototype.startEnemySelection = function() {
this._enemyWindow.refresh();
this._enemyWindow.show();
this._enemyWindow.select(0);
this._enemyWindow.activate();
this._statusWindow.hide();
};
/* 当敌人确定 */
Scene_Battle.prototype.onEnemyOk = function() {
const action = BattleManager.inputtingAction();
action.setTarget(this._enemyWindow.enemyIndex());
this.hideSubInputWindows();
this.selectNextCommand();
};
/* 当敌人取消 */
Scene_Battle.prototype.onEnemyCancel = function() {
this._enemyWindow.hide();
switch (this._actorCommandWindow.currentSymbol()) {
case "attack":
this._statusWindow.show();
this._actorCommandWindow.activate();
break;
case "skill":
this._skillWindow.show();
this._skillWindow.activate();
break;
case "item":
this._itemWindow.show();
this._itemWindow.activate();
break;
}
};
/* 当技能确定 */
Scene_Battle.prototype.onSkillOk = function() {
const skill = this._skillWindow.item();
const action = BattleManager.inputtingAction();
action.setSkill(skill.id);
BattleManager.actor().setLastBattleSkill(skill);
this.onSelectAction();
};
/* 当技能取消 */
Scene_Battle.prototype.onSkillCancel = function() {
this._skillWindow.hide();
this._statusWindow.show();
this._actorCommandWindow.show();
this._actorCommandWindow.activate();
};
/* 当物品确定 */
Scene_Battle.prototype.onItemOk = function() {
const item = this._itemWindow.item();
const action = BattleManager.inputtingAction();
action.setItem(item.id);
$gameParty.setLastItem(item);
this.onSelectAction();
};
/* 当物品取消 */
Scene_Battle.prototype.onItemCancel = function() {
this._itemWindow.hide();
this._statusWindow.show();
this._actorCommandWindow.show();
this._actorCommandWindow.activate();
};
/* 当选择行动 */
Scene_Battle.prototype.onSelectAction = function() {
const action = BattleManager.inputtingAction();
if (!action.needsSelection()) {
this.selectNextCommand();
} else if (action.isForOpponent()) {
this.startEnemySelection();
} else {
this.startActorSelection();
}
};
/* 结束指令选择 */
Scene_Battle.prototype.endCommandSelection = function() {
this.closeCommandWindows();
this.hideSubInputWindows();
this._statusWindow.deselect();
this._statusWindow.show();
};
//-----------------------------------------------------------------------------
// 场景_游戏结束
// Scene_Gameover
//
// 游戏结束画面的场景类。
// The scene class of the game over screen.
function Scene_Gameover() {
this.initialize(...arguments);
}
Scene_Gameover.prototype = Object.create(Scene_Base.prototype);
Scene_Gameover.prototype.constructor = Scene_Gameover;
/* 初始化 */
Scene_Gameover.prototype.initialize = function() {
Scene_Base.prototype.initialize.call(this);
};
/* 创建 */
Scene_Gameover.prototype.create = function() {
Scene_Base.prototype.create.call(this);
this.playGameoverMusic();
this.createBackground();
};
/* 开始 */
Scene_Gameover.prototype.start = function() {
Scene_Base.prototype.start.call(this);
this.adjustBackground();
this.startFadeIn(this.slowFadeSpeed(), false);
};
/* 更新 */
Scene_Gameover.prototype.update = function() {
if (this.isActive() && !this.isBusy() && this.isTriggered()) {
this.gotoTitle();
}
Scene_Base.prototype.update.call(this);
};
/* 停止 */
Scene_Gameover.prototype.stop = function() {
Scene_Base.prototype.stop.call(this);
this.fadeOutAll();
};
/* 结束 */
Scene_Gameover.prototype.terminate = function() {
Scene_Base.prototype.terminate.call(this);
AudioManager.stopAll();
};
/* 播放游戏结束音乐 */
Scene_Gameover.prototype.playGameoverMusic = function() {
AudioManager.stopBgm();
AudioManager.stopBgs();
AudioManager.playMe($dataSystem.gameoverMe);
};
/* 创建背景 */
Scene_Gameover.prototype.createBackground = function() {
this._backSprite = new Sprite();
this._backSprite.bitmap = ImageManager.loadSystem("GameOver");
this.addChild(this._backSprite);
};
/* 自适应背景 */
Scene_Gameover.prototype.adjustBackground = function() {
this.scaleSprite(this._backSprite);
this.centerSprite(this._backSprite);
};
/* 是否触发 */
Scene_Gameover.prototype.isTriggered = function() {
return Input.isTriggered("ok") || TouchInput.isTriggered();
};
/* 回到标题 */
Scene_Gameover.prototype.gotoTitle = function() {
SceneManager.goto(Scene_Title);
};
//-----------------------------------------------------------------------------
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/flanpan/rmmz.git
git@gitee.com:flanpan/rmmz.git
flanpan
rmmz
RMMZ脚本框架中文注释
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385