本文整理匯總了PHP中pocketmine\entity\Effect::add方法的典型用法代碼示例。如果您正苦於以下問題:PHP Effect::add方法的具體用法?PHP Effect::add怎麽用?PHP Effect::add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pocketmine\entity\Effect
的用法示例。
在下文中一共展示了Effect::add方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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));
}
}
示例2: 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;
}
示例3: 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);
}
}
}
示例4: 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();
}