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