use of com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob in project shattered-pixel-dungeon-gdx by 00-Evan.
the class GameScene method create.
@Override
public void create() {
Music.INSTANCE.play(Assets.TUNE, true);
SPDSettings.lastClass(Dungeon.hero.heroClass.ordinal());
super.create();
Camera.main.zoom(GameMath.gate(minZoom, defaultZoom + SPDSettings.zoom(), maxZoom));
scene = this;
terrain = new Group();
add(terrain);
water = new SkinnedBlock(Dungeon.level.width() * DungeonTilemap.SIZE, Dungeon.level.height() * DungeonTilemap.SIZE, Dungeon.level.waterTex()) {
@Override
protected NoosaScript script() {
return NoosaScriptNoLighting.get();
}
@Override
public void draw() {
// water has no alpha component, this improves performance
Blending.disable();
super.draw();
Blending.enable();
}
};
terrain.add(water);
ripples = new Group();
terrain.add(ripples);
DungeonTileSheet.setupVariance(Dungeon.level.map.length, Dungeon.seedCurDepth());
tiles = new DungeonTerrainTilemap();
terrain.add(tiles);
customTiles = new Group();
terrain.add(customTiles);
for (CustomTiledVisual visual : Dungeon.level.customTiles) {
addCustomTile(visual);
}
visualGrid = new GridTileMap();
terrain.add(visualGrid);
terrainFeatures = new TerrainFeaturesTilemap(Dungeon.level.plants, Dungeon.level.traps);
terrain.add(terrainFeatures);
levelVisuals = Dungeon.level.addVisuals();
add(levelVisuals);
heaps = new Group();
add(heaps);
for (IntMap.Entry<Heap> heap : Dungeon.level.heaps) {
addHeapSprite(heap.value);
}
emitters = new Group();
effects = new Group();
healthIndicators = new Group();
emoicons = new Group();
mobs = new Group();
add(mobs);
for (Mob mob : Dungeon.level.mobs) {
addMobSprite(mob);
if (Statistics.amuletObtained) {
mob.beckon(Dungeon.hero.pos);
}
}
walls = new DungeonWallsTilemap();
add(walls);
customWalls = new Group();
add(customWalls);
for (CustomTiledVisual visual : Dungeon.level.customWalls) {
addCustomWall(visual);
}
wallBlocking = new WallBlockingTilemap();
add(wallBlocking);
add(emitters);
add(effects);
gases = new Group();
add(gases);
for (Blob blob : Dungeon.level.blobs.values()) {
blob.emitter = null;
addBlobSprite(blob);
}
fog = new FogOfWar(Dungeon.level.width(), Dungeon.level.height());
add(fog);
spells = new Group();
add(spells);
statuses = new Group();
add(statuses);
add(healthIndicators);
// always appears ontop of other health indicators
add(new TargetHealthIndicator());
add(emoicons);
hero = new HeroSprite();
hero.place(Dungeon.hero.pos);
hero.updateArmor();
mobs.add(hero);
add(cellSelector = new CellSelector(tiles));
pane = new StatusPane();
pane.camera = uiCamera;
pane.setSize(uiCamera.width, 0);
add(pane);
toolbar = new Toolbar();
toolbar.camera = uiCamera;
toolbar.setRect(0, uiCamera.height - toolbar.height(), uiCamera.width, toolbar.height());
add(toolbar);
attack = new AttackIndicator();
attack.camera = uiCamera;
add(attack);
loot = new LootIndicator();
loot.camera = uiCamera;
add(loot);
action = new ActionIndicator();
action.camera = uiCamera;
add(action);
resume = new ResumeIndicator();
resume.camera = uiCamera;
add(resume);
log = new GameLog();
log.camera = uiCamera;
log.newLine();
add(log);
layoutTags();
busy = new BusyIndicator();
busy.camera = uiCamera;
busy.x = 1;
busy.y = pane.bottom() + 1;
add(busy);
switch(InterlevelScene.mode) {
case RESURRECT:
ScrollOfTeleportation.appear(Dungeon.hero, Dungeon.level.entrance);
new Flare(8, 32).color(0xFFFF66, true).show(hero, 2f);
break;
case RETURN:
ScrollOfTeleportation.appear(Dungeon.hero, Dungeon.hero.pos);
break;
case FALL:
Chasm.heroLand();
break;
case DESCEND:
switch(Dungeon.depth) {
case 1:
WndStory.showChapter(WndStory.ID_SEWERS);
break;
case 6:
WndStory.showChapter(WndStory.ID_PRISON);
break;
case 11:
WndStory.showChapter(WndStory.ID_CAVES);
break;
case 16:
WndStory.showChapter(WndStory.ID_CITY);
break;
case 22:
WndStory.showChapter(WndStory.ID_HALLS);
break;
}
if (Dungeon.hero.isAlive() && Dungeon.depth != 22) {
Badges.validateNoKilling();
}
break;
default:
}
ArrayList<Item> dropped = Dungeon.droppedItems.get(Dungeon.depth);
if (dropped != null) {
for (Item item : dropped) {
int pos = Dungeon.level.randomRespawnCell();
if (item instanceof Potion) {
((Potion) item).shatter(pos);
} else if (item instanceof Plant.Seed) {
Dungeon.level.plant((Plant.Seed) item, pos);
} else if (item instanceof Honeypot) {
Dungeon.level.drop(((Honeypot) item).shatter(null, pos), pos);
} else {
Dungeon.level.drop(item, pos);
}
}
Dungeon.droppedItems.remove(Dungeon.depth);
}
Dungeon.hero.next();
Camera.main.target = hero;
if (InterlevelScene.mode != InterlevelScene.Mode.NONE) {
if (Dungeon.depth == Statistics.deepestFloor && (InterlevelScene.mode == InterlevelScene.Mode.DESCEND || InterlevelScene.mode == InterlevelScene.Mode.FALL)) {
GLog.h(Messages.get(this, "descend"), Dungeon.depth);
Sample.INSTANCE.play(Assets.SND_DESCEND);
} else if (InterlevelScene.mode == InterlevelScene.Mode.RESET) {
GLog.h(Messages.get(this, "warp"));
} else {
GLog.h(Messages.get(this, "return"), Dungeon.depth);
}
switch(Dungeon.level.feeling) {
case CHASM:
GLog.w(Messages.get(this, "chasm"));
break;
case WATER:
GLog.w(Messages.get(this, "water"));
break;
case GRASS:
GLog.w(Messages.get(this, "grass"));
break;
case DARK:
GLog.w(Messages.get(this, "dark"));
break;
default:
}
if (Dungeon.level instanceof RegularLevel && ((RegularLevel) Dungeon.level).secretDoors > Random.IntRange(3, 4)) {
GLog.w(Messages.get(this, "secrets"));
}
InterlevelScene.mode = InterlevelScene.Mode.NONE;
fadeIn();
}
selectCell(defaultCellListener);
}
use of com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Actor method init.
public static void init() {
add(Dungeon.hero);
for (Mob mob : Dungeon.level.mobs) {
add(mob);
}
for (Blob blob : Dungeon.level.blobs.values()) {
add(blob);
}
current = null;
}
use of com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Level method restoreFromBundle.
@Override
public void restoreFromBundle(Bundle bundle) {
version = bundle.getInt(VERSION);
// saves from before 0.5.0b are not supported
if (version < ShatteredPixelDungeon.v0_5_0b) {
throw new RuntimeException("old save");
}
setSize(bundle.getInt(WIDTH), bundle.getInt(HEIGHT));
mobs = new HashSet<>();
heaps = new SparseArray<>();
blobs = new HashMap<>();
plants = new SparseArray<>();
traps = new SparseArray<>();
customTiles = new HashSet<>();
customWalls = new HashSet<>();
map = bundle.getIntArray(MAP);
visited = bundle.getBooleanArray(VISITED);
mapped = bundle.getBooleanArray(MAPPED);
entrance = bundle.getInt(ENTRANCE);
exit = bundle.getInt(EXIT);
locked = bundle.getBoolean(LOCKED);
// pre-0.6.1 saves
if (version <= ShatteredPixelDungeon.v0_6_0b) {
map = Terrain.convertTilesFrom0_6_0b(map);
}
Collection<Bundlable> collection = bundle.getCollection(HEAPS);
for (Bundlable h : collection) {
Heap heap = (Heap) h;
if (!heap.isEmpty())
heaps.put(heap.pos, heap);
}
collection = bundle.getCollection(PLANTS);
for (Bundlable p : collection) {
Plant plant = (Plant) p;
plants.put(plant.pos, plant);
}
collection = bundle.getCollection(TRAPS);
for (Bundlable p : collection) {
Trap trap = (Trap) p;
traps.put(trap.pos, trap);
}
collection = bundle.getCollection(CUSTOM_TILES);
for (Bundlable p : collection) {
CustomTiledVisual vis = (CustomTiledVisual) p;
customTiles.add(vis);
}
collection = bundle.getCollection(CUSTOM_WALLS);
for (Bundlable p : collection) {
CustomTiledVisual vis = (CustomTiledVisual) p;
customWalls.add(vis);
}
collection = bundle.getCollection(MOBS);
for (Bundlable m : collection) {
Mob mob = (Mob) m;
if (mob != null) {
mobs.add(mob);
}
}
collection = bundle.getCollection(BLOBS);
for (Bundlable b : collection) {
Blob blob = (Blob) b;
blobs.put(blob.getClass(), blob);
}
feeling = bundle.getEnum(FEELING, Feeling.class);
if (feeling == Feeling.DARK)
viewDistance = Math.round(viewDistance / 2f);
buildFlagMaps();
cleanWalls();
}
use of com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob in project shattered-pixel-dungeon-gdx by 00-Evan.
the class PrisonBossLevel method changeMap.
private void changeMap(int[] map) {
this.map = map.clone();
buildFlagMaps();
cleanWalls();
exit = entrance = 0;
for (int i = 0; i < length(); i++) if (map[i] == Terrain.ENTRANCE)
entrance = i;
else if (map[i] == Terrain.EXIT)
exit = i;
BArray.setFalse(visited);
BArray.setFalse(mapped);
for (Blob blob : blobs.values()) {
blob.fullyClear();
}
// this also resets existing visuals
addVisuals();
resetTraps();
GameScene.resetMap();
Dungeon.observe();
}
use of com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob in project shattered-pixel-dungeon-gdx by 00-Evan.
the class PotionOfPurity method shatter.
@Override
public void shatter(int cell) {
PathFinder.buildDistanceMap(cell, BArray.not(Dungeon.level.solid, null), DISTANCE);
ArrayList<Blob> blobs = new ArrayList<>();
for (Class c : affectedBlobs) {
Blob b = Dungeon.level.blobs.get(c);
if (b != null && b.volume > 0) {
blobs.add(b);
}
}
for (int i = 0; i < Dungeon.level.length(); i++) {
if (PathFinder.distance[i] < Integer.MAX_VALUE) {
for (Blob blob : blobs) {
int value = blob.cur[i];
if (value > 0) {
blob.clear(i);
blob.cur[i] = 0;
blob.volume -= value;
}
}
if (Dungeon.level.heroFOV[i]) {
CellEmitter.get(i).burst(Speck.factory(Speck.DISCOVER), 2);
}
}
}
if (Dungeon.level.heroFOV[cell]) {
splash(cell);
Sample.INSTANCE.play(Assets.SND_SHATTER);
setKnown();
GLog.i(Messages.get(this, "freshness"));
}
}
Aggregations