v0.5.0: cell selecting now prioritizes monster sprites over tiles on the ground.

This commit is contained in:
Evan Debenham 2017-01-02 00:31:55 -05:00 committed by Evan Debenham
parent bb99f8e351
commit 3273092691

View File

@ -20,11 +20,13 @@
*/ */
package com.shatteredpixel.shatteredpixeldungeon.scenes; package com.shatteredpixel.shatteredpixeldungeon.scenes;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTilemap; import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTilemap;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.watabou.input.Touchscreen.Touch; import com.watabou.input.Touchscreen.Touch;
import com.watabou.noosa.Camera;
import com.watabou.noosa.TouchArea; import com.watabou.noosa.TouchArea;
import com.watabou.utils.GameMath; import com.watabou.utils.GameMath;
import com.watabou.utils.PointF; import com.watabou.utils.PointF;
@ -52,6 +54,14 @@ public class CellSelector extends TouchArea {
} else { } else {
PointF p = Camera.main.screenToCamera( (int)touch.current.x, (int)touch.current.y );
for (Char mob : Dungeon.level.mobs){
if (mob.sprite != null && mob.sprite.overlapsPoint( p.x, p.y)){
select( mob.pos );
return;
}
}
select( ((DungeonTilemap)target).screenToTile( select( ((DungeonTilemap)target).screenToTile(
(int)touch.current.x, (int)touch.current.x,
(int)touch.current.y, (int)touch.current.y,