V0.1.0 Partial Commit
changed package and application names to differentiate from main PD release
This commit is contained in:
@@ -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.actors.blobs;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Journal;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.watabou.utils.Bundle;
|
||||
|
||||
public class Alchemy extends Blob {
|
||||
|
||||
protected int pos;
|
||||
|
||||
@Override
|
||||
public void restoreFromBundle( Bundle bundle ) {
|
||||
super.restoreFromBundle( bundle );
|
||||
|
||||
for (int i=0; i < LENGTH; i++) {
|
||||
if (cur[i] > 0) {
|
||||
pos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void evolve() {
|
||||
volume = off[pos] = cur[pos];
|
||||
|
||||
if (Dungeon.visible[pos]) {
|
||||
Journal.add( Journal.Feature.ALCHEMY );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void seed( int cell, int amount ) {
|
||||
cur[pos] = 0;
|
||||
pos = cell;
|
||||
volume = cur[pos] = amount;
|
||||
}
|
||||
|
||||
public static void transmute( int cell ) {
|
||||
Heap heap = Dungeon.level.heaps.get( cell );
|
||||
if (heap != null) {
|
||||
|
||||
Item result = heap.transmute();
|
||||
if (result != null) {
|
||||
Dungeon.level.drop( result, cell ).sprite.drop( cell );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void use( BlobEmitter emitter ) {
|
||||
super.use( emitter );
|
||||
emitter.start( Speck.factory( Speck.BUBBLE ), 0.4f, 0 );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
/*
|
||||
* 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.actors.blobs;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.BArray;
|
||||
import com.watabou.utils.Bundle;
|
||||
|
||||
public class Blob extends Actor {
|
||||
|
||||
public static final int WIDTH = Level.WIDTH;
|
||||
public static final int HEIGHT = Level.HEIGHT;
|
||||
public static final int LENGTH = Level.LENGTH;
|
||||
|
||||
public int volume = 0;
|
||||
|
||||
public int[] cur;
|
||||
protected int[] off;
|
||||
|
||||
public BlobEmitter emitter;
|
||||
|
||||
protected Blob() {
|
||||
|
||||
cur = new int[LENGTH];
|
||||
off = new int[LENGTH];
|
||||
|
||||
volume = 0;
|
||||
}
|
||||
|
||||
private static final String CUR = "cur";
|
||||
private static final String START = "start";
|
||||
|
||||
@Override
|
||||
public void storeInBundle( Bundle bundle ) {
|
||||
super.storeInBundle( bundle );
|
||||
|
||||
if (volume > 0) {
|
||||
|
||||
int start;
|
||||
for (start=0; start < LENGTH; start++) {
|
||||
if (cur[start] > 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
int end;
|
||||
for (end=LENGTH-1; end > start; end--) {
|
||||
if (cur[end] > 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bundle.put( START, start );
|
||||
bundle.put( CUR, trim( start, end + 1 ) );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private int[] trim( int start, int end ) {
|
||||
int len = end - start;
|
||||
int[] copy = new int[len];
|
||||
System.arraycopy( cur, start, copy, 0, len );
|
||||
return copy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreFromBundle( Bundle bundle ) {
|
||||
|
||||
super.restoreFromBundle( bundle );
|
||||
|
||||
int[] data = bundle.getIntArray( CUR );
|
||||
if (data != null) {
|
||||
int start = bundle.getInt( START );
|
||||
for (int i=0; i < data.length; i++) {
|
||||
cur[i + start] = data[i];
|
||||
volume += data[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (Level.resizingNeeded) {
|
||||
int[] cur = new int[Level.LENGTH];
|
||||
Arrays.fill( cur, 0 );
|
||||
|
||||
int loadedMapSize = Level.loadedMapSize;
|
||||
for (int i=0; i < loadedMapSize; i++) {
|
||||
System.arraycopy( this.cur, i * loadedMapSize, cur, i * Level.WIDTH, loadedMapSize );
|
||||
}
|
||||
|
||||
this.cur = cur;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean act() {
|
||||
|
||||
spend( TICK );
|
||||
|
||||
if (volume > 0) {
|
||||
|
||||
volume = 0;
|
||||
evolve();
|
||||
|
||||
int[] tmp = off;
|
||||
off = cur;
|
||||
cur = tmp;
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void use( BlobEmitter emitter ) {
|
||||
this.emitter = emitter;
|
||||
}
|
||||
|
||||
protected void evolve() {
|
||||
|
||||
boolean[] notBlocking = BArray.not( Level.solid, null );
|
||||
|
||||
for (int i=1; i < HEIGHT-1; i++) {
|
||||
|
||||
int from = i * WIDTH + 1;
|
||||
int to = from + WIDTH - 2;
|
||||
|
||||
for (int pos=from; pos < to; pos++) {
|
||||
if (notBlocking[pos]) {
|
||||
|
||||
int count = 1;
|
||||
int sum = cur[pos];
|
||||
|
||||
if (notBlocking[pos-1]) {
|
||||
sum += cur[pos-1];
|
||||
count++;
|
||||
}
|
||||
if (notBlocking[pos+1]) {
|
||||
sum += cur[pos+1];
|
||||
count++;
|
||||
}
|
||||
if (notBlocking[pos-WIDTH]) {
|
||||
sum += cur[pos-WIDTH];
|
||||
count++;
|
||||
}
|
||||
if (notBlocking[pos+WIDTH]) {
|
||||
sum += cur[pos+WIDTH];
|
||||
count++;
|
||||
}
|
||||
|
||||
int value = sum >= count ? (sum / count) - 1 : 0;
|
||||
off[pos] = value;
|
||||
|
||||
volume += value;
|
||||
} else {
|
||||
off[pos] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void seed( int cell, int amount ) {
|
||||
cur[cell] += amount;
|
||||
volume += amount;
|
||||
}
|
||||
|
||||
public void clear( int cell ) {
|
||||
volume -= cur[cell];
|
||||
cur[cell] = 0;
|
||||
}
|
||||
|
||||
public String tileDesc() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static<T extends Blob> T seed( int cell, int amount, Class<T> type ) {
|
||||
try {
|
||||
|
||||
T gas = (T)Dungeon.level.blobs.get( type );
|
||||
if (gas == null) {
|
||||
gas = type.newInstance();
|
||||
Dungeon.level.blobs.put( type, gas );
|
||||
}
|
||||
|
||||
gas.seed( cell, amount );
|
||||
|
||||
return gas;
|
||||
|
||||
} catch (Exception e) {
|
||||
ShatteredPixelDungeon.reportException(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* 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.actors.blobs;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.FlameParticle;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
|
||||
public class Fire extends Blob {
|
||||
|
||||
@Override
|
||||
protected void evolve() {
|
||||
|
||||
boolean[] flamable = Level.flamable;
|
||||
|
||||
int from = WIDTH + 1;
|
||||
int to = Level.LENGTH - WIDTH - 1;
|
||||
|
||||
boolean observe = false;
|
||||
|
||||
for (int pos=from; pos < to; pos++) {
|
||||
|
||||
int fire;
|
||||
|
||||
if (cur[pos] > 0) {
|
||||
|
||||
burn( pos );
|
||||
|
||||
fire = cur[pos] - 1;
|
||||
if (fire <= 0 && flamable[pos]) {
|
||||
|
||||
int oldTile = Dungeon.level.map[pos];
|
||||
Level.set( pos, Terrain.EMBERS );
|
||||
|
||||
observe = true;
|
||||
GameScene.updateMap( pos );
|
||||
if (Dungeon.visible[pos]) {
|
||||
GameScene.discoverTile( pos, oldTile );
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (flamable[pos] && (cur[pos-1] > 0 || cur[pos+1] > 0 || cur[pos-WIDTH] > 0 || cur[pos+WIDTH] > 0)) {
|
||||
fire = 4;
|
||||
burn( pos );
|
||||
} else {
|
||||
fire = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
volume += (off[pos] = fire);
|
||||
|
||||
}
|
||||
|
||||
if (observe) {
|
||||
Dungeon.observe();
|
||||
}
|
||||
}
|
||||
|
||||
private void burn( int pos ) {
|
||||
Char ch = Actor.findChar( pos );
|
||||
if (ch != null) {
|
||||
Buff.affect( ch, Burning.class ).reignite( ch );
|
||||
}
|
||||
|
||||
Heap heap = Dungeon.level.heaps.get( pos );
|
||||
if (heap != null) {
|
||||
heap.burn();
|
||||
}
|
||||
}
|
||||
|
||||
public void seed( int cell, int amount ) {
|
||||
if (cur[cell] == 0) {
|
||||
volume += amount;
|
||||
cur[cell] = amount;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void use( BlobEmitter emitter ) {
|
||||
super.use( emitter );
|
||||
emitter.start( FlameParticle.FACTORY, 0.03f, 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String tileDesc() {
|
||||
return "A fire is raging here.";
|
||||
}
|
||||
}
|
||||
@@ -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.actors.blobs;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Journal;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Shadows;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShaftParticle;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
|
||||
public class Foliage extends Blob {
|
||||
|
||||
@Override
|
||||
protected void evolve() {
|
||||
|
||||
int from = WIDTH + 1;
|
||||
int to = Level.LENGTH - WIDTH - 1;
|
||||
|
||||
int[] map = Dungeon.level.map;
|
||||
boolean regrowth = false;
|
||||
|
||||
boolean visible = false;
|
||||
|
||||
for (int pos=from; pos < to; pos++) {
|
||||
if (cur[pos] > 0) {
|
||||
|
||||
off[pos] = cur[pos];
|
||||
volume += off[pos];
|
||||
|
||||
if (map[pos] == Terrain.EMBERS) {
|
||||
map[pos] = Terrain.GRASS;
|
||||
regrowth = true;
|
||||
}
|
||||
|
||||
visible = visible || Dungeon.visible[pos];
|
||||
|
||||
} else {
|
||||
off[pos] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Hero hero = Dungeon.hero;
|
||||
if (hero.isAlive() && hero.visibleEnemies() == 0 && cur[hero.pos] > 0) {
|
||||
Buff.affect( hero, Shadows.class ).prolong();
|
||||
}
|
||||
|
||||
if (regrowth) {
|
||||
GameScene.updateMap();
|
||||
}
|
||||
|
||||
if (visible) {
|
||||
Journal.add( Journal.Feature.GARDEN );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void use( BlobEmitter emitter ) {
|
||||
super.use( emitter );
|
||||
emitter.start( ShaftParticle.FACTORY, 0.9f, 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String tileDesc() {
|
||||
return "Shafts of light pierce the gloom of the underground garden.";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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.actors.blobs;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Frost;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.SnowParticle;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class Freezing {
|
||||
|
||||
// It's not really a blob...
|
||||
|
||||
public static void affect( int cell, Fire fire ) {
|
||||
|
||||
Char ch = Actor.findChar( cell );
|
||||
if (ch != null) {
|
||||
Buff.prolong( ch, Frost.class, Frost.duration( ch ) * Random.Float( 1.0f, 1.5f ) );
|
||||
}
|
||||
|
||||
if (fire != null) {
|
||||
fire.clear( cell );
|
||||
}
|
||||
|
||||
Heap heap = Dungeon.level.heaps.get( cell );
|
||||
if (heap != null) {
|
||||
heap.freeze();
|
||||
}
|
||||
|
||||
if (Dungeon.visible[cell]) {
|
||||
CellEmitter.get( cell ).start( SnowParticle.FACTORY, 0.2f, 6 );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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.actors.blobs;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Paralysis;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||
|
||||
public class ParalyticGas extends Blob {
|
||||
|
||||
@Override
|
||||
protected void evolve() {
|
||||
super.evolve();
|
||||
|
||||
Char ch;
|
||||
for (int i=0; i < LENGTH; i++) {
|
||||
if (cur[i] > 0 && (ch = Actor.findChar( i )) != null) {
|
||||
Buff.prolong( ch, Paralysis.class, Paralysis.duration( ch ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void use( BlobEmitter emitter ) {
|
||||
super.use( emitter );
|
||||
|
||||
emitter.pour( Speck.factory( Speck.PARALYSIS ), 0.6f );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String tileDesc() {
|
||||
return "A cloud of paralytic gas is swirling here.";
|
||||
}
|
||||
}
|
||||
@@ -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.actors.blobs;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Roots;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.LeafParticle;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
|
||||
public class Regrowth extends Blob {
|
||||
|
||||
@Override
|
||||
protected void evolve() {
|
||||
super.evolve();
|
||||
|
||||
if (volume > 0) {
|
||||
|
||||
boolean mapUpdated = false;
|
||||
|
||||
for (int i=0; i < LENGTH; i++) {
|
||||
if (off[i] > 0) {
|
||||
int c = Dungeon.level.map[i];
|
||||
if (c == Terrain.EMPTY || c == Terrain.EMBERS || c == Terrain.EMPTY_DECO) {
|
||||
|
||||
Level.set( i, cur[i] > 9 ? Terrain.HIGH_GRASS : Terrain.GRASS );
|
||||
mapUpdated = true;
|
||||
|
||||
} else if (c == Terrain.GRASS && cur[i] > 9) {
|
||||
|
||||
Level.set( i, Terrain.HIGH_GRASS );
|
||||
mapUpdated = true;
|
||||
|
||||
}
|
||||
|
||||
Char ch = Actor.findChar( i );
|
||||
if (ch != null) {
|
||||
Buff.prolong( ch, Roots.class, TICK );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mapUpdated) {
|
||||
GameScene.updateMap();
|
||||
Dungeon.observe();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void use( BlobEmitter emitter ) {
|
||||
super.use( emitter );
|
||||
|
||||
emitter.start( LeafParticle.LEVEL_SPECIFIC, 0.2f, 0 );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* 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.actors.blobs;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Badges;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ResultDescriptions;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
|
||||
|
||||
public class ToxicGas extends Blob implements Hero.Doom {
|
||||
|
||||
@Override
|
||||
protected void evolve() {
|
||||
super.evolve();
|
||||
|
||||
int levelDamage = 5 + Dungeon.depth * 5;
|
||||
|
||||
Char ch;
|
||||
for (int i=0; i < LENGTH; i++) {
|
||||
if (cur[i] > 0 && (ch = Actor.findChar( i )) != null) {
|
||||
|
||||
int damage = (ch.HT + levelDamage) / 40;
|
||||
if (damage < 1) {
|
||||
damage = 1;
|
||||
}
|
||||
|
||||
ch.damage( damage, this );
|
||||
}
|
||||
}
|
||||
|
||||
Blob blob = Dungeon.level.blobs.get( ParalyticGas.class );
|
||||
if (blob != null) {
|
||||
|
||||
int par[] = blob.cur;
|
||||
|
||||
for (int i=0; i < LENGTH; i++) {
|
||||
|
||||
int t = cur[i];
|
||||
int p = par[i];
|
||||
|
||||
if (p >= t) {
|
||||
volume -= t;
|
||||
cur[i] = 0;
|
||||
} else {
|
||||
blob.volume -= p;
|
||||
par[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void use( BlobEmitter emitter ) {
|
||||
super.use( emitter );
|
||||
|
||||
emitter.pour( Speck.factory( Speck.TOXIC ), 0.6f );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String tileDesc() {
|
||||
return "A greenish cloud of toxic gas is swirling here.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeath() {
|
||||
|
||||
Badges.validateDeathFromGas();
|
||||
|
||||
Dungeon.fail( Utils.format( ResultDescriptions.GAS, Dungeon.depth ) );
|
||||
GLog.n( "You died from a toxic gas.." );
|
||||
}
|
||||
}
|
||||
@@ -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.actors.blobs;
|
||||
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Badges;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.DungeonTilemap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Journal;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Journal.Feature;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Awareness;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Identification;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||
|
||||
public class WaterOfAwareness extends WellWater {
|
||||
|
||||
private static final String TXT_PROCCED =
|
||||
"As you take a sip, you feel the knowledge pours into your mind. " +
|
||||
"Now you know everything about your equipped items. Also you sense " +
|
||||
"all items on the level and know all its secrets.";
|
||||
|
||||
@Override
|
||||
protected boolean affectHero( Hero hero ) {
|
||||
|
||||
Sample.INSTANCE.play( Assets.SND_DRINK );
|
||||
emitter.parent.add( new Identification( DungeonTilemap.tileCenterToWorld( pos ) ) );
|
||||
|
||||
hero.belongings.observe();
|
||||
|
||||
for (int i=0; i < Level.LENGTH; i++) {
|
||||
|
||||
int terr = Dungeon.level.map[i];
|
||||
if ((Terrain.flags[terr] & Terrain.SECRET) != 0) {
|
||||
|
||||
Level.set( i, Terrain.discover( terr ) );
|
||||
GameScene.updateMap( i );
|
||||
|
||||
if (Dungeon.visible[i]) {
|
||||
GameScene.discoverTile( i, terr );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Buff.affect( hero, Awareness.class, Awareness.DURATION );
|
||||
Dungeon.observe();
|
||||
|
||||
Dungeon.hero.interrupt();
|
||||
|
||||
GLog.p( TXT_PROCCED );
|
||||
|
||||
Journal.remove( Feature.WELL_OF_AWARENESS );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Item affectItem( Item item ) {
|
||||
if (item.isIdentified()) {
|
||||
return null;
|
||||
} else {
|
||||
item.identify();
|
||||
Badges.validateItemLevelAquired( item );
|
||||
|
||||
emitter.parent.add( new Identification( DungeonTilemap.tileCenterToWorld( pos ) ) );
|
||||
|
||||
Journal.remove( Feature.WELL_OF_AWARENESS );
|
||||
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void use( BlobEmitter emitter ) {
|
||||
super.use( emitter );
|
||||
emitter.pour( Speck.factory( Speck.QUESTION ), 0.3f );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String tileDesc() {
|
||||
return
|
||||
"Power of knowledge radiates from the water of this well. " +
|
||||
"Take a sip from it to reveal all secrets of equipped items.";
|
||||
}
|
||||
}
|
||||
@@ -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.actors.blobs;
|
||||
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Journal;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Journal.Feature;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Hunger;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShaftParticle;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.DewVial;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||
|
||||
public class WaterOfHealth extends WellWater {
|
||||
|
||||
private static final String TXT_PROCCED =
|
||||
"As you take a sip, you feel your wounds heal completely.";
|
||||
|
||||
@Override
|
||||
protected boolean affectHero( Hero hero ) {
|
||||
|
||||
Sample.INSTANCE.play( Assets.SND_DRINK );
|
||||
|
||||
PotionOfHealing.heal( hero );
|
||||
hero.belongings.uncurseEquipped();
|
||||
((Hunger)hero.buff( Hunger.class )).satisfy( Hunger.STARVING );
|
||||
|
||||
CellEmitter.get( pos ).start( ShaftParticle.FACTORY, 0.2f, 3 );
|
||||
|
||||
Dungeon.hero.interrupt();
|
||||
|
||||
GLog.p( TXT_PROCCED );
|
||||
|
||||
Journal.remove( Feature.WELL_OF_HEALTH );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Item affectItem( Item item ) {
|
||||
if (item instanceof DewVial && !((DewVial)item).isFull()) {
|
||||
((DewVial)item).fill();
|
||||
return item;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void use( BlobEmitter emitter ) {
|
||||
super.use( emitter );
|
||||
emitter.start( Speck.factory( Speck.HEALING ), 0.5f, 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String tileDesc() {
|
||||
return
|
||||
"Power of health radiates from the water of this well. " +
|
||||
"Take a sip from it to heal your wounds and satisfy hunger.";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
/*
|
||||
* 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.actors.blobs;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Journal;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Journal.Feature;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Generator.Category;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfMight;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfWeaponUpgrade;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon.Enchantment;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.*;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.plants.Plant;
|
||||
|
||||
public class WaterOfTransmutation extends WellWater {
|
||||
|
||||
@Override
|
||||
protected Item affectItem( Item item ) {
|
||||
|
||||
if (item instanceof MeleeWeapon) {
|
||||
|
||||
return changeWeapon( (MeleeWeapon)item );
|
||||
|
||||
} else if (item instanceof Scroll) {
|
||||
|
||||
Journal.remove( Feature.WELL_OF_TRANSMUTATION );
|
||||
return changeScroll( (Scroll)item );
|
||||
|
||||
} else if (item instanceof Potion) {
|
||||
|
||||
Journal.remove( Feature.WELL_OF_TRANSMUTATION );
|
||||
return changePotion( (Potion)item );
|
||||
|
||||
} else if (item instanceof Ring) {
|
||||
|
||||
Journal.remove( Feature.WELL_OF_TRANSMUTATION );
|
||||
return changeRing( (Ring)item );
|
||||
|
||||
} else if (item instanceof Wand) {
|
||||
|
||||
Journal.remove( Feature.WELL_OF_TRANSMUTATION );
|
||||
return changeWand( (Wand)item );
|
||||
|
||||
} else if (item instanceof Plant.Seed) {
|
||||
|
||||
Journal.remove( Feature.WELL_OF_TRANSMUTATION );
|
||||
return changeSeed( (Plant.Seed)item );
|
||||
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void use( BlobEmitter emitter ) {
|
||||
super.use( emitter );
|
||||
emitter.start( Speck.factory( Speck.CHANGE ), 0.2f, 0 );
|
||||
}
|
||||
|
||||
private MeleeWeapon changeWeapon( MeleeWeapon w ) {
|
||||
|
||||
MeleeWeapon n = null;
|
||||
|
||||
if (w instanceof Knuckles) {
|
||||
n = new Dagger();
|
||||
} else if (w instanceof Dagger) {
|
||||
n = new Knuckles();
|
||||
}
|
||||
|
||||
else if (w instanceof Spear) {
|
||||
n = new Quarterstaff();
|
||||
} else if (w instanceof Quarterstaff) {
|
||||
n = new Spear();
|
||||
}
|
||||
|
||||
else if (w instanceof Sword) {
|
||||
n = new Mace();
|
||||
} else if (w instanceof Mace) {
|
||||
n = new Sword();
|
||||
}
|
||||
|
||||
else if (w instanceof Longsword) {
|
||||
n = new BattleAxe();
|
||||
} else if (w instanceof BattleAxe) {
|
||||
n = new Longsword();
|
||||
}
|
||||
|
||||
else if (w instanceof Glaive) {
|
||||
n = new WarHammer();
|
||||
} else if (w instanceof WarHammer) {
|
||||
n = new Glaive();
|
||||
}
|
||||
|
||||
if (n != null) {
|
||||
|
||||
int level = w.level;
|
||||
if (level > 0) {
|
||||
n.upgrade( level );
|
||||
} else if (level < 0) {
|
||||
n.degrade( -level );
|
||||
}
|
||||
|
||||
if (w.isEnchanted()) {
|
||||
n.enchant( Enchantment.random() );
|
||||
}
|
||||
|
||||
n.levelKnown = w.levelKnown;
|
||||
n.cursedKnown = w.cursedKnown;
|
||||
n.cursed = w.cursed;
|
||||
|
||||
Journal.remove( Feature.WELL_OF_TRANSMUTATION );
|
||||
|
||||
return n;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Ring changeRing( Ring r ) {
|
||||
Ring n;
|
||||
do {
|
||||
n = (Ring)Generator.random( Category.RING );
|
||||
} while (n.getClass() == r.getClass());
|
||||
|
||||
n.level = 0;
|
||||
|
||||
int level = r.level;
|
||||
if (level > 0) {
|
||||
n.upgrade( level );
|
||||
} else if (level < 0) {
|
||||
n.degrade( -level );
|
||||
}
|
||||
|
||||
n.levelKnown = r.levelKnown;
|
||||
n.cursedKnown = r.cursedKnown;
|
||||
n.cursed = r.cursed;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
private Wand changeWand( Wand w ) {
|
||||
|
||||
Wand n;
|
||||
do {
|
||||
n = (Wand)Generator.random( Category.WAND );
|
||||
} while (n.getClass() == w.getClass());
|
||||
|
||||
n.level = 0;
|
||||
n.upgrade( w.level );
|
||||
|
||||
n.levelKnown = w.levelKnown;
|
||||
n.cursedKnown = w.cursedKnown;
|
||||
n.cursed = w.cursed;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
private Plant.Seed changeSeed( Plant.Seed s ) {
|
||||
|
||||
Plant.Seed n;
|
||||
|
||||
do {
|
||||
n = (Plant.Seed)Generator.random( Category.SEED );
|
||||
} while (n.getClass() == s.getClass());
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
private Scroll changeScroll( Scroll s ) {
|
||||
if (s instanceof ScrollOfUpgrade) {
|
||||
|
||||
return new ScrollOfWeaponUpgrade();
|
||||
|
||||
} else if (s instanceof ScrollOfWeaponUpgrade) {
|
||||
|
||||
return new ScrollOfUpgrade();
|
||||
|
||||
} else {
|
||||
|
||||
Scroll n;
|
||||
do {
|
||||
n = (Scroll)Generator.random( Category.SCROLL );
|
||||
} while (n.getClass() == s.getClass());
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
private Potion changePotion( Potion p ) {
|
||||
if (p instanceof PotionOfStrength) {
|
||||
|
||||
return new PotionOfMight();
|
||||
|
||||
} else if (p instanceof PotionOfMight) {
|
||||
|
||||
return new PotionOfStrength();
|
||||
|
||||
} else {
|
||||
|
||||
Potion n;
|
||||
do {
|
||||
n = (Potion)Generator.random( Category.POTION );
|
||||
} while (n.getClass() == p.getClass());
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String tileDesc() {
|
||||
return
|
||||
"Power of change radiates from the water of this well. " +
|
||||
"Throw an item into the well to turn it into something else.";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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.actors.blobs;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Roots;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.WebParticle;
|
||||
|
||||
public class Web extends Blob {
|
||||
|
||||
@Override
|
||||
protected void evolve() {
|
||||
|
||||
for (int i=0; i < LENGTH; i++) {
|
||||
|
||||
int offv = cur[i] > 0 ? cur[i] - 1 : 0;
|
||||
off[i] = offv;
|
||||
|
||||
if (offv > 0) {
|
||||
|
||||
volume += offv;
|
||||
|
||||
Char ch = Actor.findChar( i );
|
||||
if (ch != null) {
|
||||
Buff.prolong( ch, Roots.class, TICK );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void use( BlobEmitter emitter ) {
|
||||
super.use( emitter );
|
||||
|
||||
emitter.pour( WebParticle.FACTORY, 0.4f );
|
||||
}
|
||||
|
||||
public void seed( int cell, int amount ) {
|
||||
int diff = amount - cur[cell];
|
||||
if (diff > 0) {
|
||||
cur[cell] = amount;
|
||||
volume += diff;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String tileDesc() {
|
||||
return "Everything is covered with a thick web here.";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* 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.actors.blobs;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Journal;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Journal.Feature;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.watabou.utils.Bundle;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class WellWater extends Blob {
|
||||
|
||||
protected int pos;
|
||||
|
||||
@Override
|
||||
public void restoreFromBundle( Bundle bundle ) {
|
||||
super.restoreFromBundle( bundle );
|
||||
|
||||
for (int i=0; i < LENGTH; i++) {
|
||||
if (cur[i] > 0) {
|
||||
pos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void evolve() {
|
||||
volume = off[pos] = cur[pos];
|
||||
|
||||
if (Dungeon.visible[pos]) {
|
||||
if (this instanceof WaterOfAwareness) {
|
||||
Journal.add( Feature.WELL_OF_AWARENESS );
|
||||
} else if (this instanceof WaterOfHealth) {
|
||||
Journal.add( Feature.WELL_OF_HEALTH );
|
||||
} else if (this instanceof WaterOfTransmutation) {
|
||||
Journal.add( Feature.WELL_OF_TRANSMUTATION );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean affect() {
|
||||
|
||||
Heap heap;
|
||||
|
||||
if (pos == Dungeon.hero.pos && affectHero( Dungeon.hero )) {
|
||||
|
||||
volume = off[pos] = cur[pos] = 0;
|
||||
return true;
|
||||
|
||||
} else if ((heap = Dungeon.level.heaps.get( pos )) != null) {
|
||||
|
||||
Item oldItem = heap.peek();
|
||||
Item newItem = affectItem( oldItem );
|
||||
|
||||
if (newItem != null) {
|
||||
|
||||
if (newItem == oldItem) {
|
||||
|
||||
} else if (oldItem.quantity() > 1) {
|
||||
|
||||
oldItem.quantity( oldItem.quantity() - 1 );
|
||||
heap.drop( newItem );
|
||||
|
||||
} else {
|
||||
heap.replace( oldItem, newItem );
|
||||
}
|
||||
|
||||
heap.sprite.link();
|
||||
volume = off[pos] = cur[pos] = 0;
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
|
||||
int newPlace;
|
||||
do {
|
||||
newPlace = pos + Level.NEIGHBOURS8[Random.Int( 8 )];
|
||||
} while (!Level.passable[newPlace] && !Level.avoid[newPlace]);
|
||||
Dungeon.level.drop( heap.pickUp(), newPlace ).sprite.drop( pos );
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean affectHero( Hero hero ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected Item affectItem( Item item ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void seed( int cell, int amount ) {
|
||||
cur[pos] = 0;
|
||||
pos = cell;
|
||||
volume = cur[pos] = amount;
|
||||
}
|
||||
|
||||
public static void affectCell( int cell ) {
|
||||
|
||||
Class<?>[] waters = {WaterOfHealth.class, WaterOfAwareness.class, WaterOfTransmutation.class};
|
||||
|
||||
for (Class<?>waterClass : waters) {
|
||||
WellWater water = (WellWater)Dungeon.level.blobs.get( waterClass );
|
||||
if (water != null &&
|
||||
water.volume > 0 &&
|
||||
water.pos == cell &&
|
||||
water.affect()) {
|
||||
|
||||
Level.set( cell, Terrain.EMPTY_WELL );
|
||||
GameScene.updateMap( cell );
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user