當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Human::kill方法代碼示例

本文整理匯總了PHP中pocketmine\entity\Human::kill方法的典型用法代碼示例。如果您正苦於以下問題:PHP Human::kill方法的具體用法?PHP Human::kill怎麽用?PHP Human::kill使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pocketmine\entity\Human的用法示例。


在下文中一共展示了Human::kill方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: kill

 public function kill()
 {
     parent::kill();
     $this->poofAway();
 }
開發者ID:mwvent,項目名稱:WattzMCPE,代碼行數:5,代碼來源:UndeadPlayer.php

示例2: kill

 public function kill()
 {
     if ($this->dead === true or $this->spawned === false) {
         return;
     }
     parent::kill();
     if ($this->inventory !== null) {
         $this->inventory->clearAll();
     }
     $message = $this->getName() . " died";
     $cause = $this->getLastDamageCause();
     $ev = null;
     if ($cause instanceof EntityDamageEvent) {
         $ev = $cause;
         $cause = $ev->getCause();
     }
     switch ($cause) {
         case EntityDamageEvent::CAUSE_ENTITY_ATTACK:
             if ($ev instanceof EntityDamageByEntityEvent) {
                 $e = $ev->getDamager();
                 if ($e instanceof Player) {
                     $message = $this->getName() . " was killed by " . $e->getName();
                     break;
                 } elseif ($e instanceof Living) {
                     $message = $this->getName() . " was slain by " . $e->getName();
                     break;
                 }
             }
             $message = $this->getName() . " was killed";
             break;
         case EntityDamageEvent::CAUSE_PROJECTILE:
             if ($ev instanceof EntityDamageByEntityEvent) {
                 $e = $ev->getDamager();
                 if ($e instanceof Living) {
                     $message = $this->getName() . " was shot by " . $e->getName();
                     break;
                 }
             }
             $message = $this->getName() . " was shot by arrow";
             break;
         case EntityDamageEvent::CAUSE_SUICIDE:
             $message = $this->getName() . " died";
             break;
         case EntityDamageEvent::CAUSE_VOID:
             $message = $this->getName() . " fell out of the world";
             break;
         case EntityDamageEvent::CAUSE_FALL:
             if ($ev instanceof EntityDamageEvent) {
                 if ($ev->getFinalDamage() > 2) {
                     $message = $this->getName() . " fell from a high place";
                     break;
                 }
             }
             $message = $this->getName() . " hit the ground too hard";
             break;
         case EntityDamageEvent::CAUSE_SUFFOCATION:
             $message = $this->getName() . " suffocated in a wall";
             break;
         case EntityDamageEvent::CAUSE_LAVA:
             $message = $this->getName() . " tried to swim in lava";
             break;
         case EntityDamageEvent::CAUSE_FIRE:
             $message = $this->getName() . " went up in flames";
             break;
         case EntityDamageEvent::CAUSE_FIRE_TICK:
             $message = $this->getName() . " burned to death";
             break;
         case EntityDamageEvent::CAUSE_DROWNING:
             $message = $this->getName() . " drowned";
             break;
         case EntityDamageEvent::CAUSE_CONTACT:
             $message = $this->getName() . " was pricked to death";
             break;
         case EntityDamageEvent::CAUSE_BLOCK_EXPLOSION:
         case EntityDamageEvent::CAUSE_ENTITY_EXPLOSION:
         case EntityDamageEvent::CAUSE_MAGIC:
         case EntityDamageEvent::CAUSE_CUSTOM:
         default:
     }
     $this->server->getPluginManager()->callEvent($ev = new PlayerDeathEvent($this, $this->getDrops(), $message));
     if ($ev->getDeathMessage() != "") {
         $this->server->broadcast($ev->getDeathMessage(), Server::BROADCAST_CHANNEL_USERS);
     }
 }
開發者ID:boybook,項目名稱:PocketMine-MP,代碼行數:84,代碼來源:Player.php


注:本文中的pocketmine\entity\Human::kill方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。