forked from CuteLunaMoon/Survival-Pixel-Dungeon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCaveBosslevel2.java
329 lines (267 loc) · 11.6 KB
/
CaveBosslevel2.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
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
/*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2018 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.levels;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Bones;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.DM300;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.keys.SkeletonKey;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ToxicTrap;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTileSheet;
import com.watabou.noosa.Camera;
import com.watabou.noosa.Group;
import com.watabou.noosa.audio.Sample;
import com.watabou.utils.Bundle;
import com.watabou.utils.PathFinder;
import com.watabou.utils.Random;
import com.watabou.utils.Rect;
public class CavesBossLevel2 extends Level {
{
color1 = 0x534f3e;
color2 = 0xb9d661;
viewDistance = Math.min(6, viewDistance);
}
private static final int WIDTH = 32;
private static final int HEIGHT = 32;
private static final int ROOM_LEFT = 7;
private static final int ROOM_RIGHT = 12;
private static final int ROOM_TOP = 11;
private static final int ROOM_BOTTOM = 16;
private static final int gardenTop = 21;
private static final int gardenBottom = 24;
private static final int gardenLeft = 20;
private static final int gardenRight = 20;
private int arenaDoor = 13*32+7;
private boolean enteredArena = false;
private boolean keyDropped = false;
@Override
public String tilesTex() {
return Assets.TILES_CAVES;
}
@Override
public String waterTex() {
return Assets.WATER_CAVES;
}
private static final String DOOR = "door";
private static final String ENTERED = "entered";
private static final String DROPPED = "droppped";
@Override
public void storeInBundle( Bundle bundle ) {
super.storeInBundle( bundle );
bundle.put( DOOR, arenaDoor );
bundle.put( ENTERED, enteredArena );
bundle.put( DROPPED, keyDropped );
}
@Override
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle );
arenaDoor = bundle.getInt( DOOR );
enteredArena = bundle.getBoolean( ENTERED );
keyDropped = bundle.getBoolean( DROPPED );
}
@Override
protected boolean build() {
setSize(32, 32);
map = MAP_START.clone();
Foliage light = (Foliage) Dungeon.level.blobs.get( Foliage.class );
if (light == null) {
light = new Foliage();
}
for (int i= gardenTop + 1; i < gardenBottom; i++) {
for (int j= gardebLeft + 1; j < gardenRight; j++) {
light.seed( Dungeon.level, j + Dungeon.level.width() * i, 1 );
}
}
level.blobs.put( Foliage.class, light );
return true;
}
private static final int W = Terrain.WALL;
private static final int D = Terrain.DOOR;
private static final int L = Terrain.LOCKED_DOOR;
private static final int e = Terrain.EMPTY;
private static final int T = Terrain.INACTIVE_TRAP;
private static final int E = Terrain.ENTRANCE;
private static final int X = Terrain.EXIT;
private static final int M = Terrain.WALL_DECO;
private static final int P = Terrain.PEDESTAL;
private static final int B = Terrain.BOOKSHELF;
private static final int G = Terrain.HIGH_GRASS;
private static final int f = Terrain.WATER;
private static final int H = Terrain.HIDDEN_DOOR;
private static final int C = Terrain.CHASM;
// I store this static map this here
private static final int[] MAP_START =
{ W, W, W, W, W, W, W, W, W, W, X, W, W, W, W, W, W, W, W, W, W, W, W, W, W, W, W, W, W, W, W, W,
W, W, f, f, f, e, e, e, T, T, T, T, T, e, e, W, W, W, W, W, W, W, W, W, W, W, W, W, W, W, W, W,
W, W, f, f, e, e, e, e, e, T, T, T, e, e, e, W, W, W, W, M, M, G, G, G, W, W, W, W, W, W, W, W,
W, W, f, e, e, e, e, e, e, e, e, e, e, e, e, W, W, W, W, f, f, f, f, G, G, W, W, W, W, W, W, W,
W, W, e, W, e, e, e, e, e, e, e, e, T, e, 3, W, W, W, G, f, f, f, f, G, G, W, W, W, W, W, W, W,
W, W, T, W, e, e, e, e, e, e, e, e, e, e, W, W, W, W, W, f, f, f, f, G, G, W, W, W, W, W, W, W,
W, W, e, W, e, e, e, e, e, e, e, e, e, e, W, W, W, W, W, f, f, f, f, G, G, W, W, W, W, W, W, W,
W, W, W, W, W, T, e, T, W, W, W, W, W, W, W, W, W, W, W, f, f, f, f, G, G, W, W, W, W, W, W, W,
W, e, e, e, e, e, e, e, e, e, e, e, e, e, e, W, W, W, W, f, f, f, f, W, W, W, W, W, W, W, W, W,
W, e, e, e, e, e, e, e, e, e, e, e, e, e, T, W, W, W, W, f, f, f, f, W, W, W, W, W, W, W, W, W,
W, e, e, e, e, e, T, e, e, e, e, e, e, T, e, W, W, W, W, f, G, W, W, W, W, W, W, W, W, W, W, W,
W, W, e, T, e, e, W, W, W, W, W, G, e, e, e, e, W, W, W, f, W, W, W, W, W, W, W, W, W, W, W, W,
W, f, e, e, e, e, W, e, e, E, W, G, e, e, e, T, W, W, W, f, W, W, W, W, W, W, W, W, W, W, W, W,
W, f, e, e, e, T, W, e, e, e, W, G, e, e, e, e, W, W, W, f, W, W, W, W, W, W, W, W, W, W, W, W,
W, f, e, e, e, T, D, e, e, e, W, G, e, e, e, e, W, W, W, f, G, W, W, W, W, W, W, W, W, W, W, W,
W, f, e, e, e, T, W, W, W, W, W, G, e, e, T, W, W, W, W, D, W, W, W, W, W, W, W, W, W, W, W, W,
W, f, T, e, e, e, e, e, e, e, G, e, e, e, e, W, W, W, W, f, W, W, W, W, W, W, W, W, W, W, W, W,
W, e, e, e, e, e, e, e, e, e, e, e, e, e, W, W, W, W, W, f, W, W, W, W, W, W, W, W, W, W, W, W,
W, e, e, e, W, e, e, e, e, T, e, e, e, W, W, W, W, W, W, f, W, W, W, W, W, W, W, W, W, W, W, W,
W, T, e, e, e, e, e, e, e, e, e, e, e, W, W, W, W, W, W, f, W, W, W, W, W, W, W, W, W, W, W, W,
W, f, f, e, e, e, e, e, e, e, e, e, e, W, W, W, W, W, W, f, f, f, f, f, W, W, W, W, W, W, W, W,
W, f, f, f, e, e, e, e, e, T, e, W, W, W, W, W, W, W, W, G, G, G, G, f, W, W, W, W, W, W, W, W,
W, f, f, f, f, f, e, e, W, W, W, W, W, W, W, B, B, B, W, G, G, G, G, f, W, W, W, W, W, W, W, W,
W, W, W, W, W, L, W, W, W, W, W, W, W, W, W, B, e, e, H, G, G, G, G, f, W, W, W, W, W, W, W, W,
W, W, W, W, W, T, W, W, W, W, W, W, W, W, W, e, e, B, W, G, G, G, G, f, f, f, D, f, f, f, W, W,
W, W, W, W, W, e, W, W, W, W, W, W, W, W, W, H, W, W, W, W, W, W, W, W, W, W, W, W, W, f, W, W,
W, W, W, T, T, T, T, T, W, B, B, B, B, W, B, e, e, B, B, B, B, W, e, e, e, W, W, W, W, W, W, W,
W, W, W, T, T, T, T, T, W, B, e, P, B, W, e, e, e, e, B, B, B, W, e, e, e, W, W, W, W, W, W, W,
W, e, H, T, T, T, T, T, W, B, e, e, B, W, e, e, e, e, B, B, e, H, e, e, e, W, W, W, W, W, W, W,
W, W, W, T, T, T, T, T, L, e, e, e, e, H, e, e, e, e, B, B, B, W, e, e, e, W, W, W, W, W, W, W,
W, W, W, T, T, T, T, T, W, B, B, B, B, W, B, B, e, B, B, B, B, W, e, e, e, W, W, W, W, W, W, W,
W, W, W, W, W, W, W, W, W, W, W, W, W, W, W, W, W, M, W, W, W, W, W, W, W, W, W, W, W, W, W, W};
@Override
public Mob createMob() {
return null;
}
@Override
protected void createMobs() {
}
public Actor respawner() {
return null;
}
/*
@Override
protected void createItems() {
Item item = Bones.get();
if (item != null) {
int pos;
do {
pos = Random.IntRange( ROOM_LEFT, ROOM_RIGHT ) + Random.IntRange( ROOM_TOP + 1, ROOM_BOTTOM ) * width();
} while (pos == entrance);
drop( item, pos ).type = Heap.Type.REMAINS;
}
}
@Override
public int randomRespawnCell() {
int cell = entrance + PathFinder.NEIGHBOURS8[Random.Int(8)];
while (!passable[cell]){
cell = entrance + PathFinder.NEIGHBOURS8[Random.Int(8)];
}
return cell;
}
*/
@Override
public void press( int cell, Char hero ) {
super.press( cell, hero );
if (!enteredArena && outsideEntraceRoom( cell ) && hero == Dungeon.hero) {
enteredArena = true;
seal();
drop(new IronKey(1), 32*28+2);
drop(new IronKey(1), 32*6+3);
for (Mob m : mobs){
//bring the first ally with you
if (m.alignment == Char.Alignment.ALLY){
m.pos = Dungeon.hero.pos + (Random.Int(2) == 0 ? +1 : -1);
m.sprite.place(m.pos);
break;
}
}
DM300 boss = new DM300();
boss.state = boss.WANDERING;
boss.pos = 35; //static spawn
GameScene.add( boss );
set( arenaDoor, Terrain.WALL );
GameScene.updateMap( arenaDoor );
Dungeon.observe();
CellEmitter.get( arenaDoor ).start( Speck.factory( Speck.ROCK ), 0.07f, 10 );
Camera.main.shake( 3, 0.7f );
Sample.INSTANCE.play( Assets.SND_ROCKS );
}
}
@Override
public Heap drop( Item item, int cell ) {
if (!keyDropped && item instanceof SkeletonKey) {
keyDropped = true;
unseal();
CellEmitter.get( arenaDoor ).start( Speck.factory( Speck.ROCK ), 0.07f, 10 );
set( arenaDoor, Terrain.EMPTY_DECO );
GameScene.updateMap( arenaDoor );
Dungeon.observe();
}
return super.drop( item, cell );
}
private boolean outsideEntraceRoom( int cell ) {
int cx = cell % width();
int cy = cell / width();
return cx < ROOM_LEFT-1 || cx > ROOM_RIGHT+1 || cy < ROOM_TOP-1 || cy > ROOM_BOTTOM+1;
}
@Override
public String tileName( int tile ) {
switch (tile) {
case Terrain.GRASS:
return Messages.get(CavesLevel.class, "grass_name");
case Terrain.HIGH_GRASS:
return Messages.get(CavesLevel.class, "high_grass_name");
case Terrain.WATER:
return Messages.get(CavesLevel.class, "water_name");
default:
return super.tileName( tile );
}
}
@Override
public String tileDesc( int tile ) {
switch (tile) {
case Terrain.ENTRANCE:
return Messages.get(CavesLevel.class, "entrance_desc");
case Terrain.EXIT:
return Messages.get(CavesLevel.class, "exit_desc");
case Terrain.HIGH_GRASS:
return Messages.get(CavesLevel.class, "high_grass_desc");
case Terrain.WALL_DECO:
return Messages.get(CavesLevel.class, "wall_deco_desc");
case Terrain.BOOKSHELF:
return Messages.get(CavesLevel.class, " The shelve is full of strange books: necromancy, demonology, how to summon a succubus, how to pick up fair maiden. Even more strange, most of them are written in the common tongue, not Drawven. ");
default:
return super.tileDesc( tile );
}
}
@Override
public Group addVisuals() {
super.addVisuals();
CavesLevel.addCavesVisuals(this, visuals);
return visuals;
}
}