com.watabou.noosa.audio.Sample Java Examples

The following examples show how to use com.watabou.noosa.audio.Sample. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Battery.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 6 votes vote down vote up
private void apply( Wand wand ) {

        float bonus = Dungeon.hero.ringBuffsBaseZero( RingOfDurability.Durability.class ) * 0.5f;

        if( bonus > 0.0f && Random.Float() < bonus ) {
            GLog.p(TXT_CHARGE_KEEPED);
        } else {
            if( --value <= 0 ) {
                detach(curUser.belongings.backpack);
            }
        }

        if( bonus < 0.0f && Random.Float() > -bonus ) {
            GLog.n(TXT_CHARGE_WASTED);
        } else {
            wand.repair(1);
            GLog.p(TXT_REPAIR_WAND, wand.name());
        }
		
		curUser.sprite.operate(curUser.pos);
		Sample.INSTANCE.play(Assets.SND_LIGHTNING);

        curUser.sprite.centerEmitter().start(Speck.factory(Speck.KIT), 0.05f, 10);
		curUser.spend( TIME_TO_APPLY );
		curUser.busy();
	}
 
Example #2
Source File: TomeOfMastery.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 6 votes vote down vote up
public void choose( HeroSubClass way ) {
		
		detach( curUser.belongings.backpack );
		
		curUser.spend( TomeOfMastery.TIME_TO_READ );
		curUser.busy();
		
		curUser.subClass = way;
		
		curUser.sprite.operate( curUser.pos );
		Sample.INSTANCE.play( Assets.SND_MASTERY );
		
		SpellSprite.show( curUser, SpellSprite.MASTERY );
		curUser.sprite.emitter().burst( Speck.factory( Speck.MASTERY ), 12 );
		GLog.w( "You have chosen the way of the %s!", Utils.capitalize( way.title() ) );
		
//		if (way == HeroSubClass.BERSERKER && curUser.HP <= curUser.HT * Fury.LEVEL) {
//			Buff.affect( curUser, Fury.class );
//		}
	}
 
Example #3
Source File: Chasm.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 6 votes vote down vote up
public static void heroFall( int pos ) {
	
	jumpConfirmed = false;

       if( !useLevitation ) {
           if( Dungeon.hero.heroClass == HeroClass.ACOLYTE ) {
               Sample.INSTANCE.play(Assets.SND_FALLING, 1.0f, 1.0f, 1.2f);
           } else {
               Sample.INSTANCE.play(Assets.SND_FALLING);
           }
       }
	
	if (Dungeon.hero.isAlive()) {
		Dungeon.hero.interrupt();
		InterlevelScene.mode = InterlevelScene.Mode.FALL;
		if (Dungeon.level instanceof RegularLevel) {
			Room room = ((RegularLevel)Dungeon.level).room( pos );
			InterlevelScene.fallIntoPit = room != null && room.type == Room.Type.WEAK_FLOOR;
		} else {
			InterlevelScene.fallIntoPit = false;
		}
		Game.switchScene( InterlevelScene.class );
	} else {
		Dungeon.hero.sprite.visible = false;
	}
}
 
Example #4
Source File: ItemButton.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void createChildren() {
    super.createChildren();

    bg = Chrome.get( Chrome.Type.BUTTON );
    add( bg );

    slot = new ItemSlot() {
        @Override
        protected void onTouchDown() {
            bg.brightness( 1.2f );
            Sample.INSTANCE.play( Assets.SND_CLICK );
        };
        @Override
        protected void onTouchUp() {
            bg.resetColorAlpha();
        }
        @Override
        protected void onClick() {
            ItemButton.this.onClick();
        }
    };
    add( slot );
}
 
