v0.7.5: fixed an animation cancel bug that let players open containers/doors remotely and without keys
This commit is contained in:
parent
f0a44e8578
commit
388e16b53c
|
@ -1546,33 +1546,46 @@ public class Hero extends Char {
|
||||||
int doorCell = ((HeroAction.Unlock)curAction).dst;
|
int doorCell = ((HeroAction.Unlock)curAction).dst;
|
||||||
int door = Dungeon.level.map[doorCell];
|
int door = Dungeon.level.map[doorCell];
|
||||||
|
|
||||||
|
if (Dungeon.level.adjacent(pos, doorCell)) {
|
||||||
|
boolean hasKey = true;
|
||||||
if (door == Terrain.LOCKED_DOOR) {
|
if (door == Terrain.LOCKED_DOOR) {
|
||||||
Notes.remove(new IronKey(Dungeon.depth));
|
hasKey = Notes.remove(new IronKey(Dungeon.depth));
|
||||||
Level.set( doorCell, Terrain.DOOR );
|
if (hasKey) Level.set(doorCell, Terrain.DOOR);
|
||||||
} else {
|
} else {
|
||||||
Notes.remove(new SkeletonKey(Dungeon.depth));
|
hasKey = Notes.remove(new SkeletonKey(Dungeon.depth));
|
||||||
Level.set( doorCell, Terrain.UNLOCKED_EXIT );
|
if (hasKey) Level.set(doorCell, Terrain.UNLOCKED_EXIT);
|
||||||
}
|
}
|
||||||
GameScene.updateKeyDisplay();
|
|
||||||
|
|
||||||
|
if (hasKey) {
|
||||||
|
GameScene.updateKeyDisplay();
|
||||||
Level.set(doorCell, door == Terrain.LOCKED_DOOR ? Terrain.DOOR : Terrain.UNLOCKED_EXIT);
|
Level.set(doorCell, door == Terrain.LOCKED_DOOR ? Terrain.DOOR : Terrain.UNLOCKED_EXIT);
|
||||||
GameScene.updateMap(doorCell);
|
GameScene.updateMap(doorCell);
|
||||||
spend(Key.TIME_TO_UNLOCK);
|
spend(Key.TIME_TO_UNLOCK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else if (curAction instanceof HeroAction.OpenChest) {
|
} else if (curAction instanceof HeroAction.OpenChest) {
|
||||||
|
|
||||||
Heap heap = Dungeon.level.heaps.get( ((HeroAction.OpenChest)curAction).dst );
|
Heap heap = Dungeon.level.heaps.get( ((HeroAction.OpenChest)curAction).dst );
|
||||||
|
|
||||||
|
if (Dungeon.level.adjacent(pos, heap.pos)){
|
||||||
|
boolean hasKey = true;
|
||||||
if (heap.type == Type.SKELETON || heap.type == Type.REMAINS) {
|
if (heap.type == Type.SKELETON || heap.type == Type.REMAINS) {
|
||||||
Sample.INSTANCE.play( Assets.SND_BONES );
|
Sample.INSTANCE.play( Assets.SND_BONES );
|
||||||
} else if (heap.type == Type.LOCKED_CHEST){
|
} else if (heap.type == Type.LOCKED_CHEST){
|
||||||
Notes.remove(new GoldenKey(Dungeon.depth));
|
hasKey = Notes.remove(new GoldenKey(Dungeon.depth));
|
||||||
} else if (heap.type == Type.CRYSTAL_CHEST){
|
} else if (heap.type == Type.CRYSTAL_CHEST){
|
||||||
Notes.remove(new CrystalKey(Dungeon.depth));
|
hasKey = Notes.remove(new CrystalKey(Dungeon.depth));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hasKey) {
|
||||||
GameScene.updateKeyDisplay();
|
GameScene.updateKeyDisplay();
|
||||||
heap.open(this);
|
heap.open(this);
|
||||||
spend(Key.TIME_TO_UNLOCK);
|
spend(Key.TIME_TO_UNLOCK);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
curAction = null;
|
curAction = null;
|
||||||
|
|
||||||
super.onOperateComplete();
|
super.onOperateComplete();
|
||||||
|
|
|
@ -191,38 +191,43 @@ public class Notes {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void add( Landmark landmark ) {
|
public static boolean add( Landmark landmark ) {
|
||||||
LandmarkRecord l = new LandmarkRecord( landmark, Dungeon.depth );
|
LandmarkRecord l = new LandmarkRecord( landmark, Dungeon.depth );
|
||||||
if (!records.contains(l)) {
|
if (!records.contains(l)) {
|
||||||
records.add(new LandmarkRecord(landmark, Dungeon.depth));
|
boolean result = records.add(new LandmarkRecord(landmark, Dungeon.depth));
|
||||||
Collections.sort(records);
|
Collections.sort(records);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void remove( Landmark landmark ) {
|
public static boolean remove( Landmark landmark ) {
|
||||||
records.remove( new LandmarkRecord(landmark, Dungeon.depth) );
|
return records.remove( new LandmarkRecord(landmark, Dungeon.depth) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void add( Key key ){
|
public static boolean add( Key key ){
|
||||||
KeyRecord k = new KeyRecord(key);
|
KeyRecord k = new KeyRecord(key);
|
||||||
if (!records.contains(k)){
|
if (!records.contains(k)){
|
||||||
records.add(k);
|
boolean result = records.add(k);
|
||||||
Collections.sort(records);
|
Collections.sort(records);
|
||||||
|
return result;
|
||||||
} else {
|
} else {
|
||||||
k = (KeyRecord) records.get(records.indexOf(k));
|
k = (KeyRecord) records.get(records.indexOf(k));
|
||||||
k.quantity(k.quantity() + key.quantity());
|
k.quantity(k.quantity() + key.quantity());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void remove( Key key ){
|
public static boolean remove( Key key ){
|
||||||
KeyRecord k = new KeyRecord( key );
|
KeyRecord k = new KeyRecord( key );
|
||||||
if (records.contains(k)){
|
if (records.contains(k)){
|
||||||
k = (KeyRecord) records.get(records.indexOf(k));
|
k = (KeyRecord) records.get(records.indexOf(k));
|
||||||
k.quantity(k.quantity() - key.quantity());
|
k.quantity(k.quantity() - key.quantity());
|
||||||
if (k.quantity() <= 0){
|
if (k.quantity() <= 0){
|
||||||
records.remove(k);
|
return records.remove(k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int keyCount( Key key ){
|
public static int keyCount( Key key ){
|
||||||
|
|
Loading…
Reference in New Issue
Block a user