1 Star 0 Fork 5

flanpan/RMMZ脚本框架中文注释

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
rmmz_sprites.js 113.37 KB
一键复制 编辑 原始数据 按行查看 历史
9梦菌 提交于 2020-09-30 00:43 . MZ框架脚本更新至1.0.2
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177
//=============================================================================
// rmmz_sprites.js v1.0.2
//=============================================================================
//-----------------------------------------------------------------------------
// 精灵_可点击
// Sprite_Clickable
//
// 具有点击处理功能的精灵类。
// The sprite class with click handling functions.
function Sprite_Clickable() {
this.initialize(...arguments);
}
Sprite_Clickable.prototype = Object.create(Sprite.prototype);
Sprite_Clickable.prototype.constructor = Sprite_Clickable;
/* 初始化 */
Sprite_Clickable.prototype.initialize = function() {
Sprite.prototype.initialize.call(this);
this._pressed = false;
this._hovered = false;
};
/* 更新 */
Sprite_Clickable.prototype.update = function() {
Sprite.prototype.update.call(this);
this.processTouch();
};
/* 处理触摸 */
Sprite_Clickable.prototype.processTouch = function() {
if (this.isClickEnabled()) {
if (this.isBeingTouched()) {
if (!this._hovered && TouchInput.isHovered()) {
this._hovered = true;
this.onMouseEnter();
}
if (TouchInput.isTriggered()) {
this._pressed = true;
this.onPress();
}
} else {
if (this._hovered) {
this.onMouseExit();
}
this._pressed = false;
this._hovered = false;
}
if (this._pressed && TouchInput.isReleased()) {
this._pressed = false;
this.onClick();
}
} else {
this._pressed = false;
this._hovered = false;
}
};
/* 是否按下 */
Sprite_Clickable.prototype.isPressed = function() {
return this._pressed;
};
/* 是否点击启用 */
Sprite_Clickable.prototype.isClickEnabled = function() {
return this.worldVisible;
};
/* 是否开始触摸 */
Sprite_Clickable.prototype.isBeingTouched = function() {
const touchPos = new Point(TouchInput.x, TouchInput.y);
const localPos = this.worldTransform.applyInverse(touchPos);
return this.hitTest(localPos.x, localPos.y);
};
/* 命中检测
* 判断点是否在矩形区域内。
*/
Sprite_Clickable.prototype.hitTest = function(x, y) {
const rect = new Rectangle(
-this.anchor.x * this.width,
-this.anchor.y * this.height,
this.width,
this.height
);
return rect.contains(x, y);
};
/* 当鼠标进入 */
Sprite_Clickable.prototype.onMouseEnter = function() {
//
};
/* 当鼠标离开 */
Sprite_Clickable.prototype.onMouseExit = function() {
//
};
/* 当按下 */
Sprite_Clickable.prototype.onPress = function() {
//
};
/* 当点击 */
Sprite_Clickable.prototype.onClick = function() {
//
};
//-----------------------------------------------------------------------------
// 精灵_按钮
// Sprite_Button
//
// 显示按钮的精灵。
// The sprite for displaying a button.
function Sprite_Button() {
this.initialize(...arguments);
}
Sprite_Button.prototype = Object.create(Sprite_Clickable.prototype);
Sprite_Button.prototype.constructor = Sprite_Button;
/* 初始化 */
Sprite_Button.prototype.initialize = function(buttonType) {
Sprite_Clickable.prototype.initialize.call(this);
this._buttonType = buttonType;
this._clickHandler = null;
this._coldFrame = null;
this._hotFrame = null;
this.setupFrames();
};
/* 更新帧 */
Sprite_Button.prototype.setupFrames = function() {
const data = this.buttonData();
const x = data.x * this.blockWidth();
const width = data.w * this.blockWidth();
const height = this.blockHeight();
this.loadButtonImage();
this.setColdFrame(x, 0, width, height);
this.setHotFrame(x, height, width, height);
this.updateFrame();
this.updateOpacity();
};
/* 块宽度 */
Sprite_Button.prototype.blockWidth = function() {
return 48;
};
/* 块高度 */
Sprite_Button.prototype.blockHeight = function() {
return 48;
};
/* 加载按钮图像 */
Sprite_Button.prototype.loadButtonImage = function() {
this.bitmap = ImageManager.loadSystem("ButtonSet");
};
/* 按钮数据 */
Sprite_Button.prototype.buttonData = function() {
const buttonTable = {
cancel: { x: 0, w: 2 },
pageup: { x: 2, w: 1 },
pagedown: { x: 3, w: 1 },
down: { x: 4, w: 1 },
up: { x: 5, w: 1 },
down2: { x: 6, w: 1 },
up2: { x: 7, w: 1 },
ok: { x: 8, w: 2 },
menu: { x: 10, w: 1 }
};
return buttonTable[this._buttonType];
};
/* 更新 */
Sprite_Button.prototype.update = function() {
Sprite_Clickable.prototype.update.call(this);
this.checkBitmap();
this.updateFrame();
this.updateOpacity();
this.processTouch();
};
/* 检测位图 */
Sprite_Button.prototype.checkBitmap = function() {
if (this.bitmap.isReady() && this.bitmap.width < this.blockWidth() * 11) {
// Probably MV image is used
throw new Error("ButtonSet image is too small");
}
};
/* 更新帧 */
Sprite_Button.prototype.updateFrame = function() {
const frame = this.isPressed() ? this._hotFrame : this._coldFrame;
if (frame) {
this.setFrame(frame.x, frame.y, frame.width, frame.height);
}
};
/* 更新不透明度 */
Sprite_Button.prototype.updateOpacity = function() {
this.opacity = this._pressed ? 255 : 192;
};
/* 设置冷帧
* 按钮未按下时的显示区域。
*/
Sprite_Button.prototype.setColdFrame = function(x, y, width, height) {
this._coldFrame = new Rectangle(x, y, width, height);
};
/* 设置热帧
* 按钮按下时的显示区域。
*/
Sprite_Button.prototype.setHotFrame = function(x, y, width, height) {
this._hotFrame = new Rectangle(x, y, width, height);
};
/* 设置点击处理者 */
Sprite_Button.prototype.setClickHandler = function(method) {
this._clickHandler = method;
};
/* 当点击 */
Sprite_Button.prototype.onClick = function() {
if (this._clickHandler) {
this._clickHandler();
} else {
Input.virtualClick(this._buttonType);
}
};
//-----------------------------------------------------------------------------
// 精灵_人物
// Sprite_Character
//
// 显示角色的精灵。
// The sprite for displaying a character.
function Sprite_Character() {
this.initialize(...arguments);
}
Sprite_Character.prototype = Object.create(Sprite.prototype);
Sprite_Character.prototype.constructor = Sprite_Character;
/* 初始化 */
Sprite_Character.prototype.initialize = function(character) {
Sprite.prototype.initialize.call(this);
this.initMembers();
this.setCharacter(character);
};
/* 初始化成员 */
Sprite_Character.prototype.initMembers = function() {
this.anchor.x = 0.5;
this.anchor.y = 1;
this._character = null;
this._balloonDuration = 0;
this._tilesetId = 0;
this._upperBody = null;
this._lowerBody = null;
};
/* 设置人物 */
Sprite_Character.prototype.setCharacter = function(character) {
this._character = character;
};
/* 检测人物 */
Sprite_Character.prototype.checkCharacter = function(character) {
return this._character === character;
};
/* 更新 */
Sprite_Character.prototype.update = function() {
Sprite.prototype.update.call(this);
this.updateBitmap();
this.updateFrame();
this.updatePosition();
this.updateOther();
this.updateVisibility();
};
/* 更新可见性 */
Sprite_Character.prototype.updateVisibility = function() {
Sprite.prototype.updateVisibility.call(this);
if (this.isEmptyCharacter() || this._character.isTransparent()) {
this.visible = false;
}
};
/* 是否图块 */
Sprite_Character.prototype.isTile = function() {
return this._character.isTile();
};
/* 是否物体的行走图 */
Sprite_Character.prototype.isObjectCharacter = function() {
return this._character.isObjectCharacter();
};
/* 是否敌人的行走图 */
Sprite_Character.prototype.isEmptyCharacter = function() {
return this._tileId === 0 && !this._characterName;
};
/* 图块组位图 */
Sprite_Character.prototype.tilesetBitmap = function(tileId) {
const tileset = $gameMap.tileset();
const setNumber = 5 + Math.floor(tileId / 256);
return ImageManager.loadTileset(tileset.tilesetNames[setNumber]);
};
/* 更新位图 */
Sprite_Character.prototype.updateBitmap = function() {
if (this.isImageChanged()) {
this._tilesetId = $gameMap.tilesetId();
this._tileId = this._character.tileId();
this._characterName = this._character.characterName();
this._characterIndex = this._character.characterIndex();
if (this._tileId > 0) {
this.setTileBitmap();
} else {
this.setCharacterBitmap();
}
}
};
/* 是否图像改变 */
Sprite_Character.prototype.isImageChanged = function() {
return (
this._tilesetId !== $gameMap.tilesetId() ||
this._tileId !== this._character.tileId() ||
this._characterName !== this._character.characterName() ||
this._characterIndex !== this._character.characterIndex()
);
};
/* 设置图块位图 */
Sprite_Character.prototype.setTileBitmap = function() {
this.bitmap = this.tilesetBitmap(this._tileId);
};
/* 设置人物位图 */
Sprite_Character.prototype.setCharacterBitmap = function() {
this.bitmap = ImageManager.loadCharacter(this._characterName);
this._isBigCharacter = ImageManager.isBigCharacter(this._characterName);
};
/* 更新帧 */
Sprite_Character.prototype.updateFrame = function() {
if (this._tileId > 0) {
this.updateTileFrame();
} else {
this.updateCharacterFrame();
}
};
/* 更新图块帧 */
Sprite_Character.prototype.updateTileFrame = function() {
const tileId = this._tileId;
const pw = this.patternWidth();
const ph = this.patternHeight();
const sx = ((Math.floor(tileId / 128) % 2) * 8 + (tileId % 8)) * pw;
const sy = (Math.floor((tileId % 256) / 8) % 16) * ph;
this.setFrame(sx, sy, pw, ph);
};
/* 更新行走图帧 */
Sprite_Character.prototype.updateCharacterFrame = function() {
const pw = this.patternWidth();
const ph = this.patternHeight();
const sx = (this.characterBlockX() + this.characterPatternX()) * pw;
const sy = (this.characterBlockY() + this.characterPatternY()) * ph;
this.updateHalfBodySprites();
if (this._bushDepth > 0) {
const d = this._bushDepth;
this._upperBody.setFrame(sx, sy, pw, ph - d);
this._lowerBody.setFrame(sx, sy + ph - d, pw, d);
this.setFrame(sx, sy, 0, ph);
} else {
this.setFrame(sx, sy, pw, ph);
}
};
/* 行走图块位置 X */
Sprite_Character.prototype.characterBlockX = function() {
if (this._isBigCharacter) {
return 0;
} else {
const index = this._character.characterIndex();
return (index % 4) * 3;
}
};
/* 行走图块位置 Y */
Sprite_Character.prototype.characterBlockY = function() {
if (this._isBigCharacter) {
return 0;
} else {
const index = this._character.characterIndex();
return Math.floor(index / 4) * 4;
}
};
/* 行走图图案位置 X */
Sprite_Character.prototype.characterPatternX = function() {
return this._character.pattern();
};
/* 行走图图案位置 Y */
Sprite_Character.prototype.characterPatternY = function() {
return (this._character.direction() - 2) / 2;
};
/* 图案宽度 */
Sprite_Character.prototype.patternWidth = function() {
if (this._tileId > 0) {
return $gameMap.tileWidth();
} else if (this._isBigCharacter) {
return this.bitmap.width / 3;
} else {
return this.bitmap.width / 12;
}
};
/* 图案高度 */
Sprite_Character.prototype.patternHeight = function() {
if (this._tileId > 0) {
return $gameMap.tileHeight();
} else if (this._isBigCharacter) {
return this.bitmap.height / 4;
} else {
return this.bitmap.height / 8;
}
};
/* 更新半身精灵 */
Sprite_Character.prototype.updateHalfBodySprites = function() {
if (this._bushDepth > 0) {
this.createHalfBodySprites();
this._upperBody.bitmap = this.bitmap;
this._upperBody.visible = true;
this._upperBody.y = -this._bushDepth;
this._lowerBody.bitmap = this.bitmap;
this._lowerBody.visible = true;
this._upperBody.setBlendColor(this.getBlendColor());
this._lowerBody.setBlendColor(this.getBlendColor());
this._upperBody.setColorTone(this.getColorTone());
this._lowerBody.setColorTone(this.getColorTone());
this._upperBody.blendMode = this.blendMode;
this._lowerBody.blendMode = this.blendMode;
} else if (this._upperBody) {
this._upperBody.visible = false;
this._lowerBody.visible = false;
}
};
/* 创建半身精灵 */
Sprite_Character.prototype.createHalfBodySprites = function() {
if (!this._upperBody) {
this._upperBody = new Sprite();
this._upperBody.anchor.x = 0.5;
this._upperBody.anchor.y = 1;
this.addChild(this._upperBody);
}
if (!this._lowerBody) {
this._lowerBody = new Sprite();
this._lowerBody.anchor.x = 0.5;
this._lowerBody.anchor.y = 1;
this._lowerBody.opacity = 128;
this.addChild(this._lowerBody);
}
};
/* 更新位置 */
Sprite_Character.prototype.updatePosition = function() {
this.x = this._character.screenX();
this.y = this._character.screenY();
this.z = this._character.screenZ();
};
/* 更新其它 */
Sprite_Character.prototype.updateOther = function() {
this.opacity = this._character.opacity();
this.blendMode = this._character.blendMode();
this._bushDepth = this._character.bushDepth();
};
//-----------------------------------------------------------------------------
// 精灵_战斗者
// Sprite_Battler
//
// Sprite_Actor 和 Sprite_Enemy 的父类。
// The superclass of Sprite_Actor and Sprite_Enemy.
function Sprite_Battler() {
this.initialize(...arguments);
}
Sprite_Battler.prototype = Object.create(Sprite_Clickable.prototype);
Sprite_Battler.prototype.constructor = Sprite_Battler;
/* 初始化 */
Sprite_Battler.prototype.initialize = function(battler) {
Sprite_Clickable.prototype.initialize.call(this);
this.initMembers();
this.setBattler(battler);
};
/* 初始化成员 */
Sprite_Battler.prototype.initMembers = function() {
this.anchor.x = 0.5;
this.anchor.y = 1;
this._battler = null;
this._damages = [];
this._homeX = 0;
this._homeY = 0;
this._offsetX = 0;
this._offsetY = 0;
this._targetOffsetX = NaN;
this._targetOffsetY = NaN;
this._movementDuration = 0;
this._selectionEffectCount = 0;
};
/* 设置战斗者 */
Sprite_Battler.prototype.setBattler = function(battler) {
this._battler = battler;
};
/* 检测战斗者 */
Sprite_Battler.prototype.checkBattler = function(battler) {
return this._battler === battler;
};
/* 主精灵 */
Sprite_Battler.prototype.mainSprite = function() {
return this;
};
/* 设置家
* 以该位置为原点来设置战斗者的偏移位置。
*/
Sprite_Battler.prototype.setHome = function(x, y) {
this._homeX = x;
this._homeY = y;
this.updatePosition();
};
/* 更新 */
Sprite_Battler.prototype.update = function() {
Sprite_Clickable.prototype.update.call(this);
if (this._battler) {
this.updateMain();
this.updateDamagePopup();
this.updateSelectionEffect();
this.updateVisibility();
} else {
this.bitmap = null;
}
};
/* 更新可见性 */
Sprite_Battler.prototype.updateVisibility = function() {
Sprite_Clickable.prototype.updateVisibility.call(this);
if (!this._battler || !this._battler.isSpriteVisible()) {
this.visible = false;
}
};
/* 更新主函数 */
Sprite_Battler.prototype.updateMain = function() {
if (this._battler.isSpriteVisible()) {
this.updateBitmap();
this.updateFrame();
}
this.updateMove();
this.updatePosition();
};
/* 更新位图 */
Sprite_Battler.prototype.updateBitmap = function() {
//
};
/* 更新帧 */
Sprite_Battler.prototype.updateFrame = function() {
//
};
/* 更新移动 */
Sprite_Battler.prototype.updateMove = function() {
if (this._movementDuration > 0) {
const d = this._movementDuration;
this._offsetX = (this._offsetX * (d - 1) + this._targetOffsetX) / d;
this._offsetY = (this._offsetY * (d - 1) + this._targetOffsetY) / d;
this._movementDuration--;
if (this._movementDuration === 0) {
this.onMoveEnd();
}
}
};
/* 更新位置 */
Sprite_Battler.prototype.updatePosition = function() {
this.x = this._homeX + this._offsetX;
this.y = this._homeY + this._offsetY;
};
/* 更新伤害弹出层 */
Sprite_Battler.prototype.updateDamagePopup = function() {
this.setupDamagePopup();
if (this._damages.length > 0) {
for (const damage of this._damages) {
damage.update();
}
if (!this._damages[0].isPlaying()) {
this.destroyDamageSprite(this._damages[0]);
}
}
};
/* 更新选择效果 */
Sprite_Battler.prototype.updateSelectionEffect = function() {
const target = this.mainSprite();
if (this._battler.isSelected()) {
this._selectionEffectCount++;
if (this._selectionEffectCount % 30 < 15) {
target.setBlendColor([255, 255, 255, 64]);
} else {
target.setBlendColor([0, 0, 0, 0]);
}
} else if (this._selectionEffectCount > 0) {
this._selectionEffectCount = 0;
target.setBlendColor([0, 0, 0, 0]);
}
};
/* 设置伤害弹出层 */
Sprite_Battler.prototype.setupDamagePopup = function() {
if (this._battler.isDamagePopupRequested()) {
if (this._battler.isSpriteVisible()) {
this.createDamageSprite();
}
this._battler.clearDamagePopup();
this._battler.clearResult();
}
};
/* 创建伤害弹出层 */
Sprite_Battler.prototype.createDamageSprite = function() {
const last = this._damages[this._damages.length - 1];
const sprite = new Sprite_Damage();
if (last) {
sprite.x = last.x + 8;
sprite.y = last.y - 16;
} else {
sprite.x = this.x + this.damageOffsetX();
sprite.y = this.y + this.damageOffsetY();
}
sprite.setup(this._battler);
this._damages.push(sprite);
this.parent.addChild(sprite);
};
/* 销毁伤害弹出层 */
Sprite_Battler.prototype.destroyDamageSprite = function(sprite) {
this.parent.removeChild(sprite);
this._damages.remove(sprite);
sprite.destroy();
};
/* 伤害的偏移坐标 X */
Sprite_Battler.prototype.damageOffsetX = function() {
return 0;
};
/* 伤害的偏移坐标 Y */
Sprite_Battler.prototype.damageOffsetY = function() {
return 0;
};
/* 开始移动 */
Sprite_Battler.prototype.startMove = function(x, y, duration) {
if (this._targetOffsetX !== x || this._targetOffsetY !== y) {
this._targetOffsetX = x;
this._targetOffsetY = y;
this._movementDuration = duration;
if (duration === 0) {
this._offsetX = x;
this._offsetY = y;
}
}
};
/* 当移动结束 */
Sprite_Battler.prototype.onMoveEnd = function() {
//
};
/* 是否效果中 */
Sprite_Battler.prototype.isEffecting = function() {
return false;
};
/* 是否移动中 */
Sprite_Battler.prototype.isMoving = function() {
return this._movementDuration > 0;
};
/* 是否在家的坐标中 */
Sprite_Battler.prototype.inHomePosition = function() {
return this._offsetX === 0 && this._offsetY === 0;
};
/* 当鼠标进入 */
Sprite_Battler.prototype.onMouseEnter = function() {
$gameTemp.setTouchState(this._battler, "select");
};
/* 当按下 */
Sprite_Battler.prototype.onPress = function() {
$gameTemp.setTouchState(this._battler, "select");
};
/* 当点击 */
Sprite_Battler.prototype.onClick = function() {
$gameTemp.setTouchState(this._battler, "click");
};
//-----------------------------------------------------------------------------
// 精灵_角色
// Sprite_Actor
//
// 显示角色的精灵。
// The sprite for displaying an actor.
function Sprite_Actor() {
this.initialize(...arguments);
}
Sprite_Actor.prototype = Object.create(Sprite_Battler.prototype);
Sprite_Actor.prototype.constructor = Sprite_Actor;
/* 动作 */
Sprite_Actor.MOTIONS = {
walk: { index: 0, loop: true }, // 行走
wait: { index: 1, loop: true }, // 待机
chant: { index: 2, loop: true }, // 吟唱
guard: { index: 3, loop: true }, // 防御
damage: { index: 4, loop: false }, // 受伤
evade: { index: 5, loop: false }, // 躲避
thrust: { index: 6, loop: false }, // 突刺
swing: { index: 7, loop: false }, // 挥舞
missile: { index: 8, loop: false }, // 飞行道具
skill: { index: 9, loop: false }, // 技能
spell: { index: 10, loop: false }, // 魔法
item: { index: 11, loop: false }, // 物品
escape: { index: 12, loop: true }, // 逃跑
victory: { index: 13, loop: true }, // 胜利
dying: { index: 14, loop: true }, // 频死
abnormal: { index: 15, loop: true }, // 状态异常
sleep: { index: 16, loop: true }, // 睡眠
dead: { index: 17, loop: true } // 死亡
};
/* 初始化 */
Sprite_Actor.prototype.initialize = function(battler) {
Sprite_Battler.prototype.initialize.call(this, battler);
this.moveToStartPosition();
};
/* 初始化成员 */
Sprite_Actor.prototype.initMembers = function() {
Sprite_Battler.prototype.initMembers.call(this);
this._battlerName = "";
this._motion = null;
this._motionCount = 0;
this._pattern = 0;
this.createShadowSprite();
this.createWeaponSprite();
this.createMainSprite();
this.createStateSprite();
};
/* 主精灵 */
Sprite_Actor.prototype.mainSprite = function() {
return this._mainSprite;
};
/* 创建主精灵 */
Sprite_Actor.prototype.createMainSprite = function() {
this._mainSprite = new Sprite();
this._mainSprite.anchor.x = 0.5;
this._mainSprite.anchor.y = 1;
this.addChild(this._mainSprite);
};
/* 创建影子精灵 */
Sprite_Actor.prototype.createShadowSprite = function() {
this._shadowSprite = new Sprite();
this._shadowSprite.bitmap = ImageManager.loadSystem("Shadow2");
this._shadowSprite.anchor.x = 0.5;
this._shadowSprite.anchor.y = 0.5;
this._shadowSprite.y = -2;
this.addChild(this._shadowSprite);
};
/* 创建武器精灵 */
Sprite_Actor.prototype.createWeaponSprite = function() {
this._weaponSprite = new Sprite_Weapon();
this.addChild(this._weaponSprite);
};
/* 创建状态精灵 */
Sprite_Actor.prototype.createStateSprite = function() {
this._stateSprite = new Sprite_StateOverlay();
this.addChild(this._stateSprite);
};
/* 设置战斗者 */
Sprite_Actor.prototype.setBattler = function(battler) {
Sprite_Battler.prototype.setBattler.call(this, battler);
if (battler !== this._actor) {
this._actor = battler;
if (battler) {
this.setActorHome(battler.index());
} else {
this._mainSprite.bitmap = null;
}
this.startEntryMotion();
this._stateSprite.setup(battler);
}
};
/* 移动到开始位置 */
Sprite_Actor.prototype.moveToStartPosition = function() {
this.startMove(300, 0, 0);
};
/* 设置角色家 */
Sprite_Actor.prototype.setActorHome = function(index) {
this.setHome(600 + index * 32, 280 + index * 48);
};
/* 更新 */
Sprite_Actor.prototype.update = function() {
Sprite_Battler.prototype.update.call(this);
this.updateShadow();
if (this._actor) {
this.updateMotion();
}
};
/* 更新影子 */
Sprite_Actor.prototype.updateShadow = function() {
this._shadowSprite.visible = !!this._actor;
};
/* 更新主函数 */
Sprite_Actor.prototype.updateMain = function() {
Sprite_Battler.prototype.updateMain.call(this);
if (this._actor.isSpriteVisible() && !this.isMoving()) {
this.updateTargetPosition();
}
};
/* 设置动作 */
Sprite_Actor.prototype.setupMotion = function() {
if (this._actor.isMotionRequested()) {
this.startMotion(this._actor.motionType());
this._actor.clearMotion();
}
};
/* 设置武器动画 */
Sprite_Actor.prototype.setupWeaponAnimation = function() {
if (this._actor.isWeaponAnimationRequested()) {
this._weaponSprite.setup(this._actor.weaponImageId());
this._actor.clearWeaponAnimation();
}
};
/* 开始动作 */
Sprite_Actor.prototype.startMotion = function(motionType) {
const newMotion = Sprite_Actor.MOTIONS[motionType];
if (this._motion !== newMotion) {
this._motion = newMotion;
this._motionCount = 0;
this._pattern = 0;
}
};
/* 更新目标位置 */
Sprite_Actor.prototype.updateTargetPosition = function() {
if (this._actor.canMove() && BattleManager.isEscaped()) {
this.retreat();
} else if (this.shouldStepForward()) {
this.stepForward();
} else if (!this.inHomePosition()) {
this.stepBack();
}
};
/* 是否应该踏步向前 */
Sprite_Actor.prototype.shouldStepForward = function() {
return this._actor.isInputting() || this._actor.isActing();
};
/* 更新位图 */
Sprite_Actor.prototype.updateBitmap = function() {
Sprite_Battler.prototype.updateBitmap.call(this);
const name = this._actor.battlerName();
if (this._battlerName !== name) {
this._battlerName = name;
this._mainSprite.bitmap = ImageManager.loadSvActor(name);
}
};
/* 更新帧 */
Sprite_Actor.prototype.updateFrame = function() {
Sprite_Battler.prototype.updateFrame.call(this);
const bitmap = this._mainSprite.bitmap;
if (bitmap) {
const motionIndex = this._motion ? this._motion.index : 0;
const pattern = this._pattern < 3 ? this._pattern : 1;
const cw = bitmap.width / 9;
const ch = bitmap.height / 6;
const cx = Math.floor(motionIndex / 6) * 3 + pattern;
const cy = motionIndex % 6;
this._mainSprite.setFrame(cx * cw, cy * ch, cw, ch);
this.setFrame(0, 0, cw, ch);
}
};
/* 更新移动 */
Sprite_Actor.prototype.updateMove = function() {
const bitmap = this._mainSprite.bitmap;
if (!bitmap || bitmap.isReady()) {
Sprite_Battler.prototype.updateMove.call(this);
}
};
/* 更新动作 */
Sprite_Actor.prototype.updateMotion = function() {
this.setupMotion();
this.setupWeaponAnimation();
if (this._actor.isMotionRefreshRequested()) {
this.refreshMotion();
this._actor.clearMotion();
}
this.updateMotionCount();
};
/* 更新动作计数 */
Sprite_Actor.prototype.updateMotionCount = function() {
if (this._motion && ++this._motionCount >= this.motionSpeed()) {
if (this._motion.loop) {
this._pattern = (this._pattern + 1) % 4;
} else if (this._pattern < 2) {
this._pattern++;
} else {
this.refreshMotion();
}
this._motionCount = 0;
}
};
/* 动作速度 */
Sprite_Actor.prototype.motionSpeed = function() {
return 12;
};
/* 刷新动作 */
Sprite_Actor.prototype.refreshMotion = function() {
const actor = this._actor;
if (actor) {
const stateMotion = actor.stateMotionIndex();
if (actor.isInputting() || actor.isActing()) {
this.startMotion("walk");
} else if (stateMotion === 3) {
this.startMotion("dead");
} else if (stateMotion === 2) {
this.startMotion("sleep");
} else if (actor.isChanting()) {
this.startMotion("chant");
} else if (actor.isGuard() || actor.isGuardWaiting()) {
this.startMotion("guard");
} else if (stateMotion === 1) {
this.startMotion("abnormal");
} else if (actor.isDying()) {
this.startMotion("dying");
} else if (actor.isUndecided()) {
this.startMotion("walk");
} else {
this.startMotion("wait");
}
}
};
/* 开始进入动作 */
Sprite_Actor.prototype.startEntryMotion = function() {
if (this._actor && this._actor.canMove()) {
this.startMotion("walk");
this.startMove(0, 0, 30);
} else if (!this.isMoving()) {
this.refreshMotion();
this.startMove(0, 0, 0);
}
};
/* 踏步向前 */
Sprite_Actor.prototype.stepForward = function() {
this.startMove(-48, 0, 12);
};
/* 踏步向后 */
Sprite_Actor.prototype.stepBack = function() {
this.startMove(0, 0, 12);
};
/* 撤退 */
Sprite_Actor.prototype.retreat = function() {
this.startMove(300, 0, 30);
};
/* 当移动结束 */
Sprite_Actor.prototype.onMoveEnd = function() {
Sprite_Battler.prototype.onMoveEnd.call(this);
if (!BattleManager.isBattleEnd()) {
this.refreshMotion();
}
};
/* 伤害的偏移坐标 X */
Sprite_Actor.prototype.damageOffsetX = function() {
return Sprite_Battler.prototype.damageOffsetX.call(this) - 32;
};
/* 伤害的偏移坐标 Y */
Sprite_Actor.prototype.damageOffsetY = function() {
return Sprite_Battler.prototype.damageOffsetY.call(this);
};
//-----------------------------------------------------------------------------
// 精灵_敌人
// Sprite_Enemy
//
// 显示敌人的精灵。
// The sprite for displaying an enemy.
function Sprite_Enemy() {
this.initialize(...arguments);
}
Sprite_Enemy.prototype = Object.create(Sprite_Battler.prototype);
Sprite_Enemy.prototype.constructor = Sprite_Enemy;
/* 初始化 */
Sprite_Enemy.prototype.initialize = function(battler) {
Sprite_Battler.prototype.initialize.call(this, battler);
};
/* 初始化成员 */
Sprite_Enemy.prototype.initMembers = function() {
Sprite_Battler.prototype.initMembers.call(this);
this._enemy = null;
this._appeared = false;
this._battlerName = "";
this._battlerHue = 0;
this._effectType = null;
this._effectDuration = 0;
this._shake = 0;
this.createStateIconSprite();
};
/* 创建状态图标精灵 */
Sprite_Enemy.prototype.createStateIconSprite = function() {
this._stateIconSprite = new Sprite_StateIcon();
this.addChild(this._stateIconSprite);
};
/* 设置战斗者 */
Sprite_Enemy.prototype.setBattler = function(battler) {
Sprite_Battler.prototype.setBattler.call(this, battler);
this._enemy = battler;
this.setHome(battler.screenX(), battler.screenY());
this._stateIconSprite.setup(battler);
};
/* 更新 */
Sprite_Enemy.prototype.update = function() {
Sprite_Battler.prototype.update.call(this);
if (this._enemy) {
this.updateEffect();
this.updateStateSprite();
}
};
/* 更新位图 */
Sprite_Enemy.prototype.updateBitmap = function() {
Sprite_Battler.prototype.updateBitmap.call(this);
const name = this._enemy.battlerName();
const hue = this._enemy.battlerHue();
if (this._battlerName !== name || this._battlerHue !== hue) {
this._battlerName = name;
this._battlerHue = hue;
this.loadBitmap(name);
this.setHue(hue);
this.initVisibility();
}
};
/* 加载位图 */
Sprite_Enemy.prototype.loadBitmap = function(name) {
if ($gameSystem.isSideView()) {
this.bitmap = ImageManager.loadSvEnemy(name);
} else {
this.bitmap = ImageManager.loadEnemy(name);
}
};
/* 设置色相 */
Sprite_Enemy.prototype.setHue = function(hue) {
Sprite_Battler.prototype.setHue.call(this, hue);
for (const child of this.children) {
if (child.setHue) {
child.setHue(-hue);
}
}
};
/* 更新帧 */
Sprite_Enemy.prototype.updateFrame = function() {
Sprite_Battler.prototype.updateFrame.call(this);
if (this._effectType === "bossCollapse") {
this.setFrame(0, 0, this.bitmap.width, this._effectDuration);
} else {
this.setFrame(0, 0, this.bitmap.width, this.bitmap.height);
}
};
/* 更新位置 */
Sprite_Enemy.prototype.updatePosition = function() {
Sprite_Battler.prototype.updatePosition.call(this);
this.x += this._shake;
};
/* 更新状态精灵 */
Sprite_Enemy.prototype.updateStateSprite = function() {
this._stateIconSprite.y = -Math.round((this.bitmap.height + 40) * 0.9);
if (this._stateIconSprite.y < 20 - this.y) {
this._stateIconSprite.y = 20 - this.y;
}
};
/* 初始化可见性 */
Sprite_Enemy.prototype.initVisibility = function() {
this._appeared = this._enemy.isAlive();
if (!this._appeared) {
this.opacity = 0;
}
};
/* 设置效果 */
Sprite_Enemy.prototype.setupEffect = function() {
if (this._appeared && this._enemy.isEffectRequested()) {
this.startEffect(this._enemy.effectType());
this._enemy.clearEffect();
}
if (!this._appeared && this._enemy.isAlive()) {
this.startEffect("appear");
} else if (this._appeared && this._enemy.isHidden()) {
this.startEffect("disappear");
}
};
/* 开始效果 */
Sprite_Enemy.prototype.startEffect = function(effectType) {
this._effectType = effectType;
switch (this._effectType) {
case "appear":
this.startAppear();
break;
case "disappear":
this.startDisappear();
break;
case "whiten":
this.startWhiten();
break;
case "blink":
this.startBlink();
break;
case "collapse":
this.startCollapse();
break;
case "bossCollapse":
this.startBossCollapse();
break;
case "instantCollapse":
this.startInstantCollapse();
break;
}
this.revertToNormal();
};
/* 开始出现 */
Sprite_Enemy.prototype.startAppear = function() {
this._effectDuration = 16;
this._appeared = true;
};
/* 开始消失 */
Sprite_Enemy.prototype.startDisappear = function() {
this._effectDuration = 32;
this._appeared = false;
};
/* 开始变白 */
Sprite_Enemy.prototype.startWhiten = function() {
this._effectDuration = 16;
};
/* 开始闪烁 */
Sprite_Enemy.prototype.startBlink = function() {
this._effectDuration = 20;
};
/* 开始倒下 */
Sprite_Enemy.prototype.startCollapse = function() {
this._effectDuration = 32;
this._appeared = false;
};
/* 开始 BOSS 倒下 */
Sprite_Enemy.prototype.startBossCollapse = function() {
this._effectDuration = this.bitmap.height;
this._appeared = false;
};
/* 开始瞬间倒下 */
Sprite_Enemy.prototype.startInstantCollapse = function() {
this._effectDuration = 16;
this._appeared = false;
};
/* 更新效果 */
Sprite_Enemy.prototype.updateEffect = function() {
this.setupEffect();
if (this._effectDuration > 0) {
this._effectDuration--;
switch (this._effectType) {
case "whiten":
this.updateWhiten();
break;
case "blink":
this.updateBlink();
break;
case "appear":
this.updateAppear();
break;
case "disappear":
this.updateDisappear();
break;
case "collapse":
this.updateCollapse();
break;
case "bossCollapse":
this.updateBossCollapse();
break;
case "instantCollapse":
this.updateInstantCollapse();
break;
}
if (this._effectDuration === 0) {
this._effectType = null;
}
}
};
/* 是否效果中 */
Sprite_Enemy.prototype.isEffecting = function() {
return this._effectType !== null;
};
/* 回到普通 */
Sprite_Enemy.prototype.revertToNormal = function() {
this._shake = 0;
this.blendMode = 0;
this.opacity = 255;
this.setBlendColor([0, 0, 0, 0]);
};
/* 更新变白 */
Sprite_Enemy.prototype.updateWhiten = function() {
const alpha = 128 - (16 - this._effectDuration) * 8;
this.setBlendColor([255, 255, 255, alpha]);
};
/* 更新闪烁 */
Sprite_Enemy.prototype.updateBlink = function() {
this.opacity = this._effectDuration % 10 < 5 ? 255 : 0;
};
/* 更新出现 */
Sprite_Enemy.prototype.updateAppear = function() {
this.opacity = (16 - this._effectDuration) * 16;
};
/* 更新消失 */
Sprite_Enemy.prototype.updateDisappear = function() {
this.opacity = 256 - (32 - this._effectDuration) * 10;
};
/* 更新倒下 */
Sprite_Enemy.prototype.updateCollapse = function() {
this.blendMode = 1;
this.setBlendColor([255, 128, 128, 128]);
this.opacity *= this._effectDuration / (this._effectDuration + 1);
};
/* 更新 BOSS 倒下 */
Sprite_Enemy.prototype.updateBossCollapse = function() {
this._shake = (this._effectDuration % 2) * 4 - 2;
this.blendMode = 1;
this.opacity *= this._effectDuration / (this._effectDuration + 1);
this.setBlendColor([255, 255, 255, 255 - this.opacity]);
if (this._effectDuration % 20 === 19) {
SoundManager.playBossCollapse2();
}
};
/* 更新瞬间倒下 */
Sprite_Enemy.prototype.updateInstantCollapse = function() {
this.opacity = 0;
};
/* 伤害的偏移坐标 X */
Sprite_Enemy.prototype.damageOffsetX = function() {
return Sprite_Battler.prototype.damageOffsetX.call(this);
};
/* 伤害的偏移坐标 Y */
Sprite_Enemy.prototype.damageOffsetY = function() {
return Sprite_Battler.prototype.damageOffsetY.call(this) - 8;
};
//-----------------------------------------------------------------------------
// 精灵_动画
// Sprite_Animation
//
// 显示动画的精灵。
// The sprite for displaying an animation.
function Sprite_Animation() {
this.initialize(...arguments);
}
Sprite_Animation.prototype = Object.create(Sprite.prototype);
Sprite_Animation.prototype.constructor = Sprite_Animation;
/* 初始化 */
Sprite_Animation.prototype.initialize = function() {
Sprite.prototype.initialize.call(this);
this.initMembers();
};
/* 初始化成员 */
Sprite_Animation.prototype.initMembers = function() {
this._targets = [];
this._animation = null;
this._mirror = false;
this._delay = 0;
this._previous = null;
this._effect = null;
this._handle = null;
this._playing = false;
this._started = false;
this._frameIndex = 0;
this._maxTimingFrames = 0;
this._flashColor = [0, 0, 0, 0];
this._flashDuration = 0;
this._viewportSize = 4096;
this._originalViewport = null;
this.z = 8;
};
/* 销毁 */
Sprite_Animation.prototype.destroy = function(options) {
Sprite.prototype.destroy.call(this, options);
if (this._handle) {
this._handle.stop();
}
this._effect = null;
this._handle = null;
this._playing = false;
this._started = false;
};
/* 设置 */
// prettier-ignore
Sprite_Animation.prototype.setup = function(
targets, animation, mirror, delay, previous
) {
this._targets = targets;
this._animation = animation;
this._mirror = mirror;
this._delay = delay;
this._previous = previous;
this._effect = EffectManager.load(animation.effectName);
this._playing = true;
const timings = animation.soundTimings.concat(animation.flashTimings);
for (const timing of timings) {
if (timing.frame > this._maxTimingFrames) {
this._maxTimingFrames = timing.frame;
}
}
};
/* 更新 */
Sprite_Animation.prototype.update = function() {
Sprite.prototype.update.call(this);
if (this._delay > 0) {
this._delay--;
} else if (this._playing) {
if (!this._started && this.canStart()) {
if (this._effect) {
if (this._effect.isLoaded) {
this._handle = Graphics.effekseer.play(this._effect);
this._started = true;
} else {
EffectManager.checkErrors();
}
} else {
this._started = true;
}
}
if (this._started) {
this.updateEffectGeometry();
this.updateMain();
this.updateFlash();
}
}
};
/* 是否能开始 */
Sprite_Animation.prototype.canStart = function() {
if (this._previous && this.shouldWaitForPrevious()) {
return !this._previous.isPlaying();
} else {
return true;
}
};
/* 是否应该等待上一个 */
Sprite_Animation.prototype.shouldWaitForPrevious = function() {
// [备注] Effekseer 在某些移动设备上非常重度,因此我们不会同时显示许多效果。
// [Note] Effekseer is very heavy on some mobile devices, so we don't
// display many effects at the same time.
return Utils.isMobileDevice();
};
/* 更新效果几何图形 */
Sprite_Animation.prototype.updateEffectGeometry = function() {
const scale = this._animation.scale / 100;
const r = Math.PI / 180;
const rx = this._animation.rotation.x * r;
const ry = this._animation.rotation.y * r;
const rz = this._animation.rotation.z * r;
if (this._handle) {
this._handle.setLocation(0, 0, 0);
this._handle.setRotation(rx, ry, rz);
this._handle.setScale(scale, scale, scale);
this._handle.setSpeed(this._animation.speed / 100);
}
};
/* 更新主函数 */
Sprite_Animation.prototype.updateMain = function() {
this.processSoundTimings();
this.processFlashTimings();
this._frameIndex++;
this.checkEnd();
};
/* 处理声音时间安排 */
Sprite_Animation.prototype.processSoundTimings = function() {
for (const timing of this._animation.soundTimings) {
if (timing.frame === this._frameIndex) {
AudioManager.playSe(timing.se);
}
}
};
/* 处理闪烁时间安排 */
Sprite_Animation.prototype.processFlashTimings = function() {
for (const timing of this._animation.flashTimings) {
if (timing.frame === this._frameIndex) {
this._flashColor = timing.color.clone();
this._flashDuration = timing.duration;
}
}
};
/* 检测结束 */
Sprite_Animation.prototype.checkEnd = function() {
if (
this._frameIndex > this._maxTimingFrames &&
this._flashDuration === 0 &&
!(this._handle && this._handle.exists)
) {
this._playing = false;
}
};
/* 更新闪烁 */
Sprite_Animation.prototype.updateFlash = function() {
if (this._flashDuration > 0) {
const d = this._flashDuration--;
this._flashColor[3] *= (d - 1) / d;
for (const target of this._targets) {
target.setBlendColor(this._flashColor);
}
}
};
/* 是否播放中 */
Sprite_Animation.prototype.isPlaying = function() {
return this._playing;
};
/* 设置旋转 */
Sprite_Animation.prototype.setRotation = function(x, y, z) {
if (this._handle) {
this._handle.setRotation(x, y, z);
}
};
/* 渲染 */
Sprite_Animation.prototype._render = function(renderer) {
if (this._targets.length > 0 && this._handle && this._handle.exists) {
this.onBeforeRender(renderer);
this.saveViewport(renderer);
this.setProjectionMatrix(renderer);
this.setCameraMatrix(renderer);
this.setViewport(renderer);
Graphics.effekseer.beginDraw();
Graphics.effekseer.drawHandle(this._handle);
Graphics.effekseer.endDraw();
this.resetViewport(renderer);
this.onAfterRender(renderer);
}
};
/* 设置投影矩阵 */
Sprite_Animation.prototype.setProjectionMatrix = function(renderer) {
const x = this._mirror ? -1 : 1;
const y = -1;
const p = -(this._viewportSize / renderer.view.height);
// prettier-ignore
Graphics.effekseer.setProjectionMatrix([
x, 0, 0, 0,
0, y, 0, 0,
0, 0, 1, p,
0, 0, 0, 1,
]);
};
/* 设置相机矩阵 */
Sprite_Animation.prototype.setCameraMatrix = function(/*renderer*/) {
// prettier-ignore
Graphics.effekseer.setCameraMatrix([
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, -10, 1
]);
};
/* 设置可视区域 */
Sprite_Animation.prototype.setViewport = function(renderer) {
const vw = this._viewportSize;
const vh = this._viewportSize;
const vx = this._animation.offsetX - vw / 2;
const vy = this._animation.offsetY - vh / 2;
const pos = this.targetPosition(renderer);
renderer.gl.viewport(vx + pos.x, vy + pos.y, vw, vh);
};
/* 目标位置 */
Sprite_Animation.prototype.targetPosition = function(renderer) {
const pos = new Point();
if (this._animation.displayType === 2) {
pos.x = renderer.view.width / 2;
pos.y = renderer.view.height / 2;
} else {
for (const target of this._targets) {
const tpos = this.targetSpritePosition(target);
pos.x += tpos.x;
pos.y += tpos.y;
}
pos.x /= this._targets.length;
pos.y /= this._targets.length;
}
return pos;
};
/* 目标精灵位置 */
Sprite_Animation.prototype.targetSpritePosition = function(sprite) {
const point = new Point(0, -sprite.height / 2);
sprite.updateTransform();
return sprite.worldTransform.apply(point);
};
/* 保存可视区域 */
Sprite_Animation.prototype.saveViewport = function(renderer) {
// [备注] 检索可视区域有点重度。
// [Note] Retrieving the viewport is somewhat heavy.
if (!this._originalViewport) {
this._originalViewport = renderer.gl.getParameter(renderer.gl.VIEWPORT);
}
};
/* 重设可视区域 */
Sprite_Animation.prototype.resetViewport = function(renderer) {
const vp = this._originalViewport;
renderer.gl.viewport(vp[0], vp[1], vp[2], vp[3]);
};
/* 当渲染之前 */
Sprite_Animation.prototype.onBeforeRender = function(renderer) {
renderer.batch.flush();
renderer.geometry.reset();
};
/* 当渲染之后 */
Sprite_Animation.prototype.onAfterRender = function(renderer) {
renderer.texture.contextChange();
renderer.texture.reset();
renderer.geometry.reset();
renderer.state.reset();
renderer.shader.reset();
renderer.framebuffer.reset();
};
//-----------------------------------------------------------------------------
// 精灵_MV的动画
// Sprite_AnimationMV
//
// 显示旧格式动画的精灵。
// The sprite for displaying an old format animation.
function Sprite_AnimationMV() {
this.initialize(...arguments);
}
Sprite_AnimationMV.prototype = Object.create(Sprite.prototype);
Sprite_AnimationMV.prototype.constructor = Sprite_AnimationMV;
/* 初始化 */
Sprite_AnimationMV.prototype.initialize = function() {
Sprite.prototype.initialize.call(this);
this.initMembers();
};
/* 初始化成员 */
Sprite_AnimationMV.prototype.initMembers = function() {
this._targets = [];
this._animation = null;
this._mirror = false;
this._delay = 0;
this._rate = 4;
this._duration = 0;
this._flashColor = [0, 0, 0, 0];
this._flashDuration = 0;
this._screenFlashDuration = 0;
this._hidingDuration = 0;
this._hue1 = 0;
this._hue2 = 0;
this._bitmap1 = null;
this._bitmap2 = null;
this._cellSprites = [];
this._screenFlashSprite = null;
this.z = 8;
};
/* 设置 */
// prettier-ignore
Sprite_AnimationMV.prototype.setup = function(
targets, animation, mirror, delay
) {
this._targets = targets;
this._animation = animation;
this._mirror = mirror;
this._delay = delay;
if (this._animation) {
this.setupRate();
this.setupDuration();
this.loadBitmaps();
this.createCellSprites();
this.createScreenFlashSprite();
}
};
/* 设置倍率 */
Sprite_AnimationMV.prototype.setupRate = function() {
this._rate = 4;
};
/* 设置持续时间 */
Sprite_AnimationMV.prototype.setupDuration = function() {
this._duration = this._animation.frames.length * this._rate + 1;
};
/* 更新 */
Sprite_AnimationMV.prototype.update = function() {
Sprite.prototype.update.call(this);
this.updateMain();
this.updateFlash();
this.updateScreenFlash();
this.updateHiding();
};
/* 更新闪烁 */
Sprite_AnimationMV.prototype.updateFlash = function() {
if (this._flashDuration > 0) {
const d = this._flashDuration--;
this._flashColor[3] *= (d - 1) / d;
for (const target of this._targets) {
target.setBlendColor(this._flashColor);
}
}
};
/* 更新画面闪烁 */
Sprite_AnimationMV.prototype.updateScreenFlash = function() {
if (this._screenFlashDuration > 0) {
const d = this._screenFlashDuration--;
if (this._screenFlashSprite) {
this._screenFlashSprite.x = -this.absoluteX();
this._screenFlashSprite.y = -this.absoluteY();
this._screenFlashSprite.opacity *= (d - 1) / d;
this._screenFlashSprite.visible = this._screenFlashDuration > 0;
}
}
};
/* 绝对坐标 X */
Sprite_AnimationMV.prototype.absoluteX = function() {
let x = 0;
let object = this;
while (object) {
x += object.x;
object = object.parent;
}
return x;
};
/* 绝对坐标 Y */
Sprite_AnimationMV.prototype.absoluteY = function() {
let y = 0;
let object = this;
while (object) {
y += object.y;
object = object.parent;
}
return y;
};
/* 更新隐藏 */
Sprite_AnimationMV.prototype.updateHiding = function() {
if (this._hidingDuration > 0) {
this._hidingDuration--;
if (this._hidingDuration === 0) {
for (const target of this._targets) {
target.show();
}
}
}
};
/* 是否播放中 */
Sprite_AnimationMV.prototype.isPlaying = function() {
return this._duration > 0;
};
/* 加载位图 */
Sprite_AnimationMV.prototype.loadBitmaps = function() {
const name1 = this._animation.animation1Name;
const name2 = this._animation.animation2Name;
this._hue1 = this._animation.animation1Hue;
this._hue2 = this._animation.animation2Hue;
this._bitmap1 = ImageManager.loadAnimation(name1);
this._bitmap2 = ImageManager.loadAnimation(name2);
};
/* 是否准备好 */
Sprite_AnimationMV.prototype.isReady = function() {
return (
this._bitmap1 &&
this._bitmap1.isReady() &&
this._bitmap2 &&
this._bitmap2.isReady()
);
};
/* 创建单元精灵 */
Sprite_AnimationMV.prototype.createCellSprites = function() {
this._cellSprites = [];
for (let i = 0; i < 16; i++) {
const sprite = new Sprite();
sprite.anchor.x = 0.5;
sprite.anchor.y = 0.5;
this._cellSprites.push(sprite);
this.addChild(sprite);
}
};
/* 创建画面闪烁精灵 */
Sprite_AnimationMV.prototype.createScreenFlashSprite = function() {
this._screenFlashSprite = new ScreenSprite();
this.addChild(this._screenFlashSprite);
};
/* 更新主函数 */
Sprite_AnimationMV.prototype.updateMain = function() {
if (this.isPlaying() && this.isReady()) {
if (this._delay > 0) {
this._delay--;
} else {
this._duration--;
this.updatePosition();
if (this._duration % this._rate === 0) {
this.updateFrame();
}
if (this._duration <= 0) {
this.onEnd();
}
}
}
};
/* 更新位置 */
Sprite_AnimationMV.prototype.updatePosition = function() {
if (this._animation.position === 3) {
this.x = this.parent.width / 2;
this.y = this.parent.height / 2;
} else if (this._targets.length > 0) {
const target = this._targets[0];
const parent = target.parent;
const grandparent = parent ? parent.parent : null;
this.x = target.x;
this.y = target.y;
if (this.parent === grandparent) {
this.x += parent.x;
this.y += parent.y;
}
if (this._animation.position === 0) {
this.y -= target.height;
} else if (this._animation.position === 1) {
this.y -= target.height / 2;
}
}
};
/* 更新帧 */
Sprite_AnimationMV.prototype.updateFrame = function() {
if (this._duration > 0) {
const frameIndex = this.currentFrameIndex();
this.updateAllCellSprites(this._animation.frames[frameIndex]);
for (const timing of this._animation.timings) {
if (timing.frame === frameIndex) {
this.processTimingData(timing);
}
}
}
};
/* 当前帧索引 */
Sprite_AnimationMV.prototype.currentFrameIndex = function() {
return (
this._animation.frames.length -
Math.floor((this._duration + this._rate - 1) / this._rate)
);
};
/* 更新所有单元精灵 */
Sprite_AnimationMV.prototype.updateAllCellSprites = function(frame) {
if (this._targets.length > 0) {
for (let i = 0; i < this._cellSprites.length; i++) {
const sprite = this._cellSprites[i];
if (i < frame.length) {
this.updateCellSprite(sprite, frame[i]);
} else {
sprite.visible = false;
}
}
}
};
/* 更新单元精灵 */
Sprite_AnimationMV.prototype.updateCellSprite = function(sprite, cell) {
const pattern = cell[0];
if (pattern >= 0) {
const sx = (pattern % 5) * 192;
const sy = Math.floor((pattern % 100) / 5) * 192;
const mirror = this._mirror;
sprite.bitmap = pattern < 100 ? this._bitmap1 : this._bitmap2;
sprite.setHue(pattern < 100 ? this._hue1 : this._hue2);
sprite.setFrame(sx, sy, 192, 192);
sprite.x = cell[1];
sprite.y = cell[2];
sprite.rotation = (cell[4] * Math.PI) / 180;
sprite.scale.x = cell[3] / 100;
if (cell[5]) {
sprite.scale.x *= -1;
}
if (mirror) {
sprite.x *= -1;
sprite.rotation *= -1;
sprite.scale.x *= -1;
}
sprite.scale.y = cell[3] / 100;
sprite.opacity = cell[6];
sprite.blendMode = cell[7];
sprite.visible = true;
} else {
sprite.visible = false;
}
};
/* 处理时间安排数据 */
Sprite_AnimationMV.prototype.processTimingData = function(timing) {
const duration = timing.flashDuration * this._rate;
switch (timing.flashScope) {
case 1:
this.startFlash(timing.flashColor, duration);
break;
case 2:
this.startScreenFlash(timing.flashColor, duration);
break;
case 3:
this.startHiding(duration);
break;
}
if (timing.se) {
AudioManager.playSe(timing.se);
}
};
/* 开始闪烁 */
Sprite_AnimationMV.prototype.startFlash = function(color, duration) {
this._flashColor = color.clone();
this._flashDuration = duration;
};
/* 开始画面闪烁 */
Sprite_AnimationMV.prototype.startScreenFlash = function(color, duration) {
this._screenFlashDuration = duration;
if (this._screenFlashSprite) {
this._screenFlashSprite.setColor(color[0], color[1], color[2]);
this._screenFlashSprite.opacity = color[3];
}
};
/* 开始隐藏 */
Sprite_AnimationMV.prototype.startHiding = function(duration) {
this._hidingDuration = duration;
for (const target of this._targets) {
target.hide();
}
};
/* 当结束 */
Sprite_AnimationMV.prototype.onEnd = function() {
this._flashDuration = 0;
this._screenFlashDuration = 0;
this._hidingDuration = 0;
for (const target of this._targets) {
target.setBlendColor([0, 0, 0, 0]);
target.show();
}
};
//-----------------------------------------------------------------------------
// 精灵_战斗背景
// Sprite_Battleback
//
// 在战斗中显示背景图片的精灵。
// The sprite for displaying a background image in battle.
function Sprite_Battleback() {
this.initialize(...arguments);
}
Sprite_Battleback.prototype = Object.create(TilingSprite.prototype);
Sprite_Battleback.prototype.constructor = Sprite_Battleback;
/* 初始化 */
Sprite_Battleback.prototype.initialize = function(type) {
TilingSprite.prototype.initialize.call(this);
if (type === 0) {
this.bitmap = this.battleback1Bitmap();
} else {
this.bitmap = this.battleback2Bitmap();
}
};
/* 自适应位置 */
Sprite_Battleback.prototype.adjustPosition = function() {
this.width = Math.floor((1000 * Graphics.width) / 816);
this.height = Math.floor((740 * Graphics.height) / 624);
this.x = (Graphics.width - this.width) / 2;
if ($gameSystem.isSideView()) {
this.y = Graphics.height - this.height;
} else {
this.y = 0;
}
const ratioX = this.width / this.bitmap.width;
const ratioY = this.height / this.bitmap.height;
const scale = Math.max(ratioX, ratioY, 1.0);
this.scale.x = scale;
this.scale.y = scale;
};
/* 战斗背景 1 位图 */
Sprite_Battleback.prototype.battleback1Bitmap = function() {
return ImageManager.loadBattleback1(this.battleback1Name());
};
/* 战斗背景 2 位图 */
Sprite_Battleback.prototype.battleback2Bitmap = function() {
return ImageManager.loadBattleback2(this.battleback2Name());
};
/* 战斗背景 1 名称 */
Sprite_Battleback.prototype.battleback1Name = function() {
if (BattleManager.isBattleTest()) {
return $dataSystem.battleback1Name;
} else if ($gameMap.battleback1Name() !== null) {
return $gameMap.battleback1Name();
} else if ($gameMap.isOverworld()) {
return this.overworldBattleback1Name();
} else {
return "";
}
};
/* 战斗背景 2 名称 */
Sprite_Battleback.prototype.battleback2Name = function() {
if (BattleManager.isBattleTest()) {
return $dataSystem.battleback2Name;
} else if ($gameMap.battleback2Name() !== null) {
return $gameMap.battleback2Name();
} else if ($gameMap.isOverworld()) {
return this.overworldBattleback2Name();
} else {
return "";
}
};
/* 主世界战斗背景 1 名称 */
Sprite_Battleback.prototype.overworldBattleback1Name = function() {
if ($gamePlayer.isInVehicle()) {
return this.shipBattleback1Name();
} else {
return this.normalBattleback1Name();
}
};
/* 主世界战斗背景 2 名称 */
Sprite_Battleback.prototype.overworldBattleback2Name = function() {
if ($gamePlayer.isInVehicle()) {
return this.shipBattleback2Name();
} else {
return this.normalBattleback2Name();
}
};
/* 普通战斗背景 1 名称 */
Sprite_Battleback.prototype.normalBattleback1Name = function() {
return (
this.terrainBattleback1Name(this.autotileType(1)) ||
this.terrainBattleback1Name(this.autotileType(0)) ||
this.defaultBattleback1Name()
);
};
/* 普通战斗背景 2 名称 */
Sprite_Battleback.prototype.normalBattleback2Name = function() {
return (
this.terrainBattleback2Name(this.autotileType(1)) ||
this.terrainBattleback2Name(this.autotileType(0)) ||
this.defaultBattleback2Name()
);
};
/* 地形战斗背景 1 名称 */
Sprite_Battleback.prototype.terrainBattleback1Name = function(type) {
switch (type) {
case 24:
case 25:
return "Wasteland";
case 26:
case 27:
return "DirtField";
case 32:
case 33:
return "Desert";
case 34:
return "Lava1";
case 35:
return "Lava2";
case 40:
case 41:
return "Snowfield";
case 42:
return "Clouds";
case 4:
case 5:
return "PoisonSwamp";
default:
return null;
}
};
/* 地形战斗背景 2 名称 */
Sprite_Battleback.prototype.terrainBattleback2Name = function(type) {
switch (type) {
case 20:
case 21:
return "Forest";
case 22:
case 30:
case 38:
return "Cliff";
case 24:
case 25:
case 26:
case 27:
return "Wasteland";
case 32:
case 33:
return "Desert";
case 34:
case 35:
return "Lava";
case 40:
case 41:
return "Snowfield";
case 42:
return "Clouds";
case 4:
case 5:
return "PoisonSwamp";
}
};
/* 默认战斗背景 1 名称 */
Sprite_Battleback.prototype.defaultBattleback1Name = function() {
return "Grassland";
};
/* 默认战斗背景 2 名称 */
Sprite_Battleback.prototype.defaultBattleback2Name = function() {
return "Grassland";
};
/* 飞艇战斗背景 1 名称 */
Sprite_Battleback.prototype.shipBattleback1Name = function() {
return "Ship";
};
/* 飞艇战斗背景 2 名称 */
Sprite_Battleback.prototype.shipBattleback2Name = function() {
return "Ship";
};
/* 自动图块类型 */
Sprite_Battleback.prototype.autotileType = function(z) {
return $gameMap.autotileType($gamePlayer.x, $gamePlayer.y, z);
};
//-----------------------------------------------------------------------------
// 精灵_伤害
// Sprite_Damage
//
// 显示弹出伤害的精灵。
// The sprite for displaying a popup damage.
function Sprite_Damage() {
this.initialize(...arguments);
}
Sprite_Damage.prototype = Object.create(Sprite.prototype);
Sprite_Damage.prototype.constructor = Sprite_Damage;
/* 初始化 */
Sprite_Damage.prototype.initialize = function() {
Sprite.prototype.initialize.call(this);
this._duration = 90;
this._flashColor = [0, 0, 0, 0];
this._flashDuration = 0;
this._colorType = 0;
};
/* 销毁 */
Sprite_Damage.prototype.destroy = function(options) {
for (const child of this.children) {
if (child.bitmap) {
child.bitmap.destroy();
}
}
Sprite.prototype.destroy.call(this, options);
};
/* 设置 */
Sprite_Damage.prototype.setup = function(target) {
const result = target.result();
if (result.missed || result.evaded) {
this._colorType = 0;
this.createMiss();
} else if (result.hpAffected) {
this._colorType = result.hpDamage >= 0 ? 0 : 1;
this.createDigits(result.hpDamage);
} else if (target.isAlive() && result.mpDamage !== 0) {
this._colorType = result.mpDamage >= 0 ? 2 : 3;
this.createDigits(result.mpDamage);
}
if (result.critical) {
this.setupCriticalEffect();
}
};
/* 设置暴击效果 */
Sprite_Damage.prototype.setupCriticalEffect = function() {
this._flashColor = [255, 0, 0, 160];
this._flashDuration = 60;
};
/* 字体 */
Sprite_Damage.prototype.fontFace = function() {
return $gameSystem.numberFontFace();
};
/* 字体大小 */
Sprite_Damage.prototype.fontSize = function() {
return $gameSystem.mainFontSize() + 4;
};
/* 伤害颜色 */
Sprite_Damage.prototype.damageColor = function() {
return ColorManager.damageColor(this._colorType);
};
/* 描边颜色 */
Sprite_Damage.prototype.outlineColor = function() {
return "rgba(0, 0, 0, 0.7)";
};
/* 描边宽度 */
Sprite_Damage.prototype.outlineWidth = function() {
return 4;
};
/* 创建未命中 */
Sprite_Damage.prototype.createMiss = function() {
const h = this.fontSize();
const w = Math.floor(h * 3.0);
const sprite = this.createChildSprite(w, h);
sprite.bitmap.drawText("Miss", 0, 0, w, h, "center");
sprite.dy = 0;
};
/* 创建数字 */
Sprite_Damage.prototype.createDigits = function(value) {
const string = Math.abs(value).toString();
const h = this.fontSize();
const w = Math.floor(h * 0.75);
for (let i = 0; i < string.length; i++) {
const sprite = this.createChildSprite(w, h);
sprite.bitmap.drawText(string[i], 0, 0, w, h, "center");
sprite.x = (i - (string.length - 1) / 2) * w;
sprite.dy = -i;
}
};
/* 创建子精灵 */
Sprite_Damage.prototype.createChildSprite = function(width, height) {
const sprite = new Sprite();
sprite.bitmap = this.createBitmap(width, height);
sprite.anchor.x = 0.5;
sprite.anchor.y = 1;
sprite.y = -40;
sprite.ry = sprite.y;
this.addChild(sprite);
return sprite;
};
/* 创建位图 */
Sprite_Damage.prototype.createBitmap = function(width, height) {
const bitmap = new Bitmap(width, height);
bitmap.fontFace = this.fontFace();
bitmap.fontSize = this.fontSize();
bitmap.textColor = this.damageColor();
bitmap.outlineColor = this.outlineColor();
bitmap.outlineWidth = this.outlineWidth();
return bitmap;
};
/* 更新 */
Sprite_Damage.prototype.update = function() {
Sprite.prototype.update.call(this);
if (this._duration > 0) {
this._duration--;
for (const child of this.children) {
this.updateChild(child);
}
}
this.updateFlash();
this.updateOpacity();
};
/* 更新子元素 */
Sprite_Damage.prototype.updateChild = function(sprite) {
sprite.dy += 0.5;
sprite.ry += sprite.dy;
if (sprite.ry >= 0) {
sprite.ry = 0;
sprite.dy *= -0.6;
}
sprite.y = Math.round(sprite.ry);
sprite.setBlendColor(this._flashColor);
};
/* 更新闪烁 */
Sprite_Damage.prototype.updateFlash = function() {
if (this._flashDuration > 0) {
const d = this._flashDuration--;
this._flashColor[3] *= (d - 1) / d;
}
};
/* 更新不透明度 */
Sprite_Damage.prototype.updateOpacity = function() {
if (this._duration < 10) {
this.opacity = (255 * this._duration) / 10;
}
};
/* 是否播放中 */
Sprite_Damage.prototype.isPlaying = function() {
return this._duration > 0;
};
//-----------------------------------------------------------------------------
// 精灵_计量
// Sprite_Gauge
//
// 显示状态计量的精灵。
// The sprite for displaying a status gauge.
function Sprite_Gauge() {
this.initialize(...arguments);
}
Sprite_Gauge.prototype = Object.create(Sprite.prototype);
Sprite_Gauge.prototype.constructor = Sprite_Gauge;
/* 初始化 */
Sprite_Gauge.prototype.initialize = function() {
Sprite.prototype.initialize.call(this);
this.initMembers();
this.createBitmap();
};
/* 初始化成员 */
Sprite_Gauge.prototype.initMembers = function() {
this._battler = null;
this._statusType = "";
this._value = NaN;
this._maxValue = NaN;
this._targetValue = NaN;
this._targetMaxValue = NaN;
this._duration = 0;
this._flashingCount = 0;
};
/* 销毁 */
Sprite_Gauge.prototype.destroy = function(options) {
this.bitmap.destroy();
Sprite.prototype.destroy.call(this, options);
};
/* 创建位图 */
Sprite_Gauge.prototype.createBitmap = function() {
const width = this.bitmapWidth();
const height = this.bitmapHeight();
this.bitmap = new Bitmap(width, height);
};
/* 位图宽度 */
Sprite_Gauge.prototype.bitmapWidth = function() {
return 128;
};
/* 位图高度 */
Sprite_Gauge.prototype.bitmapHeight = function() {
return 24;
};
/* 计量高度 */
Sprite_Gauge.prototype.gaugeHeight = function() {
return 12;
};
/* 计量坐标 X */
Sprite_Gauge.prototype.gaugeX = function() {
return this._statusType === "time" ? 0 : 30;
};
/* 标签坐标 Y */
Sprite_Gauge.prototype.labelY = function() {
return 3;
};
/* 标签字体 */
Sprite_Gauge.prototype.labelFontFace = function() {
return $gameSystem.mainFontFace();
};
/* 标签字体大小 */
Sprite_Gauge.prototype.labelFontSize = function() {
return $gameSystem.mainFontSize() - 2;
};
/* 值字体 */
Sprite_Gauge.prototype.valueFontFace = function() {
return $gameSystem.numberFontFace();
};
/* 值字体大小 */
Sprite_Gauge.prototype.valueFontSize = function() {
return $gameSystem.mainFontSize() - 6;
};
/* 设置 */
Sprite_Gauge.prototype.setup = function(battler, statusType) {
this._battler = battler;
this._statusType = statusType;
this._value = this.currentValue();
this._maxValue = this.currentMaxValue();
this.updateBitmap();
};
/* 更新 */
Sprite_Gauge.prototype.update = function() {
Sprite.prototype.update.call(this);
this.updateBitmap();
};
/* 更新位图 */
Sprite_Gauge.prototype.updateBitmap = function() {
const value = this.currentValue();
const maxValue = this.currentMaxValue();
if (value !== this._targetValue || maxValue !== this._targetMaxValue) {
this.updateTargetValue(value, maxValue);
}
this.updateGaugeAnimation();
this.updateFlashing();
};
/* 更新目标值 */
Sprite_Gauge.prototype.updateTargetValue = function(value, maxValue) {
this._targetValue = value;
this._targetMaxValue = maxValue;
if (isNaN(this._value)) {
this._value = value;
this._maxValue = maxValue;
this.redraw();
} else {
this._duration = this.smoothness();
}
};
/* 平滑
* 值变化的时候计量平滑的改变,即在一段时间内慢慢改变。
*/
Sprite_Gauge.prototype.smoothness = function() {
return this._statusType === "time" ? 5 : 20;
};
/* 更新计量动画 */
Sprite_Gauge.prototype.updateGaugeAnimation = function() {
if (this._duration > 0) {
const d = this._duration;
this._value = (this._value * (d - 1) + this._targetValue) / d;
this._maxValue = (this._maxValue * (d - 1) + this._targetMaxValue) / d;
this._duration--;
this.redraw();
}
};
/* 更新闪烁 */
Sprite_Gauge.prototype.updateFlashing = function() {
if (this._statusType === "time") {
this._flashingCount++;
if (this._battler.isInputting()) {
if (this._flashingCount % 30 < 15) {
this.setBlendColor(this.flashingColor1());
} else {
this.setBlendColor(this.flashingColor2());
}
} else {
this.setBlendColor([0, 0, 0, 0]);
}
}
};
/* 闪烁颜色 1 */
Sprite_Gauge.prototype.flashingColor1 = function() {
return [255, 255, 255, 64];
};
/* 闪烁颜色 2 */
Sprite_Gauge.prototype.flashingColor2 = function() {
return [0, 0, 255, 48];
};
/* 是否有效的 */
Sprite_Gauge.prototype.isValid = function() {
if (this._battler) {
if (this._statusType === "tp" && !this._battler.isPreserveTp()) {
return $gameParty.inBattle();
} else {
return true;
}
}
return false;
};
/* 当前值 */
Sprite_Gauge.prototype.currentValue = function() {
if (this._battler) {
switch (this._statusType) {
case "hp":
return this._battler.hp;
case "mp":
return this._battler.mp;
case "tp":
return this._battler.tp;
case "time":
return this._battler.tpbChargeTime();
}
}
return NaN;
};
/* 当前最大值 */
Sprite_Gauge.prototype.currentMaxValue = function() {
if (this._battler) {
switch (this._statusType) {
case "hp":
return this._battler.mhp;
case "mp":
return this._battler.mmp;
case "tp":
return this._battler.maxTp();
case "time":
return 1;
}
}
return NaN;
};
/* 标签 */
Sprite_Gauge.prototype.label = function() {
switch (this._statusType) {
case "hp":
return TextManager.hpA;
case "mp":
return TextManager.mpA;
case "tp":
return TextManager.tpA;
default:
return "";
}
};
/* 计量背景颜色 */
Sprite_Gauge.prototype.gaugeBackColor = function() {
return ColorManager.gaugeBackColor();
};
/* 计量颜色 1 */
Sprite_Gauge.prototype.gaugeColor1 = function() {
switch (this._statusType) {
case "hp":
return ColorManager.hpGaugeColor1();
case "mp":
return ColorManager.mpGaugeColor1();
case "tp":
return ColorManager.tpGaugeColor1();
case "time":
return ColorManager.ctGaugeColor1();
default:
return ColorManager.normalColor();
}
};
/* 计量颜色 2 */
Sprite_Gauge.prototype.gaugeColor2 = function() {
switch (this._statusType) {
case "hp":
return ColorManager.hpGaugeColor2();
case "mp":
return ColorManager.mpGaugeColor2();
case "tp":
return ColorManager.tpGaugeColor2();
case "time":
return ColorManager.ctGaugeColor2();
default:
return ColorManager.normalColor();
}
};
/* 标签颜色 */
Sprite_Gauge.prototype.labelColor = function() {
return ColorManager.systemColor();
};
/* 标签描边颜色 */
Sprite_Gauge.prototype.labelOutlineColor = function() {
return ColorManager.outlineColor();
};
/* 标签描边宽度 */
Sprite_Gauge.prototype.labelOutlineWidth = function() {
return 3;
};
/* 值颜色 */
Sprite_Gauge.prototype.valueColor = function() {
switch (this._statusType) {
case "hp":
return ColorManager.hpColor(this._battler);
case "mp":
return ColorManager.mpColor(this._battler);
case "tp":
return ColorManager.tpColor(this._battler);
default:
return ColorManager.normalColor();
}
};
/* 值描边颜色 */
Sprite_Gauge.prototype.valueOutlineColor = function() {
return "rgba(0, 0, 0, 1)";
};
/* 值描边宽度 */
Sprite_Gauge.prototype.valueOutlineWidth = function() {
return 2;
};
/* 重绘 */
Sprite_Gauge.prototype.redraw = function() {
this.bitmap.clear();
const currentValue = this.currentValue();
if (!isNaN(currentValue)) {
this.drawGauge();
if (this._statusType !== "time") {
this.drawLabel();
if (this.isValid()) {
this.drawValue();
}
}
}
};
/* 绘制计量 */
Sprite_Gauge.prototype.drawGauge = function() {
const gaugeX = this.gaugeX();
const gaugeY = this.bitmapHeight() - this.gaugeHeight();
const gaugewidth = this.bitmapWidth() - gaugeX;
const gaugeHeight = this.gaugeHeight();
this.drawGaugeRect(gaugeX, gaugeY, gaugewidth, gaugeHeight);
};
/* 绘制计量矩形区域 */
Sprite_Gauge.prototype.drawGaugeRect = function(x, y, width, height) {
const rate = this.gaugeRate();
const fillW = Math.floor((width - 2) * rate);
const fillH = height - 2;
const color0 = this.gaugeBackColor();
const color1 = this.gaugeColor1();
const color2 = this.gaugeColor2();
this.bitmap.fillRect(x, y, width, height, color0);
this.bitmap.gradientFillRect(x + 1, y + 1, fillW, fillH, color1, color2);
};
/* 计量比例 */
Sprite_Gauge.prototype.gaugeRate = function() {
if (this.isValid()) {
const value = this._value;
const maxValue = this._maxValue;
return maxValue > 0 ? value / maxValue : 0;
} else {
return 0;
}
};
/* 绘制标签 */
Sprite_Gauge.prototype.drawLabel = function() {
const label = this.label();
const x = this.labelOutlineWidth() / 2;
const y = this.labelY();
const width = this.bitmapWidth();
const height = this.bitmapHeight();
this.setupLabelFont();
this.bitmap.paintOpacity = this.labelOpacity();
this.bitmap.drawText(label, x, y, width, height, "left");
this.bitmap.paintOpacity = 255;
};
/* 设置标签字体 */
Sprite_Gauge.prototype.setupLabelFont = function() {
this.bitmap.fontFace = this.labelFontFace();
this.bitmap.fontSize = this.labelFontSize();
this.bitmap.textColor = this.labelColor();
this.bitmap.outlineColor = this.labelOutlineColor();
this.bitmap.outlineWidth = this.labelOutlineWidth();
};
/* 标签不透明度 */
Sprite_Gauge.prototype.labelOpacity = function() {
return this.isValid() ? 255 : 160;
};
/* 绘制值 */
Sprite_Gauge.prototype.drawValue = function() {
const currentValue = this.currentValue();
const width = this.bitmapWidth();
const height = this.bitmapHeight();
this.setupValueFont();
this.bitmap.drawText(currentValue, 0, 0, width, height, "right");
};
/* 设置值字体 */
Sprite_Gauge.prototype.setupValueFont = function() {
this.bitmap.fontFace = this.valueFontFace();
this.bitmap.fontSize = this.valueFontSize();
this.bitmap.textColor = this.valueColor();
this.bitmap.outlineColor = this.valueOutlineColor();
this.bitmap.outlineWidth = this.valueOutlineWidth();
};
//-----------------------------------------------------------------------------
// 精灵_名字
// Sprite_Name
//
// 显示状态名字的精灵。
// The sprite for displaying a status gauge.
function Sprite_Name() {
this.initialize(...arguments);
}
Sprite_Name.prototype = Object.create(Sprite.prototype);
Sprite_Name.prototype.constructor = Sprite_Name;
/* 初始化 */
Sprite_Name.prototype.initialize = function() {
Sprite.prototype.initialize.call(this);
this.initMembers();
this.createBitmap();
};
/* 初始化成员 */
Sprite_Name.prototype.initMembers = function() {
this._battler = null;
this._name = "";
this._textColor = "";
};
/* 销毁 */
Sprite_Name.prototype.destroy = function(options) {
this.bitmap.destroy();
Sprite.prototype.destroy.call(this, options);
};
/* 创建位图 */
Sprite_Name.prototype.createBitmap = function() {
const width = this.bitmapWidth();
const height = this.bitmapHeight();
this.bitmap = new Bitmap(width, height);
};
/* 位图宽度 */
Sprite_Name.prototype.bitmapWidth = function() {
return 128;
};
/* 位图高度 */
Sprite_Name.prototype.bitmapHeight = function() {
return 24;
};
/* 字体 */
Sprite_Name.prototype.fontFace = function() {
return $gameSystem.mainFontFace();
};
/* 字体大小 */
Sprite_Name.prototype.fontSize = function() {
return $gameSystem.mainFontSize();
};
/* 设置 */
Sprite_Name.prototype.setup = function(battler) {
this._battler = battler;
this.updateBitmap();
};
/* 更新 */
Sprite_Name.prototype.update = function() {
Sprite.prototype.update.call(this);
this.updateBitmap();
};
/* 更新位图 */
Sprite_Name.prototype.updateBitmap = function() {
const name = this.name();
const color = this.textColor();
if (name !== this._name || color !== this._textColor) {
this._name = name;
this._textColor = color;
this.redraw();
}
};
/* 名称 */
Sprite_Name.prototype.name = function() {
return this._battler ? this._battler.name() : "";
};
/* 文本颜色 */
Sprite_Name.prototype.textColor = function() {
return ColorManager.hpColor(this._battler);
};
/* 描边颜色 */
Sprite_Name.prototype.outlineColor = function() {
return ColorManager.outlineColor();
};
/* 描边宽度 */
Sprite_Name.prototype.outlineWidth = function() {
return 3;
};
/* 重绘 */
Sprite_Name.prototype.redraw = function() {
const name = this.name();
const width = this.bitmapWidth();
const height = this.bitmapHeight();
this.setupFont();
this.bitmap.clear();
this.bitmap.drawText(name, 0, 0, width, height, "left");
};
/* 设置字体 */
Sprite_Name.prototype.setupFont = function() {
this.bitmap.fontFace = this.fontFace();
this.bitmap.fontSize = this.fontSize();
this.bitmap.textColor = this.textColor();
this.bitmap.outlineColor = this.outlineColor();
this.bitmap.outlineWidth = this.outlineWidth();
};
//-----------------------------------------------------------------------------
// 精灵_状态图标
// Sprite_StateIcon
//
// 显示状态图标的精灵。
// The sprite for displaying state icons.
function Sprite_StateIcon() {
this.initialize(...arguments);
}
Sprite_StateIcon.prototype = Object.create(Sprite.prototype);
Sprite_StateIcon.prototype.constructor = Sprite_StateIcon;
/* 初始化 */
Sprite_StateIcon.prototype.initialize = function() {
Sprite.prototype.initialize.call(this);
this.initMembers();
this.loadBitmap();
};
/* 初始化成员 */
Sprite_StateIcon.prototype.initMembers = function() {
this._battler = null;
this._iconIndex = 0;
this._animationCount = 0;
this._animationIndex = 0;
this.anchor.x = 0.5;
this.anchor.y = 0.5;
};
/* 加载位图 */
Sprite_StateIcon.prototype.loadBitmap = function() {
this.bitmap = ImageManager.loadSystem("IconSet");
this.setFrame(0, 0, 0, 0);
};
/* 设置 */
Sprite_StateIcon.prototype.setup = function(battler) {
if (this._battler !== battler) {
this._battler = battler;
this._animationCount = this.animationWait();
}
};
/* 更新 */
Sprite_StateIcon.prototype.update = function() {
Sprite.prototype.update.call(this);
this._animationCount++;
if (this._animationCount >= this.animationWait()) {
this.updateIcon();
this.updateFrame();
this._animationCount = 0;
}
};
/* 动画等待帧数 */
Sprite_StateIcon.prototype.animationWait = function() {
return 40;
};
/* 更新图标 */
Sprite_StateIcon.prototype.updateIcon = function() {
const icons = [];
if (this.shouldDisplay()) {
icons.push(...this._battler.allIcons());
}
if (icons.length > 0) {
this._animationIndex++;
if (this._animationIndex >= icons.length) {
this._animationIndex = 0;
}
this._iconIndex = icons[this._animationIndex];
} else {
this._animationIndex = 0;
this._iconIndex = 0;
}
};
/* 是否应该显示 */
Sprite_StateIcon.prototype.shouldDisplay = function() {
const battler = this._battler;
return battler && (battler.isActor() || battler.isAlive());
};
/* 更新帧 */
Sprite_StateIcon.prototype.updateFrame = function() {
const pw = ImageManager.iconWidth;
const ph = ImageManager.iconHeight;
const sx = (this._iconIndex % 16) * pw;
const sy = Math.floor(this._iconIndex / 16) * ph;
this.setFrame(sx, sy, pw, ph);
};
//-----------------------------------------------------------------------------
// 精灵_状态覆盖
// Sprite_StateOverlay
//
// 显示状态的覆盖图像的精灵。
// The sprite for displaying an overlay image for a state.
function Sprite_StateOverlay() {
this.initialize(...arguments);
}
Sprite_StateOverlay.prototype = Object.create(Sprite.prototype);
Sprite_StateOverlay.prototype.constructor = Sprite_StateOverlay;
/* 初始化 */
Sprite_StateOverlay.prototype.initialize = function() {
Sprite.prototype.initialize.call(this);
this.initMembers();
this.loadBitmap();
};
/* 初始化成员 */
Sprite_StateOverlay.prototype.initMembers = function() {
this._battler = null;
this._overlayIndex = 0;
this._animationCount = 0;
this._pattern = 0;
this.anchor.x = 0.5;
this.anchor.y = 1;
};
/* 加载位图 */
Sprite_StateOverlay.prototype.loadBitmap = function() {
this.bitmap = ImageManager.loadSystem("States");
this.setFrame(0, 0, 0, 0);
};
/* 设置 */
Sprite_StateOverlay.prototype.setup = function(battler) {
this._battler = battler;
};
/* 更新 */
Sprite_StateOverlay.prototype.update = function() {
Sprite.prototype.update.call(this);
this._animationCount++;
if (this._animationCount >= this.animationWait()) {
this.updatePattern();
this.updateFrame();
this._animationCount = 0;
}
};
/* 动画等待帧数 */
Sprite_StateOverlay.prototype.animationWait = function() {
return 8;
};
/* 更新图案 */
Sprite_StateOverlay.prototype.updatePattern = function() {
this._pattern++;
this._pattern %= 8;
if (this._battler) {
this._overlayIndex = this._battler.stateOverlayIndex();
} else {
this._overlayIndex = 0;
}
};
/* 更新帧 */
Sprite_StateOverlay.prototype.updateFrame = function() {
if (this._overlayIndex > 0) {
const w = 96;
const h = 96;
const sx = this._pattern * w;
const sy = (this._overlayIndex - 1) * h;
this.setFrame(sx, sy, w, h);
} else {
this.setFrame(0, 0, 0, 0);
}
};
//-----------------------------------------------------------------------------
// 精灵_武器
// Sprite_Weapon
//
// 显示攻击的武器图像的精灵。
// The sprite for displaying a weapon image for attacking.
function Sprite_Weapon() {
this.initialize(...arguments);
}
Sprite_Weapon.prototype = Object.create(Sprite.prototype);
Sprite_Weapon.prototype.constructor = Sprite_Weapon;
/* 初始化 */
Sprite_Weapon.prototype.initialize = function() {
Sprite.prototype.initialize.call(this);
this.initMembers();
};
/* 初始化成员 */
Sprite_Weapon.prototype.initMembers = function() {
this._weaponImageId = 0;
this._animationCount = 0;
this._pattern = 0;
this.anchor.x = 0.5;
this.anchor.y = 1;
this.x = -16;
};
/* 设置 */
Sprite_Weapon.prototype.setup = function(weaponImageId) {
this._weaponImageId = weaponImageId;
this._animationCount = 0;
this._pattern = 0;
this.loadBitmap();
this.updateFrame();
};
/* 更新 */
Sprite_Weapon.prototype.update = function() {
Sprite.prototype.update.call(this);
this._animationCount++;
if (this._animationCount >= this.animationWait()) {
this.updatePattern();
this.updateFrame();
this._animationCount = 0;
}
};
/* 动画等待帧数 */
Sprite_Weapon.prototype.animationWait = function() {
return 12;
};
/* 更新图案 */
Sprite_Weapon.prototype.updatePattern = function() {
this._pattern++;
if (this._pattern >= 3) {
this._weaponImageId = 0;
}
};
/* 加载位图 */
Sprite_Weapon.prototype.loadBitmap = function() {
const pageId = Math.floor((this._weaponImageId - 1) / 12) + 1;
if (pageId >= 1) {
this.bitmap = ImageManager.loadSystem("Weapons" + pageId);
} else {
this.bitmap = ImageManager.loadSystem("");
}
};
/* 更新帧 */
Sprite_Weapon.prototype.updateFrame = function() {
if (this._weaponImageId > 0) {
const index = (this._weaponImageId - 1) % 12;
const w = 96;
const h = 64;
const sx = (Math.floor(index / 6) * 3 + this._pattern) * w;
const sy = Math.floor(index % 6) * h;
this.setFrame(sx, sy, w, h);
} else {
this.setFrame(0, 0, 0, 0);
}
};
/* 是否播放中 */
Sprite_Weapon.prototype.isPlaying = function() {
return this._weaponImageId > 0;
};
//-----------------------------------------------------------------------------
// 精灵_气泡
// Sprite_Balloon
//
// 显示气泡图标的精灵。
// The sprite for displaying a balloon icon.
function Sprite_Balloon() {
this.initialize(...arguments);
}
Sprite_Balloon.prototype = Object.create(Sprite.prototype);
Sprite_Balloon.prototype.constructor = Sprite_Balloon;
/* 初始化 */
Sprite_Balloon.prototype.initialize = function() {
Sprite.prototype.initialize.call(this);
this.initMembers();
this.loadBitmap();
};
/* 初始化成员 */
Sprite_Balloon.prototype.initMembers = function() {
this._target = null;
this._balloonId = 0;
this._duration = 0;
this.anchor.x = 0.5;
this.anchor.y = 1;
this.z = 7;
};
/* 加载位图 */
Sprite_Balloon.prototype.loadBitmap = function() {
this.bitmap = ImageManager.loadSystem("Balloon");
this.setFrame(0, 0, 0, 0);
};
/* 设置 */
Sprite_Balloon.prototype.setup = function(targetSprite, balloonId) {
this._target = targetSprite;
this._balloonId = balloonId;
this._duration = 8 * this.speed() + this.waitTime();
};
/* 更新 */
Sprite_Balloon.prototype.update = function() {
Sprite.prototype.update.call(this);
if (this._duration > 0) {
this._duration--;
if (this._duration > 0) {
this.updatePosition();
this.updateFrame();
}
}
};
/* 更新位置 */
Sprite_Balloon.prototype.updatePosition = function() {
this.x = this._target.x;
this.y = this._target.y - this._target.height;
};
/* 更新帧 */
Sprite_Balloon.prototype.updateFrame = function() {
const w = 48;
const h = 48;
const sx = this.frameIndex() * w;
const sy = (this._balloonId - 1) * h;
this.setFrame(sx, sy, w, h);
};
/* 速度 */
Sprite_Balloon.prototype.speed = function() {
return 8;
};
/* 等待时间 */
Sprite_Balloon.prototype.waitTime = function() {
return 12;
};
/* 帧索引 */
Sprite_Balloon.prototype.frameIndex = function() {
const index = (this._duration - this.waitTime()) / this.speed();
return 7 - Math.max(Math.floor(index), 0);
};
/* 是否播放中 */
Sprite_Balloon.prototype.isPlaying = function() {
return this._duration > 0;
};
//-----------------------------------------------------------------------------
// 精灵_图片
// Sprite_Picture
//
// 显示图片的精灵。
// The sprite for displaying a picture.
function Sprite_Picture() {
this.initialize(...arguments);
}
Sprite_Picture.prototype = Object.create(Sprite_Clickable.prototype);
Sprite_Picture.prototype.constructor = Sprite_Picture;
/* 初始化 */
Sprite_Picture.prototype.initialize = function(pictureId) {
Sprite_Clickable.prototype.initialize.call(this);
this._pictureId = pictureId;
this._pictureName = "";
this.update();
};
/* 图片 */
Sprite_Picture.prototype.picture = function() {
return $gameScreen.picture(this._pictureId);
};
/* 更新 */
Sprite_Picture.prototype.update = function() {
Sprite_Clickable.prototype.update.call(this);
this.updateBitmap();
if (this.visible) {
this.updateOrigin();
this.updatePosition();
this.updateScale();
this.updateTone();
this.updateOther();
}
};
/* 更新位图 */
Sprite_Picture.prototype.updateBitmap = function() {
const picture = this.picture();
if (picture) {
const pictureName = picture.name();
if (this._pictureName !== pictureName) {
this._pictureName = pictureName;
this.loadBitmap();
}
this.visible = true;
} else {
this._pictureName = "";
this.bitmap = null;
this.visible = false;
}
};
/* 更新起始 */
Sprite_Picture.prototype.updateOrigin = function() {
const picture = this.picture();
if (picture.origin() === 0) {
this.anchor.x = 0;
this.anchor.y = 0;
} else {
this.anchor.x = 0.5;
this.anchor.y = 0.5;
}
};
/* 更新位置 */
Sprite_Picture.prototype.updatePosition = function() {
const picture = this.picture();
this.x = Math.round(picture.x());
this.y = Math.round(picture.y());
};
/* 更新缩放 */
Sprite_Picture.prototype.updateScale = function() {
const picture = this.picture();
this.scale.x = picture.scaleX() / 100;
this.scale.y = picture.scaleY() / 100;
};
/* 更新色调 */
Sprite_Picture.prototype.updateTone = function() {
const picture = this.picture();
if (picture.tone()) {
this.setColorTone(picture.tone());
} else {
this.setColorTone([0, 0, 0, 0]);
}
};
/* 更新其它 */
Sprite_Picture.prototype.updateOther = function() {
const picture = this.picture();
this.opacity = picture.opacity();
this.blendMode = picture.blendMode();
this.rotation = (picture.angle() * Math.PI) / 180;
};
/* 加载位图 */
Sprite_Picture.prototype.loadBitmap = function() {
this.bitmap = ImageManager.loadPicture(this._pictureName);
};
//-----------------------------------------------------------------------------
// 精灵_计时器
// Sprite_Timer
//
// 显示计时器的精灵。
// The sprite for displaying the timer.
function Sprite_Timer() {
this.initialize(...arguments);
}
Sprite_Timer.prototype = Object.create(Sprite.prototype);
Sprite_Timer.prototype.constructor = Sprite_Timer;
/* 初始化 */
Sprite_Timer.prototype.initialize = function() {
Sprite.prototype.initialize.call(this);
this._seconds = 0;
this.createBitmap();
this.update();
};
/* 销毁 */
Sprite_Timer.prototype.destroy = function(options) {
this.bitmap.destroy();
Sprite.prototype.destroy.call(this, options);
};
/* 创建位图 */
Sprite_Timer.prototype.createBitmap = function() {
this.bitmap = new Bitmap(96, 48);
this.bitmap.fontFace = this.fontFace();
this.bitmap.fontSize = this.fontSize();
this.bitmap.outlineColor = ColorManager.outlineColor();
};
/* 字体 */
Sprite_Timer.prototype.fontFace = function() {
return $gameSystem.numberFontFace();
};
/* 字体大小 */
Sprite_Timer.prototype.fontSize = function() {
return $gameSystem.mainFontSize() + 8;
};
/* 更新 */
Sprite_Timer.prototype.update = function() {
Sprite.prototype.update.call(this);
this.updateBitmap();
this.updatePosition();
this.updateVisibility();
};
/* 更新位图 */
Sprite_Timer.prototype.updateBitmap = function() {
if (this._seconds !== $gameTimer.seconds()) {
this._seconds = $gameTimer.seconds();
this.redraw();
}
};
/* 重绘 */
Sprite_Timer.prototype.redraw = function() {
const text = this.timerText();
const width = this.bitmap.width;
const height = this.bitmap.height;
this.bitmap.clear();
this.bitmap.drawText(text, 0, 0, width, height, "center");
};
/* 计时器文本 */
Sprite_Timer.prototype.timerText = function() {
const min = Math.floor(this._seconds / 60) % 60;
const sec = this._seconds % 60;
return min.padZero(2) + ":" + sec.padZero(2);
};
/* 更新位置 */
Sprite_Timer.prototype.updatePosition = function() {
this.x = (Graphics.width - this.bitmap.width) / 2;
this.y = 0;
};
/* 更新可见性 */
Sprite_Timer.prototype.updateVisibility = function() {
this.visible = $gameTimer.isWorking();
};
//-----------------------------------------------------------------------------
// 精灵_目的地
// Sprite_Destination
//
//显示触摸输入的目的地的精灵。
// The sprite for displaying the destination place of the touch input.
function Sprite_Destination() {
this.initialize(...arguments);
}
Sprite_Destination.prototype = Object.create(Sprite.prototype);
Sprite_Destination.prototype.constructor = Sprite_Destination;
/* 初始化 */
Sprite_Destination.prototype.initialize = function() {
Sprite.prototype.initialize.call(this);
this.createBitmap();
this._frameCount = 0;
};
/* 销毁 */
Sprite_Destination.prototype.destroy = function(options) {
if (this.bitmap) {
this.bitmap.destroy();
}
Sprite.prototype.destroy.call(this, options);
};
/* 更新 */
Sprite_Destination.prototype.update = function() {
Sprite.prototype.update.call(this);
if ($gameTemp.isDestinationValid()) {
this.updatePosition();
this.updateAnimation();
this.visible = true;
} else {
this._frameCount = 0;
this.visible = false;
}
};
/* 创建位图 */
Sprite_Destination.prototype.createBitmap = function() {
const tileWidth = $gameMap.tileWidth();
const tileHeight = $gameMap.tileHeight();
this.bitmap = new Bitmap(tileWidth, tileHeight);
this.bitmap.fillAll("white");
this.anchor.x = 0.5;
this.anchor.y = 0.5;
this.blendMode = 1;
};
/* 更新位置 */
Sprite_Destination.prototype.updatePosition = function() {
const tileWidth = $gameMap.tileWidth();
const tileHeight = $gameMap.tileHeight();
const x = $gameTemp.destinationX();
const y = $gameTemp.destinationY();
this.x = ($gameMap.adjustX(x) + 0.5) * tileWidth;
this.y = ($gameMap.adjustY(y) + 0.5) * tileHeight;
};
/* 更新动画 */
Sprite_Destination.prototype.updateAnimation = function() {
this._frameCount++;
this._frameCount %= 20;
this.opacity = (20 - this._frameCount) * 6;
this.scale.x = 1 + this._frameCount / 20;
this.scale.y = this.scale.x;
};
//-----------------------------------------------------------------------------
// 精灵组_基础
// Spriteset_Base
//
// Spriteset_Map 和 Spriteset_Battle 的父类。
// The superclass of Spriteset_Map and Spriteset_Battle.
function Spriteset_Base() {
this.initialize(...arguments);
}
Spriteset_Base.prototype = Object.create(Sprite.prototype);
Spriteset_Base.prototype.constructor = Spriteset_Base;
/* 初始化 */
Spriteset_Base.prototype.initialize = function() {
Sprite.prototype.initialize.call(this);
this.setFrame(0, 0, Graphics.width, Graphics.height);
this.loadSystemImages();
this.createLowerLayer();
this.createUpperLayer();
this._animationSprites = [];
};
/* 销毁 */
Spriteset_Base.prototype.destroy = function(options) {
this.removeAllAnimations();
Sprite.prototype.destroy.call(this, options);
};
/* 加载系统图像 */
Spriteset_Base.prototype.loadSystemImages = function() {
//
};
/* 创建下方的图层 */
Spriteset_Base.prototype.createLowerLayer = function() {
this.createBaseSprite();
this.createBaseFilters();
};
/* 创建上方的图层 */
Spriteset_Base.prototype.createUpperLayer = function() {
this.createPictures();
this.createTimer();
this.createOverallFilters();
};
/* 更新 */
Spriteset_Base.prototype.update = function() {
Sprite.prototype.update.call(this);
this.updateBaseFilters();
this.updateOverallFilters();
this.updatePosition();
this.updateAnimations();
};
/* 更新基础精灵 */
Spriteset_Base.prototype.createBaseSprite = function() {
this._baseSprite = new Sprite();
this._blackScreen = new ScreenSprite();
this._blackScreen.opacity = 255;
this.addChild(this._baseSprite);
this._baseSprite.addChild(this._blackScreen);
};
/* 创建基础过滤器 */
Spriteset_Base.prototype.createBaseFilters = function() {
this._baseSprite.filters = [];
this._baseColorFilter = new ColorFilter();
this._baseSprite.filters.push(this._baseColorFilter);
};
/* 创建图片 */
Spriteset_Base.prototype.createPictures = function() {
const rect = this.pictureContainerRect();
this._pictureContainer = new Sprite();
this._pictureContainer.setFrame(rect.x, rect.y, rect.width, rect.height);
for (let i = 1; i <= $gameScreen.maxPictures(); i++) {
this._pictureContainer.addChild(new Sprite_Picture(i));
}
this.addChild(this._pictureContainer);
};
/* 图片容器矩形区域 */
Spriteset_Base.prototype.pictureContainerRect = function() {
return new Rectangle(0, 0, Graphics.width, Graphics.height);
};
/* 创建计时器 */
Spriteset_Base.prototype.createTimer = function() {
this._timerSprite = new Sprite_Timer();
this.addChild(this._timerSprite);
};
/* 创建整体过滤器 */
Spriteset_Base.prototype.createOverallFilters = function() {
this.filters = [];
this._overallColorFilter = new ColorFilter();
this.filters.push(this._overallColorFilter);
};
/*更新基础过滤器 */
Spriteset_Base.prototype.updateBaseFilters = function() {
const filter = this._baseColorFilter;
filter.setColorTone($gameScreen.tone());
};
/* 更新整体过滤器 */
Spriteset_Base.prototype.updateOverallFilters = function() {
const filter = this._overallColorFilter;
filter.setBlendColor($gameScreen.flashColor());
filter.setBrightness($gameScreen.brightness());
};
/* 更新位置 */
Spriteset_Base.prototype.updatePosition = function() {
const screen = $gameScreen;
const scale = screen.zoomScale();
this.scale.x = scale;
this.scale.y = scale;
this.x = Math.round(-screen.zoomX() * (scale - 1));
this.y = Math.round(-screen.zoomY() * (scale - 1));
this.x += Math.round(screen.shake());
};
/* 寻找目标精灵 */
Spriteset_Base.prototype.findTargetSprite = function(/*target*/) {
return null;
};
/* 更新动画 */
Spriteset_Base.prototype.updateAnimations = function() {
for (const sprite of this._animationSprites) {
if (!sprite.isPlaying()) {
this.removeAnimation(sprite);
}
}
this.processAnimationRequests();
};
/* 处理动画请求 */
Spriteset_Base.prototype.processAnimationRequests = function() {
for (;;) {
const request = $gameTemp.retrieveAnimation();
if (request) {
this.createAnimation(request);
} else {
break;
}
}
};
/* 创建动画 */
Spriteset_Base.prototype.createAnimation = function(request) {
const animation = $dataAnimations[request.animationId];
const targets = request.targets;
const mirror = request.mirror;
let delay = this.animationBaseDelay();
const nextDelay = this.animationNextDelay();
if (this.isAnimationForEach(animation)) {
for (const target of targets) {
this.createAnimationSprite([target], animation, mirror, delay);
delay += nextDelay;
}
} else {
this.createAnimationSprite(targets, animation, mirror, delay);
}
};
/* 创建动画精灵 */
// prettier-ignore
Spriteset_Base.prototype.createAnimationSprite = function(
targets, animation, mirror, delay
) {
const mv = this.isMVAnimation(animation);
const sprite = new (mv ? Sprite_AnimationMV : Sprite_Animation)();
const targetSprites = this.makeTargetSprites(targets);
const baseDelay = this.animationBaseDelay();
const previous = delay > baseDelay ? this.lastAnimationSprite() : null;
if (this.animationShouldMirror(targets[0])) {
mirror = !mirror;
}
sprite.targetObjects = targets;
sprite.setup(targetSprites, animation, mirror, delay, previous);
this._effectsContainer.addChild(sprite);
this._animationSprites.push(sprite);
};
/* 是否 MV 的动画 */
Spriteset_Base.prototype.isMVAnimation = function(animation) {
return !!animation.frames;
};
/* 制作目标精灵 */
Spriteset_Base.prototype.makeTargetSprites = function(targets) {
const targetSprites = [];
for (const target of targets) {
const targetSprite = this.findTargetSprite(target);
if (targetSprite) {
targetSprites.push(targetSprite);
}
}
return targetSprites;
};
/* 上一个动画精灵 */
Spriteset_Base.prototype.lastAnimationSprite = function() {
return this._animationSprites[this._animationSprites.length - 1];
};
/* 是否每一个目标的动画 */
Spriteset_Base.prototype.isAnimationForEach = function(animation) {
const mv = this.isMVAnimation(animation);
return mv ? animation.position !== 3 : animation.displayType === 0;
};
/* 动画基础延迟 */
Spriteset_Base.prototype.animationBaseDelay = function() {
return 8;
};
/* 动画下一个延迟 */
Spriteset_Base.prototype.animationNextDelay = function() {
return 12;
};
/* 动画是否应该镜像 */
Spriteset_Base.prototype.animationShouldMirror = function(target) {
return target && target.isActor && target.isActor();
};
/* 移除动画 */
Spriteset_Base.prototype.removeAnimation = function(sprite) {
this._animationSprites.remove(sprite);
this._effectsContainer.removeChild(sprite);
for (const target of sprite.targetObjects) {
if (target.endAnimation) {
target.endAnimation();
}
}
sprite.destroy();
};
/* 移除所有动画 */
Spriteset_Base.prototype.removeAllAnimations = function() {
for (const sprite of this._animationSprites) {
this.removeAnimation(sprite);
}
};
/* 是否动画播放中 */
Spriteset_Base.prototype.isAnimationPlaying = function() {
return this._animationSprites.length > 0;
};
//-----------------------------------------------------------------------------
// 精灵组_地图
// Spriteset_Map
//
// 地图画面上的一组精灵。
// The set of sprites on the map screen.
function Spriteset_Map() {
this.initialize(...arguments);
}
Spriteset_Map.prototype = Object.create(Spriteset_Base.prototype);
Spriteset_Map.prototype.constructor = Spriteset_Map;
/* 初始化 */
Spriteset_Map.prototype.initialize = function() {
Spriteset_Base.prototype.initialize.call(this);
this._balloonSprites = [];
};
/* 销毁 */
Spriteset_Map.prototype.destroy = function(options) {
this.removeAllBalloons();
Spriteset_Base.prototype.destroy.call(this, options);
};
/* 加载系统图像 */
Spriteset_Map.prototype.loadSystemImages = function() {
Spriteset_Base.prototype.loadSystemImages.call(this);
ImageManager.loadSystem("Balloon");
ImageManager.loadSystem("Shadow1");
};
/* 创建下方的图层 */
Spriteset_Map.prototype.createLowerLayer = function() {
Spriteset_Base.prototype.createLowerLayer.call(this);
this.createParallax();
this.createTilemap();
this.createCharacters();
this.createShadow();
this.createDestination();
this.createWeather();
};
/* 更新 */
Spriteset_Map.prototype.update = function() {
Spriteset_Base.prototype.update.call(this);
this.updateTileset();
this.updateParallax();
this.updateTilemap();
this.updateShadow();
this.updateWeather();
this.updateAnimations();
this.updateBalloons();
};
/* 隐藏人物 */
Spriteset_Map.prototype.hideCharacters = function() {
for (const sprite of this._characterSprites) {
if (!sprite.isTile() && !sprite.isObjectCharacter()) {
sprite.hide();
}
}
};
/* 创建远景 */
Spriteset_Map.prototype.createParallax = function() {
this._parallax = new TilingSprite();
this._parallax.move(0, 0, Graphics.width, Graphics.height);
this._baseSprite.addChild(this._parallax);
};
/* 创建图块地图 */
Spriteset_Map.prototype.createTilemap = function() {
const tilemap = new Tilemap();
tilemap.tileWidth = $gameMap.tileWidth();
tilemap.tileHeight = $gameMap.tileHeight();
tilemap.setData($gameMap.width(), $gameMap.height(), $gameMap.data());
tilemap.horizontalWrap = $gameMap.isLoopHorizontal();
tilemap.verticalWrap = $gameMap.isLoopVertical();
this._baseSprite.addChild(tilemap);
this._effectsContainer = tilemap;
this._tilemap = tilemap;
this.loadTileset();
};
/* 加载图块组 */
Spriteset_Map.prototype.loadTileset = function() {
this._tileset = $gameMap.tileset();
if (this._tileset) {
const bitmaps = [];
const tilesetNames = this._tileset.tilesetNames;
for (const name of tilesetNames) {
bitmaps.push(ImageManager.loadTileset(name));
}
this._tilemap.setBitmaps(bitmaps);
this._tilemap.flags = $gameMap.tilesetFlags();
}
};
/* 创建人物 */
Spriteset_Map.prototype.createCharacters = function() {
this._characterSprites = [];
for (const event of $gameMap.events()) {
this._characterSprites.push(new Sprite_Character(event));
}
for (const vehicle of $gameMap.vehicles()) {
this._characterSprites.push(new Sprite_Character(vehicle));
}
for (const follower of $gamePlayer.followers().reverseData()) {
this._characterSprites.push(new Sprite_Character(follower));
}
this._characterSprites.push(new Sprite_Character($gamePlayer));
for (const sprite of this._characterSprites) {
this._tilemap.addChild(sprite);
}
};
/* 创建影子 */
Spriteset_Map.prototype.createShadow = function() {
this._shadowSprite = new Sprite();
this._shadowSprite.bitmap = ImageManager.loadSystem("Shadow1");
this._shadowSprite.anchor.x = 0.5;
this._shadowSprite.anchor.y = 1;
this._shadowSprite.z = 6;
this._tilemap.addChild(this._shadowSprite);
};
/* 创建目的地 */
Spriteset_Map.prototype.createDestination = function() {
this._destinationSprite = new Sprite_Destination();
this._destinationSprite.z = 9;
this._tilemap.addChild(this._destinationSprite);
};
/* 创建天气 */
Spriteset_Map.prototype.createWeather = function() {
this._weather = new Weather();
this.addChild(this._weather);
};
/* 更新图块组 */
Spriteset_Map.prototype.updateTileset = function() {
if (this._tileset !== $gameMap.tileset()) {
this.loadTileset();
}
};
/* 更新远景 */
Spriteset_Map.prototype.updateParallax = function() {
if (this._parallaxName !== $gameMap.parallaxName()) {
this._parallaxName = $gameMap.parallaxName();
this._parallax.bitmap = ImageManager.loadParallax(this._parallaxName);
}
if (this._parallax.bitmap) {
this._parallax.origin.x = $gameMap.parallaxOx();
this._parallax.origin.y = $gameMap.parallaxOy();
}
};
/* 更新图块地图 */
Spriteset_Map.prototype.updateTilemap = function() {
this._tilemap.origin.x = $gameMap.displayX() * $gameMap.tileWidth();
this._tilemap.origin.y = $gameMap.displayY() * $gameMap.tileHeight();
};
/* 更新影子 */
Spriteset_Map.prototype.updateShadow = function() {
const airship = $gameMap.airship();
this._shadowSprite.x = airship.shadowX();
this._shadowSprite.y = airship.shadowY();
this._shadowSprite.opacity = airship.shadowOpacity();
};
/* 更新天气 */
Spriteset_Map.prototype.updateWeather = function() {
this._weather.type = $gameScreen.weatherType();
this._weather.power = $gameScreen.weatherPower();
this._weather.origin.x = $gameMap.displayX() * $gameMap.tileWidth();
this._weather.origin.y = $gameMap.displayY() * $gameMap.tileHeight();
};
/* 更新气泡图标 */
Spriteset_Map.prototype.updateBalloons = function() {
for (const sprite of this._balloonSprites) {
if (!sprite.isPlaying()) {
this.removeBalloon(sprite);
}
}
this.processBalloonRequests();
};
/* 处理气泡图标请求 */
Spriteset_Map.prototype.processBalloonRequests = function() {
for (;;) {
const request = $gameTemp.retrieveBalloon();
if (request) {
this.createBalloon(request);
} else {
break;
}
}
};
/* 创建气泡图标 */
Spriteset_Map.prototype.createBalloon = function(request) {
const targetSprite = this.findTargetSprite(request.target);
if (targetSprite) {
const sprite = new Sprite_Balloon();
sprite.targetObject = request.target;
sprite.setup(targetSprite, request.balloonId);
this._effectsContainer.addChild(sprite);
this._balloonSprites.push(sprite);
}
};
/* 移除气泡图标 */
Spriteset_Map.prototype.removeBalloon = function(sprite) {
this._balloonSprites.remove(sprite);
this._effectsContainer.removeChild(sprite);
if (sprite.targetObject.endBalloon) {
sprite.targetObject.endBalloon();
}
sprite.destroy();
};
/* 移除所有气泡图标 */
Spriteset_Map.prototype.removeAllBalloons = function() {
for (const sprite of this._balloonSprites) {
this.removeBalloon(sprite);
}
};
/* 寻找目标精灵 */
Spriteset_Map.prototype.findTargetSprite = function(target) {
return this._characterSprites.find(sprite => sprite.checkCharacter(target));
};
/* 动画基础延迟 */
Spriteset_Map.prototype.animationBaseDelay = function() {
return 0;
};
//-----------------------------------------------------------------------------
// 精灵组_战斗
// Spriteset_Battle
//
// 战斗画面上的一组精灵。
// The set of sprites on the battle screen.
function Spriteset_Battle() {
this.initialize(...arguments);
}
Spriteset_Battle.prototype = Object.create(Spriteset_Base.prototype);
Spriteset_Battle.prototype.constructor = Spriteset_Battle;
/* 初始化 */
Spriteset_Battle.prototype.initialize = function() {
Spriteset_Base.prototype.initialize.call(this);
this._battlebackLocated = false;
};
/* 加载系统图像 */
Spriteset_Battle.prototype.loadSystemImages = function() {
Spriteset_Base.prototype.loadSystemImages.call(this);
ImageManager.loadSystem("Shadow2");
ImageManager.loadSystem("Weapons1");
ImageManager.loadSystem("Weapons2");
ImageManager.loadSystem("Weapons3");
};
/* 创建下方的图层 */
Spriteset_Battle.prototype.createLowerLayer = function() {
Spriteset_Base.prototype.createLowerLayer.call(this);
this.createBackground();
this.createBattleback();
this.createBattleField();
this.createEnemies();
this.createActors();
};
/* 创建背景 */
Spriteset_Battle.prototype.createBackground = function() {
this._backgroundFilter = new PIXI.filters.BlurFilter();
this._backgroundSprite = new Sprite();
this._backgroundSprite.bitmap = SceneManager.backgroundBitmap();
this._backgroundSprite.filters = [this._backgroundFilter];
this._baseSprite.addChild(this._backgroundSprite);
};
/* 创建战斗背景 */
Spriteset_Battle.prototype.createBattleback = function() {
this._back1Sprite = new Sprite_Battleback(0);
this._back2Sprite = new Sprite_Battleback(1);
this._baseSprite.addChild(this._back1Sprite);
this._baseSprite.addChild(this._back2Sprite);
};
/* 创建战斗场地 */
Spriteset_Battle.prototype.createBattleField = function() {
const width = Graphics.boxWidth;
const height = Graphics.boxHeight;
const x = (Graphics.width - width) / 2;
const y = (Graphics.height - height) / 2;
this._battleField = new Sprite();
this._battleField.setFrame(0, 0, width, height);
this._battleField.x = x;
this._battleField.y = y - this.battleFieldOffsetY();
this._baseSprite.addChild(this._battleField);
this._effectsContainer = this._battleField;
};
/* 战斗场地偏移坐标 Y */
Spriteset_Battle.prototype.battleFieldOffsetY = function() {
return 24;
};
/* 更新 */
Spriteset_Battle.prototype.update = function() {
Spriteset_Base.prototype.update.call(this);
this.updateActors();
this.updateBattleback();
this.updateAnimations();
};
/* 更新战斗背景 */
Spriteset_Battle.prototype.updateBattleback = function() {
if (!this._battlebackLocated) {
this._back1Sprite.adjustPosition();
this._back2Sprite.adjustPosition();
this._battlebackLocated = true;
}
};
/* 创建敌人 */
Spriteset_Battle.prototype.createEnemies = function() {
const enemies = $gameTroop.members();
const sprites = [];
for (const enemy of enemies) {
sprites.push(new Sprite_Enemy(enemy));
}
sprites.sort(this.compareEnemySprite.bind(this));
for (const sprite of sprites) {
this._battleField.addChild(sprite);
}
this._enemySprites = sprites;
};
/* 比较敌人精灵
* 排序用,坐标 Y 越大越前面,当坐标 Y 一样时则精灵 ID 越大越前面。
*/
Spriteset_Battle.prototype.compareEnemySprite = function(a, b) {
if (a.y !== b.y) {
return a.y - b.y;
} else {
return b.spriteId - a.spriteId;
}
};
/* 创建角色 */
Spriteset_Battle.prototype.createActors = function() {
this._actorSprites = [];
if ($gameSystem.isSideView()) {
for (let i = 0; i < $gameParty.maxBattleMembers(); i++) {
const sprite = new Sprite_Actor();
this._actorSprites.push(sprite);
this._battleField.addChild(sprite);
}
}
};
/* 更新角色 */
Spriteset_Battle.prototype.updateActors = function() {
const members = $gameParty.battleMembers();
for (let i = 0; i < this._actorSprites.length; i++) {
this._actorSprites[i].setBattler(members[i]);
}
};
/* 寻找目标精灵 */
Spriteset_Battle.prototype.findTargetSprite = function(target) {
return this.battlerSprites().find(sprite => sprite.checkBattler(target));
};
/* 战斗精灵 */
Spriteset_Battle.prototype.battlerSprites = function() {
return this._enemySprites.concat(this._actorSprites);
};
/* 是否效果中 */
Spriteset_Battle.prototype.isEffecting = function() {
return this.battlerSprites().some(sprite => sprite.isEffecting());
};
/* 是否有人在移动中 */
Spriteset_Battle.prototype.isAnyoneMoving = function() {
return this.battlerSprites().some(sprite => sprite.isMoving());
};
/* 是否繁忙 */
Spriteset_Battle.prototype.isBusy = function() {
return this.isAnimationPlaying() || this.isAnyoneMoving();
};
//-----------------------------------------------------------------------------
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/flanpan/rmmz.git
git@gitee.com:flanpan/rmmz.git
flanpan
rmmz
RMMZ脚本框架中文注释
master

搜索帮助