Example #5
Source File: ItemSprite.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 6 votes vote down vote up
public void drop() {

		if (heap.isEmpty()) {
			return;
		}
			
		dropInterval = DROP_INTERVAL;
		
		speed.set( 0, -100 );
		acc.set( 0, -speed.y / DROP_INTERVAL * 2 );
		
		if (visible && heap != null && heap.type == Heap.Type.HEAP && heap.peek() instanceof Gold) {
			CellEmitter.center( heap.pos ).burst( Speck.factory( Speck.COIN ), 5 );
			Sample.INSTANCE.play( Assets.SND_GOLD, 1, 1, Random.Float( 0.9f, 1.1f ) );
		}
	}
 
Example #6
Source File: Whetstone.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 6 votes vote down vote up
private void apply( Weapon weapon ) {

        float bonus = Dungeon.hero.ringBuffsBaseZero( RingOfDurability.Durability.class ) * 0.5f;

        if( bonus > 0.0f && Random.Float() < bonus ) {
            GLog.p(TXT_CHARGE_KEEPED);
        } else {
            if( --value <= 0 ) {
                detach(curUser.belongings.backpack);
            }
        }

        if( bonus < 0.0f && Random.Float() > -bonus ) {
            GLog.n(TXT_CHARGE_WASTED);
        } else {
            weapon.repair(1);
            GLog.p(TXT_REPAIR_WEAPON, weapon.name());
        }

		curUser.sprite.operate(curUser.pos);
		Sample.INSTANCE.play(Assets.SND_MISS);

        curUser.sprite.centerEmitter().start(Speck.factory(Speck.KIT), 0.05f, 10);
		curUser.spend( TIME_TO_APPLY );
		curUser.busy();
	}
 
Example #7
Source File: Shopkeeper.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
protected void callForHelp() {

        for (Mob mob : Dungeon.level.mobs) {
            if (mob.pos != pos) {
                mob.beckon( pos );
            }
        }

        if (Dungeon.visible[pos]) {
            CellEmitter.center( pos ).start( Speck.factory(Speck.SCREAM), 0.3f, 3 );
        }

        Sample.INSTANCE.play( Assets.SND_CHALLENGE );
    }
 
Example #8
Source File: GnollShaman.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onRangedAttack( int cell ) {

    MagicMissile.blueLight(sprite.parent, pos, cell,
            new Callback() {
                @Override
                public void call() {
                    onCastComplete();
                }
            });

    Sample.INSTANCE.play(Assets.SND_ZAP);

    super.onRangedAttack( cell );
}
 
Example #9
Source File: WandOfAcidSpray.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
private void onHit( int damage, int cell ) {

        Char ch = Actor.findChar( cell );

        if( ch != null ){
            ch.damage( damage, curUser, Element.ACID );
        }

        if( Dungeon.visible[ cell ] && ( Dungeon.level.solid[ cell ] || ch != null ) ){
            CellEmitter.center( cell ).burst( AcidParticle.BURST, 3 );
//            CellEmitter.get( cell ).start( Speck.factory( Speck.BLAST_ACID, false ), 0.05f, 3 );
            Sample.INSTANCE.play( Assets.SND_PUFF, 0.5f, 0.5f, 1.0f );
        }

    }
 
Example #10
Source File: Game.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onPause() {
	super.onPause();
	
	if (scene != null) {
		scene.pause();
	}
	
	view.onPause();
	Script.reset();
	
	Music.INSTANCE.pause();
	Sample.INSTANCE.pause();
}
 
Example #11
Source File: Scroll.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
protected static void isUsed( Hero user, Scroll scroll ) {

        scroll.setKnown();
        Invisibility.dispel(user);
        user.spendAndNext(TIME_TO_READ);
        Sample.INSTANCE.play(Assets.SND_READ);
        QuickSlot.refresh();

        SpellSprite.show(user, scroll.spellSprite, scroll.spellColour);
        new Flare( 6, 32 ).color(scroll.spellColour, true).show(curUser.sprite, 2f);

    }
 
