v0.2.3: implementation on timekeepers hourglass (almost done!)
This commit is contained in:
parent
59df503355
commit
5bf2d72a90
|
@ -749,6 +749,10 @@ public class Hero extends Char {
|
|||
if (hunger != null && !hunger.isStarving()) {
|
||||
hunger.satisfy( -Hunger.STARVING / 10 );
|
||||
}
|
||||
|
||||
Buff buff = buff(TimekeepersHourglass.timeFreeze.class);
|
||||
if (buff != null)
|
||||
buff.detach();
|
||||
|
||||
InterlevelScene.mode = InterlevelScene.Mode.DESCEND;
|
||||
Game.switchScene( InterlevelScene.class );
|
||||
|
@ -789,6 +793,10 @@ public class Hero extends Char {
|
|||
hunger.satisfy( -Hunger.STARVING / 10 );
|
||||
}
|
||||
|
||||
Buff buff = buff(TimekeepersHourglass.timeFreeze.class);
|
||||
if (buff != null)
|
||||
buff.detach();
|
||||
|
||||
InterlevelScene.mode = InterlevelScene.Mode.ASCEND;
|
||||
Game.switchScene( InterlevelScene.class );
|
||||
}
|
||||
|
|
|
@ -17,14 +17,12 @@
|
|||
*/
|
||||
package com.shatteredpixel.shatteredpixeldungeon.items;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TimekeepersHourglass;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfBlink;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.InterlevelScene;
|
||||
|
@ -32,8 +30,12 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.utils.Bundle;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class LloydsBeacon extends Item {
|
||||
|
||||
private static final String TXT_PREVENTING =
|
||||
|
@ -135,6 +137,11 @@ public class LloydsBeacon extends Item {
|
|||
Dungeon.level.press( returnPos, hero );
|
||||
Dungeon.observe();
|
||||
} else {
|
||||
|
||||
Buff buff = Dungeon.hero.buff(TimekeepersHourglass.timeFreeze.class);
|
||||
if (buff != null)
|
||||
buff.detach();
|
||||
|
||||
InterlevelScene.mode = InterlevelScene.Mode.RETURN;
|
||||
InterlevelScene.returnDepth = returnDepth;
|
||||
InterlevelScene.returnPos = returnPos;
|
||||
|
|
|
@ -37,8 +37,8 @@ public class TimekeepersHourglass extends Artifact {
|
|||
|
||||
level = 0;
|
||||
levelCap = 5;
|
||||
charge = 5+level;
|
||||
chargeCap = 5+level;
|
||||
charge = 10+level*2;
|
||||
chargeCap = 10+level*2;
|
||||
defaultAction = AC_ACTIVATE;
|
||||
}
|
||||
|
||||
|
@ -85,6 +85,13 @@ public class TimekeepersHourglass extends Artifact {
|
|||
super.execute(hero, action);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activate(Char ch) {
|
||||
super.activate(ch);
|
||||
if (activeBuff != null)
|
||||
activeBuff.attachTo(ch);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ArtifactBuff passiveBuff() {
|
||||
return new hourglassRecharge();
|
||||
|
@ -92,7 +99,7 @@ public class TimekeepersHourglass extends Artifact {
|
|||
|
||||
@Override
|
||||
public Item upgrade() {
|
||||
chargeCap++;
|
||||
chargeCap+= 2;
|
||||
|
||||
//for artifact transmutation.
|
||||
while (level+1 > sandBags)
|
||||
|
@ -115,12 +122,14 @@ public class TimekeepersHourglass extends Artifact {
|
|||
//needs to bundle chargecap as it is dynamic.
|
||||
private static final String CHARGECAP = "chargecap";
|
||||
private static final String SANDBAGS = "sandbags";
|
||||
private static final String BUFF = "buff";
|
||||
|
||||
@Override
|
||||
public void storeInBundle( Bundle bundle ) {
|
||||
super.storeInBundle(bundle);
|
||||
bundle.put( CHARGECAP, chargeCap );
|
||||
bundle.put( SANDBAGS, sandBags );
|
||||
bundle.put( BUFF , activeBuff );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -128,13 +137,14 @@ public class TimekeepersHourglass extends Artifact {
|
|||
super.restoreFromBundle(bundle);
|
||||
chargeCap = bundle.getInt( CHARGECAP );
|
||||
sandBags = bundle.getInt( SANDBAGS );
|
||||
activeBuff = (ArtifactBuff)bundle.get( BUFF );
|
||||
}
|
||||
|
||||
public class hourglassRecharge extends ArtifactBuff {
|
||||
@Override
|
||||
public boolean act() {
|
||||
if (charge < chargeCap) {
|
||||
partialCharge += 1 / (40f - (chargeCap - charge)*3f);
|
||||
partialCharge += 1 / (60f - (chargeCap - charge)*2f);
|
||||
|
||||
if (partialCharge >= 1) {
|
||||
partialCharge --;
|
||||
|
@ -160,12 +170,13 @@ public class TimekeepersHourglass extends Artifact {
|
|||
|
||||
@Override
|
||||
public boolean attachTo(Char target) {
|
||||
spend(charge*2);
|
||||
((Hero)target).spendAndNext(charge*2);
|
||||
spend(charge);
|
||||
((Hero)target).spendAndNext(charge);
|
||||
|
||||
//shouldn't punish the player for going into stasis frequently
|
||||
Hunger hunger = target.buff(Hunger.class);
|
||||
if (hunger != null && !hunger.isStarving())
|
||||
hunger.satisfy(charge*2);
|
||||
hunger.satisfy(charge);
|
||||
|
||||
charge = 0;
|
||||
|
||||
|
@ -182,10 +193,15 @@ public class TimekeepersHourglass extends Artifact {
|
|||
detach();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detach() {
|
||||
super.detach();
|
||||
Dungeon.observe();
|
||||
}
|
||||
}
|
||||
|
||||
public class timeFreeze extends ArtifactBuff {
|
||||
//todo: add visual effects
|
||||
|
||||
float partialTime = 0f;
|
||||
|
||||
|
@ -194,7 +210,7 @@ public class TimekeepersHourglass extends Artifact {
|
|||
public boolean processTime(float time){
|
||||
partialTime += time;
|
||||
|
||||
while (partialTime >= 1){
|
||||
while (partialTime >= 1f){
|
||||
partialTime --;
|
||||
charge --;
|
||||
}
|
||||
|
@ -234,6 +250,32 @@ public class TimekeepersHourglass extends Artifact {
|
|||
QuickSlot.refresh();
|
||||
super.detach();
|
||||
}
|
||||
|
||||
private static final String PRESSES = "presses";
|
||||
private static final String PARTIALTIME = "partialtime";
|
||||
|
||||
@Override
|
||||
public void storeInBundle(Bundle bundle) {
|
||||
super.storeInBundle(bundle);
|
||||
|
||||
int[] values = new int[presses.size()];
|
||||
for (int i = 0; i < values.length; i ++)
|
||||
values[i] = presses.get(i);
|
||||
bundle.put( PRESSES , values );
|
||||
|
||||
bundle.put( PARTIALTIME , partialTime );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreFromBundle(Bundle bundle) {
|
||||
super.restoreFromBundle(bundle);
|
||||
|
||||
int[] values = bundle.getIntArray( PRESSES );
|
||||
for (int i = 0; i < values.length; i ++)
|
||||
presses.add(values[i]);
|
||||
|
||||
partialTime = bundle.getFloat( PARTIALTIME );
|
||||
}
|
||||
}
|
||||
|
||||
public static class sandBag extends Item {
|
||||
|
|
|
@ -847,7 +847,8 @@ public abstract class Level implements Bundlable {
|
|||
int cx = c.pos % WIDTH;
|
||||
int cy = c.pos / WIDTH;
|
||||
|
||||
boolean sighted = c.buff( Blindness.class ) == null && c.buff( Shadows.class ) == null && c.isAlive();
|
||||
boolean sighted = c.buff( Blindness.class ) == null && c.buff( Shadows.class ) == null
|
||||
&& c.buff( TimekeepersHourglass.timeStasis.class ) == null && c.isAlive();
|
||||
if (sighted) {
|
||||
ShadowCaster.castShadow( cx, cy, fieldOfView, c.viewDistance );
|
||||
} else {
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
package com.shatteredpixel.shatteredpixeldungeon.levels.features;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TimekeepersHourglass;
|
||||
import com.watabou.noosa.Camera;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
|
@ -67,6 +68,10 @@ public class Chasm {
|
|||
jumpConfirmed = false;
|
||||
|
||||
Sample.INSTANCE.play( Assets.SND_FALLING );
|
||||
|
||||
Buff buff = Dungeon.hero.buff(TimekeepersHourglass.timeFreeze.class);
|
||||
if (buff != null)
|
||||
buff.detach();
|
||||
|
||||
if (Dungeon.hero.isAlive()) {
|
||||
Dungeon.hero.interrupt();
|
||||
|
|
Loading…
Reference in New Issue
Block a user