本文整理汇总了Java中com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.NPC类的典型用法代码示例。如果您正苦于以下问题:Java NPC类的具体用法?Java NPC怎么用?Java NPC使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NPC类属于com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs包,在下文中一共展示了NPC类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Interact
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.NPC; //导入依赖的package包/类
public Interact( NPC npc ) {
this.npc = npc;
}
示例2: actInteract
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.NPC; //导入依赖的package包/类
private boolean actInteract( HeroAction.Interact action ) {
NPC npc = action.npc;
if (Level.adjacent( pos, npc.pos )) {
ready();
sprite.turnTo( pos, npc.pos );
npc.interact();
return false;
} else {
if (Level.fieldOfView[npc.pos] && getCloser( npc.pos )) {
return true;
} else {
ready();
return false;
}
}
}
示例3: handle
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.NPC; //导入依赖的package包/类
public boolean handle( int cell ) {
if (cell == -1) {
return false;
}
Char ch;
Heap heap;
if (Dungeon.level.map[cell] == Terrain.ALCHEMY && cell != pos) {
curAction = new HeroAction.Cook( cell );
} else
if (Level.fieldOfView[cell] && (ch = Actor.findChar( cell )) instanceof Mob) {
if (ch instanceof NPC) {
curAction = new HeroAction.Interact( (NPC)ch );
} else {
curAction = new HeroAction.Attack( ch );
}
} else if ((heap = Dungeon.level.heaps.get( cell )) != null) {
switch (heap.type) {
case HEAP:
curAction = new HeroAction.PickUp( cell );
break;
case FOR_SALE:
curAction = heap.size() == 1 && heap.peek().price() > 0 ?
new HeroAction.Buy( cell ) :
new HeroAction.PickUp( cell );
break;
default:
curAction = new HeroAction.OpenChest( cell );
}
} else if (Dungeon.level.map[cell] == Terrain.LOCKED_DOOR || Dungeon.level.map[cell] == Terrain.LOCKED_EXIT) {
curAction = new HeroAction.Unlock( cell );
} else if (cell == Dungeon.level.exit) {
curAction = new HeroAction.Descend( cell );
} else if (cell == Dungeon.level.entrance) {
curAction = new HeroAction.Ascend( cell );
} else {
curAction = new HeroAction.Move( cell );
lastAction = null;
}
return act();
}
示例4: WndQuest
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.NPC; //导入依赖的package包/类
public WndQuest( NPC questgiver, String text ) {
super( questgiver.sprite(), Utils.capitalize( questgiver.name ), text );
}
示例5: actInteract
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.NPC; //导入依赖的package包/类
private boolean actInteract( HeroAction.Interact action ) {
NPC npc = action.npc;
if (Dungeon.level.adjacent( pos, npc.pos )) {
ready();
sprite.turnTo( pos, npc.pos );
return npc.interact();
} else {
if (fieldOfView[npc.pos] && getCloser( npc.pos )) {
return true;
} else {
ready();
return false;
}
}
}
示例6: handle
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.NPC; //导入依赖的package包/类
public boolean handle( int cell ) {
if (cell == -1) {
return false;
}
Char ch;
Heap heap;
if (Dungeon.level.map[cell] == Terrain.ALCHEMY && cell != pos) {
curAction = new HeroAction.Alchemy( cell );
} else if (fieldOfView[cell] && (ch = Actor.findChar( cell )) instanceof Mob) {
if (ch instanceof NPC) {
curAction = new HeroAction.Interact( (NPC)ch );
} else {
curAction = new HeroAction.Attack( ch );
}
} else if ((heap = Dungeon.level.heaps.get( cell )) != null
//moving to an item doesn't auto-pickup when enemies are near...
&& (visibleEnemies.size() == 0 || cell == pos ||
//...but only for standard heaps, chests and similar open as normal.
(heap.type != Type.HEAP && heap.type != Type.FOR_SALE))) {
switch (heap.type) {
case HEAP:
curAction = new HeroAction.PickUp( cell );
break;
case FOR_SALE:
curAction = heap.size() == 1 && heap.peek().price() > 0 ?
new HeroAction.Buy( cell ) :
new HeroAction.PickUp( cell );
break;
default:
curAction = new HeroAction.OpenChest( cell );
}
} else if (Dungeon.level.map[cell] == Terrain.LOCKED_DOOR || Dungeon.level.map[cell] == Terrain.LOCKED_EXIT) {
curAction = new HeroAction.Unlock( cell );
} else if (cell == Dungeon.level.exit && Dungeon.depth < 26) {
curAction = new HeroAction.Descend( cell );
} else if (cell == Dungeon.level.entrance) {
curAction = new HeroAction.Ascend( cell );
} else {
curAction = new HeroAction.Move( cell );
lastAction = null;
}
return true;
}
示例7: WndQuest
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.NPC; //导入依赖的package包/类
public WndQuest( NPC questgiver, String text ) {
super( questgiver.sprite(), Messages.titleCase( questgiver.name ), text );
}
示例8: onZap
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.NPC; //导入依赖的package包/类
@Override
protected void onZap(Ballistica bolt) {
Char ch = Actor.findChar(bolt.collisionPos);
if (ch != null){
if (!(ch instanceof Mob) || ch instanceof NPC){
return;
}
Mob enemy = (Mob) ch;
float corruptingPower = 2 + level();
//base enemy resistance is usually based on their exp, but in special cases it is based on other criteria
float enemyResist = 1 + enemy.EXP;
if (ch instanceof Mimic || ch instanceof Statue){
enemyResist = 1 + Dungeon.depth;
} else if (ch instanceof Piranha || ch instanceof Bee) {
enemyResist = 1 + Dungeon.depth/2f;
} else if (ch instanceof Wraith) {
//this is so low because wraiths are always at max hp
enemyResist = 1 + Dungeon.depth/5f;
} else if (ch instanceof Yog.BurningFist || ch instanceof Yog.RottingFist) {
enemyResist = 1 + 30;
} else if (ch instanceof Yog.Larva || ch instanceof King.Undead){
enemyResist = 1 + 5;
} else if (ch instanceof Swarm){
//child swarms don't give exp, so we force this here.
enemyResist = 1 + 3;
}
//100% health: 3x resist 75%: 2.1x resist 50%: 1.5x resist 25%: 1.1x resist
enemyResist *= 1 + 2*Math.pow(enemy.HP/(float)enemy.HT, 2);
//debuffs placed on the enemy reduce their resistance
for (Buff buff : enemy.buffs()){
if (MAJOR_DEBUFFS.containsKey(buff.getClass())) enemyResist *= MAJOR_DEBUFF_WEAKEN;
else if (MINOR_DEBUFFS.containsKey(buff.getClass())) enemyResist *= MINOR_DEBUFF_WEAKEN;
else if (buff.type == Buff.buffType.NEGATIVE) enemyResist *= MINOR_DEBUFF_WEAKEN;
}
//cannot re-corrupt or doom an enemy, so give them a major debuff instead
if(enemy.buff(Corruption.class) != null || enemy.buff(Doom.class) != null){
enemyResist = corruptingPower*.99f;
}
if (corruptingPower > enemyResist){
corruptEnemy( enemy );
} else {
float debuffChance = corruptingPower / enemyResist;
if (Random.Float() < debuffChance){
debuffEnemy( enemy, MAJOR_DEBUFFS);
} else {
debuffEnemy( enemy, MINOR_DEBUFFS);
}
}
processSoulMark(ch, chargesPerCast());
} else {
Dungeon.level.press(bolt.collisionPos, null);
}
}
示例9: handle
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.NPC; //导入依赖的package包/类
public boolean handle( int cell ) {
if (cell == -1) {
return false;
}
Char ch;
Heap heap;
if (Dungeon.level.map[cell] == Terrain.ALCHEMY && cell != pos) {
curAction = new HeroAction.Alchemy( cell );
} else if (fieldOfView[cell] && (ch = Actor.findChar( cell )) instanceof Mob) {
if (ch instanceof NPC) {
curAction = new HeroAction.Interact( (NPC)ch );
} else {
curAction = new HeroAction.Attack( ch );
}
} else if ((heap = Dungeon.level.heaps.get( cell )) != null
//moving to an item doesn't auto-pickup when enemies are near...
&& (visibleEnemies.size() == 0 || cell == pos ||
//...but only for standard heaps, chests and similar open as normal.
(heap.type != Type.HEAP && heap.type != Type.FOR_SALE))) {
switch (heap.type) {
case HEAP:
curAction = new HeroAction.PickUp( cell );
break;
case FOR_SALE:
curAction = heap.size() == 1 && heap.peek().price() > 0 ?
new HeroAction.Buy( cell ) :
new HeroAction.PickUp( cell );
break;
default:
curAction = new HeroAction.OpenChest( cell );
}
} else if (Dungeon.level.map[cell] == Terrain.LOCKED_DOOR || Dungeon.level.map[cell] == Terrain.LOCKED_EXIT) {
curAction = new HeroAction.Unlock( cell );
} else if (cell == Dungeon.level.exit && Dungeon.depth < 26) {
curAction = new HeroAction.Descend( cell );
} else if (cell == Dungeon.level.entrance) {
curAction = new HeroAction.Ascend( cell );
} else {
curAction = new HeroAction.Move( cell );
lastAction = null;
}
if (ready)
return act();
else
return false;
}
示例10: onZap
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.NPC; //导入依赖的package包/类
@Override
protected void onZap( int cell ) {
Char ch = Actor.findChar( cell );
if (ch == curUser) {
setKnown();
ScrollOfTeleportation.teleportHero( curUser );
} else if (ch != null && !(ch instanceof NPC)) {
int count = 10;
int pos;
do {
pos = Dungeon.level.randomRespawnCell();
if (count-- <= 0) {
break;
}
} while (pos == -1);
if (pos == -1) {
GLog.w( ScrollOfTeleportation.TXT_NO_TELEPORT );
} else {
ch.pos = pos;
ch.sprite.place( ch.pos );
ch.sprite.visible = Dungeon.visible[pos];
GLog.i( curUser.name + " teleported " + ch.name + " to somewhere" );
}
} else {
GLog.i( "nothing happened" );
}
}