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


PHP Effect::getId方法代码示例

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


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

示例1: addEffect

 public function addEffect(Effect $effect)
 {
     if (isset($this->effects[$effect->getId()])) {
         $oldEffect = $this->effects[$effect->getId()];
         if (abs($effect->getAmplifier()) <= $oldEffect->getAmplifier() or abs($effect->getAmplifier()) === abs($oldEffect->getAmplifier()) and $effect->getDuration() < $oldEffect->getDuration()) {
             return;
         }
         $effect->add($this, true);
     } else {
         $effect->add($this, false);
     }
     $this->effects[$effect->getId()] = $effect;
     $this->recalculateEffectColor();
     if ($effect->getId() === Effect::HEALTH_BOOST) {
         $this->setHealth($this->getHealth() + 4 * ($effect->getAmplifier() + 1));
     }
 }
开发者ID:RedstoneAlmeida,项目名称:Steadfast2,代码行数:17,代码来源:Entity.php

示例2: addEffect

 public function addEffect(Effect $effect)
 {
     if (isset($this->effects[$effect->getId()])) {
         $oldEffect = $this->effects[$effect->getId()];
         if (abs($effect->getAmplifier()) <= $oldEffect->getAmplifier() or abs($effect->getAmplifier()) === abs($oldEffect->getAmplifier()) and $effect->getDuration() < $oldEffect->getDuration()) {
             return;
         }
         $effect->add($this, true);
     } else {
         $effect->add($this, false);
     }
     $this->effects[$effect->getId()] = $effect;
     $this->recalculateEffectColor();
     if ($effect->getId() === Effect::HEALTH_BOOST) {
         $this->setHealth($this->getHealth() + 4 * ($effect->getAmplifier() + 1));
     }
     if ($effect->getId() === Effect::HEALING) {
         if ($this->getHealth() + 2 * ($effect->getAmplifier() + 1) > $this->getMaxHealth()) {
             $ev = new EntityRegainHealthEvent($this, $this->getMaxHealth() - $this->getHealth(), EntityRegainHealthEvent::CAUSE_MAGIC);
             $this->heal($ev->getAmount(), $ev);
         } else {
             $ev = new EntityRegainHealthEvent($this, 2 * ($effect->getAmplifier() + 1), EntityRegainHealthEvent::CAUSE_MAGIC);
             $this->heal($ev->getAmount(), $ev);
         }
     }
     if ($effect->getId() === Effect::HARMING) {
         if ($this->getHealth() - 3 * ($effect->getAmplifier() + 1) < 0) {
             $ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_MAGIC, $this->getHealth());
             $this->attack($ev->getFinalDamage(), $ev);
         } else {
             $ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_MAGIC, 3 * ($effect->getAmplifier() + 1));
             $this->attack($ev->getFinalDamage(), $ev);
         }
     }
 }
开发者ID:Cecil107,项目名称:PocketMine-0.13.0,代码行数:35,代码来源:Entity.php

示例3: addEffect

 public function addEffect(Effect $effect)
 {
     Server::getInstance()->getPluginManager()->callEvent($ev = new EntityEffectAddEvent($this, $effect));
     if ($ev->isCancelled()) {
         return false;
     }
     if ($effect->getId() === Effect::HEALTH_BOOST) {
         $this->setHealth($this->getHealth() + 4 * ($effect->getAmplifier() + 1));
     }
     if ($effect->getId() === Effect::ABSORPTION and $this instanceof Human) {
         $this->setAbsorption(4 * ($effect->getAmplifier() + 1));
     }
     if (isset($this->effects[$effect->getId()])) {
         $oldEffect = $this->effects[$effect->getId()];
         if ($effect->getAmplifier() <= $oldEffect->getAmplifier() and $effect->getDuration() < $oldEffect->getDuration()) {
             return;
         }
         $effect->add($this, true, $oldEffect);
     } else {
         $effect->add($this, false);
     }
     $this->effects[$effect->getId()] = $effect;
     $this->recalculateEffectColor();
     return true;
 }
开发者ID:kniffo80,项目名称:Genisys,代码行数:25,代码来源:Entity.php

示例4: switchLevelVanish

 /**
  * Allow to switch between levels Vanished!
  * You need to teleport the player to a different level in order to call this event
  *
  * @param Player $player
  * @param Level $origin
  * @param Level $target
  */
 public function switchLevelVanish(Player $player, Level $origin, Level $target)
 {
     if ($origin->getName() !== $target->getName() && $this->isVanished($player)) {
         // This will be used if the specified player has "noPacket" enabled.
         // A temporal check will be used for "the other players".
         $noPacket = $this->hasNoPacket($player);
         // Just as prevention if any player has "noPacket" disabled...
         $pk = new MobEffectPacket();
         $pk->effectId = $this->invisibilityEffect->getId();
         $pk->amplifier = $this->invisibilityEffect->getAmplifier();
         $pk->particles = $this->invisibilityEffect->isVisible();
         $pk->duration = $this->invisibilityEffect->getDuration();
         // Show to origin's players
         $pk->eventId = MobEffectPacket::EVENT_REMOVE;
         foreach ($origin->getPlayers() as $p) {
             if ($p !== $player) {
                 if ($this->isVanished($player)) {
                     if (!$noPacket) {
                         $pk->eid = $player->getId();
                         $p->dataPacket($pk);
                     } else {
                         $p->showPlayer($player);
                     }
                 }
                 if ($this->isVanished($p)) {
                     if (!$this->hasNoPacket($p)) {
                         $pk->eid = $p->getId();
                         $player->dataPacket($pk);
                     } else {
                         $player->showPlayer($p);
                     }
                 }
             }
         }
         // Hide to target's players
         $pk->eventId = MobEffectPacket::EVENT_ADD;
         foreach ($target->getPlayers() as $p) {
             if ($p !== $player) {
                 if ($this->isVanished($player)) {
                     if (!$noPacket) {
                         $pk->eid = $player->getId();
                         $p->dataPacket($pk);
                     } else {
                         $p->hidePlayer($player);
                     }
                 }
                 if ($this->isVanished($p)) {
                     if (!$this->hasNoPacket($p)) {
                         $pk->eid = $p->getId();
                         $player->dataPacket($pk);
                     } else {
                         $player->hidePlayer($p);
                     }
                 }
             }
         }
     }
 }
开发者ID:mwvent,项目名称:WattzEssentialsPE,代码行数:66,代码来源:Loader.php

示例5: addEffect

 public function addEffect(Effect $effect)
 {
     if ($effect->getId() === Effect::HEALTH_BOOST) {
         $this->setHealth($this->getHealth() + 4 * ($effect->getAmplifier() + 1));
     }
     if ($effect->getId() === Effect::ABSORPTION and $this instanceof Human) {
         $this->setAbsorption(4 * ($effect->getAmplifier() + 1));
     }
     if (isset($this->effects[$effect->getId()])) {
         $oldEffect = $this->effects[$effect->getId()];
         if ($effect->getAmplifier() <= $oldEffect->getAmplifier() and $effect->getDuration() < $oldEffect->getDuration()) {
             return;
         }
         $effect->add($this, true, $oldEffect);
     } else {
         $effect->add($this, false);
     }
     $this->effects[$effect->getId()] = $effect;
     $this->recalculateEffectColor();
 }
开发者ID:yungtechboy1,项目名称:Genisys,代码行数:20,代码来源:Entity.php


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