-
Notifications
You must be signed in to change notification settings - Fork 5
/
rpg_scenes.js
2607 lines (2222 loc) · 75.9 KB
/
rpg_scenes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//=============================================================================
// rpg_scenes.js v1.1.0
//=============================================================================
//-----------------------------------------------------------------------------
// Scene_Base
//
// The superclass of all scenes within the game.
//场景基类 这里的场景概念和unity里的scene flash里的关键帧(或者说场景)类似
// 不过他居然把scene又做成一个大的displaycontainer...
// 感觉可以分开写 不要把渲染也扯进来 只作为单独的游戏跳转单元就好了
function Scene_Base() {
this.initialize.apply(this, arguments);
}
//继承于Stage类 所以scene是一个特殊的显示对象 可以理解为安卓里最外面的布局对象 以及flash的stage对象
Scene_Base.prototype = Object.create(Stage.prototype);
Scene_Base.prototype.constructor = Scene_Base;
Scene_Base.prototype.initialize = function () {
Stage.prototype.initialize.call(this);
this._active = false;
this._fadeSign = 0;
this._fadeDuration = 0;
this._fadeSprite = null;
};
Scene_Base.prototype.create = function () {
};
/**
* 当前场景是否处在活动状态
* @returns {boolean}
*/
Scene_Base.prototype.isActive = function () {
return this._active;
};
/**
* 场景是否准备完毕 因为场景需要用到一些资源 这些资源需要加载到内存里
其实这种分场景的设计架构挺好的 Unity也是这样 可以把资源分开加载了 不会一开始花费很长的加载时间
*/
Scene_Base.prototype.isReady = function () {
return ImageManager.isReady();
};
/**
* 激活该场景
*/
Scene_Base.prototype.start = function () {
this._active = true;
};
/**
* 场景更新
*/
Scene_Base.prototype.update = function () {
//更新fade(淡入淡出)
this.updateFade();
//更新子级
this.updateChildren();
//检查音频管理器是否出错
AudioManager.checkErrors();
};
/**
* 停止该场景
*/
Scene_Base.prototype.stop = function () {
this._active = false;
};
/**
* 是否正在渐变中
* @returns {boolean}
*/
Scene_Base.prototype.isBusy = function () {
return this._fadeDuration > 0;
};
Scene_Base.prototype.terminate = function () {
};
/**
* 创建一个window层 专门用来放ui对象
*/
Scene_Base.prototype.createWindowLayer = function () {
var width = Graphics.boxWidth;
var height = Graphics.boxHeight;
var x = (Graphics.width - width) / 2;
var y = (Graphics.height - height) / 2;
this._windowLayer = new WindowLayer();
this._windowLayer.move(x, y, width, height);
this.addChild(this._windowLayer);
};
/**
* 添加window对象到windowLayer中
* @param window
*/
Scene_Base.prototype.addWindow = function (window) {
this._windowLayer.addChild(window);
};
/**
* 开始淡入
* @param duration
* @param white
*/
Scene_Base.prototype.startFadeIn = function (duration, white) {
this.createFadeSprite(white);
this._fadeSign = 1;
this._fadeDuration = duration || 30;
this._fadeSprite.opacity = 255;
};
/**
* 开始淡出
* @param duration
* @param white
*/
Scene_Base.prototype.startFadeOut = function (duration, white) {
this.createFadeSprite(white);
this._fadeSign = -1;
this._fadeDuration = duration || 30;
this._fadeSprite.opacity = 0;
};
/**
* 貌似淡入淡出都是在最底层加一个纯色的正方形 然后开始渐变颜色来实现的
* @param white
*/
Scene_Base.prototype.createFadeSprite = function (white) {
if (!this._fadeSprite) {
this._fadeSprite = new ScreenSprite();
this.addChild(this._fadeSprite);
}
if (white) {
this._fadeSprite.setWhite();
} else {
this._fadeSprite.setBlack();
}
};
Scene_Base.prototype.updateFade = function () {
if (this._fadeDuration > 0) {
var d = this._fadeDuration;
if (this._fadeSign > 0) {
this._fadeSprite.opacity -= this._fadeSprite.opacity / d;
} else {
this._fadeSprite.opacity += (255 - this._fadeSprite.opacity) / d;
}
this._fadeDuration--;
}
};
Scene_Base.prototype.updateChildren = function () {
//依次调用子对象的内部循环
this.children.forEach(function (child) {
if (child.update) {
child.update();
}
});
};
Scene_Base.prototype.popScene = function () {
SceneManager.pop();
};
/**
* 检查人是否都死光,是的话跳转到游戏结束场景
* 说实话 这种耦合简直太糟糕了 这样的功能根本就不应该写在scene_base里
* 应该由一个第三方类来判断 然后控制跳转
*/
Scene_Base.prototype.checkGameover = function () {
if ($gameParty.isAllDead()) {
SceneManager.goto(Scene_Gameover);
}
};
Scene_Base.prototype.fadeOutAll = function () {
var time = this.slowFadeSpeed() / 60;
AudioManager.fadeOutBgm(time);
AudioManager.fadeOutBgs(time);
AudioManager.fadeOutMe(time);
this.startFadeOut(this.slowFadeSpeed());
};
Scene_Base.prototype.fadeSpeed = function () {
return 24;
};
Scene_Base.prototype.slowFadeSpeed = function () {
return this.fadeSpeed() * 2;
};
//-----------------------------------------------------------------------------
// Scene_Boot
//
// The scene class for initializing the entire game.
//启动场景(这个场景貌似不会显示 在加载一些数据初始化之后就跳转到标题场景了)
function Scene_Boot() {
this.initialize.apply(this, arguments);
}
Scene_Boot.prototype = Object.create(Scene_Base.prototype);
Scene_Boot.prototype.constructor = Scene_Boot;
Scene_Boot.prototype.initialize = function () {
Scene_Base.prototype.initialize.call(this);
//记录游戏启动的时间信息
this._startDate = Date.now();
};
Scene_Boot.prototype.create = function () {
Scene_Base.prototype.create.call(this);
//加载游戏数据
DataManager.loadDatabase();
//加载游戏配置
ConfigManager.load();
//加载系统图片
this.loadSystemImages();
};
Scene_Boot.prototype.loadSystemImages = function () {
ImageManager.loadSystem('Window');
ImageManager.loadSystem('IconSet');
ImageManager.loadSystem('Balloon');
ImageManager.loadSystem('Shadow1');
ImageManager.loadSystem('Shadow2');
ImageManager.loadSystem('Damage');
ImageManager.loadSystem('States');
ImageManager.loadSystem('Weapons1');
ImageManager.loadSystem('Weapons2');
ImageManager.loadSystem('Weapons3');
ImageManager.loadSystem('ButtonSet');
};
/**
* 数据是否加载完毕
* @returns {*}
*/
Scene_Boot.prototype.isReady = function () {
if (Scene_Base.prototype.isReady.call(this)) {
//检测是否数据装载完毕
return DataManager.isDatabaseLoaded() && this.isGameFontLoaded();
} else {
return false;
}
};
/**
* 游戏字体是否加载完毕
* @returns {boolean}
*/
Scene_Boot.prototype.isGameFontLoaded = function () {
if (Graphics.isFontLoaded('GameFont')) {
return true;
} else {
var elapsed = Date.now() - this._startDate;
if (elapsed >= 20000) {
throw new Error('Failed to load GameFont');
}
}
};
Scene_Boot.prototype.start = function () {
//调用基类方法,相当于super.start()
Scene_Base.prototype.start.call(this);
SoundManager.preloadImportantSounds();
if (DataManager.isBattleTest()) {
DataManager.setupBattleTest();
SceneManager.goto(Scene_Battle);
} else if (DataManager.isEventTest()) {
DataManager.setupEventTest();
SceneManager.goto(Scene_Map);
} else {
//检查玩家的位置是否正确设置
this.checkPlayerLocation();
//初始化游戏数据
DataManager.setupNewGame();
//跳转到标题界面场景
SceneManager.goto(Scene_Title);
//标题的命令组初始化
Window_TitleCommand.initCommandPosition();
}
this.updateDocumentTitle();
};
Scene_Boot.prototype.updateDocumentTitle = function () {
document.title = $dataSystem.gameTitle;
};
/**
* 检查是否设置了玩家的初始位置
*/
Scene_Boot.prototype.checkPlayerLocation = function () {
if ($dataSystem.startMapId === 0) {
throw new Error('Player\'s starting position is not set');
}
};
//-----------------------------------------------------------------------------
// Scene_Title
//
// The scene class of the title screen.
/**
* 标题界面场景
* @constructor
*/
function Scene_Title() {
this.initialize.apply(this, arguments);
}
//继承于Scene_Base
Scene_Title.prototype = Object.create(Scene_Base.prototype);
Scene_Title.prototype.constructor = Scene_Title;
Scene_Title.prototype.initialize = function () {
Scene_Base.prototype.initialize.call(this);
};
Scene_Title.prototype.create = function () {
Scene_Base.prototype.create.call(this);
this.createBackground();
this.createForeground();
this.createWindowLayer();
this.createCommandWindow();
};
Scene_Title.prototype.start = function () {
Scene_Base.prototype.start.call(this);
SceneManager.clearStack();
this.centerSprite(this._backSprite1);
this.centerSprite(this._backSprite2);
this.playTitleMusic();
this.startFadeIn(this.fadeSpeed(), false);
};
Scene_Title.prototype.update = function () {
if (!this.isBusy()) {
this._commandWindow.open();
}
Scene_Base.prototype.update.call(this);
};
Scene_Title.prototype.isBusy = function () {
return this._commandWindow.isClosing() || Scene_Base.prototype.isBusy.call(this);
};
Scene_Title.prototype.terminate = function () {
Scene_Base.prototype.terminate.call(this);
SceneManager.snapForBackground();
};
Scene_Title.prototype.createBackground = function () {
//添加图片到容器中 scene貌似也和渲染有关 看代码是继承于pixi的类似于as3的displaycontainer的东西
//我感觉不和渲染搅在一起会更好..我写的话肯定分开两个类了
this._backSprite1 = new Sprite(ImageManager.loadTitle1($dataSystem.title1Name));
this._backSprite2 = new Sprite(ImageManager.loadTitle2($dataSystem.title2Name));
this.addChild(this._backSprite1);
this.addChild(this._backSprite2);
};
Scene_Title.prototype.createForeground = function () {
this._gameTitleSprite = new Sprite(new Bitmap(Graphics.width, Graphics.height));
this.addChild(this._gameTitleSprite);
if ($dataSystem.optDrawTitle) {
this.drawGameTitle();
}
};
//绘制游戏标题
Scene_Title.prototype.drawGameTitle = function () {
var x = 20;
var y = Graphics.height / 4;
var maxWidth = Graphics.width - x * 2;
//获取标题数据
var text = $dataSystem.gameTitle;
this._gameTitleSprite.bitmap.outlineColor = 'black';
this._gameTitleSprite.bitmap.outlineWidth = 8;
this._gameTitleSprite.bitmap.fontSize = 72;
this._gameTitleSprite.bitmap.drawText(text, x, y, maxWidth, 48, 'center');
};
//居中sprite
Scene_Title.prototype.centerSprite = function (sprite) {
sprite.x = Graphics.width / 2;
sprite.y = Graphics.height / 2;
sprite.anchor.x = 0.5;
sprite.anchor.y = 0.5;
};
/**
* 添加ui(list命令组)
*/
Scene_Title.prototype.createCommandWindow = function () {
this._commandWindow = new Window_TitleCommand();
this._commandWindow.setHandler('newGame', this.commandNewGame.bind(this));
this._commandWindow.setHandler('continue', this.commandContinue.bind(this));
this._commandWindow.setHandler('options', this.commandOptions.bind(this));
this.addWindow(this._commandWindow);
};
/**
* 点击新游戏后触发 跳转到地图场景
*/
Scene_Title.prototype.commandNewGame = function () {
DataManager.setupNewGame();
//关闭窗口
this._commandWindow.close();
//淡出
this.fadeOutAll();
SceneManager.goto(Scene_Map);
};
Scene_Title.prototype.commandContinue = function () {
this._commandWindow.close();
SceneManager.push(Scene_Load);
};
Scene_Title.prototype.commandOptions = function () {
this._commandWindow.close();
SceneManager.push(Scene_Options);
};
Scene_Title.prototype.playTitleMusic = function () {
AudioManager.playBgm($dataSystem.titleBgm);
AudioManager.stopBgs();
AudioManager.stopMe();
};
//-----------------------------------------------------------------------------
// Scene_Map
//
// The scene class of the map screen.
/**
* 地图场景(游戏场景)
* @constructor
*/
function Scene_Map() {
this.initialize.apply(this, arguments);
}
Scene_Map.prototype = Object.create(Scene_Base.prototype);
Scene_Map.prototype.constructor = Scene_Map;
Scene_Map.prototype.initialize = function () {
Scene_Base.prototype.initialize.call(this);
this._waitCount = 0;
this._encounterEffectDuration = 0;
this._mapLoaded = false;
this._touchCount = 0;
};
Scene_Map.prototype.create = function () {
Scene_Base.prototype.create.call(this);
this._transfer = $gamePlayer.isTransferring();
var mapId = this._transfer ? $gamePlayer.newMapId() : $gameMap.mapId();
//加载地图数据
DataManager.loadMapData(mapId);
};
Scene_Map.prototype.isReady = function () {
//地图数据是否已经加载完成
if (!this._mapLoaded && DataManager.isMapLoaded()) {
this.onMapLoaded();
this._mapLoaded = true;
}
return this._mapLoaded && Scene_Base.prototype.isReady.call(this);
};
//地图加载完毕时回调
Scene_Map.prototype.onMapLoaded = function () {
if (this._transfer) {
$gamePlayer.performTransfer();
}
this.createDisplayObjects();
};
//启动
Scene_Map.prototype.start = function () {
Scene_Base.prototype.start.call(this);
SceneManager.clearStack();
if (this._transfer) {
this.fadeInForTransfer();
this._mapNameWindow.open();
$gameMap.autoplay();
} else if (this.needsFadeIn()) {
this.startFadeIn(this.fadeSpeed(), false);
}
this.menuCalling = false;
};
//更新
Scene_Map.prototype.update = function () {
this.updateDestination();
this.updateMainMultiply();
if (this.isSceneChangeOk()) {
this.updateScene();
} else if (SceneManager.isNextScene(Scene_Battle)) {
this.updateEncounterEffect();
}
this.updateWaitCount();
Scene_Base.prototype.update.call(this);
};
//更新
Scene_Map.prototype.updateMainMultiply = function () {
this.updateMain();
if (this.isFastForward()) {
this.updateMain();
}
};
/**
* 地图场景主循环
*/
Scene_Map.prototype.updateMain = function () {
var active = this.isActive();
$gameMap.update(active);
$gamePlayer.update(active);
$gameTimer.update(active);
$gameScreen.update();
};
Scene_Map.prototype.isFastForward = function () {
return ($gameMap.isEventRunning() && !SceneManager.isSceneChanging() &&
(Input.isLongPressed('ok') || TouchInput.isLongPressed()));
};
//停止
Scene_Map.prototype.stop = function () {
Scene_Base.prototype.stop.call(this);
$gamePlayer.straighten();
this._mapNameWindow.close();
if (this.needsSlowFadeOut()) {
this.startFadeOut(this.slowFadeSpeed(), false);
} else if (SceneManager.isNextScene(Scene_Map)) {
this.fadeOutForTransfer();
} else if (SceneManager.isNextScene(Scene_Battle)) {
this.launchBattle();
}
};
//
Scene_Map.prototype.isBusy = function () {
return ((this._messageWindow && this._messageWindow.isClosing()) ||
this._waitCount > 0 || this._encounterEffectDuration > 0 ||
Scene_Base.prototype.isBusy.call(this));
};
Scene_Map.prototype.terminate = function () {
Scene_Base.prototype.terminate.call(this);
if (!SceneManager.isNextScene(Scene_Battle)) {
this._spriteset.update();
this._mapNameWindow.hide();
SceneManager.snapForBackground();
}
$gameScreen.clearZoom();
};
Scene_Map.prototype.needsFadeIn = function () {
return (SceneManager.isPreviousScene(Scene_Battle) ||
SceneManager.isPreviousScene(Scene_Load));
};
Scene_Map.prototype.needsSlowFadeOut = function () {
return (SceneManager.isNextScene(Scene_Title) ||
SceneManager.isNextScene(Scene_Gameover));
};
Scene_Map.prototype.updateWaitCount = function () {
if (this._waitCount > 0) {
this._waitCount--;
return true;
}
return false;
};
Scene_Map.prototype.updateDestination = function () {
if (this.isMapTouchOk()) {
this.processMapTouch();
} else {
$gameTemp.clearDestination();
this._touchCount = 0;
}
};
Scene_Map.prototype.isMapTouchOk = function () {
return this.isActive() && $gamePlayer.canMove();
};
Scene_Map.prototype.processMapTouch = function () {
if (TouchInput.isTriggered() || this._touchCount > 0) {
if (TouchInput.isPressed()) {
if (this._touchCount === 0 || this._touchCount >= 15) {
var x = $gameMap.canvasToMapX(TouchInput.x);
var y = $gameMap.canvasToMapY(TouchInput.y);
$gameTemp.setDestination(x, y);
}
this._touchCount++;
} else {
this._touchCount = 0;
}
}
};
Scene_Map.prototype.isSceneChangeOk = function () {
return this.isActive() && !$gameMessage.isBusy();
};
Scene_Map.prototype.updateScene = function () {
this.checkGameover();
if (!SceneManager.isSceneChanging()) {
this.updateTransferPlayer();
}
if (!SceneManager.isSceneChanging()) {
this.updateEncounter();
}
if (!SceneManager.isSceneChanging()) {
this.updateCallMenu();
}
if (!SceneManager.isSceneChanging()) {
this.updateCallDebug();
}
};
Scene_Map.prototype.createDisplayObjects = function () {
this.createSpriteset();
this.createMapNameWindow();
this.createWindowLayer();
this.createAllWindows();
};
Scene_Map.prototype.createSpriteset = function () {
this._spriteset = new Spriteset_Map();
this.addChild(this._spriteset);
};
Scene_Map.prototype.createAllWindows = function () {
this.createMessageWindow();
this.createScrollTextWindow();
};
Scene_Map.prototype.createMapNameWindow = function () {
this._mapNameWindow = new Window_MapName();
this.addChild(this._mapNameWindow);
};
Scene_Map.prototype.createMessageWindow = function () {
this._messageWindow = new Window_Message();
this.addWindow(this._messageWindow);
this._messageWindow.subWindows().forEach(function (window) {
this.addWindow(window);
}, this);
};
Scene_Map.prototype.createScrollTextWindow = function () {
this._scrollTextWindow = new Window_ScrollText();
this.addWindow(this._scrollTextWindow);
};
Scene_Map.prototype.updateTransferPlayer = function () {
if ($gamePlayer.isTransferring()) {
SceneManager.goto(Scene_Map);
}
};
Scene_Map.prototype.updateEncounter = function () {
if ($gamePlayer.executeEncounter()) {
SceneManager.push(Scene_Battle);
}
};
Scene_Map.prototype.updateCallMenu = function () {
if (this.isMenuEnabled()) {
if (this.isMenuCalled()) {
this.menuCalling = true;
}
if (this.menuCalling && !$gamePlayer.isMoving()) {
this.callMenu();
}
} else {
this.menuCalling = false;
}
};
Scene_Map.prototype.isMenuEnabled = function () {
return $gameSystem.isMenuEnabled() && !$gameMap.isEventRunning();
};
Scene_Map.prototype.isMenuCalled = function () {
return Input.isTriggered('menu') || TouchInput.isCancelled();
};
Scene_Map.prototype.callMenu = function () {
SoundManager.playOk();
SceneManager.push(Scene_Menu);
Window_MenuCommand.initCommandPosition();
$gameTemp.clearDestination();
this._mapNameWindow.hide();
this._waitCount = 2;
};
Scene_Map.prototype.updateCallDebug = function () {
if (this.isDebugCalled()) {
SceneManager.push(Scene_Debug);
}
};
Scene_Map.prototype.isDebugCalled = function () {
return Input.isTriggered('debug') && $gameTemp.isPlaytest();
};
Scene_Map.prototype.fadeInForTransfer = function () {
var fadeType = $gamePlayer.fadeType();
switch (fadeType) {
case 0:
case 1:
this.startFadeIn(this.fadeSpeed(), fadeType === 1);
break;
}
};
Scene_Map.prototype.fadeOutForTransfer = function () {
var fadeType = $gamePlayer.fadeType();
switch (fadeType) {
case 0:
case 1:
this.startFadeOut(this.fadeSpeed(), fadeType === 1);
break;
}
};
Scene_Map.prototype.launchBattle = function () {
BattleManager.saveBgmAndBgs();
this.stopAudioOnBattleStart();
SoundManager.playBattleStart();
this.startEncounterEffect();
this._mapNameWindow.hide();
};
Scene_Map.prototype.stopAudioOnBattleStart = function () {
if (!AudioManager.isCurrentBgm($gameSystem.battleBgm())) {
AudioManager.stopBgm();
}
AudioManager.stopBgs();
AudioManager.stopMe();
AudioManager.stopSe();
};
Scene_Map.prototype.startEncounterEffect = function () {
this._spriteset.hideCharacters();
this._encounterEffectDuration = this.encounterEffectSpeed();
};
Scene_Map.prototype.updateEncounterEffect = function () {
if (this._encounterEffectDuration > 0) {
this._encounterEffectDuration--;
var speed = this.encounterEffectSpeed();
var n = speed - this._encounterEffectDuration;
var p = n / speed;
var q = ((p - 1) * 20 * p + 5) * p + 1;
var zoomX = $gamePlayer.screenX();
var zoomY = $gamePlayer.screenY() - 24;
if (n === 2) {
$gameScreen.setZoom(zoomX, zoomY, 1);
this.snapForBattleBackground();
this.startFlashForEncounter(speed / 2);
}
$gameScreen.setZoom(zoomX, zoomY, q);
if (n === Math.floor(speed / 6)) {
this.startFlashForEncounter(speed / 2);
}
if (n === Math.floor(speed / 2)) {
BattleManager.playBattleBgm();
this.startFadeOut(this.fadeSpeed());
}
}
};
Scene_Map.prototype.snapForBattleBackground = function () {
this._windowLayer.visible = false;
SceneManager.snapForBackground();
this._windowLayer.visible = true;
};
Scene_Map.prototype.startFlashForEncounter = function (duration) {
var color = [255, 255, 255, 255];
$gameScreen.startFlash(color, duration);
};
Scene_Map.prototype.encounterEffectSpeed = function () {
return 60;
};
//-----------------------------------------------------------------------------
// Scene_MenuBase
//
// The superclass of all the menu-type scenes.
function Scene_MenuBase() {
this.initialize.apply(this, arguments);
}
Scene_MenuBase.prototype = Object.create(Scene_Base.prototype);
Scene_MenuBase.prototype.constructor = Scene_MenuBase;
Scene_MenuBase.prototype.initialize = function () {
Scene_Base.prototype.initialize.call(this);
};
Scene_MenuBase.prototype.create = function () {
Scene_Base.prototype.create.call(this);
this.createBackground();
this.updateActor();
this.createWindowLayer();
};
Scene_MenuBase.prototype.actor = function () {
return this._actor;
};
Scene_MenuBase.prototype.updateActor = function () {
this._actor = $gameParty.menuActor();
};
/**
* 创建背景 是一个模糊化的当前游戏运行截图
*/
Scene_MenuBase.prototype.createBackground = function () {
this._backgroundSprite = new Sprite();
this._backgroundSprite.bitmap = SceneManager.backgroundBitmap();
this.addChild(this._backgroundSprite);
};
/**
* 设置背景透明度
* @param opacity
*/
Scene_MenuBase.prototype.setBackgroundOpacity = function (opacity) {
this._backgroundSprite.opacity = opacity;
};
/**
* 创建帮助文本容器
*/
Scene_MenuBase.prototype.createHelpWindow = function () {
this._helpWindow = new Window_Help();
this.addWindow(this._helpWindow);
};
Scene_MenuBase.prototype.nextActor = function () {
$gameParty.makeMenuActorNext();
this.updateActor();
this.onActorChange();
};
Scene_MenuBase.prototype.previousActor = function () {
$gameParty.makeMenuActorPrevious();
this.updateActor();
this.onActorChange();
};
Scene_MenuBase.prototype.onActorChange = function () {
};
//-----------------------------------------------------------------------------
// Scene_Menu
// 菜单场景 (默认按ESC呼出)
// The scene class of the menu screen.
function Scene_Menu() {
this.initialize.apply(this, arguments);
}
Scene_Menu.prototype = Object.create(Scene_MenuBase.prototype);
Scene_Menu.prototype.constructor = Scene_Menu;
Scene_Menu.prototype.initialize = function () {
Scene_MenuBase.prototype.initialize.call(this);
};
Scene_Menu.prototype.create = function () {
Scene_MenuBase.prototype.create.call(this);
//创建左侧列表
this.createCommandWindow();
//创建显示金钱的文本框
this.createGoldWindow();
//创建右侧状态框
this.createStatusWindow();
};
Scene_Menu.prototype.start = function () {
Scene_MenuBase.prototype.start.call(this);
this._statusWindow.refresh();
};
/**
* 添加命令对应的处理器
*/
Scene_Menu.prototype.createCommandWindow = function () {
this._commandWindow = new Window_MenuCommand(0, 0);
this._commandWindow.setHandler('item', this.commandItem.bind(this));
this._commandWindow.setHandler('skill', this.commandPersonal.bind(this));
this._commandWindow.setHandler('equip', this.commandPersonal.bind(this));
this._commandWindow.setHandler('status', this.commandPersonal.bind(this));
this._commandWindow.setHandler('formation', this.commandFormation.bind(this));
this._commandWindow.setHandler('options', this.commandOptions.bind(this));
this._commandWindow.setHandler('save', this.commandSave.bind(this));
this._commandWindow.setHandler('gameEnd', this.commandGameEnd.bind(this));
this._commandWindow.setHandler('cancel', this.popScene.bind(this));
this.addWindow(this._commandWindow);
};
Scene_Menu.prototype.createGoldWindow = function () {
this._goldWindow = new Window_Gold(0, 0);
this._goldWindow.y = Graphics.boxHeight - this._goldWindow.height;
this.addWindow(this._goldWindow);
};
Scene_Menu.prototype.createStatusWindow = function () {
this._statusWindow = new Window_MenuStatus(this._commandWindow.width, 0);
this.addWindow(this._statusWindow);
};
Scene_Menu.prototype.commandItem = function () {
SceneManager.push(Scene_Item);
};
Scene_Menu.prototype.commandPersonal = function () {
this._statusWindow.setFormationMode(false);
this._statusWindow.selectLast();
this._statusWindow.activate();
this._statusWindow.setHandler('ok', this.onPersonalOk.bind(this));
this._statusWindow.setHandler('cancel', this.onPersonalCancel.bind(this));
};
Scene_Menu.prototype.commandFormation = function () {
this._statusWindow.setFormationMode(true);
this._statusWindow.selectLast();
this._statusWindow.activate();
this._statusWindow.setHandler('ok', this.onFormationOk.bind(this));
this._statusWindow.setHandler('cancel', this.onFormationCancel.bind(this));
};
Scene_Menu.prototype.commandOptions = function () {
SceneManager.push(Scene_Options);
};
Scene_Menu.prototype.commandSave = function () {
SceneManager.push(Scene_Save);
};
Scene_Menu.prototype.commandGameEnd = function () {
SceneManager.push(Scene_GameEnd);
};
Scene_Menu.prototype.onPersonalOk = function () {
switch (this._commandWindow.currentSymbol()) {
case 'skill':
SceneManager.push(Scene_Skill);
break;
case 'equip':
SceneManager.push(Scene_Equip);
break;
case 'status':
SceneManager.push(Scene_Status);
break;
}
};
Scene_Menu.prototype.onPersonalCancel = function () {
this._statusWindow.deselect();
this._commandWindow.activate();
};
Scene_Menu.prototype.onFormationOk = function () {
var index = this._statusWindow.index();
var actor = $gameParty.members()[index];
var pendingIndex = this._statusWindow.pendingIndex();
if (pendingIndex >= 0) {
$gameParty.swapOrder(index, pendingIndex);
this._statusWindow.setPendingIndex(-1);
this._statusWindow.redrawItem(index);
} else {
this._statusWindow.setPendingIndex(index);
}
this._statusWindow.activate();
};