-
Notifications
You must be signed in to change notification settings - Fork 0
/
view_bgm.java
203 lines (181 loc) · 5.31 KB
/
view_bgm.java
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
import javax.swing.*;
import java.util.*;
import java.awt.event.*;
import java.awt.*;
/* View : SE */
class View_se extends Sound_Pack implements Observer {
private Character ch;
private Enemy ene;
private Maze maze;
private Have_Item have_item;
private Step_Trap step_trap;
private Bgm_se deathenemy_se;
private Bgm_se sword_se;
private Bgm_se hammer_se;
private Bgm_se book_se;
private Bgm_se coin_se;
private Bgm_se getitem_se;
private Bgm_se star_se;
private Bgm_se trap_se;
private Bgm_se game_bgm;
private Bgm_se lunatic_bgm;
// コンストラクタ
public View_se(Maze maze, Character ch, Enemy ene) {
this.maze = maze;
this.ch = ch;
this.ene = ene;
this.have_item = ch.getHave_Item();
this.step_trap = ch.getStep_Trap();
deathenemy_se = getSoundPack("DeathEnemy");
sword_se = getSoundPack("Sword");
hammer_se = getSoundPack("Hammer");
book_se = getSoundPack("Book");
coin_se = getSoundPack("Coin");
getitem_se = getSoundPack("getItem");
trap_se = getSoundPack("Trap");
star_se = getSoundPack("Star");
game_bgm = getSoundPack("Game");
lunatic_bgm = getSoundPack("Lunatic");
this.ene.addObserver(this);
this.have_item.addObserver(this);
this.step_trap.addObserver(this);
}
// SEを鳴らす
public void Play_SE() {
if (ene.getFlagDeath()) {
deathenemy_se.play();
}
if (have_item.getSwordSE()) {
sword_se.play();
}
if (have_item.getHammerSE()) {
hammer_se.play();
}
if (have_item.getBookSE()) {
book_se.play();
}
if (have_item.getGetitemSE()) {
getitem_se.play();
}
if (have_item.getCoinSE()) {
coin_se.play();
}
if (step_trap.getTrapSE()) {
trap_se.play();
}
if (have_item.getStarSE()) {
star_se.play();
}
}
// SEを止める
public void Stop_SE() {
if (ch.getRowchar() == maze.getRowgoal() && ch.getColchar() == maze.getColgoal()) {
star_se.stop();
}
}
// アップデート
public void update(Observable o, Object arg) {
Play_SE();
Stop_SE();
}
// BGMを鳴らす
public void Play_BGM() {
if (maze.getMode() == 3) {
lunatic_bgm.play();
} else {
game_bgm.play();
}
}
// BGMを止める
public void Stop_BGM() {
if (maze.getMode() == 3) {
lunatic_bgm.stop();
} else {
game_bgm.stop();
}
}
}
/* View : ガチャ画面のときのSE */
class View_seGacha extends Sound_Pack implements Observer {
private Gacha gacha;
private Bgm_se gacha_se;
// コンストラクタ
public View_seGacha(Gacha gacha) {
this.gacha = gacha;
gacha_se = getSoundPack("Gacha");
this.gacha.addObserver(this);
}
// SEを鳴らす
public void Play_SE() {
if (gacha.getFlagGacha()) {
gacha_se.play();
}
}
// アップデート
public void update(Observable o, Object arg) {
Play_SE();
}
}
/* View : 各画面のBGM */
class View_bgm extends Sound_Pack {
private Bgm_se start_bgm;
private Bgm_se game_bgm;
private Bgm_se gameover_bgm;
private Bgm_se result_bgm;
// コンストラクタ
public View_bgm() {
start_bgm = getSoundPack("Start");
game_bgm = getSoundPack("Game");
gameover_bgm = getSoundPack("GameOver");
result_bgm = getSoundPack("Result");
}
// BGMを流す
public void Play_BGM(String str) {
if (str.equals("Start")) {
start_bgm.play();
start_bgm.loop();
} else if (str.equals("Game")) {
game_bgm.play();
game_bgm.loop();
} else if (str.equals("GameOver")) {
gameover_bgm.play();
gameover_bgm.loop();
} else if (str.equals("Result")) {
result_bgm.play();
result_bgm.loop();
}
}
// BGMを止める
public void Stop_BGM(String str) {
if (str.equals("Start")) {
start_bgm.stop();
} else if (str.equals("Game")) {
game_bgm.stop();
} else if (str.equals("GameOver")) {
gameover_bgm.stop();
} else if (str.equals("Result")) {
result_bgm.stop();
}
}
}
/* View : ボタンを押す */
class View_seButton extends Sound_Pack implements Observer {
private Select_Item select_item;
private Bgm_se button_se;
// コンストラクタ
public View_seButton(Select_Item select_item) {
this.select_item = select_item;
button_se = getSoundPack("Button");
this.select_item.addObserver(this);
}
// 鳴らす
public void Play_SE() {
if (select_item.getFlagButton()) {
button_se.play();
}
}
// アップデート
public void update(Observable o, Object arg) {
Play_SE();
}
}