v0.2.3: further hourglass implementation
This commit is contained in:
parent
3d55729861
commit
15c4bd66b7
|
@ -898,7 +898,10 @@ public class Hero extends Char {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void damage( int dmg, Object src ) {
|
public void damage( int dmg, Object src ) {
|
||||||
|
if (buff(TimekeepersHourglass.timeStasis.class) != null)
|
||||||
|
return;
|
||||||
|
|
||||||
restoreHealth = false;
|
restoreHealth = false;
|
||||||
|
|
||||||
if (!(src instanceof Hunger) && damageInterrupt)
|
if (!(src instanceof Hunger) && damageInterrupt)
|
||||||
|
@ -1123,6 +1126,10 @@ public class Hero extends Char {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add( Buff buff ) {
|
public void add( Buff buff ) {
|
||||||
|
//TODO: test this, may break some things
|
||||||
|
if (buff(TimekeepersHourglass.timeStasis.class) != null)
|
||||||
|
return;
|
||||||
|
|
||||||
super.add( buff );
|
super.add( buff );
|
||||||
|
|
||||||
if (sprite != null) {
|
if (sprite != null) {
|
||||||
|
|
|
@ -2,6 +2,8 @@ package com.shatteredpixel.shatteredpixeldungeon.items.artifacts;
|
||||||
|
|
||||||
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.Char;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Hunger;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||||
|
@ -148,7 +150,33 @@ public class TimekeepersHourglass extends Artifact {
|
||||||
}
|
}
|
||||||
|
|
||||||
public class timeStasis extends ArtifactBuff {
|
public class timeStasis extends ArtifactBuff {
|
||||||
//todo: add logic here
|
//todo: add visuals, test
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean attachTo(Char target) {
|
||||||
|
spend(charge*2);
|
||||||
|
((Hero)target).spend(charge*2);
|
||||||
|
|
||||||
|
Hunger hunger = target.buff(Hunger.class);
|
||||||
|
if (hunger != null && !hunger.isStarving())
|
||||||
|
hunger.satisfy(charge*2);
|
||||||
|
|
||||||
|
charge = 0;
|
||||||
|
|
||||||
|
target.invisible++;
|
||||||
|
|
||||||
|
QuickSlot.refresh();
|
||||||
|
|
||||||
|
return super.attachTo(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean act() {
|
||||||
|
target.invisible --;
|
||||||
|
detach();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class timeFreeze extends ArtifactBuff {
|
public class timeFreeze extends ArtifactBuff {
|
||||||
|
@ -156,6 +184,8 @@ public class TimekeepersHourglass extends Artifact {
|
||||||
|
|
||||||
float partialTime = 0f;
|
float partialTime = 0f;
|
||||||
|
|
||||||
|
ArrayList<Integer> presses = new ArrayList<Integer>();
|
||||||
|
|
||||||
public boolean processTime(float time){
|
public boolean processTime(float time){
|
||||||
partialTime += time;
|
partialTime += time;
|
||||||
|
|
||||||
|
@ -174,8 +204,16 @@ public class TimekeepersHourglass extends Artifact {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void delayedPress(int cell){
|
||||||
|
if (!presses.contains(cell))
|
||||||
|
presses.add(cell);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void detach(){
|
public void detach(){
|
||||||
|
for (int cell : presses)
|
||||||
|
Dungeon.level.press(cell, null);
|
||||||
|
|
||||||
charge = 0;
|
charge = 0;
|
||||||
QuickSlot.refresh();
|
QuickSlot.refresh();
|
||||||
super.detach();
|
super.detach();
|
||||||
|
|
|
@ -44,6 +44,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Stylus;
|
import com.shatteredpixel.shatteredpixeldungeon.items.Stylus;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
|
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.AlchemistsToolkit;
|
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.AlchemistsToolkit;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TimekeepersHourglass;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.food.Blandfruit;
|
import com.shatteredpixel.shatteredpixeldungeon.items.food.Blandfruit;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.food.Food;
|
import com.shatteredpixel.shatteredpixeldungeon.items.food.Food;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
|
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
|
||||||
|
@ -661,6 +662,13 @@ public abstract class Level implements Bundlable {
|
||||||
Chasm.heroFall( cell );
|
Chasm.heroFall( cell );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TimekeepersHourglass.timeFreeze timeFreeze = null;
|
||||||
|
|
||||||
|
if (ch != null)
|
||||||
|
timeFreeze = ch.buff(TimekeepersHourglass.timeFreeze.class);
|
||||||
|
|
||||||
|
boolean frozen = timeFreeze != null;
|
||||||
|
|
||||||
boolean trap = false;
|
boolean trap = false;
|
||||||
|
|
||||||
|
@ -670,56 +678,56 @@ public abstract class Level implements Bundlable {
|
||||||
GLog.i( TXT_HIDDEN_PLATE_CLICKS );
|
GLog.i( TXT_HIDDEN_PLATE_CLICKS );
|
||||||
case Terrain.TOXIC_TRAP:
|
case Terrain.TOXIC_TRAP:
|
||||||
trap = true;
|
trap = true;
|
||||||
ToxicTrap.trigger( cell, ch );
|
if (!frozen) ToxicTrap.trigger( cell, ch );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Terrain.SECRET_FIRE_TRAP:
|
case Terrain.SECRET_FIRE_TRAP:
|
||||||
GLog.i( TXT_HIDDEN_PLATE_CLICKS );
|
GLog.i( TXT_HIDDEN_PLATE_CLICKS );
|
||||||
case Terrain.FIRE_TRAP:
|
case Terrain.FIRE_TRAP:
|
||||||
trap = true;
|
trap = true;
|
||||||
FireTrap.trigger( cell, ch );
|
if (!frozen) FireTrap.trigger( cell, ch );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Terrain.SECRET_PARALYTIC_TRAP:
|
case Terrain.SECRET_PARALYTIC_TRAP:
|
||||||
GLog.i( TXT_HIDDEN_PLATE_CLICKS );
|
GLog.i( TXT_HIDDEN_PLATE_CLICKS );
|
||||||
case Terrain.PARALYTIC_TRAP:
|
case Terrain.PARALYTIC_TRAP:
|
||||||
trap = true;
|
trap = true;
|
||||||
ParalyticTrap.trigger( cell, ch );
|
if (!frozen) ParalyticTrap.trigger( cell, ch );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Terrain.SECRET_POISON_TRAP:
|
case Terrain.SECRET_POISON_TRAP:
|
||||||
GLog.i( TXT_HIDDEN_PLATE_CLICKS );
|
GLog.i( TXT_HIDDEN_PLATE_CLICKS );
|
||||||
case Terrain.POISON_TRAP:
|
case Terrain.POISON_TRAP:
|
||||||
trap = true;
|
trap = true;
|
||||||
PoisonTrap.trigger( cell, ch );
|
if (!frozen) PoisonTrap.trigger( cell, ch );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Terrain.SECRET_ALARM_TRAP:
|
case Terrain.SECRET_ALARM_TRAP:
|
||||||
GLog.i( TXT_HIDDEN_PLATE_CLICKS );
|
GLog.i( TXT_HIDDEN_PLATE_CLICKS );
|
||||||
case Terrain.ALARM_TRAP:
|
case Terrain.ALARM_TRAP:
|
||||||
trap = true;
|
trap = true;
|
||||||
AlarmTrap.trigger( cell, ch );
|
if (!frozen) AlarmTrap.trigger( cell, ch );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Terrain.SECRET_LIGHTNING_TRAP:
|
case Terrain.SECRET_LIGHTNING_TRAP:
|
||||||
GLog.i( TXT_HIDDEN_PLATE_CLICKS );
|
GLog.i( TXT_HIDDEN_PLATE_CLICKS );
|
||||||
case Terrain.LIGHTNING_TRAP:
|
case Terrain.LIGHTNING_TRAP:
|
||||||
trap = true;
|
trap = true;
|
||||||
LightningTrap.trigger( cell, ch );
|
if (!frozen) LightningTrap.trigger( cell, ch );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Terrain.SECRET_GRIPPING_TRAP:
|
case Terrain.SECRET_GRIPPING_TRAP:
|
||||||
GLog.i( TXT_HIDDEN_PLATE_CLICKS );
|
GLog.i( TXT_HIDDEN_PLATE_CLICKS );
|
||||||
case Terrain.GRIPPING_TRAP:
|
case Terrain.GRIPPING_TRAP:
|
||||||
trap = true;
|
trap = true;
|
||||||
GrippingTrap.trigger( cell, ch );
|
if (!frozen) GrippingTrap.trigger( cell, ch );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Terrain.SECRET_SUMMONING_TRAP:
|
case Terrain.SECRET_SUMMONING_TRAP:
|
||||||
GLog.i( TXT_HIDDEN_PLATE_CLICKS );
|
GLog.i( TXT_HIDDEN_PLATE_CLICKS );
|
||||||
case Terrain.SUMMONING_TRAP:
|
case Terrain.SUMMONING_TRAP:
|
||||||
trap = true;
|
trap = true;
|
||||||
SummoningTrap.trigger( cell, ch );
|
if (!frozen) SummoningTrap.trigger( cell, ch );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Terrain.HIGH_GRASS:
|
case Terrain.HIGH_GRASS:
|
||||||
|
@ -741,13 +749,26 @@ public abstract class Level implements Bundlable {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trap) {
|
if (trap && !frozen) {
|
||||||
Sample.INSTANCE.play( Assets.SND_TRAP );
|
|
||||||
if (ch == Dungeon.hero) {
|
if (Dungeon.visible[cell])
|
||||||
|
Sample.INSTANCE.play( Assets.SND_TRAP );
|
||||||
|
|
||||||
|
if (ch == Dungeon.hero)
|
||||||
Dungeon.hero.interrupt();
|
Dungeon.hero.interrupt();
|
||||||
}
|
|
||||||
set( cell, Terrain.INACTIVE_TRAP );
|
set( cell, Terrain.INACTIVE_TRAP );
|
||||||
GameScene.updateMap( cell );
|
GameScene.updateMap( cell );
|
||||||
|
|
||||||
|
} else if (trap && frozen){
|
||||||
|
|
||||||
|
Sample.INSTANCE.play( Assets.SND_TRAP );
|
||||||
|
|
||||||
|
Level.set( cell, Terrain.discover( map[cell] ) );
|
||||||
|
GameScene.updateMap( cell );
|
||||||
|
|
||||||
|
timeFreeze.delayedPress(cell);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Plant plant = plants.get( cell );
|
Plant plant = plants.get( cell );
|
||||||
|
|
Loading…
Reference in New Issue
Block a user