Beispiel #1
0
 function calculate()
 {
     if ($this->calculed == false) {
         $this->calculing = true;
         $startFinder = new PathFinder($this, $this->fromTile, null);
         $startFinder->applyForBest();
         $i = 0;
         while (count($this->_buffer) && $i < $this->_maxIteration) {
             $pathFinder = $this->removeFromBufferAt(0);
             $pathFinder->calculate();
             $i++;
         }
         $this->success = $i < $this->_maxIteration;
         if (!$this->success) {
             debug('busted');
         }
         $this->calculed = true;
     }
 }
Beispiel #2
0
 function calculate()
 {
     $adjacentTiles = array($this->getTopTile(), $this->getRightTile(), $this->getBottomTile(), $this->getLeftTile());
     foreach ($adjacentTiles as $t) {
         //if(empty($this->lastTile['tile'])){
         //	debug($this->lastTile);
         //}
         if ($t && (empty($this->lastTile) || $t['Tile']['id'] != $this->lastTile['Tile']['id']) && $this->_calculator->testTileForPathing($t)) {
             $pathFinder = new PathFinder($this->_calculator, $t, $this->curTile);
             $pathFinder->applyForBest();
         }
     }
 }