Magic_Ling_Pixel_Dungeon/src/com/shatteredpixel/shatteredpixeldungeon/sprites/TrapSprite.java

91 lines
2.5 KiB
Java

/*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2015 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.sprites;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.DungeonTilemap;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap;
import com.watabou.noosa.Image;
import com.watabou.noosa.TextureFilm;
public class TrapSprite extends Image {
private static TextureFilm frames;
private int pos = -1;
//trap colors
public static final int RED = 0;
public static final int ORANGE = 1;
public static final int YELLOW = 2;
public static final int GREEN = 3;
public static final int TEAL = 4;
public static final int VIOLET = 5;
public static final int WHITE = 6;
public static final int GREY = 7;
public static final int BLACK = 8;
//trap shapes
public static final int DOTS = 0;
public static final int WAVES = 1;
public static final int GRILL = 2;
public static final int STARS = 3;
public static final int DIAMOND = 4;
public static final int CROSSHAIR = 5;
public static final int LARGE_DOT = 6;
public TrapSprite() {
super( Assets.TRAPS );
if (frames == null) {
frames = new TextureFilm( texture, 16, 16 );
}
origin.set( 8, 12 );
}
public TrapSprite( int image ) {
this();
reset( image );
}
public void reset( Trap trap ) {
revive();
reset( (trap.active ? trap.color : BLACK) + (trap.shape * 16) );
alpha( 1f );
pos = trap.pos;
x = (pos % Level.WIDTH) * DungeonTilemap.SIZE;
y = (pos / Level.WIDTH) * DungeonTilemap.SIZE;
}
public void reset( int image ) {
frame( frames.get( image ) );
}
}