v0.3.0: added support for item sprites to contain emitters
This commit is contained in:
@@ -37,6 +37,7 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.QuickSlotButton;
|
|||||||
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.audio.Sample;
|
import com.watabou.noosa.audio.Sample;
|
||||||
|
import com.watabou.noosa.particles.Emitter;
|
||||||
import com.watabou.utils.Bundlable;
|
import com.watabou.utils.Bundlable;
|
||||||
import com.watabou.utils.Bundle;
|
import com.watabou.utils.Bundle;
|
||||||
import com.watabou.utils.Callback;
|
import com.watabou.utils.Callback;
|
||||||
@@ -358,6 +359,8 @@ public class Item implements Bundlable {
|
|||||||
public ItemSprite.Glowing glowing() {
|
public ItemSprite.Glowing glowing() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Emitter emitter() { return null; }
|
||||||
|
|
||||||
public String info() {
|
public String info() {
|
||||||
return desc();
|
return desc();
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||||
|
import com.watabou.noosa.particles.Emitter;
|
||||||
import com.watabou.utils.PointF;
|
import com.watabou.utils.PointF;
|
||||||
import com.watabou.utils.Random;
|
import com.watabou.utils.Random;
|
||||||
|
|
||||||
@@ -49,6 +50,9 @@ public class ItemSprite extends MovieClip {
|
|||||||
public Heap heap;
|
public Heap heap;
|
||||||
|
|
||||||
private Glowing glowing;
|
private Glowing glowing;
|
||||||
|
//FIXME: a lot of this emitter functionality isn't very well implemented.
|
||||||
|
//right now I want to ship 0.3.0, but should refactor in the future.
|
||||||
|
protected Emitter emitter;
|
||||||
private float phase;
|
private float phase;
|
||||||
private boolean glowUp;
|
private boolean glowUp;
|
||||||
|
|
||||||
@@ -101,6 +105,12 @@ public class ItemSprite extends MovieClip {
|
|||||||
dropInterval = 0;
|
dropInterval = 0;
|
||||||
|
|
||||||
heap = null;
|
heap = null;
|
||||||
|
if (emitter != null) emitter.revive();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void visible(boolean value){
|
||||||
|
this.visible = value;
|
||||||
|
if (emitter != null) emitter.visible = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PointF worldToCamera( int cell ) {
|
public PointF worldToCamera( int cell ) {
|
||||||
@@ -150,6 +160,13 @@ public class ItemSprite extends MovieClip {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ItemSprite view(Item item){
|
public ItemSprite view(Item item){
|
||||||
|
if (this.emitter != null) this.emitter.on = false;
|
||||||
|
Emitter emitter = item.emitter();
|
||||||
|
if (emitter != null && parent != null) {
|
||||||
|
emitter.pos( this );
|
||||||
|
parent.add( emitter );
|
||||||
|
this.emitter = emitter;
|
||||||
|
}
|
||||||
return view(item.image(), item.glowing());
|
return view(item.image(), item.glowing());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +177,7 @@ public class ItemSprite extends MovieClip {
|
|||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
super.update();
|
super.update();
|
||||||
@@ -210,7 +227,7 @@ public class ItemSprite extends MovieClip {
|
|||||||
ba = glowing.blue * value;
|
ba = glowing.blue * value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int pick( int index, int x, int y ) {
|
public static int pick( int index, int x, int y ) {
|
||||||
Bitmap bmp = TextureCache.get( Assets.ITEMS ).bitmap;
|
Bitmap bmp = TextureCache.get( Assets.ITEMS ).bitmap;
|
||||||
int rows = bmp.getWidth() / SIZE;
|
int rows = bmp.getWidth() / SIZE;
|
||||||
|
|||||||
@@ -133,12 +133,14 @@ public class ItemSlot extends Button {
|
|||||||
if (item == null) {
|
if (item == null) {
|
||||||
|
|
||||||
active = false;
|
active = false;
|
||||||
icon.visible = topLeft.visible = topRight.visible = bottomRight.visible = false;
|
topLeft.visible = topRight.visible = bottomRight.visible = false;
|
||||||
|
icon.visible(false);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
active = true;
|
active = true;
|
||||||
icon.visible = topLeft.visible = topRight.visible = bottomRight.visible = true;
|
topLeft.visible = topRight.visible = bottomRight.visible = true;
|
||||||
|
icon.visible(true);
|
||||||
|
|
||||||
icon.view( item );
|
icon.view( item );
|
||||||
|
|
||||||
|
|||||||
@@ -365,6 +365,7 @@ public class Toolbar extends Component {
|
|||||||
visible =
|
visible =
|
||||||
active =
|
active =
|
||||||
false;
|
false;
|
||||||
|
if (emitter != null) emitter.on = false;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
float p = left / DURATION;
|
float p = left / DURATION;
|
||||||
|
|||||||
Reference in New Issue
Block a user