本文整理汇总了PHP中pocketmine\Player::getLocation方法的典型用法代码示例。如果您正苦于以下问题:PHP Player::getLocation方法的具体用法?PHP Player::getLocation怎么用?PHP Player::getLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\Player
的用法示例。
在下文中一共展示了Player::getLocation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMaskLocation
public function getMaskLocation(Player $player)
{
// always return player current location if there is an error
if (!$this->maskLoc) {
return $player->getLocation();
}
if (!preg_match('#^((\\?spawn\\?)|((\\-)?[0-9]+,(\\-)?[0-9]+,(\\-)?[0-9]+))@([^/\\\\]+)$#', $this->maskLocPos, $match)) {
return $player->getLocation();
}
$pos = $match[1];
$world = $match[7];
$level = $player->getLevel();
if ($world === "?default?") {
$level = $player->getServer()->getDefaultLevel();
} elseif ($world !== "?current?") {
$level = $player->getServer()->getLevelByName($world);
if (!$level instanceof Level) {
$level = $player->getLevel();
}
}
if ($pos === "?spawn?") {
$position = $level->getSpawnLocation();
} else {
list($x, $y, $z) = explode(",", $pos);
$position = new Position((int) $x, (int) $y, (int) $z, $level);
}
return $position;
}
示例2: getLocation
public function getLocation()
{
return $this->player->getLocation();
}
示例3: addSpawn
public function addSpawn(Player $player)
{
$this->getLevelConfig();
$location = $player->getLocation();
$lobby = strtolower($player->getLevel()->getName());
if ($this->level->getNested($lobby . ".spawns") !== null) {
$spawns = $this->level->getNested($lobby . ".spawns");
$count = count(array_keys($spawns));
} else {
$count = 0;
}
$this->level->setNested($lobby . ".spawns." . $count, array("x" => round($location->getFloorX(), 0), "y" => round($location->getFloorY(), 0), "z" => round($location->getFloorZ(), 0)));
$this->setLevelConfig();
$player->sendMessage(TextFormat::GREEN . "Spawn set");
return true;
}
示例4: touch
public function touch(Player $damager, Player $entity)
{
$damagerGameId = $this->players[$damager->getName()];
$entityGameId = $this->players[$entity->getName()];
if ($damagerGameId === $entityGameId && $damagerGameId !== "NONE") {
$returnVal = $this->games[$damagerGameId]->touch($damager->getName(), $entity->getName());
switch ($returnVal) {
case GameManager::RETURNTYPE_TOUCH_ALREADY_TOUCED_FAILED:
$damager->sendMessage(TextFormat::RED . $this->getTranslation("TOUCH_ALREADY_TOUCHED"));
break;
case GameManager::RETURNTYPE_TOUCH_IN_PREPARATION_OR_REST_FAILED:
$damager->sendMessage(TextFormat::RED . $this->getTranslation("PREPARATION_OR_REST"));
break;
case GameManager::RETURNTYPE_TOUCH_SUCCEED:
$this->notifyTipForPlayers($damagerGameId, TextFormat::DARK_PURPLE . $this->getTranslation("TOUCH_MESSAGE", $damager->getName(), $entity->getName()));
$this->notifyForPlayers($damagerGameId, TextFormat::DARK_PURPLE . $this->getTranslation("TOUCH_MESSAGE", $damager->getName(), $entity->getName()));
$this->createTouchEffect($entity->getLocation(), $entity->getEyeHeight(), $damager->getLocation(), $damager->getEyeHeight());
break;
}
return $returnVal;
}
return false;
}