本文整理汇总了PHP中pocketmine\utils\Random::nextSignedFloat方法的典型用法代码示例。如果您正苦于以下问题:PHP Random::nextSignedFloat方法的具体用法?PHP Random::nextSignedFloat怎么用?PHP Random::nextSignedFloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\utils\Random
的用法示例。
在下文中一共展示了Random::nextSignedFloat方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute(CommandSender $sender, $currentAlias, array $args)
{
if (!$this->testPermission($sender)) {
return true;
}
if (count($args) < 7) {
$sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage]));
return true;
}
if ($sender instanceof Player) {
$level = $sender->getLevel();
} else {
$level = $sender->getServer()->getDefaultLevel();
}
$name = strtolower($args[0]);
$pos = new Vector3((double) $args[1], (double) $args[2], (double) $args[3]);
$xd = (double) $args[4];
$yd = (double) $args[5];
$zd = (double) $args[6];
$count = isset($args[7]) ? max(1, (int) $args[7]) : 1;
$data = isset($args[8]) ? (int) $args[8] : null;
$particle = $this->getParticle($name, $pos, $xd, $yd, $zd, $data);
if ($particle === null) {
$sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.particle.notFound", [$name]));
return true;
}
$sender->sendMessage(new TranslationContainer("commands.particle.success", [$name, $count]));
$random = new Random((int) (microtime(true) * 1000) + mt_rand());
for ($i = 0; $i < $count; ++$i) {
$particle->setComponents($pos->x + $random->nextSignedFloat() * $xd, $pos->y + $random->nextSignedFloat() * $yd, $pos->z + $random->nextSignedFloat() * $zd);
$level->addParticle($particle);
}
return true;
}
示例2: execute
public function execute(CommandSender $sender, $currentAlias, array $args)
{
if (!$this->testPermission($sender)) {
return \true;
}
if (\count($args) < 7) {
return \true;
}
if ($sender instanceof Player) {
$level = $sender->getLevel();
} else {
$level = $sender->getServer()->getDefaultLevel();
}
$name = \strtolower($args[0]);
$pos = new Vector3((double) $args[1], (double) $args[2], (double) $args[3]);
$xd = (double) $args[4];
$yd = (double) $args[5];
$zd = (double) $args[6];
$count = isset($args[7]) ? \max(1, (int) $args[7]) : 1;
$data = isset($args[8]) ? (int) $args[8] : \null;
$particle = $this->getParticle($name, $pos, $xd, $yd, $zd, $data);
if ($particle === \null) {
return \true;
}
$random = new Random((int) (\microtime(\true) * 1000) + \mt_rand());
for ($i = 0; $i < $count; ++$i) {
$particle->setComponents($pos->x + $random->nextSignedFloat() * $xd, $pos->y + $random->nextSignedFloat() * $yd, $pos->z + $random->nextSignedFloat() * $zd);
$level->addParticle($particle);
}
return \true;
}
示例3: addParticles
public static function addParticles(Level $level, $name, Position $pos1, $count = 5)
{
$xd = (double) 280;
$yd = (double) 260;
$zd = (double) 280;
$particle1 = self::getParticle($name, $pos1, $xd, $yd, $zd, 0);
$random = new Random((int) (\microtime(\true) * 1000) + \mt_rand());
for ($i = 0; $i < $count; ++$i) {
$particle1->setComponents($pos1->x + $random->nextSignedFloat() * $xd, $pos1->y + $random->nextSignedFloat() * $yd, $pos1->z + $random->nextSignedFloat() * $zd);
$level->addParticle($particle1);
}
}
示例4: grantCoins
public function grantCoins($coins, $ignoreGrind = false, $effects = true)
{
if (!$ignoreGrind and $this->isGrinding()) {
$coins *= Settings::getGrindFactor($this->getRank());
}
if ($effects) {
$this->getPlayer()->getLevel()->addSound(new FizzSound($this->getPlayer()), [$this->getPlayer()]);
$random = new Random(time() + $coins);
$player = $this->getPlayer();
$particle = new TerrainParticle($player, Block::get(Block::GOLD_BLOCK));
$level = $player->getLevel();
$recipients = [$player];
for ($i = 0; $i < 50; $i++) {
$x = $random->nextSignedFloat();
$y = $random->nextSignedFloat() * $player->eyeHeight / 2;
$z = $random->nextSignedFloat();
$particle->setComponents($player->x + $x, $player->y + $player->eyeHeight / 2 + $y, $player->z + $z);
$level->addParticle($particle, $recipients);
}
}
$this->setCoins($out = $this->getCoins() + $coins);
return [$coins, $out];
}
示例5: addParticles
public static function addParticles(Level $level, $name, Position $pos1, $count = 5)
{
// $pos = new Vector3((float) $args[1], (float) $args[2], (float) $args[3]);
$xd = (double) 380;
$yd = (double) 360;
$zd = (double) 380;
// $count = 8;
// $data = isset($args[8]) ? (int) $args[8] : \null;
// $pos = new Vector3((float) $args[1], (float) $args[2], (float) $args[3]);
$particle1 = self::getParticle($name, $pos1, $xd, $yd, $zd, 0);
$random = new Random((int) (\microtime(\true) * 1000) + \mt_rand());
for ($i = 0; $i < $count; ++$i) {
$particle1->setComponents($pos1->x + $random->nextSignedFloat() * $xd, $pos1->y + $random->nextSignedFloat() * $yd, $pos1->z + $random->nextSignedFloat() * $zd);
$level->addParticle($particle1);
}
}
示例6: grantCoins
public function grantCoins($coins, $ignoreGrind = false, $effects = true, $bonus = true)
{
if (!$ignoreGrind and $this->isGrinding()) {
$coins *= Settings::getGrindFactor($this->getRank());
}
if ($effects) {
$this->getPlayer()->getLevel()->addSound(new FizzSound($this->getPlayer()), [$this->getPlayer()]);
$random = new Random(time() + $coins);
$player = $this->getPlayer();
$particle = new TerrainParticle($player, Block::get(Block::GOLD_BLOCK));
$level = $player->getLevel();
$recipients = [$player];
for ($i = 0; $i < 500; $i++) {
$x = $random->nextSignedFloat();
$y = $random->nextSignedFloat();
$z = $random->nextSignedFloat();
$particle->setComponents($player->x + $x, $player->y + $y, $player->z + $z);
$level->addParticle($particle, $recipients);
}
}
$this->setCoins($out = $this->getCoins() + $coins);
if ($bonus) {
if (mt_rand(0, 99) === 0) {
$add = mt_rand(25, 50);
} elseif (mt_rand(0, 499) === 0) {
$add = mt_rand(150, 300);
} elseif (mt_rand(0, 749) === 0) {
$add = mt_rand(300, 500);
}
if (isset($add)) {
$this->grantCoins($add, false, true, false);
}
}
return [$coins, $out];
}
示例7: displaySmoke
public function displaySmoke(Position $pos)
{
//particle smoke 120 71 124 1 1 1 35 200
$random = new Random((int) (microtime(true) * 1000) + mt_rand());
$particle = new SmokeParticle(new Vector3($pos->x, $pos->y + 0.7, $pos->z), 200);
for ($i = 0; $i < 35; ++$i) {
$particle->setComponents($pos->x + $random->nextSignedFloat(), $pos->y + $random->nextSignedFloat(), $pos->z + $random->nextSignedFloat());
$pos->getLevel()->addParticle($particle);
}
}