当前位置: 首页>>代码示例>>Java>>正文


Java Living.damage方法代码示例

本文整理汇总了Java中org.spongepowered.api.entity.living.Living.damage方法的典型用法代码示例。如果您正苦于以下问题:Java Living.damage方法的具体用法?Java Living.damage怎么用?Java Living.damage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.spongepowered.api.entity.living.Living的用法示例。


在下文中一共展示了Living.damage方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: canDamage

import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
public static boolean canDamage(IActiveCharacter character, Living l) {
	if (character.getPlayer() == l) {
		return false;
	}
	if (l.getType() == EntityTypes.PLAYER) {
		if (character.hasParty()) {
			IActiveCharacter c = globalScope.characterService.getCharacter(l.getUniqueId());
			if (character.getParty().getPlayers().contains(c)) {
				return false;
			}
		}
	}
	DamageSource build = new SpongeDamageSourceBuilder()
			.type(NDamageType.DAMAGE_CHECK)
			.absolute()
			.build();

	return l.damage(0, build);
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:20,代码来源:Utils.java

示例2: cast

import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
@Override
public SkillResult cast(IActiveCharacter iActiveCharacter, ExtendedSkillInfo extendedSkillInfo, SkillModifier skillModifier) {
	int r = (int) settings.getLevelNodeValue(SkillNodes.RADIUS, extendedSkillInfo.getTotalLevel());
	Set<Entity> nearbyEntities = Utils.getNearbyEntities(iActiveCharacter.getPlayer().getLocation(), r);
	float damage = settings.getLevelNodeValue(SkillNodes.DAMAGE, extendedSkillInfo.getTotalLevel());
	SkillDamageSourceBuilder builder = new SkillDamageSourceBuilder();
	builder.fromSkill(this);
	builder.setCaster(iActiveCharacter);
	SkillDamageSource src = builder.build();
	for (Entity e : nearbyEntities) {
		if (Utils.isLivingEntity(e)) {
			Living l = (Living) e;
			if (Utils.canDamage(iActiveCharacter, l)) {
				l.damage(damage, src);
				Decorator.strikeLightning(l);
			}
		}
	}
	return SkillResult.OK;
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:21,代码来源:SkillMegabolt.java

示例3: castOn

import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
@Override
public SkillResult castOn(Living target, IActiveCharacter source, ExtendedSkillInfo info) {
	long duration = getLongNodeValue(info, SkillNodes.DURATION);
	double damage = getDoubleNodeValue(info, SkillNodes.DAMAGE);
	IEntity e = entityService.get(target);
	StunEffect stunEffect = new StunEffect(e, duration);
	effectService.addEffect(stunEffect, e, this);
	if (damage > 0) {
		SkillDamageSourceBuilder builder = new SkillDamageSourceBuilder();
		builder.fromSkill(this);
		builder.setTarget(e);
		builder.setCaster(source);
		SkillDamageSource s = builder.build();
		target.damage(damage, s);
	}
	return SkillResult.OK;
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:18,代码来源:Stun.java

示例4: castOn

import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
@Override
public SkillResult castOn(Living target, IActiveCharacter source, ExtendedSkillInfo info) {
	Player entity = source.getEntity();
	Double max = entity.get(Keys.MAX_HEALTH).get();
	Double a = entity.get(Keys.HEALTH).get();
	a = max - a;
	a *= getFloatNodeValue(info, SkillNodes.MULTIPLIER);
	max = getDoubleNodeValue(info, "max-damage");
	if (max > 0) {
		a = a < max ? max : a;
	}
	SkillDamageSource build = new SkillDamageSourceBuilder()
			.fromSkill(this)
			.setTarget(entityService.get(target))
			.setCaster(source).build();
	target.damage(a, build);
	return SkillResult.CANCELLED;
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:19,代码来源:Empathy.java

示例5: freezeEntities

import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
private void freezeEntities() {
  Zombie boss = getBoss().get();

  double total = 0;
  for (Living entity : getContained(Living.class)) {
    if (entity.equals(boss)) {
      continue;
    }
    BlockType curType = entity.getLocation().getBlockType();
    if (curType != BlockTypes.WATER && curType != BlockTypes.FLOWING_WATER) {
      continue;
    }
    if (entity instanceof Zombie) {
      entity.offer(Keys.HEALTH, 0D);
      EntityHealthUtil.heal(boss, 1);
      total += .02;
    } else if (!Probability.getChance(5)) {
      entity.damage(Probability.getRandom(25), EntityDamageSource.builder().entity(boss).type(DamageTypes.MAGIC).build());
    }
  }
  modifyDifficulty(-total);
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:23,代码来源:PatientXInstance.java

示例6: castOn

import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
@Override
public SkillResult castOn(Living target, IActiveCharacter source, ExtendedSkillInfo info) {
	float damage = settings.getLevelNodeValue(SkillNodes.DAMAGE, info.getTotalLevel());
	SkillDamageSourceBuilder build = new SkillDamageSourceBuilder();
	build.fromSkill(this);
	build.setCaster(source);
	target.damage(damage, build.build());
	Decorator.strikeLightning(target);
	return SkillResult.OK;
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:11,代码来源:SkillLightning.java

示例7: onTick

import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
@Override
public void onTick() {
	Living entity = getConsumer().getEntity();
	if (Utils.canDamage(caster, entity)) {
		entity.damage(damage, damageSource);
		//todo some particles
		NtRpgPlugin.GlobalScope.entityService.healEntity(caster, damage, damageSource.getSkill());
	}
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:10,代码来源:PandemicEffect.java

示例8: damage

import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
public void damage() {
	Living entity = getConsumer().getEntity();
	SkillDamageSourceBuilder build = new SkillDamageSourceBuilder();
	build.setEffect(this);
	build.setCaster(source);
	build.type(NDamageType.LIGHTNING);
	entity.damage(model.damage, build.build());
	Decorator.strikeLightning(entity);
	model.timesToHit--;
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:11,代码来源:MultiboltEffect.java

示例9: run

import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
@Override
public void run(Living owner, Living target, DamageEntityEvent event) {
  double damage = Probability.getRandom(target instanceof Player ? 3 : 10) * 50;
  if (target.damage(damage, damageSource(owner))) {
    notify(owner, Text.of(TextColors.YELLOW, "Your sword tears through the flesh of its victim."));
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:8,代码来源:Decimate.java

示例10: run

import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
@Override
public void run(Living owner, Living attacker, DamageEntityEvent event) {
  double reflectionAmount = event.getBaseDamage() * modifier;
  event.setBaseDamage(event.getBaseDamage() - reflectionAmount);
  attacker.damage(Math.max(minimum, reflectionAmount), damageSource(owner));
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:7,代码来源:DamageReflection.java

示例11: damage

import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
public void damage(T boss, Living entity) {
  entity.damage(
      getDamage(boss.getDetail()),
      EntityDamageSource.builder().type(DamageTypes.ATTACK).entity(boss.getTargetEntity().get()).build()
  );
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:7,代码来源:DamageNearby.java

示例12: run

import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
@Override
public void run(Living owner, Living target, DamageEntityEvent event) {
  EntityHealthUtil.heal(owner, 5);

  ParticleGenerator.mobSpawnerFlames(target.getLocation(), 4);

  target.damage(20, damageSource(owner));

  notify(owner, Text.of(TextColors.YELLOW, "Your weapon glows dimly."));
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:11,代码来源:HealingLight.java


注:本文中的org.spongepowered.api.entity.living.Living.damage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。