Example #12
Source File: Game.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onResume() {
	super.onResume();
	
	now = 0;
	view.onResume();
	
	Music.INSTANCE.resume();
	Sample.INSTANCE.resume();
}
 
Example #13
Source File: OilLantern.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onSelect( Integer target ) {

    if (target != null) {

        Ballistica.cast( curUser.pos, target, false, true );

        int cell = Ballistica.trace[ 0 ];

        if( Ballistica.distance > 0 ){
            cell = Ballistica.trace[ 1 ];
        }

        if( Level.flammable[ cell ] || !Level.solid[ cell ] && !Level.chasm[ cell ] ){
            GameScene.add( Blob.seed( cell, 5, Fire.class ) );
        }

        ((OilLantern)curItem).flasks--;
        Invisibility.dispel();

        if( curUser.pos == cell ) {
            GLog.i( TXT_BURN_SELF );
        } else if( Level.flammable[ cell ] || !Level.solid[ cell ] && !Level.chasm[ cell ] ){
            GLog.i( TXT_BURN_TILE );
        } else {
            GLog.i( TXT_BURN_FAIL );
        }

        Sample.INSTANCE.play(Assets.SND_BURNING, 0.6f, 0.6f, 1.5f);
        CellEmitter.get( cell ).burst( FlameParticle.FACTORY, 5 );

        curUser.sprite.operate(cell);
        curUser.busy();
        curUser.spend( Actor.TICK );

    }
}
 
Example #14
Source File: DwarvenKing.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
		public void
        die( Object cause, Element dmg ) {

//            if( buff( Enraged.class ) != null && king != null && king.isAlive() && cause != king ) {
//                for (int n : Level.NEIGHBOURS8) {
//
//                    int p = pos + n;
//
//                    Char ch = findChar(p);
//
//                    if (ch != null && ch.isAlive()) {
//                        ch.damage(Char.absorb(damageRoll(), ch.armorClass() / 2), EXPLOSION, Element.PHYSICAL);
//                    }
//                }
//
//                sprite.emitter().burst( FlameParticle.FACTORY, 10 );
//            }

            if( well > 0 && king != null) {
                GameScene.add( Blob.seed( well, spawnDelay( king.breaks ), Spawner.class ) );
            }

			if (Dungeon.visible[pos]) {
				Sample.INSTANCE.play( Assets.SND_BONES );
                sprite.emitter().burst( Speck.factory( Speck.BONE ), 6 );
			}

            super.die( cause, dmg );
		}
 
Example #15
Source File: Game.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onDestroy() {
	super.onDestroy();
	destroyGame();
	
	Music.INSTANCE.mute();
	Sample.INSTANCE.reset();
}
 
Example #16
Source File: Tengu.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
private void jump() {

        timeToJump = 0;

        for( int i = 0 ; i < 4 ; i++ ){
            int trapPos;
            do{
                trapPos = Random.Int( Level.LENGTH );
            }
            while( !Level.fieldOfView[ trapPos ] || !Level.passable[ trapPos ] || Actor.findChar( trapPos ) != null );

            if( Dungeon.level.map[ trapPos ] == Terrain.INACTIVE_TRAP ){
                Level.set( trapPos, Terrain.BLADE_TRAP );
                GameScene.updateMap( trapPos );
                ScrollOfClairvoyance.discover( trapPos );
            }
        }

        ArrayList<Integer> cells = new ArrayList<>();

        for( Integer cell : Dungeon.level.filterTrappedCells( Dungeon.level.getPassableCellsList() ) ){

            if( pos != cell && !Level.adjacent( pos, cell ) && Level.fieldOfView[ cell ] ) {
                cells.add( cell );
            }

        }

		int newPos = !cells.isEmpty() ? Random.element( cells ) : pos ;

        sprite.move( pos, newPos );
        move( newPos );

        if( Dungeon.visible[ newPos ] ){
            CellEmitter.get( newPos ).burst( Speck.factory( Speck.WOOL ), 6 );
            Sample.INSTANCE.play( Assets.SND_PUFF );
        }

		spend( 1 / moveSpeed() );
	}
 
