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


PHP Entity::getEffect方法代码示例

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


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

示例1: addAttackerModifiers

 protected function addAttackerModifiers(Entity $damager)
 {
     if ($damager->hasEffect(Effect::STRENGTH)) {
         $this->setDamage($this->getDamage(self::MODIFIER_BASE) * 0.3 * ($damager->getEffect(Effect::STRENGTH)->getAmplifier() + 1), self::MODIFIER_STRENGTH);
     }
     if ($damager->hasEffect(Effect::WEAKNESS)) {
         $this->setDamage(-($this->getDamage(self::MODIFIER_BASE) * 0.2 * ($damager->getEffect(Effect::WEAKNESS)->getAmplifier() + 1)), self::MODIFIER_WEAKNESS);
     }
 }
开发者ID:worlds1,项目名称:NIGHTMARE,代码行数:9,代码来源:EntityDamageByEntityEvent.php

示例2: addAttackerModifiers

 protected function addAttackerModifiers(Entity $damager)
 {
     if ($damager->hasEffect(Effect::STRENGTH)) {
         $this->setRateDamage(1 + 0.3 * ($damager->getEffect(Effect::STRENGTH)->getAmplifier() + 1), self::MODIFIER_STRENGTH);
     }
     if ($damager->hasEffect(Effect::WEAKNESS)) {
         $eff_level = 1 - 0.2 * ($damager->getEffect(Effect::WEAKNESS)->getAmplifier() + 1);
         if ($eff_level < 0) {
             $eff_level = 0;
         }
         $this->setRateDamage($eff_level, self::MODIFIER_WEAKNESS);
     }
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:13,代码来源:EntityDamageByEntityEvent.php

示例3: __construct

 /**
  * @param Entity    $entity
  * @param int       $cause
  * @param int|int[] $damage
  *
  * @throws \Exception
  */
 public function __construct(Entity $entity, $cause, $damage)
 {
     $this->entity = $entity;
     $this->cause = $cause;
     if (is_array($damage)) {
         $this->modifiers = $damage;
     } else {
         $this->modifiers = [self::MODIFIER_BASE => $damage];
     }
     $this->originals = $this->modifiers;
     if (!isset($this->modifiers[self::MODIFIER_BASE])) {
         throw new \InvalidArgumentException("BASE Damage modifier missing");
     }
     if ($entity->hasEffect(Effect::DAMAGE_RESISTANCE)) {
         $this->setDamage(-($this->getDamage(self::MODIFIER_BASE) * 0.2 * ($entity->getEffect(Effect::DAMAGE_RESISTANCE)->getAmplifier() + 1)), self::MODIFIER_RESISTANCE);
     }
 }
开发者ID:ianju,项目名称:PocketMine-MP,代码行数:24,代码来源:EntityDamageEvent.php

示例4: __construct

 /**
  * @param Entity    $entity
  * @param int       $cause
  * @param int|int[] $damage
  *
  * @throws \Exception
  */
 public function __construct(Entity $entity, $cause, $damage)
 {
     $this->entity = $entity;
     $this->cause = $cause;
     if (is_array($damage)) {
         $this->modifiers = $damage;
     } else {
         $this->modifiers = [self::MODIFIER_BASE => $damage];
     }
     $this->originals = $this->modifiers;
     if (!isset($this->modifiers[self::MODIFIER_BASE])) {
         throw new \InvalidArgumentException("BASE Damage modifier missing");
     }
     //For DAMAGE_RESISTANCE
     if ($cause !== self::CAUSE_VOID and $cause !== self::CAUSE_SUICIDE) {
         if ($entity->hasEffect(Effect::DAMAGE_RESISTANCE)) {
             $RES_level = 1 - 0.2 * ($entity->getEffect(Effect::DAMAGE_RESISTANCE)->getAmplifier() + 1);
             if ($RES_level < 0) {
                 $RES_level = 0;
             }
             $this->setRateDamage($RES_level, self::MODIFIER_RESISTANCE);
         }
     }
     //TODO: add zombie
     if ($entity instanceof Player and $entity->getInventory() instanceof PlayerInventory) {
         switch ($cause) {
             case self::CAUSE_CONTACT:
             case self::CAUSE_ENTITY_ATTACK:
             case self::CAUSE_PROJECTILE:
             case self::CAUSE_FIRE:
             case self::CAUSE_LAVA:
             case self::CAUSE_BLOCK_EXPLOSION:
             case self::CAUSE_ENTITY_EXPLOSION:
             case self::CAUSE_LIGHTNING:
                 $points = 0;
                 foreach ($entity->getInventory()->getArmorContents() as $index => $i) {
                     if ($i->isArmor()) {
                         $points += $i->getArmorValue();
                         $this->usedArmors[$index] = 1;
                     }
                 }
                 if ($points !== 0) {
                     $this->setRateDamage(1 - 0.04 * $points, self::MODIFIER_ARMOR);
                 }
                 //For Protection
                 $spe_Prote = null;
                 switch ($cause) {
                     case self::CAUSE_ENTITY_EXPLOSION:
                     case self::CAUSE_BLOCK_EXPLOSION:
                         $spe_Prote = Enchantment::TYPE_ARMOR_EXPLOSION_PROTECTION;
                         break;
                     case self::CAUSE_FIRE:
                     case self::CAUSE_LAVA:
                         $spe_Prote = Enchantment::TYPE_ARMOR_FIRE_PROTECTION;
                         break;
                     case self::CAUSE_PROJECTILE:
                         $spe_Prote = Enchantment::TYPE_ARMOR_PROJECTILE_PROTECTION;
                         break;
                     default:
                         break;
                 }
                 foreach ($this->usedArmors as $index => $cost) {
                     $i = $entity->getInventory()->getArmorItem($index);
                     if ($i->isArmor()) {
                         $this->EPF += $i->getEnchantmentLevel(Enchantment::TYPE_ARMOR_PROTECTION);
                         $this->fireProtectL = max($this->fireProtectL, $i->getEnchantmentLevel(Enchantment::TYPE_ARMOR_FIRE_PROTECTION));
                         if ($i->getEnchantmentLevel(Enchantment::TYPE_ARMOR_THORNS) > 0) {
                             $this->thornsLevel[$index] = $i->getEnchantmentLevel(Enchantment::TYPE_ARMOR_THORNS);
                         }
                         if ($spe_Prote !== null) {
                             $this->EPF += 2 * $i->getEnchantmentLevel($spe_Prote);
                         }
                     }
                 }
                 break;
             case self::CAUSE_FALL:
                 //Feather Falling
                 $i = $entity->getInventory()->getBoots();
                 if ($i->isArmor()) {
                     $this->EPF += $i->getEnchantmentLevel(Enchantment::TYPE_ARMOR_PROTECTION);
                     $this->EPF += 3 * $i->getEnchantmentLevel(Enchantment::TYPE_ARMOR_FALL_PROTECTION);
                 }
                 break;
             case self::CAUSE_FIRE_TICK:
             case self::CAUSE_SUFFOCATION:
             case self::CAUSE_DROWNING:
             case self::CAUSE_VOID:
             case self::CAUSE_SUICIDE:
             case self::CAUSE_MAGIC:
             case self::CAUSE_CUSTOM:
             case self::CAUSE_STARVATION:
                 break;
             default:
//.........这里部分代码省略.........
开发者ID:iTXTech,项目名称:Genisys,代码行数:101,代码来源:EntityDamageEvent.php


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