Exemplo n.º 1
0
 function calculPath($character, $toTile = null, $range = 0, $fromTile = null)
 {
     if (is_array($character) && !empty($character['toTile'])) {
         $opt = $character;
         $defOpt = array('character' => null, 'toTile' => null, 'range' => 0, 'fromTile' => null);
         $opt = array_merge($defOpt, $opt);
         extract($opt);
     }
     App::import('Lib', 'PathCalculator');
     $pathing = new PathCalculator($character, $toTile, $range, $fromTile);
     $pathing->calculate();
     if ($pathing->calculed && $pathing->success) {
         return $pathing->toData();
     }
     return false;
 }
Exemplo n.º 2
0
 function admin_test()
 {
     App::import('Lib', 'PathCalculator');
     $pathing = new PathCalculator(1, 1);
     $pathing->calculate();
     debug($this->Path->read(null, 286));
     $path = array();
     foreach ($pathing->_steps as $step) {
         $path[] = $step->getTileId();
     }
     $x = -16;
     $y = -16;
     $w = 32;
     $h = 32;
     $this->Tile = ClassRegistry::init('Tile');
     $tiles = $this->Tile->getRect(array('x' => $x, 'y' => $y, 'w' => $w, 'h' => $h, 'zone_id' => 1, 'aliased' => true));
     $this->set('tiles', $tiles);
     $this->set('x', $x);
     $this->set('y', $y);
     $this->set('w', $w);
     $this->set('h', $h);
     $this->set('styled', array('path' => $path));
 }