v0.9.1b: added some vfx to scroll of transmutation and recycle spell
This commit is contained in:
parent
d4ba5f0941
commit
bdfa4351bf
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2015 Oleg Dolya
|
||||
*
|
||||
* Shattered Pixel Dungeon
|
||||
* Copyright (C) 2014-2021 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.effects;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.ui.Component;
|
||||
|
||||
public class Transmuting extends Component {
|
||||
private static final int SIZE = 16;
|
||||
|
||||
private enum Phase {
|
||||
FADE_IN, TRANSMUTING, FADE_OUT
|
||||
}
|
||||
|
||||
private static final float FADE_IN_TIME = 0.2f;
|
||||
private static final float TRANSMUTING_TIME = 1.4f;
|
||||
private static final float FADE_OUT_TIME = 0.4f;
|
||||
|
||||
private static final float ALPHA = 0.6f;
|
||||
|
||||
ItemSprite oldSprite;
|
||||
ItemSprite newSprite;
|
||||
|
||||
private Char target;
|
||||
|
||||
private Phase phase;
|
||||
private float duration;
|
||||
private float passed;
|
||||
|
||||
public Transmuting( Item oldItem, Item newItem ){
|
||||
oldSprite = new ItemSprite(oldItem);
|
||||
oldSprite.originToCenter();
|
||||
add(oldSprite);
|
||||
newSprite = new ItemSprite(newItem);
|
||||
newSprite.originToCenter();
|
||||
add(newSprite);
|
||||
|
||||
oldSprite.alpha(0f);
|
||||
newSprite.alpha(0f);
|
||||
|
||||
phase = Phase.FADE_IN;
|
||||
duration = FADE_IN_TIME;
|
||||
passed = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
super.update();
|
||||
|
||||
oldSprite.x = newSprite.x = target.sprite.center().x - SIZE / 2;
|
||||
oldSprite.y = newSprite.y = target.sprite.y - SIZE;
|
||||
|
||||
switch (phase) {
|
||||
case FADE_IN:
|
||||
oldSprite.alpha( passed / duration * ALPHA );
|
||||
oldSprite.scale.set( passed / duration );
|
||||
break;
|
||||
case TRANSMUTING:
|
||||
oldSprite.alpha((TRANSMUTING_TIME - passed) / duration * ALPHA);
|
||||
newSprite.alpha(passed / duration * ALPHA);
|
||||
break;
|
||||
case FADE_OUT:
|
||||
newSprite.alpha( (1 - passed / duration) * ALPHA );
|
||||
newSprite.scale.set( 1 + passed / duration );
|
||||
break;
|
||||
}
|
||||
|
||||
if ((passed += Game.elapsed) > duration) {
|
||||
switch (phase) {
|
||||
case FADE_IN:
|
||||
phase = Phase.TRANSMUTING;
|
||||
duration = TRANSMUTING_TIME;
|
||||
break;
|
||||
case TRANSMUTING:
|
||||
phase = Phase.FADE_OUT;
|
||||
duration = FADE_OUT_TIME;
|
||||
break;
|
||||
case FADE_OUT:
|
||||
kill();
|
||||
break;
|
||||
}
|
||||
|
||||
passed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static void show( Char ch, Item oldItem, Item newItem ) {
|
||||
|
||||
if (!ch.sprite.visible) {
|
||||
return;
|
||||
}
|
||||
|
||||
Transmuting sprite = new Transmuting( oldItem, newItem );
|
||||
sprite.target = ch;
|
||||
ch.sprite.parent.add( sprite );
|
||||
}
|
||||
|
||||
}
|
|
@ -24,6 +24,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items.scrolls;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.Challenges;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Transmuting;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
|
@ -117,7 +118,7 @@ public class ScrollOfTransmutation extends InventoryScroll {
|
|||
if (result.isIdentified()){
|
||||
Catalog.setSeen(result.getClass());
|
||||
}
|
||||
//TODO might be nice to have a spellsprite for this, like Enchanting
|
||||
Transmuting.show(curUser, item, result);
|
||||
curUser.sprite.emitter().start(Speck.factory(Speck.CHANGE), 0.2f, 10);
|
||||
GLog.p( Messages.get(this, "morph") );
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@ package com.shatteredpixel.shatteredpixeldungeon.items.spells;
|
|||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Challenges;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Transmuting;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
|
||||
|
@ -73,7 +75,8 @@ public class Recycle extends InventorySpell {
|
|||
if (!result.collect()){
|
||||
Dungeon.level.drop(result, curUser.pos).sprite.drop();
|
||||
}
|
||||
//TODO visuals
|
||||
Transmuting.show(curUser, item, result);
|
||||
curUser.sprite.emitter().start(Speck.factory(Speck.CHANGE), 0.2f, 10);
|
||||
}
|
||||
|
||||
public static boolean isRecyclable(Item item){
|
||||
|
|
Loading…
Reference in New Issue
Block a user