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


PHP Human::setHealth方法代碼示例

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


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

示例1: setHealth

 public function setHealth($amount)
 {
     parent::setHealth($amount);
     if ($this->spawned === true) {
         $pk = new SetHealthPacket();
         $pk->health = $this->getHealth();
         $this->dataPacket($pk);
     }
 }
開發者ID:NewDelion,項目名稱:PocketMine-0.13.x,代碼行數:9,代碼來源:Player.php

示例2: setHealth

 public function setHealth($amount)
 {
     parent::setHealth($amount);
     if ($this->spawned === true) {
         $this->foodTick = 0;
         $this->getAttribute()->getAttribute(AttributeManager::MAX_HEALTH)->setValue($amount);
         if ($amount <= 0) {
             $pk = new RespawnPacket();
             $pos = $this->getSpawn();
             $pk->x = $pos->x;
             $pk->y = $pos->y;
             $pk->z = $pos->z;
             $this->dataPacket($pk);
         }
     }
 }
開發者ID:KillerXtream,項目名稱:ImagicalMine,代碼行數:16,代碼來源:Player.php

示例3: setHealth

 public function setHealth($amount)
 {
     parent::setHealth($amount);
     if ($this->spawned === true) {
         $this->foodTick = 0;
         $this->getAttribute()->getAttribute(AttributeManager::MAX_HEALTH)->setMaxValue($this->getMaxHealth())->setValue($amount);
     }
 }
開發者ID:PepbookPvP,項目名稱:Genisys,代碼行數:8,代碼來源:Player.php

示例4: setHealth

 public function setHealth($amount)
 {
     parent::setHealth($amount);
     if ($this->spawned === true) {
         $this->foodTick = 0;
         if ($amount <= 0) {
             $this->kill();
             return;
         }
         $this->getAttribute()->getAttribute(AttributeManager::MAX_HEALTH)->setValue($amount);
     }
 }
開發者ID:TexusDark,項目名稱:ImagicalMine,代碼行數:12,代碼來源:Player.php

示例5: setHealth

 public function setHealth($amount)
 {
     parent::setHealth($amount);
     if ($this->spawned === \true) {
         ////            if($amount === 20 || $amount === 0) {
         //                $pk = new SetHealthPacket();
         //                $pk->health = $this->getHealth();
         //                $this->dataPacket($pk);
         ////            }
         $this->foodTick = 0;
         $this->getAttribute()->getAttribute(AttributeManager::MAX_HEALTH)->setValue($amount);
     }
 }
開發者ID:AASSuper,項目名稱:PocketMine_0.13,代碼行數:13,代碼來源:Player.php

示例6: setHealth

 public function setHealth($amount)
 {
     parent::setHealth($amount);
     if ($this->spawned === true) {
         $pk = new UpdateAttributesPacket();
         $this->foodTick = 0;
         $pk->minValue = 0;
         $pk->maxValue = $this->getMaxHealth();
         $pk->value = $amount;
         $pk->name = UpdateAttributesPacket::HEALTH;
         $this->dataPacket($pk);
     }
 }
開發者ID:WonderlandPE,項目名稱:Steadfast2,代碼行數:13,代碼來源:Player.php

示例7: setHealth

 public function setHealth($amount)
 {
     parent::setHealth($amount);
     if ($this->spawned === true) {
         $pk = new SetHealthPacket();
         $pk->health = $this->getHealth();
         $this->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS));
     }
 }
開發者ID:richarrj,項目名稱:PocketMine-MP,代碼行數:9,代碼來源:Player.php

示例8: setHealth

 public function setHealth($amount)
 {
     parent::setHealth($amount);
     if ($this->spawned === true) {
         #$this->health = $amount;
         $this->getAttributeMap()->getAttribute(Attribute::HEALTH)->setMaxValue($this->getMaxHealth())->setValue($amount, false);
         //maybe setmax causes doublehit
         //Client hack: (Client always shows hit animation on SetHealthPacket) (Now its there because of /kill)
         if (!$this->isAlive()) {
             $pk = new SetHealthPacket();
             $pk->health = $this->getHealth();
             $this->dataPacket($pk);
         }
         $this->foodTickTimer = 0;
     }
 }
開發者ID:robske110,項目名稱:ClearSky,代碼行數:16,代碼來源:Player.php


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