V0.2.0: Initial implementation for Sandals of Nature

This commit is contained in:
Evan Debenham 2014-09-08 15:41:09 -04:00
parent 33a6533d08
commit e8b3365f08
3 changed files with 141 additions and 12 deletions

View File

@ -0,0 +1,119 @@
package com.shatteredpixel.shatteredpixeldungeon.items.artifacts;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Roots;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.EarthParticle;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.food.Blandfruit;
import com.shatteredpixel.shatteredpixeldungeon.items.food.Food;
import com.shatteredpixel.shatteredpixeldungeon.plants.Earthroot;
import com.shatteredpixel.shatteredpixeldungeon.plants.Plant;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
import com.watabou.noosa.Camera;
import java.util.ArrayList;
/**
* Created by debenhame on 08/09/2014.
*/
public class SandalsOfNature extends Artifact {
{
name = "Sandals of Nature";
image = ItemSpriteSheet.ARTIFACT_SANDALS;
level = 0;
levelCap = 3;
charge = 0;
//partialcharge, chargeCap and exp are unused
}
public static final String AC_FEED = "FEED";
public static final String AC_ROOT = "ROOT";
protected String inventoryTitle = "Select a seed";
protected WndBag.Mode mode = WndBag.Mode.SEED;
public ArrayList<String> seeds = new ArrayList<String>();
@Override
public ArrayList<String> actions( Hero hero ) {
ArrayList<String> actions = super.actions( hero );
if (isEquipped( hero ) && level < 3)
actions.add(AC_FEED);
if (isEquipped( hero ) && charge > 0)
actions.add(AC_ROOT);
return actions;
}
@Override
public void execute( Hero hero, String action ) {
super.execute(hero, action);
if (action.equals(AC_FEED)){
GameScene.selectItem(itemSelector, mode, inventoryTitle);
} else if (action.equals(AC_ROOT)){
if (charge > 0){
Buff.prolong( hero, Roots.class, 5);
Buff.affect( hero, Earthroot.Armor.class ).level( charge );
CellEmitter.bottom(hero.pos).start( EarthParticle.FACTORY, 0.05f, 8 );
Camera.main.shake( 1, 0.4f );
charge = 0;
}
}
}
@Override
public String status() {
if (charge > 0)
return Utils.format("%d", charge);
else
return null;
}
@Override
protected ArtifactBuff passiveBuff() {
return new Naturalism();
}
@Override
public String desc() {
//TODO: add description
return "";
}
//TODO: add bundle logic
public class Naturalism extends ArtifactBuff{
public int level() { return level; }
public void charge() {
if (charge < 25*level){
charge++;
}
}
}
protected WndBag.Listener itemSelector = new WndBag.Listener() {
@Override
public void onSelect( Item item ) {
if (item != null && item instanceof Plant.Seed) {
if (seeds.contains(item.name())){
GLog.w("The plant has already gained nutrients from that seed.");
} else {
seeds.add(item.name());
if (seeds.size() >= 5+level){
seeds.clear();
//upgrade logic
}
}
}
}
};
}

View File

@ -27,6 +27,7 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.LeafParticle;
import com.shatteredpixel.shatteredpixeldungeon.items.Dewdrop;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.SandalsOfNature;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfHerbalism.Herbalism;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
@ -40,21 +41,22 @@ public class HighGrass {
Level.set( pos, Terrain.GRASS );
GameScene.updateMap( pos );
int herbalismLevel = 0;
if (ch != null) {
Herbalism herbalism = ch.buff( Herbalism.class );
if (herbalism != null) {
herbalismLevel = herbalism.level;
}
}
int naturalismLevel = 0;
if (ch != null) {
SandalsOfNature.Naturalism naturalism = ch.buff( SandalsOfNature.Naturalism.class );
if (naturalism != null) {
naturalismLevel = naturalism.level()+1;
naturalism.charge();
}
}
// Seed
if (herbalismLevel >= 0 && Random.Int( 18 ) <= Random.Int( herbalismLevel + 1 )) {
if (Random.Int(18-((int)(naturalismLevel*3.34))) == 0) {
level.drop( Generator.random( Generator.Category.SEED ), pos ).sprite.drop();
}
// Dew
if (herbalismLevel >= 0 && Random.Int( 6 ) <= Random.Int( herbalismLevel + 1 )) {
if (Random.Int( 6-naturalismLevel ) == 0) {
level.drop( new Dewdrop(), pos ).sprite.drop();
}

View File

@ -19,6 +19,7 @@ package com.shatteredpixel.shatteredpixeldungeon.plants;
import java.util.ArrayList;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.SandalsOfNature;
import com.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
@ -67,10 +68,17 @@ public class Plant implements Bundlable {
}
if (Dungeon.hero.subClass == HeroSubClass.WARDEN) {
if (Random.Int( 5 ) == 0) {
int naturalismLevel = 0;
SandalsOfNature.Naturalism naturalism = Dungeon.hero.buff( SandalsOfNature.Naturalism.class );
if (naturalism != null) {
naturalismLevel = naturalism.level()+1;
}
if (Random.Int( 5 - (naturalismLevel/2) ) == 0) {
Dungeon.level.drop( Generator.random( Generator.Category.SEED ), pos ).sprite.drop();
}
if (Random.Int( 5 ) == 0) {
if (Random.Int( 5 - naturalismLevel ) == 0) {
Dungeon.level.drop( new Dewdrop(), pos ).sprite.drop();
}
}