Example #17
Source File: Gold.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
	public boolean doPickUp( Hero hero ) {
		
		Dungeon.gold += quantity;
		Statistics.goldCollected += quantity;
		Badges.validateGoldCollected();
		
		GameScene.pickUp( this );
		hero.sprite.showStatus( CharSprite.NEUTRAL, TXT_VALUE, quantity );
//		hero.spendAndNext( TIME_TO_PICK_UP );
		
		Sample.INSTANCE.play( Assets.SND_GOLD, 1, 1, Random.Float( 0.9f, 1.1f ) );
		
		return true;
	}
 
Example #18
Source File: Door.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
public static void enter( int pos ) {
	Level.set(pos, Terrain.OPEN_DOOR);
	Dungeon.observe();
	
	if (Dungeon.visible[pos]) {
           GameScene.updateMap( pos );
		Sample.INSTANCE.play( Assets.SND_OPEN );
	}
}
 
Example #19
Source File: Guard.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
public void proc( boolean withShield ) {

        if( target.sprite.visible ) {
            Sample.INSTANCE.play( Assets.SND_HIT, 1, 1, 0.5f );
            target.sprite.showStatus(CharSprite.DEFAULT, TXT_BLOCKED );
//            target.sprite.showStatus(CharSprite.DEFAULT, withShield ? TXT_BLOCKED : TXT_PARRIED);

            if (target == Dungeon.hero) {
                Camera.main.shake(2, 0.1f);
            }
        }
    }
 
Example #20
Source File: IceBlock.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
public void melt() {

		target.resetColorAlpha();
		killAndErase();

		if (visible) {
			Splash.at( target.center(), 0xFFB2D6FF, 5 );
			Sample.INSTANCE.play( Assets.SND_SHATTER, 1, 1, 0.5f );
		}
	}
 
Example #21
Source File: WandOfIceBarrier.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
        public void onSelect( Integer target ){

            if( target != null && !source.equals( target ) ){

                target = Ballistica.cast( source, target, false, false );
                MagicMissile.shards( curUser.sprite.parent, source, target, null );

                if( Ballistica.distance > 0 ){

                    for( int i = 1 ; i <= Ballistica.distance ; i++ ){
                        cells.add( Ballistica.trace[ i ] );
                    }
                }

//                target = Ballistica.cast( source, source + source - target, false, false );
//                MagicMissile.shards( curUser.sprite.parent, source, target, null );
//
//                if( Ballistica.distance > 0 ){
//
//                    for( int i = 1 ; i <= Ballistica.distance ; i++ ){
//                        cells.add( Ballistica.trace[ i ] );
//                    }
//                }
            }

            Sample.INSTANCE.play( Assets.SND_ZAP );
            callback.call();

        }
 
Example #22
Source File: Burning.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void applyVisual() {

    if (target.sprite.visible) {
        Sample.INSTANCE.play( Assets.SND_BURNING );
    }

    target.sprite.add( CharSprite.State.BURNING );
}
 
Example #23
Source File: StartScene.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onTouchDown() {
	
	emitter.revive();
	emitter.start( Speck.factory( Speck.LIGHT ), 0.05f, 7 );
	
	Sample.INSTANCE.play( Assets.SND_CLICK, 1, 1, 1.2f );
	updateClass( cl );
}
 
