当前位置: 首页>>代码示例>>PHP>>正文


PHP Vector3::multiply方法代码示例

本文整理汇总了PHP中pocketmine\math\Vector3::multiply方法的典型用法代码示例。如果您正苦于以下问题:PHP Vector3::multiply方法的具体用法?PHP Vector3::multiply怎么用?PHP Vector3::multiply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pocketmine\math\Vector3的用法示例。


在下文中一共展示了Vector3::multiply方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onUpdate

 public function onUpdate($currentTick)
 {
     if ($this->closed !== false) {
         return false;
     }
     if ($this->willMove(100)) {
         if (++$this->switchDirectionTicker === $this->switchDirectionTicks) {
             $this->switchDirectionTicker = 0;
             if (mt_rand(0, 100) < 50) {
                 $this->flyDirection = null;
             }
         }
         $this->lastUpdate = $currentTick;
         $this->timings->startTiming();
         if ($this->isAlive()) {
             if ($this->y > $this->highestY and $this->flyDirection !== null) {
                 $this->flyDirection->y = -0.5;
             }
             $inAir = !$this->isInsideOfSolid() and !$this->isInsideOfWater();
             if (!$inAir) {
                 $this->flyDirection = null;
             }
             if ($this->flyDirection instanceof Vector3) {
                 //var_dump($this->flyDirection);
                 $this->setMotion($this->flyDirection->multiply($this->flySpeed));
             } else {
                 $this->flyDirection = $this->generateRandomDirection();
                 $this->flySpeed = mt_rand(50, 100) / 500;
                 $this->setMotion($this->flyDirection);
             }
             //$expectedPos = new Vector3($this->x + $this->motionX, $this->y + $this->motionY, $this->z + $this->motionZ);
             //$motion = $this->flyDirection->multiply($this->flySpeed);
             $this->move($this->motionX, $this->motionY, $this->motionZ);
             $this->updateMovement();
             //$this->getLevel()->addEntityMotion($this->chunk->getX(), $this->chunk->getZ(), $this->getId(), $motion->x, $motion->y, $motion->z);
             //echo "EID = {$this->getId()}, motionX = $this->motionX, motionY = $this->motionY, motionZ = $this->motionZ\n";
             /*
             
                             if($expectedPos->distanceSquared($this) > 0){
                                 $this->flyDirection = $this->generateRandomDirection();
                                 $this->flySpeed = mt_rand(50, 100) / 500;
                             }
             
                             $friction = 1 - $this->drag;
             
                             $this->motionX *= $friction;
                             $this->motionY *= 1 - $this->drag;
                             $this->motionZ *= $friction;
             */
             $f = sqrt($this->motionX ** 2 + $this->motionZ ** 2);
             $this->yaw = -atan2($this->motionX, $this->motionZ) * 180 / M_PI;
             $this->pitch = -atan2($f, $this->motionY) * 180 / M_PI;
             if ($this->onGround and $this->flyDirection instanceof Vector3) {
                 $this->flyDirection->y *= -1;
             }
         }
     }
     parent::onUpdate($currentTick);
     //parent::entityBaseTick();
     $this->timings->stopTiming();
     return !$this->onGround or abs($this->motionX) > 1.0E-5 or abs($this->motionY) > 1.0E-5 or abs($this->motionZ) > 1.0E-5;
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:62,代码来源:FlyingAnimal.php


注:本文中的pocketmine\math\Vector3::multiply方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。