V0.1.0 Partial Commit
changed package and application names to differentiate from main PD release
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2014 Oleg Dolya
|
||||
*
|
||||
* 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.painters;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.watabou.utils.Point;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class ArmoryPainter extends Painter {
|
||||
|
||||
public static void paint( Level level, Room room ) {
|
||||
|
||||
fill( level, room, Terrain.WALL );
|
||||
fill( level, room, 1, Terrain.EMPTY );
|
||||
|
||||
Room.Door entrance = room.entrance();
|
||||
Point statue = null;
|
||||
if (entrance.x == room.left) {
|
||||
statue = new Point( room.right-1, Random.Int( 2 ) == 0 ? room.top+1 : room.bottom-1 );
|
||||
} else if (entrance.x == room.right) {
|
||||
statue = new Point( room.left+1, Random.Int( 2 ) == 0 ? room.top+1 : room.bottom-1 );
|
||||
} else if (entrance.y == room.top) {
|
||||
statue = new Point( Random.Int( 2 ) == 0 ? room.left+1 : room.right-1, room.bottom-1 );
|
||||
} else if (entrance.y == room.bottom) {
|
||||
statue = new Point( Random.Int( 2 ) == 0 ? room.left+1 : room.right-1, room.top+1 );
|
||||
}
|
||||
if (statue != null) {
|
||||
set( level, statue, Terrain.STATUE );
|
||||
}
|
||||
|
||||
int n = Random.IntRange( 2, 3 );
|
||||
for (int i=0; i < n; i++) {
|
||||
int pos;
|
||||
do {
|
||||
pos = room.random();
|
||||
} while (level.map[pos] != Terrain.EMPTY || level.heaps.get( pos ) != null);
|
||||
level.drop( prize( level ), pos );
|
||||
}
|
||||
|
||||
entrance.set( Room.Door.Type.LOCKED );
|
||||
level.addItemToSpawn( new IronKey( Dungeon.depth ) );
|
||||
}
|
||||
|
||||
private static Item prize( Level level ) {
|
||||
return Generator.random( Random.oneOf(
|
||||
Generator.Category.ARMOR,
|
||||
Generator.Category.WEAPON
|
||||
) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2014 Oleg Dolya
|
||||
*
|
||||
* 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.painters;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Blacksmith;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class BlacksmithPainter extends Painter {
|
||||
|
||||
public static void paint( Level level, Room room ) {
|
||||
|
||||
fill( level, room, Terrain.WALL );
|
||||
fill( level, room, 1, Terrain.FIRE_TRAP );
|
||||
fill( level, room, 2, Terrain.EMPTY_SP );
|
||||
|
||||
for (int i=0; i < 2; i++) {
|
||||
int pos;
|
||||
do {
|
||||
pos = room.random();
|
||||
} while (level.map[pos] != Terrain.EMPTY_SP);
|
||||
level.drop(
|
||||
Generator.random( Random.oneOf(
|
||||
Generator.Category.ARMOR,
|
||||
Generator.Category.WEAPON
|
||||
) ), pos );
|
||||
}
|
||||
|
||||
for (Room.Door door : room.connected.values()) {
|
||||
door.set( Room.Door.Type.UNLOCKED );
|
||||
drawInside( level, room, door, 1, Terrain.EMPTY );
|
||||
}
|
||||
|
||||
Blacksmith npc = new Blacksmith();
|
||||
do {
|
||||
npc.pos = room.random( 1 );
|
||||
} while (level.heaps.get( npc.pos ) != null);
|
||||
level.mobs.add( npc );
|
||||
Actor.occupyCell( npc );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2014 Oleg Dolya
|
||||
*
|
||||
* 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.painters;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
|
||||
public class BossExitPainter extends Painter {
|
||||
|
||||
public static void paint( Level level, Room room ) {
|
||||
|
||||
fill( level, room, Terrain.WALL );
|
||||
fill( level, room, 1, Terrain.EMPTY );
|
||||
|
||||
for (Room.Door door : room.connected.values()) {
|
||||
door.set( Room.Door.Type.REGULAR );
|
||||
}
|
||||
|
||||
level.exit = room.top * Level.WIDTH + (room.left + room.right) / 2;
|
||||
set( level, level.exit, Terrain.LOCKED_EXIT );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2014 Oleg Dolya
|
||||
*
|
||||
* 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.painters;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Heap.Type;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.watabou.utils.Point;
|
||||
|
||||
public class CryptPainter extends Painter {
|
||||
|
||||
public static void paint( Level level, Room room ) {
|
||||
|
||||
fill( level, room, Terrain.WALL );
|
||||
fill( level, room, 1, Terrain.EMPTY );
|
||||
|
||||
Point c = room.center();
|
||||
int cx = c.x;
|
||||
int cy = c.y;
|
||||
|
||||
Room.Door entrance = room.entrance();
|
||||
|
||||
entrance.set( Room.Door.Type.LOCKED );
|
||||
level.addItemToSpawn( new IronKey( Dungeon.depth ) );
|
||||
|
||||
if (entrance.x == room.left) {
|
||||
set( level, new Point( room.right-1, room.top+1 ), Terrain.STATUE );
|
||||
set( level, new Point( room.right-1, room.bottom-1 ), Terrain.STATUE );
|
||||
cx = room.right - 2;
|
||||
} else if (entrance.x == room.right) {
|
||||
set( level, new Point( room.left+1, room.top+1 ), Terrain.STATUE );
|
||||
set( level, new Point( room.left+1, room.bottom-1 ), Terrain.STATUE );
|
||||
cx = room.left + 2;
|
||||
} else if (entrance.y == room.top) {
|
||||
set( level, new Point( room.left+1, room.bottom-1 ), Terrain.STATUE );
|
||||
set( level, new Point( room.right-1, room.bottom-1 ), Terrain.STATUE );
|
||||
cy = room.bottom - 2;
|
||||
} else if (entrance.y == room.bottom) {
|
||||
set( level, new Point( room.left+1, room.top+1 ), Terrain.STATUE );
|
||||
set( level, new Point( room.right-1, room.top+1 ), Terrain.STATUE );
|
||||
cy = room.top + 2;
|
||||
}
|
||||
|
||||
level.drop( prize( level ), cx + cy * Level.WIDTH ).type = Type.TOMB;
|
||||
}
|
||||
|
||||
private static Item prize( Level level ) {
|
||||
|
||||
Item prize = Generator.random( Generator.Category.ARMOR );
|
||||
|
||||
for (int i=0; i < 3; i++) {
|
||||
Item another = Generator.random( Generator.Category.ARMOR );
|
||||
if (another.level > prize.level) {
|
||||
prize = another;
|
||||
}
|
||||
}
|
||||
|
||||
return prize;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2014 Oleg Dolya
|
||||
*
|
||||
* 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.painters;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
|
||||
public class EntrancePainter extends Painter {
|
||||
|
||||
public static void paint( Level level, Room room ) {
|
||||
|
||||
fill( level, room, Terrain.WALL );
|
||||
fill( level, room, 1, Terrain.EMPTY );
|
||||
|
||||
for (Room.Door door : room.connected.values()) {
|
||||
door.set( Room.Door.Type.REGULAR );
|
||||
}
|
||||
|
||||
level.entrance = room.random( 1 );
|
||||
set( level, level.entrance, Terrain.ENTRANCE );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2014 Oleg Dolya
|
||||
*
|
||||
* 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.painters;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
|
||||
public class ExitPainter extends Painter {
|
||||
|
||||
public static void paint( Level level, Room room ) {
|
||||
|
||||
fill( level, room, Terrain.WALL );
|
||||
fill( level, room, 1, Terrain.EMPTY );
|
||||
|
||||
for (Room.Door door : room.connected.values()) {
|
||||
door.set( Room.Door.Type.REGULAR );
|
||||
}
|
||||
|
||||
level.exit = room.random( 1 );
|
||||
set( level, level.exit, Terrain.EXIT );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2014 Oleg Dolya
|
||||
*
|
||||
* 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.painters;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Foliage;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.plants.Sungrass;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class GardenPainter extends Painter {
|
||||
|
||||
public static void paint( Level level, Room room ) {
|
||||
|
||||
fill( level, room, Terrain.WALL );
|
||||
fill( level, room, 1, Terrain.HIGH_GRASS );
|
||||
fill( level, room, 2, Terrain.GRASS );
|
||||
|
||||
room.entrance().set( Room.Door.Type.REGULAR );
|
||||
|
||||
int bushes = Random.Int( 3 ) == 0 ? (Random.Int( 5 ) == 0 ? 2 : 1) : 0;
|
||||
for (int i=0; i < bushes; i++) {
|
||||
level.plant( new Sungrass.Seed(), room.random() );
|
||||
}
|
||||
|
||||
Foliage light = (Foliage)level.blobs.get( Foliage.class );
|
||||
if (light == null) {
|
||||
light = new Foliage();
|
||||
}
|
||||
for (int i=room.top + 1; i < room.bottom; i++) {
|
||||
for (int j=room.left + 1; j < room.right; j++) {
|
||||
light.seed( j + Level.WIDTH * i, 1 );
|
||||
}
|
||||
}
|
||||
level.blobs.put( Foliage.class, light );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2014 Oleg Dolya
|
||||
*
|
||||
* 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.painters;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Alchemy;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.watabou.utils.Point;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class LaboratoryPainter extends Painter {
|
||||
|
||||
public static void paint( Level level, Room room ) {
|
||||
|
||||
fill( level, room, Terrain.WALL );
|
||||
fill( level, room, 1, Terrain.EMPTY_SP );
|
||||
|
||||
Room.Door entrance = room.entrance();
|
||||
|
||||
Point pot = null;
|
||||
if (entrance.x == room.left) {
|
||||
pot = new Point( room.right-1, Random.Int( 2 ) == 0 ? room.top + 1 : room.bottom - 1 );
|
||||
} else if (entrance.x == room.right) {
|
||||
pot = new Point( room.left+1, Random.Int( 2 ) == 0 ? room.top + 1 : room.bottom - 1 );
|
||||
} else if (entrance.y == room.top) {
|
||||
pot = new Point( Random.Int( 2 ) == 0 ? room.left + 1 : room.right - 1, room.bottom-1 );
|
||||
} else if (entrance.y == room.bottom) {
|
||||
pot = new Point( Random.Int( 2 ) == 0 ? room.left + 1 : room.right - 1, room.top+1 );
|
||||
}
|
||||
set( level, pot, Terrain.ALCHEMY );
|
||||
|
||||
Alchemy alchemy = new Alchemy();
|
||||
alchemy.seed( pot.x + Level.WIDTH * pot.y, 1 );
|
||||
level.blobs.put( Alchemy.class, alchemy );
|
||||
|
||||
int n = Random.IntRange( 2, 3 );
|
||||
for (int i=0; i < n; i++) {
|
||||
int pos;
|
||||
do {
|
||||
pos = room.random();
|
||||
} while (
|
||||
level.map[pos] != Terrain.EMPTY_SP ||
|
||||
level.heaps.get( pos ) != null);
|
||||
level.drop( prize( level ), pos );
|
||||
}
|
||||
|
||||
entrance.set( Room.Door.Type.LOCKED );
|
||||
level.addItemToSpawn( new IronKey( Dungeon.depth ) );
|
||||
}
|
||||
|
||||
private static Item prize( Level level ) {
|
||||
|
||||
Item prize = level.itemToSpanAsPrize();
|
||||
if (prize instanceof Potion) {
|
||||
return prize;
|
||||
} else if (prize != null) {
|
||||
level.addItemToSpawn( prize );
|
||||
}
|
||||
|
||||
return Generator.random( Generator.Category.POTION );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2014 Oleg Dolya
|
||||
*
|
||||
* 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.painters;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.watabou.utils.Point;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class LibraryPainter extends Painter {
|
||||
|
||||
public static void paint( Level level, Room room ) {
|
||||
|
||||
fill( level, room, Terrain.WALL );
|
||||
fill( level, room, 1, Terrain.EMPTY );
|
||||
|
||||
Room.Door entrance = room.entrance();
|
||||
Point a = null;
|
||||
Point b = null;
|
||||
|
||||
if (entrance.x == room.left) {
|
||||
a = new Point( room.left+1, entrance.y-1 );
|
||||
b = new Point( room.left+1, entrance.y+1 );
|
||||
fill( level, room.right - 1, room.top + 1, 1, room.height() - 1 , Terrain.BOOKSHELF );
|
||||
} else if (entrance.x == room.right) {
|
||||
a = new Point( room.right-1, entrance.y-1 );
|
||||
b = new Point( room.right-1, entrance.y+1 );
|
||||
fill( level, room.left+1, room.top + 1, 1, room.height() - 1 , Terrain.BOOKSHELF );
|
||||
} else if (entrance.y == room.top) {
|
||||
a = new Point( entrance.x+1, room.top+1 );
|
||||
b = new Point( entrance.x-1, room.top+1 );
|
||||
fill( level, room.left + 1, room.bottom-1, room.width() - 1, 1 , Terrain.BOOKSHELF );
|
||||
} else if (entrance.y == room.bottom) {
|
||||
a = new Point( entrance.x+1, room.bottom-1 );
|
||||
b = new Point( entrance.x-1, room.bottom-1 );
|
||||
fill( level, room.left + 1, room.top+1, room.width() - 1, 1 , Terrain.BOOKSHELF );
|
||||
}
|
||||
if (a != null && level.map[a.x + a.y * Level.WIDTH] == Terrain.EMPTY) {
|
||||
set( level, a, Terrain.STATUE );
|
||||
}
|
||||
if (b != null && level.map[b.x + b.y * Level.WIDTH] == Terrain.EMPTY) {
|
||||
set( level, b, Terrain.STATUE );
|
||||
}
|
||||
|
||||
int n = Random.IntRange( 2, 3 );
|
||||
for (int i=0; i < n; i++) {
|
||||
int pos;
|
||||
do {
|
||||
pos = room.random();
|
||||
} while (level.map[pos] != Terrain.EMPTY || level.heaps.get( pos ) != null);
|
||||
level.drop( prize( level), pos );
|
||||
}
|
||||
|
||||
entrance.set( Room.Door.Type.LOCKED );
|
||||
level.addItemToSpawn( new IronKey( Dungeon.depth ) );
|
||||
}
|
||||
|
||||
private static Item prize( Level level ) {
|
||||
|
||||
Item prize = level.itemToSpanAsPrize();
|
||||
if (prize instanceof Scroll) {
|
||||
return prize;
|
||||
} else if (prize != null) {
|
||||
level.addItemToSpawn( prize );
|
||||
}
|
||||
|
||||
return Generator.random( Generator.Category.SCROLL );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2014 Oleg Dolya
|
||||
*
|
||||
* 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.painters;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.WaterOfAwareness;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.WaterOfHealth;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.WaterOfTransmutation;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.WellWater;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.watabou.utils.Point;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class MagicWellPainter extends Painter {
|
||||
|
||||
private static final Class<?>[] WATERS =
|
||||
{WaterOfAwareness.class, WaterOfHealth.class, WaterOfTransmutation.class};
|
||||
|
||||
public static void paint( Level level, Room room ) {
|
||||
|
||||
fill( level, room, Terrain.WALL );
|
||||
fill( level, room, 1, Terrain.EMPTY );
|
||||
|
||||
Point c = room.center();
|
||||
set( level, c.x, c.y, Terrain.WELL );
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends WellWater> waterClass =
|
||||
Dungeon.depth >= Dungeon.transmutation ?
|
||||
WaterOfTransmutation.class :
|
||||
(Class<? extends WellWater>)Random.element( WATERS );
|
||||
|
||||
if (waterClass == WaterOfTransmutation.class) {
|
||||
Dungeon.transmutation = Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
WellWater water = (WellWater)level.blobs.get( waterClass );
|
||||
if (water == null) {
|
||||
try {
|
||||
water = waterClass.newInstance();
|
||||
} catch (Exception e) {
|
||||
water = null;
|
||||
}
|
||||
}
|
||||
water.seed( c.x + Level.WIDTH * c.y, 1 );
|
||||
level.blobs.put( waterClass, water );
|
||||
|
||||
room.entrance().set( Room.Door.Type.REGULAR );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2014 Oleg Dolya
|
||||
*
|
||||
* 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.painters;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Room;
|
||||
import com.watabou.utils.Point;
|
||||
import com.watabou.utils.Rect;
|
||||
|
||||
public class Painter {
|
||||
|
||||
public static void set( Level level, int cell, int value ) {
|
||||
level.map[cell] = value;
|
||||
}
|
||||
|
||||
public static void set( Level level, int x, int y, int value ) {
|
||||
set( level, x + y * Level.WIDTH, value );
|
||||
}
|
||||
|
||||
public static void set( Level level, Point p, int value ) {
|
||||
set( level, p.x, p.y, value );
|
||||
}
|
||||
|
||||
public static void fill( Level level, int x, int y, int w, int h, int value ) {
|
||||
|
||||
int width = Level.WIDTH;
|
||||
|
||||
int pos = y * width + x;
|
||||
for (int i=y; i < y + h; i++, pos += width) {
|
||||
Arrays.fill( level.map, pos, pos + w, value );
|
||||
}
|
||||
}
|
||||
|
||||
public static void fill( Level level, Rect rect, int value ) {
|
||||
fill( level, rect.left, rect.top, rect.width() + 1, rect.height() + 1, value );
|
||||
}
|
||||
|
||||
public static void fill( Level level, Rect rect, int m, int value ) {
|
||||
fill( level, rect.left + m, rect.top + m, rect.width() + 1 - m*2, rect.height() + 1 - m*2, value );
|
||||
}
|
||||
|
||||
public static void fill( Level level, Rect rect, int l, int t, int r, int b, int value ) {
|
||||
fill( level, rect.left + l, rect.top + t, rect.width() + 1 - (l + r), rect.height() + 1 - (t + b), value );
|
||||
}
|
||||
|
||||
public static Point drawInside( Level level, Room room, Point from, int n, int value ) {
|
||||
|
||||
Point step = new Point();
|
||||
if (from.x == room.left) {
|
||||
step.set( +1, 0 );
|
||||
} else if (from.x == room.right) {
|
||||
step.set( -1, 0 );
|
||||
} else if (from.y == room.top) {
|
||||
step.set( 0, +1 );
|
||||
} else if (from.y == room.bottom) {
|
||||
step.set( 0, -1 );
|
||||
}
|
||||
|
||||
Point p = new Point( from ).offset( step );
|
||||
for (int i=0; i < n; i++) {
|
||||
if (value != -1) {
|
||||
set( level, p, value );
|
||||
}
|
||||
p.offset( step );
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2014 Oleg Dolya
|
||||
*
|
||||
* 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.painters;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Room;
|
||||
import com.watabou.utils.Point;
|
||||
|
||||
public class PassagePainter extends Painter {
|
||||
|
||||
private static int pasWidth;
|
||||
private static int pasHeight;
|
||||
|
||||
public static void paint( Level level, Room room ) {
|
||||
|
||||
pasWidth = room.width() - 2;
|
||||
pasHeight = room.height() - 2;
|
||||
|
||||
int floor = level.tunnelTile();
|
||||
|
||||
ArrayList<Integer> joints = new ArrayList<Integer>();
|
||||
for (Point door : room.connected.values()) {
|
||||
joints.add( xy2p( room, door ) );
|
||||
}
|
||||
Collections.sort( joints );
|
||||
|
||||
int nJoints = joints.size();
|
||||
int perimeter = pasWidth * 2 + pasHeight * 2;
|
||||
|
||||
int start = 0;
|
||||
int maxD = joints.get( 0 ) + perimeter - joints.get( nJoints - 1 );
|
||||
for (int i=1; i < nJoints; i++) {
|
||||
int d = joints.get( i ) - joints.get( i - 1 );
|
||||
if (d > maxD) {
|
||||
maxD = d;
|
||||
start = i;
|
||||
}
|
||||
}
|
||||
|
||||
int end = (start + nJoints - 1) % nJoints;
|
||||
|
||||
int p = joints.get( start );
|
||||
do {
|
||||
set( level, p2xy( room, p ), floor );
|
||||
p = (p + 1) % perimeter;
|
||||
} while (p != joints.get( end ));
|
||||
|
||||
set( level, p2xy( room, p ), floor );
|
||||
|
||||
for (Room.Door door : room.connected.values()) {
|
||||
door.set( Room.Door.Type.TUNNEL );
|
||||
}
|
||||
}
|
||||
|
||||
private static int xy2p( Room room, Point xy ) {
|
||||
if (xy.y == room.top) {
|
||||
|
||||
return (xy.x - room.left - 1);
|
||||
|
||||
} else if (xy.x == room.right) {
|
||||
|
||||
return (xy.y - room.top - 1) + pasWidth;
|
||||
|
||||
} else if (xy.y == room.bottom) {
|
||||
|
||||
return (room.right - xy.x - 1) + pasWidth + pasHeight;
|
||||
|
||||
} else {
|
||||
|
||||
if (xy.y == room.top + 1) {
|
||||
return 0;
|
||||
} else {
|
||||
return (room.bottom - xy.y - 1) + pasWidth * 2 + pasHeight;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static Point p2xy( Room room, int p ) {
|
||||
if (p < pasWidth) {
|
||||
|
||||
return new Point( room.left + 1 + p, room.top + 1);
|
||||
|
||||
} else if (p < pasWidth + pasHeight) {
|
||||
|
||||
return new Point( room.right - 1, room.top + 1 + (p - pasWidth) );
|
||||
|
||||
} else if (p < pasWidth * 2 + pasHeight) {
|
||||
|
||||
return new Point( room.right - 1 - (p - (pasWidth + pasHeight)), room.bottom - 1 );
|
||||
|
||||
} else {
|
||||
|
||||
return new Point( room.left + 1, room.bottom - 1 - (p - (pasWidth * 2 + pasHeight)) );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2014 Oleg Dolya
|
||||
*
|
||||
* 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.painters;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Heap.Type;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.watabou.utils.Point;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class PitPainter extends Painter {
|
||||
|
||||
public static void paint( Level level, Room room ) {
|
||||
|
||||
fill( level, room, Terrain.WALL );
|
||||
fill( level, room, 1, Terrain.EMPTY );
|
||||
|
||||
Room.Door entrance = room.entrance();
|
||||
entrance.set( Room.Door.Type.LOCKED );
|
||||
|
||||
Point well = null;
|
||||
if (entrance.x == room.left) {
|
||||
well = new Point( room.right-1, Random.Int( 2 ) == 0 ? room.top + 1 : room.bottom - 1 );
|
||||
} else if (entrance.x == room.right) {
|
||||
well = new Point( room.left+1, Random.Int( 2 ) == 0 ? room.top + 1 : room.bottom - 1 );
|
||||
} else if (entrance.y == room.top) {
|
||||
well = new Point( Random.Int( 2 ) == 0 ? room.left + 1 : room.right - 1, room.bottom-1 );
|
||||
} else if (entrance.y == room.bottom) {
|
||||
well = new Point( Random.Int( 2 ) == 0 ? room.left + 1 : room.right - 1, room.top+1 );
|
||||
}
|
||||
set( level, well, Terrain.EMPTY_WELL );
|
||||
|
||||
int remains = room.random();
|
||||
while (level.map[remains] == Terrain.EMPTY_WELL) {
|
||||
remains = room.random();
|
||||
}
|
||||
|
||||
level.drop( new IronKey( Dungeon.depth ), remains ).type = Type.SKELETON;
|
||||
|
||||
if (Random.Int( 5 ) == 0) {
|
||||
level.drop( Generator.random( Generator.Category.RING ), remains );
|
||||
} else {
|
||||
level.drop( Generator.random( Random.oneOf(
|
||||
Generator.Category.WEAPON,
|
||||
Generator.Category.ARMOR
|
||||
) ), remains );
|
||||
}
|
||||
|
||||
int n = Random.IntRange( 1, 2 );
|
||||
for (int i=0; i < n; i++) {
|
||||
level.drop( prize( level ), remains );
|
||||
}
|
||||
}
|
||||
|
||||
private static Item prize( Level level ) {
|
||||
|
||||
Item prize = level.itemToSpanAsPrize();
|
||||
if (prize != null) {
|
||||
return prize;
|
||||
}
|
||||
|
||||
return Generator.random( Random.oneOf(
|
||||
Generator.Category.POTION,
|
||||
Generator.Category.SCROLL,
|
||||
Generator.Category.FOOD,
|
||||
Generator.Category.GOLD
|
||||
) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2014 Oleg Dolya
|
||||
*
|
||||
* 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.painters;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Piranha;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfInvisibility;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class PoolPainter extends Painter {
|
||||
|
||||
private static final int NPIRANHAS = 3;
|
||||
|
||||
public static void paint( Level level, Room room ) {
|
||||
|
||||
fill( level, room, Terrain.WALL );
|
||||
fill( level, room, 1, Terrain.WATER );
|
||||
|
||||
Room.Door door = room.entrance();
|
||||
door.set( Room.Door.Type.REGULAR );
|
||||
|
||||
int x = -1;
|
||||
int y = -1;
|
||||
if (door.x == room.left) {
|
||||
|
||||
x = room.right - 1;
|
||||
y = room.top + room.height() / 2;
|
||||
|
||||
} else if (door.x == room.right) {
|
||||
|
||||
x = room.left + 1;
|
||||
y = room.top + room.height() / 2;
|
||||
|
||||
} else if (door.y == room.top) {
|
||||
|
||||
x = room.left + room.width() / 2;
|
||||
y = room.bottom - 1;
|
||||
|
||||
} else if (door.y == room.bottom) {
|
||||
|
||||
x = room.left + room.width() / 2;
|
||||
y = room.top + 1;
|
||||
|
||||
}
|
||||
|
||||
int pos = x + y * Level.WIDTH;
|
||||
level.drop( prize( level ), pos ).type =
|
||||
Random.Int( 3 ) == 0 ? Heap.Type.CHEST : Heap.Type.HEAP;
|
||||
set( level, pos, Terrain.PEDESTAL );
|
||||
|
||||
level.addItemToSpawn( new PotionOfInvisibility() );
|
||||
|
||||
for (int i=0; i < NPIRANHAS; i++) {
|
||||
Piranha piranha = new Piranha();
|
||||
do {
|
||||
piranha.pos = room.random();
|
||||
} while (level.map[piranha.pos] != Terrain.WATER|| Actor.findChar( piranha.pos ) != null);
|
||||
level.mobs.add( piranha );
|
||||
Actor.occupyCell( piranha );
|
||||
}
|
||||
}
|
||||
|
||||
private static Item prize( Level level ) {
|
||||
|
||||
Item prize = level.itemToSpanAsPrize();
|
||||
if (prize != null) {
|
||||
return prize;
|
||||
}
|
||||
|
||||
prize = Generator.random( Random.oneOf(
|
||||
Generator.Category.WEAPON,
|
||||
Generator.Category.ARMOR
|
||||
) );
|
||||
|
||||
for (int i=0; i < 4; i++) {
|
||||
Item another = Generator.random( Random.oneOf(
|
||||
Generator.Category.WEAPON,
|
||||
Generator.Category.ARMOR
|
||||
) );
|
||||
if (another.level > prize.level) {
|
||||
prize = another;
|
||||
}
|
||||
}
|
||||
|
||||
return prize;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2014 Oleg Dolya
|
||||
*
|
||||
* 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.painters;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.RatKing;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Gold;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class RatKingPainter extends Painter {
|
||||
|
||||
public static void paint( Level level, Room room ) {
|
||||
|
||||
fill( level, room, Terrain.WALL );
|
||||
fill( level, room, 1, Terrain.EMPTY_SP );
|
||||
|
||||
Room.Door entrance = room.entrance();
|
||||
entrance.set( Room.Door.Type.HIDDEN );
|
||||
int door = entrance.x + entrance.y * Level.WIDTH;
|
||||
|
||||
for (int i=room.left + 1; i < room.right; i++) {
|
||||
addChest( level, (room.top + 1) * Level.WIDTH + i, door );
|
||||
addChest( level, (room.bottom - 1) * Level.WIDTH + i, door );
|
||||
}
|
||||
|
||||
for (int i=room.top + 2; i < room.bottom - 1; i++) {
|
||||
addChest( level, i * Level.WIDTH + room.left + 1, door );
|
||||
addChest( level, i * Level.WIDTH + room.right - 1, door );
|
||||
}
|
||||
|
||||
RatKing king = new RatKing();
|
||||
king.pos = room.random( 1 );
|
||||
level.mobs.add( king );
|
||||
}
|
||||
|
||||
private static void addChest( Level level, int pos, int door ) {
|
||||
|
||||
if (pos == door - 1 ||
|
||||
pos == door + 1 ||
|
||||
pos == door - Level.WIDTH ||
|
||||
pos == door + Level.WIDTH) {
|
||||
return;
|
||||
}
|
||||
|
||||
Item prize;
|
||||
switch (Random.Int( 10 )) {
|
||||
case 0:
|
||||
prize = Generator.random( Generator.Category.WEAPON );
|
||||
if (prize instanceof MissileWeapon) {
|
||||
prize.quantity( 1 );
|
||||
} else {
|
||||
prize.degrade( Random.Int( 3 ) );
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
prize = Generator.random( Generator.Category.ARMOR ).degrade( Random.Int( 3 ) );
|
||||
break;
|
||||
default:
|
||||
prize = new Gold( Random.IntRange( 1, 5 ) );
|
||||
break;
|
||||
}
|
||||
|
||||
level.drop( prize, pos ).type = Heap.Type.CHEST;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2014 Oleg Dolya
|
||||
*
|
||||
* 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.painters;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.ImpShopkeeper;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Shopkeeper;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Ankh;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Torch;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.armor.*;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.bags.ScrollHolder;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.bags.SeedPouch;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.bags.WandHolster;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.food.OverpricedRation;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfIdentify;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicMapping;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRemoveCurse;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.*;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.LastShopLevel;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.watabou.utils.Point;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class ShopPainter extends Painter {
|
||||
|
||||
private static int pasWidth;
|
||||
private static int pasHeight;
|
||||
|
||||
public static void paint( Level level, Room room ) {
|
||||
|
||||
fill( level, room, Terrain.WALL );
|
||||
fill( level, room, 1, Terrain.EMPTY_SP );
|
||||
|
||||
pasWidth = room.width() - 2;
|
||||
pasHeight = room.height() - 2;
|
||||
int per = pasWidth * 2 + pasHeight * 2;
|
||||
|
||||
Item[] range = range();
|
||||
|
||||
int pos = xy2p( room, room.entrance() ) + (per - range.length) / 2;
|
||||
for (int i=0; i < range.length; i++) {
|
||||
|
||||
Point xy = p2xy( room, (pos + per) % per );
|
||||
int cell = xy.x + xy.y * Level.WIDTH;
|
||||
|
||||
if (level.heaps.get( cell ) != null) {
|
||||
do {
|
||||
cell = room.random();
|
||||
} while (level.heaps.get( cell ) != null);
|
||||
}
|
||||
|
||||
level.drop( range[i], cell ).type = Heap.Type.FOR_SALE;
|
||||
|
||||
pos++;
|
||||
}
|
||||
|
||||
placeShopkeeper( level, room );
|
||||
|
||||
for (Room.Door door : room.connected.values()) {
|
||||
door.set( Room.Door.Type.REGULAR );
|
||||
}
|
||||
}
|
||||
|
||||
private static Item[] range() {
|
||||
|
||||
ArrayList<Item> items = new ArrayList<Item>();
|
||||
|
||||
switch (Dungeon.depth) {
|
||||
|
||||
case 6:
|
||||
items.add( (Random.Int( 2 ) == 0 ? new Quarterstaff() : new Spear()).identify() );
|
||||
items.add( new LeatherArmor().identify() );
|
||||
items.add( new SeedPouch() );
|
||||
break;
|
||||
|
||||
case 11:
|
||||
items.add( (Random.Int( 2 ) == 0 ? new Sword() : new Mace()).identify() );
|
||||
items.add( new MailArmor().identify() );
|
||||
items.add( new ScrollHolder() );
|
||||
break;
|
||||
|
||||
case 16:
|
||||
items.add( (Random.Int( 2 ) == 0 ? new Longsword() : new BattleAxe()).identify() );
|
||||
items.add( new ScaleArmor().identify() );
|
||||
items.add( new WandHolster() );
|
||||
break;
|
||||
|
||||
case 21:
|
||||
switch (Random.Int( 3 )) {
|
||||
case 0:
|
||||
items.add( new Glaive().identify() );
|
||||
break;
|
||||
case 1:
|
||||
items.add( new WarHammer().identify() );
|
||||
break;
|
||||
case 2:
|
||||
items.add( new PlateArmor().identify() );
|
||||
break;
|
||||
}
|
||||
items.add( new Torch() );
|
||||
items.add( new Torch() );
|
||||
break;
|
||||
}
|
||||
|
||||
items.add( new PotionOfHealing() );
|
||||
for (int i=0; i < 3; i++) {
|
||||
items.add( Generator.random( Generator.Category.POTION ) );
|
||||
}
|
||||
|
||||
items.add( new ScrollOfIdentify() );
|
||||
items.add( new ScrollOfRemoveCurse() );
|
||||
items.add( new ScrollOfMagicMapping() );
|
||||
items.add( Generator.random( Generator.Category.SCROLL ) );
|
||||
|
||||
items.add( new OverpricedRation() );
|
||||
items.add( new OverpricedRation() );
|
||||
|
||||
items.add( new Ankh() );
|
||||
|
||||
Item[] range =items.toArray( new Item[0] );
|
||||
Random.shuffle( range );
|
||||
|
||||
return range;
|
||||
}
|
||||
|
||||
private static void placeShopkeeper( Level level, Room room ) {
|
||||
|
||||
int pos;
|
||||
do {
|
||||
pos = room.random();
|
||||
} while (level.heaps.get( pos ) != null);
|
||||
|
||||
Mob shopkeeper = level instanceof LastShopLevel ? new ImpShopkeeper() : new Shopkeeper();
|
||||
shopkeeper.pos = pos;
|
||||
level.mobs.add( shopkeeper );
|
||||
|
||||
if (level instanceof LastShopLevel) {
|
||||
for (int i=0; i < Level.NEIGHBOURS9.length; i++) {
|
||||
int p = shopkeeper.pos + Level.NEIGHBOURS9[i];
|
||||
if (level.map[p] == Terrain.EMPTY_SP) {
|
||||
level.map[p] = Terrain.WATER;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static int xy2p( Room room, Point xy ) {
|
||||
if (xy.y == room.top) {
|
||||
|
||||
return (xy.x - room.left - 1);
|
||||
|
||||
} else if (xy.x == room.right) {
|
||||
|
||||
return (xy.y - room.top - 1) + pasWidth;
|
||||
|
||||
} else if (xy.y == room.bottom) {
|
||||
|
||||
return (room.right - xy.x - 1) + pasWidth + pasHeight;
|
||||
|
||||
} else {
|
||||
|
||||
if (xy.y == room.top + 1) {
|
||||
return 0;
|
||||
} else {
|
||||
return (room.bottom - xy.y - 1) + pasWidth * 2 + pasHeight;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static Point p2xy( Room room, int p ) {
|
||||
if (p < pasWidth) {
|
||||
|
||||
return new Point( room.left + 1 + p, room.top + 1);
|
||||
|
||||
} else if (p < pasWidth + pasHeight) {
|
||||
|
||||
return new Point( room.right - 1, room.top + 1 + (p - pasWidth) );
|
||||
|
||||
} else if (p < pasWidth * 2 + pasHeight) {
|
||||
|
||||
return new Point( room.right - 1 - (p - (pasWidth + pasHeight)), room.bottom - 1 );
|
||||
|
||||
} else {
|
||||
|
||||
return new Point( room.left + 1, room.bottom - 1 - (p - (pasWidth * 2 + pasHeight)) );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,240 @@
|
||||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2014 Oleg Dolya
|
||||
*
|
||||
* 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.painters;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Gold;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.watabou.utils.Point;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class StandardPainter extends Painter {
|
||||
|
||||
public static void paint( Level level, Room room ) {
|
||||
|
||||
fill( level, room, Terrain.WALL );
|
||||
for (Room.Door door : room.connected.values()) {
|
||||
door.set( Room.Door.Type.REGULAR );
|
||||
}
|
||||
|
||||
if (!Dungeon.bossLevel() && Random.Int( 5 ) == 0) {
|
||||
switch (Random.Int( 6 )) {
|
||||
case 0:
|
||||
if (level.feeling != Level.Feeling.GRASS) {
|
||||
if (Math.min( room.width(), room.height() ) >= 4 && Math.max( room.width(), room.height() ) >= 6) {
|
||||
paintGraveyard( level, room );
|
||||
return;
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
// Burned room
|
||||
}
|
||||
case 1:
|
||||
if (Dungeon.depth > 1) {
|
||||
paintBurned( level, room );
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (Math.max( room.width(), room.height() ) >= 4) {
|
||||
paintStriped( level, room );
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (room.width() >= 6 && room.height() >= 6) {
|
||||
paintStudy( level, room );
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (level.feeling != Level.Feeling.WATER) {
|
||||
if (room.connected.size() == 2 && room.width() >= 4 && room.height() >= 4) {
|
||||
paintBridge( level, room );
|
||||
return;
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
// Fissure
|
||||
}
|
||||
case 5:
|
||||
if (!Dungeon.bossLevel() && !Dungeon.bossLevel( Dungeon.depth + 1 ) &&
|
||||
Math.min( room.width(), room.height() ) >= 5) {
|
||||
paintFissure( level, room );
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fill( level, room, 1, Terrain.EMPTY );
|
||||
}
|
||||
|
||||
private static void paintBurned( Level level, Room room ) {
|
||||
for (int i=room.top + 1; i < room.bottom; i++) {
|
||||
for (int j=room.left + 1; j < room.right; j++) {
|
||||
int t = Terrain.EMBERS;
|
||||
switch (Random.Int( 5 )) {
|
||||
case 0:
|
||||
t = Terrain.EMPTY;
|
||||
break;
|
||||
case 1:
|
||||
t = Terrain.FIRE_TRAP;
|
||||
break;
|
||||
case 2:
|
||||
t = Terrain.SECRET_FIRE_TRAP;
|
||||
break;
|
||||
case 3:
|
||||
t = Terrain.INACTIVE_TRAP;
|
||||
break;
|
||||
}
|
||||
level.map[i * Level.WIDTH + j] = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void paintGraveyard( Level level, Room room ) {
|
||||
fill( level, room.left + 1, room.top + 1, room.width() - 1, room.height() - 1 , Terrain.GRASS );
|
||||
|
||||
int w = room.width() - 1;
|
||||
int h = room.height() - 1;
|
||||
int nGraves = Math.max( w, h ) / 2;
|
||||
|
||||
int index = Random.Int( nGraves );
|
||||
|
||||
int shift = Random.Int( 2 );
|
||||
for (int i=0; i < nGraves; i++) {
|
||||
int pos = w > h ?
|
||||
room.left + 1 + shift + i * 2 + (room.top + 2 + Random.Int( h-2 )) * Level.WIDTH :
|
||||
(room.left + 2 + Random.Int( w-2 )) + (room.top + 1 + shift + i * 2) * Level.WIDTH;
|
||||
level.drop( i == index ? Generator.random() : new Gold(), pos ).type = Heap.Type.TOMB;
|
||||
}
|
||||
}
|
||||
|
||||
private static void paintStriped( Level level, Room room ) {
|
||||
fill( level, room.left + 1, room.top + 1, room.width() - 1, room.height() - 1 , Terrain.EMPTY_SP );
|
||||
|
||||
if (room.width() > room.height()) {
|
||||
for (int i=room.left + 2; i < room.right; i += 2) {
|
||||
fill( level, i, room.top + 1, 1, room.height() - 1, Terrain.HIGH_GRASS );
|
||||
}
|
||||
} else {
|
||||
for (int i=room.top + 2; i < room.bottom; i += 2) {
|
||||
fill( level, room.left + 1, i, room.width() - 1, 1, Terrain.HIGH_GRASS );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void paintStudy( Level level, Room room ) {
|
||||
fill( level, room.left + 1, room.top + 1, room.width() - 1, room.height() - 1 , Terrain.BOOKSHELF );
|
||||
fill( level, room.left + 2, room.top + 2, room.width() - 3, room.height() - 3 , Terrain.EMPTY_SP );
|
||||
|
||||
for (Point door : room.connected.values()) {
|
||||
if (door.x == room.left) {
|
||||
set( level, door.x + 1, door.y, Terrain.EMPTY );
|
||||
} else if (door.x == room.right) {
|
||||
set( level, door.x - 1, door.y, Terrain.EMPTY );
|
||||
} else if (door.y == room.top) {
|
||||
set( level, door.x, door.y + 1, Terrain.EMPTY );
|
||||
} else if (door.y == room.bottom) {
|
||||
set( level, door.x , door.y - 1, Terrain.EMPTY );
|
||||
}
|
||||
}
|
||||
|
||||
set( level, room.center(), Terrain.PEDESTAL );
|
||||
}
|
||||
|
||||
private static void paintBridge( Level level, Room room ) {
|
||||
|
||||
fill( level, room.left + 1, room.top + 1, room.width() - 1, room.height() - 1 ,
|
||||
!Dungeon.bossLevel() && !Dungeon.bossLevel( Dungeon.depth + 1 ) && Random.Int( 3 ) == 0 ?
|
||||
Terrain.CHASM :
|
||||
Terrain.WATER );
|
||||
|
||||
Point door1 = null;
|
||||
Point door2 = null;
|
||||
for (Point p : room.connected.values()) {
|
||||
if (door1 == null) {
|
||||
door1 = p;
|
||||
} else {
|
||||
door2 = p;
|
||||
}
|
||||
}
|
||||
|
||||
if ((door1.x == room.left && door2.x == room.right) ||
|
||||
(door1.x == room.right && door2.x == room.left)) {
|
||||
|
||||
int s = room.width() / 2;
|
||||
|
||||
drawInside( level, room, door1, s, Terrain.EMPTY_SP );
|
||||
drawInside( level, room, door2, s, Terrain.EMPTY_SP );
|
||||
fill( level, room.center().x, Math.min( door1.y, door2.y ), 1, Math.abs( door1.y - door2.y ) + 1, Terrain.EMPTY_SP );
|
||||
|
||||
} else
|
||||
if ((door1.y == room.top && door2.y == room.bottom) ||
|
||||
(door1.y == room.bottom && door2.y == room.top)) {
|
||||
|
||||
int s = room.height() / 2;
|
||||
|
||||
drawInside( level, room, door1, s, Terrain.EMPTY_SP );
|
||||
drawInside( level, room, door2, s, Terrain.EMPTY_SP );
|
||||
fill( level, Math.min( door1.x, door2.x ), room.center().y, Math.abs( door1.x - door2.x ) + 1, 1, Terrain.EMPTY_SP );
|
||||
|
||||
} else
|
||||
if (door1.x == door2.x) {
|
||||
|
||||
fill( level, door1.x == room.left ? room.left + 1 : room.right - 1, Math.min( door1.y, door2.y ), 1, Math.abs( door1.y - door2.y ) + 1, Terrain.EMPTY_SP );
|
||||
|
||||
} else
|
||||
if (door1.y == door2.y) {
|
||||
|
||||
fill( level, Math.min( door1.x, door2.x ), door1.y == room.top ? room.top + 1 : room.bottom - 1, Math.abs( door1.x - door2.x ) + 1, 1, Terrain.EMPTY_SP );
|
||||
|
||||
} else
|
||||
if (door1.y == room.top || door1.y == room.bottom) {
|
||||
|
||||
drawInside( level, room, door1, Math.abs( door1.y - door2.y ), Terrain.EMPTY_SP );
|
||||
drawInside( level, room, door2, Math.abs( door1.x - door2.x ), Terrain.EMPTY_SP );
|
||||
|
||||
} else
|
||||
if (door1.x == room.left || door1.x == room.right) {
|
||||
|
||||
drawInside( level, room, door1, Math.abs( door1.x - door2.x ), Terrain.EMPTY_SP );
|
||||
drawInside( level, room, door2, Math.abs( door1.y - door2.y ), Terrain.EMPTY_SP );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static void paintFissure( Level level, Room room ) {
|
||||
fill( level, room.left + 1, room.top + 1, room.width() - 1, room.height() - 1 ,Terrain.EMPTY );
|
||||
|
||||
for (int i=room.top + 2; i < room.bottom - 1; i++) {
|
||||
for (int j=room.left + 2; j < room.right - 1; j++) {
|
||||
int v = Math.min( i - room.top, room.bottom - i );
|
||||
int h = Math.min( j - room.left, room.right - j );
|
||||
if (Math.min( v, h ) > 2 || Random.Int( 2 ) == 0) {
|
||||
set( level, j, i, Terrain.CHASM );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2014 Oleg Dolya
|
||||
*
|
||||
* 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.painters;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Statue;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.watabou.utils.Point;
|
||||
|
||||
public class StatuePainter extends Painter {
|
||||
|
||||
public static void paint( Level level, Room room ) {
|
||||
|
||||
fill( level, room, Terrain.WALL );
|
||||
fill( level, room, 1, Terrain.EMPTY );
|
||||
|
||||
Point c = room.center();
|
||||
int cx = c.x;
|
||||
int cy = c.y;
|
||||
|
||||
Room.Door door = room.entrance();
|
||||
|
||||
door.set( Room.Door.Type.LOCKED );
|
||||
level.addItemToSpawn( new IronKey( Dungeon.depth ) );
|
||||
|
||||
if (door.x == room.left) {
|
||||
|
||||
fill( level, room.right - 1, room.top + 1, 1, room.height() - 1 , Terrain.STATUE );
|
||||
cx = room.right - 2;
|
||||
|
||||
} else if (door.x == room.right) {
|
||||
|
||||
fill( level, room.left + 1, room.top + 1, 1, room.height() - 1 , Terrain.STATUE );
|
||||
cx = room.left + 2;
|
||||
|
||||
} else if (door.y == room.top) {
|
||||
|
||||
fill( level, room.left + 1, room.bottom - 1, room.width() - 1, 1 , Terrain.STATUE );
|
||||
cy = room.bottom - 2;
|
||||
|
||||
} else if (door.y == room.bottom) {
|
||||
|
||||
fill( level, room.left + 1, room.top + 1, room.width() - 1, 1 , Terrain.STATUE );
|
||||
cy = room.top + 2;
|
||||
|
||||
}
|
||||
|
||||
Statue statue = new Statue();
|
||||
statue.pos = cx + cy * Level.WIDTH;
|
||||
level.mobs.add( statue );
|
||||
Actor.occupyCell( statue );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2014 Oleg Dolya
|
||||
*
|
||||
* 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.painters;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfLiquidFlame;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class StoragePainter extends Painter {
|
||||
|
||||
public static void paint( Level level, Room room ) {
|
||||
|
||||
final int floor = Terrain.EMPTY_SP;
|
||||
|
||||
fill( level, room, Terrain.WALL );
|
||||
fill( level, room, 1, floor );
|
||||
|
||||
int n = Random.IntRange( 3, 4 );
|
||||
for (int i=0; i < n; i++) {
|
||||
int pos;
|
||||
do {
|
||||
pos = room.random();
|
||||
} while (level.map[pos] != floor);
|
||||
level.drop( prize( level ), pos );
|
||||
}
|
||||
|
||||
room.entrance().set( Room.Door.Type.BARRICADE );
|
||||
level.addItemToSpawn( new PotionOfLiquidFlame() );
|
||||
}
|
||||
|
||||
private static Item prize( Level level ) {
|
||||
|
||||
Item prize = level.itemToSpanAsPrize();
|
||||
if (prize != null) {
|
||||
return prize;
|
||||
}
|
||||
|
||||
return Generator.random( Random.oneOf(
|
||||
Generator.Category.POTION,
|
||||
Generator.Category.SCROLL,
|
||||
Generator.Category.FOOD,
|
||||
Generator.Category.GOLD
|
||||
) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2014 Oleg Dolya
|
||||
*
|
||||
* 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.painters;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfLevitation;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class TrapsPainter extends Painter {
|
||||
|
||||
public static void paint( Level level, Room room ) {
|
||||
|
||||
Integer traps[] = {
|
||||
Terrain.TOXIC_TRAP, Terrain.TOXIC_TRAP, Terrain.TOXIC_TRAP,
|
||||
Terrain.PARALYTIC_TRAP, Terrain.PARALYTIC_TRAP,
|
||||
!Dungeon.bossLevel( Dungeon.depth + 1 ) ? Terrain.CHASM : Terrain.SUMMONING_TRAP };
|
||||
fill( level, room, Terrain.WALL );
|
||||
fill( level, room, 1, Random.element( traps ) );
|
||||
|
||||
Room.Door door = room.entrance();
|
||||
door.set( Room.Door.Type.REGULAR );
|
||||
|
||||
int lastRow = level.map[room.left + 1 + (room.top + 1) * Level.WIDTH] == Terrain.CHASM ? Terrain.CHASM : Terrain.EMPTY;
|
||||
|
||||
int x = -1;
|
||||
int y = -1;
|
||||
if (door.x == room.left) {
|
||||
x = room.right - 1;
|
||||
y = room.top + room.height() / 2;
|
||||
fill( level, x, room.top + 1, 1, room.height() - 1 , lastRow );
|
||||
} else if (door.x == room.right) {
|
||||
x = room.left + 1;
|
||||
y = room.top + room.height() / 2;
|
||||
fill( level, x, room.top + 1, 1, room.height() - 1 , lastRow );
|
||||
} else if (door.y == room.top) {
|
||||
x = room.left + room.width() / 2;
|
||||
y = room.bottom - 1;
|
||||
fill( level, room.left + 1, y, room.width() - 1, 1 , lastRow );
|
||||
} else if (door.y == room.bottom) {
|
||||
x = room.left + room.width() / 2;
|
||||
y = room.top + 1;
|
||||
fill( level, room.left + 1, y, room.width() - 1, 1 , lastRow );
|
||||
}
|
||||
|
||||
int pos = x + y * Level.WIDTH;
|
||||
if (Random.Int( 3 ) == 0) {
|
||||
if (lastRow == Terrain.CHASM) {
|
||||
set( level, pos, Terrain.EMPTY );
|
||||
}
|
||||
level.drop( prize( level ), pos ).type = Heap.Type.CHEST;
|
||||
} else {
|
||||
set( level, pos, Terrain.PEDESTAL );
|
||||
level.drop( prize( level ), pos );
|
||||
}
|
||||
|
||||
level.addItemToSpawn( new PotionOfLevitation() );
|
||||
}
|
||||
|
||||
private static Item prize( Level level ) {
|
||||
|
||||
Item prize = level.itemToSpanAsPrize();
|
||||
if (prize != null) {
|
||||
return prize;
|
||||
}
|
||||
|
||||
prize = Generator.random( Random.oneOf(
|
||||
Generator.Category.WEAPON,
|
||||
Generator.Category.ARMOR
|
||||
) );
|
||||
|
||||
for (int i=0; i < 3; i++) {
|
||||
Item another = Generator.random( Random.oneOf(
|
||||
Generator.Category.WEAPON,
|
||||
Generator.Category.ARMOR
|
||||
) );
|
||||
if (another.level > prize.level) {
|
||||
prize = another;
|
||||
}
|
||||
}
|
||||
|
||||
return prize;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2014 Oleg Dolya
|
||||
*
|
||||
* 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.painters;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Gold;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class TreasuryPainter extends Painter {
|
||||
|
||||
public static void paint( Level level, Room room ) {
|
||||
|
||||
fill( level, room, Terrain.WALL );
|
||||
fill( level, room, 1, Terrain.EMPTY );
|
||||
|
||||
set( level, room.center(), Terrain.STATUE );
|
||||
|
||||
Heap.Type heapType = Random.Int( 2 ) == 0 ? Heap.Type.CHEST : Heap.Type.HEAP;
|
||||
|
||||
int n = Random.IntRange( 2, 3 );
|
||||
for (int i=0; i < n; i++) {
|
||||
int pos;
|
||||
do {
|
||||
pos = room.random();
|
||||
} while (level.map[pos] != Terrain.EMPTY || level.heaps.get( pos ) != null);
|
||||
level.drop( new Gold().random(), pos ).type = heapType;
|
||||
}
|
||||
|
||||
if (heapType == Heap.Type.HEAP) {
|
||||
for (int i=0; i < 6; i++) {
|
||||
int pos;
|
||||
do {
|
||||
pos = room.random();
|
||||
} while (level.map[pos] != Terrain.EMPTY);
|
||||
level.drop( new Gold( Random.IntRange( 1, 3 ) ), pos );
|
||||
}
|
||||
}
|
||||
|
||||
room.entrance().set( Room.Door.Type.LOCKED );
|
||||
level.addItemToSpawn( new IronKey( Dungeon.depth ) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2014 Oleg Dolya
|
||||
*
|
||||
* 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.painters;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Room;
|
||||
import com.watabou.utils.Point;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class TunnelPainter extends Painter {
|
||||
|
||||
public static void paint( Level level, Room room ) {
|
||||
|
||||
int floor = level.tunnelTile();
|
||||
|
||||
Point c = room.center();
|
||||
|
||||
if (room.width() > room.height() || (room.width() == room.height() && Random.Int( 2 ) == 0)) {
|
||||
|
||||
int from = room.right - 1;
|
||||
int to = room.left + 1;
|
||||
|
||||
for (Room.Door door : room.connected.values()) {
|
||||
|
||||
int step = door.y < c.y ? +1 : -1;
|
||||
|
||||
if (door.x == room.left) {
|
||||
|
||||
from = room.left + 1;
|
||||
for (int i=door.y; i != c.y; i += step) {
|
||||
set( level, from, i, floor );
|
||||
}
|
||||
|
||||
} else if (door.x == room.right) {
|
||||
|
||||
to = room.right - 1;
|
||||
for (int i=door.y; i != c.y; i += step) {
|
||||
set( level, to, i, floor );
|
||||
}
|
||||
|
||||
} else {
|
||||
if (door.x < from) {
|
||||
from = door.x;
|
||||
}
|
||||
if (door.x > to) {
|
||||
to = door.x;
|
||||
}
|
||||
|
||||
for (int i=door.y+step; i != c.y; i += step) {
|
||||
set( level, door.x, i, floor );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=from; i <= to; i++) {
|
||||
set( level, i, c.y, floor );
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
int from = room.bottom - 1;
|
||||
int to = room.top + 1;
|
||||
|
||||
for (Room.Door door : room.connected.values()) {
|
||||
|
||||
int step = door.x < c.x ? +1 : -1;
|
||||
|
||||
if (door.y == room.top) {
|
||||
|
||||
from = room.top + 1;
|
||||
for (int i=door.x; i != c.x; i += step) {
|
||||
set( level, i, from, floor );
|
||||
}
|
||||
|
||||
} else if (door.y == room.bottom) {
|
||||
|
||||
to = room.bottom - 1;
|
||||
for (int i=door.x; i != c.x; i += step) {
|
||||
set( level, i, to, floor );
|
||||
}
|
||||
|
||||
} else {
|
||||
if (door.y < from) {
|
||||
from = door.y;
|
||||
}
|
||||
if (door.y > to) {
|
||||
to = door.y;
|
||||
}
|
||||
|
||||
for (int i=door.x+step; i != c.x; i += step) {
|
||||
set( level, i, door.y, floor );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=from; i <= to; i++) {
|
||||
set( level, c.x, i, floor );
|
||||
}
|
||||
}
|
||||
|
||||
for (Room.Door door : room.connected.values()) {
|
||||
door.set( Room.Door.Type.TUNNEL );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2014 Oleg Dolya
|
||||
*
|
||||
* 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.painters;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Heap.Type;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.keys.GoldenKey;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class VaultPainter extends Painter {
|
||||
|
||||
public static void paint( Level level, Room room ) {
|
||||
|
||||
fill( level, room, Terrain.WALL );
|
||||
fill( level, room, 1, Terrain.EMPTY );
|
||||
|
||||
int cx = (room.left + room.right) / 2;
|
||||
int cy = (room.top + room.bottom) / 2;
|
||||
int c = cx + cy * Level.WIDTH;
|
||||
|
||||
switch (Random.Int( 3 )) {
|
||||
|
||||
case 0:
|
||||
level.drop( prize( level ), c ).type = Type.LOCKED_CHEST;
|
||||
level.addItemToSpawn( new GoldenKey( Dungeon.depth ) );
|
||||
break;
|
||||
|
||||
case 1:
|
||||
Item i1, i2;
|
||||
do {
|
||||
i1 = prize( level );
|
||||
i2 = prize( level );
|
||||
} while (i1.getClass() == i2.getClass());
|
||||
level.drop( i1, c ).type = Type.CRYSTAL_CHEST;
|
||||
level.drop( i2, c + Level.NEIGHBOURS8[Random.Int( 8 )]).type = Type.CRYSTAL_CHEST;
|
||||
level.addItemToSpawn( new GoldenKey( Dungeon.depth ) );
|
||||
break;
|
||||
|
||||
case 2:
|
||||
level.drop( prize( level ), c );
|
||||
set( level, c, Terrain.PEDESTAL );
|
||||
break;
|
||||
}
|
||||
|
||||
room.entrance().set( Room.Door.Type.LOCKED );
|
||||
level.addItemToSpawn( new IronKey( Dungeon.depth ) );
|
||||
}
|
||||
|
||||
private static Item prize( Level level ) {
|
||||
return Generator.random( Random.oneOf(
|
||||
Generator.Category.WAND,
|
||||
Generator.Category.RING
|
||||
) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2014 Oleg Dolya
|
||||
*
|
||||
* 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.painters;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.watabou.utils.Point;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class WeakFloorPainter extends Painter {
|
||||
|
||||
public static void paint( Level level, Room room ) {
|
||||
|
||||
fill( level, room, Terrain.WALL );
|
||||
fill( level, room, 1, Terrain.CHASM );
|
||||
|
||||
Room.Door door = room.entrance();
|
||||
door.set( Room.Door.Type.REGULAR );
|
||||
|
||||
if (door.x == room.left) {
|
||||
for (int i=room.top + 1; i < room.bottom; i++) {
|
||||
drawInside( level, room, new Point( room.left, i ), Random.IntRange( 1, room.width() - 2 ), Terrain.EMPTY_SP );
|
||||
}
|
||||
} else if (door.x == room.right) {
|
||||
for (int i=room.top + 1; i < room.bottom; i++) {
|
||||
drawInside( level, room, new Point( room.right, i ), Random.IntRange( 1, room.width() - 2 ), Terrain.EMPTY_SP );
|
||||
}
|
||||
} else if (door.y == room.top) {
|
||||
for (int i=room.left + 1; i < room.right; i++) {
|
||||
drawInside( level, room, new Point( i, room.top ), Random.IntRange( 1, room.height() - 2 ), Terrain.EMPTY_SP );
|
||||
}
|
||||
} else if (door.y == room.bottom) {
|
||||
for (int i=room.left + 1; i < room.right; i++) {
|
||||
drawInside( level, room, new Point( i, room.bottom ), Random.IntRange( 1, room.height() - 2 ), Terrain.EMPTY_SP );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user