Example #24
Source File: WandOfThornvines.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onZap( int cell ) {

       // stats of thornvine depend on magic stats and wand stats
       int stats = damageRoll();
       int level = getCharges();

       // first we check the targeted tile
       if( Thornvine.spawnAt( stats, level, cell ) == null ) {

           // then we check the previous tile
           int prevCell = Ballistica.trace[ Ballistica.distance - 1 ];

           if( Thornvine.spawnAt( stats, level, prevCell ) == null ) {

               // and THEN we check all tiles around the targeted
               ArrayList<Integer> candidates = new ArrayList<Integer>();

               for (int n : Level.NEIGHBOURS8) {
                   int pos = cell + n;
                   if( Level.adjacent( pos, prevCell ) && !Level.solid[ pos ] && !Level.chasm[ pos ] && Actor.findChar( pos ) == null ){
                       candidates.add( pos );
                   }
               }

               if ( candidates.size() > 0 ){
                   Thornvine.spawnAt( stats, level, candidates.get( Random.Int( candidates.size() ) ) );
               } else {
                   GLog.i( "nothing happened" );
               }
           }
       }

       CellEmitter.center( cell ).burst( LeafParticle.GENERAL, 5 );
       Sample.INSTANCE.play( Assets.SND_PLANT );
}
 
Example #25
Source File: Blacksmith.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
public static void upgrade( Item item1, Item item2 ) {
		
		Item first, second;
		if (item2.bonus > item1.bonus) {
			first = item2;
			second = item1;
		} else {
			first = item1;
			second = item2;
		}

        Dungeon.hero.sprite.emitter().start(Speck.factory(Speck.UP), 0.2f, 3);
        Sample.INSTANCE.play( Assets.SND_EVOKE );
        Item.evoke( Dungeon.hero );

		if (first.isEquipped( Dungeon.hero )) {
			((EquipableItem)first).doUnequip( Dungeon.hero, true );
		}

		first.upgrade();
        first.state = Math.min( 3, Math.max( first.state, second.state ) + 1 );
        first.fix();

		GLog.p( TXT_LOOKS_BETTER, first.name() );

		Dungeon.hero.spendAndNext( 2f );
//		Badges.validateItemLevelAcquired(first);

		if (second.isEquipped( Dungeon.hero )) {
			((EquipableItem)second).doUnequip( Dungeon.hero, false );
		}
		second.detachAll( Dungeon.hero.belongings.backpack );

		Quest.reforged = true;
		
		Journal.remove( Journal.Feature.TROLL );
	}
 
Example #26
Source File: Thunderstorm.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 4 votes vote down vote up
public static void viewed() {
    GameScene.flash(0x888888);
    Sample.INSTANCE.play(Assets.SND_BLAST);
    Camera.main.shake(3, 0.3f);
    Dungeon.hero.interrupt();
}
 
Example #27
Source File: PrefsButton.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onTouchDown() {
	image.brightness( 1.5f );
	Sample.INSTANCE.play( Assets.SND_CLICK );
}
 
Example #28
Source File: WandOfBlastWave.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 4 votes vote down vote up
protected void fx( int cell, Callback callback ) {
	MagicMissile.blast( curUser.sprite.parent, curUser.pos, cell, callback );
	Sample.INSTANCE.play( Assets.SND_ZAP );
}
 
Example #29
Source File: ThrowingWeapon.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
    public boolean doPickUp( Hero hero ) {

        Class<?>c = getClass();

        if (hero.belongings.weap2 != null && hero.belongings.weap2.getClass() == c) {

            hero.belongings.weap2.quantity += quantity;

            GameScene.pickUp( this );
            Sample.INSTANCE.play(Assets.SND_ITEM);

//            hero.spendAndNext(TIME_TO_PICK_UP);

            QuickSlot.refresh();

            return true;

        } else {

            return super.doPickUp(hero);

        }

    }
 
Example #30
Source File: ScrollOfRaiseDead.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void doRead() {

       ArrayList<Wraith> summoned = Wraith.spawnAround( curUser.magicPower() / 3, curUser.pos, 1 );

       for( Wraith w : summoned ){

           float duration = Random.Int( 16, 20 ) * ( 110 + curUser.magicPower() ) / 100;

           BuffActive.add( w, Controlled.class, duration );

       }

       Sample.INSTANCE.play(Assets.SND_DEATH);

	super.doRead();
}