Пример #1
0
 public static function getTimeSinceLastCheckpointSide(Dolumar_Underworld_Models_Mission $mission, Neuron_GameServer_Map_Location $location)
 {
     $db = Neuron_DB_Database::getInstance();
     $time = $db->query("\n\t\t\tSELECT\n\t\t\t\tUNIX_TIMESTAMP(uc_date) AS datum\n\t\t\tFROM\n\t\t\t\tunderworld_checkpoints\n\t\t\tWHERE\n\t\t\t\tum_id = {$mission->getId()} AND\n\t\t\t\tuc_x = {$location->x()} AND\n\t\t\t\tuc_y = {$location->y()}\n\t\t");
     if (count($time) > 0) {
         return NOW - $time[0]['datum'];
     } else {
         return 0;
     }
 }
Пример #2
0
 public function getLocation(Neuron_GameServer_Map_Location $location, $objectcount = 0)
 {
     // Fetch the image from the old map object
     $l = $this->map->getLocation($location->x(), $location->y(), $objectcount > 0);
     $color = $l->getMapColor();
     $image = $l->getImage();
     // Make a new sprite
     $out = new Neuron_GameServer_Map_Display_Sprite(STATIC_URL . 'images/tiles/' . $image['image'] . '.gif');
     $out->setColor(new Neuron_GameServer_Map_Color($color[0], $color[1], $color[2]));
     return array($out);
 }
Пример #3
0
 public function addMapUpdate(Neuron_GameServer_Map_Location $location, $action)
 {
     $x = $location->x();
     $y = $location->y();
     switch ($action) {
         case 'BUILD':
         case 'DESTROY':
             break;
         default:
             $action = 'BUILD';
             break;
     }
     $db = Neuron_DB_Database::getInstance();
     $x = intval($x);
     $y = intval($y);
     $db->query("\n\t\t\tINSERT INTO\n\t\t\t\tn_map_updates\n\t\t\tSET\n\t\t\t\tmu_action = '{$action}',\n\t\t\t\tmu_x = {$x},\n\t\t\t\tmu_y = {$y},\n\t\t\t\tmu_date = FROM_UNIXTIME(" . NOW . ")\n\t\t");
 }
Пример #4
0
 public static function insert(Dolumar_Underworld_Models_Mission $mission, Dolumar_Underworld_Models_Side $side, Neuron_GameServer_Map_Location $location)
 {
     $db = Neuron_DB_Database::getInstance();
     $side = intval($side->getId());
     $db->query("\n\t\t\tINSERT INTO\n\t\t\t\tunderworld_explored\n\t\t\tSET\n\t\t\t\tue_side = {$side},\n\t\t\t\tum_id = {$mission->getId()},\n\t\t\t\tue_x = {$location->x()},\n\t\t\t\tue_y = {$location->y()}\n\t\t");
 }
Пример #5
0
 public function getDistance(Neuron_GameServer_Map_Location $location)
 {
     return sqrt(pow($location->x() - $this->x(), 2) + pow($location->y() - $this->y(), 2) + pow($location->z() - $this->z(), 2));
 }
Пример #6
0
 public function moveArmy(Dolumar_Players_Player $me, Neuron_GameServer_Map_Location $location)
 {
     if (!$location instanceof Dolumar_Underworld_Map_Locations_Location) {
         $x = $location->x();
         $y = $location->y();
         $location = $this->getMap()->getBackgroundManager()->getSingleLocation($x, $y);
     }
     if (!$this->canMove($me)) {
         $this->error = 'move_not_authorized';
         return false;
     }
     $path = $this->execMove($location);
     if ($path) {
         $this->getMap()->getMission()->getLogger()->move($me, $this, $location, $path);
         return true;
     } else {
         return false;
     }
 }
Пример #7
0
 /**
  *	Return the correct path between two points,
  *	avoiding all objects (except same side objects) and
  *	unpassable locations.
  */
 public function getPath(Dolumar_Underworld_Models_Side $side, Neuron_GameServer_Map_Location $start, Neuron_GameServer_Map_Location $end, $maxRadius, $isTargetAnObject = false)
 {
     // Prepare thze area that needs to be inspected
     $minx = $start->x() - $maxRadius;
     $miny = $start->y() - $maxRadius;
     $maxx = $start->x() + $maxRadius;
     $maxy = $start->y() + $maxRadius;
     $area = array();
     for ($y = 0; $y < $maxRadius * 2; $y++) {
         $area[$y] = array();
         for ($x = 0; $x < $maxRadius * 2; $x++) {
             $area[$y][$x] = $this->getPassCost($minx + $x, $miny + $y);
         }
     }
     // Mark all objects as not passable
     $center = array($minx + ($maxx - $minx) / 2, $miny + ($maxy - $miny) / 2);
     $range = $maxRadius * 2;
     $objarea = new Neuron_GameServer_Map_Area(new Neuron_GameServer_Map_Location($center[0], $center[1]), $range);
     $objects = $this->getMapObjectManager()->getDisplayObjects($objarea);
     foreach ($objects as $v) {
         $location = $v->getLocation();
         $area[floor($location[1]) - $miny][floor($location[0]) - $minx] = 0;
     }
     $transformed_start = $start->transform(-$minx, -$miny);
     $transformed_end = $end->transform(-$minx, -$miny);
     // If the target is an object,
     // it should always be passable
     if ($isTargetAnObject) {
         $area[$transformed_end->y()][$transformed_end->x()] = 1;
     }
     // Path finder
     $pathfinder = new Neuron_GameServer_Map_Pathfinder();
     $pathfinder->setMap($area);
     $path = $pathfinder->getPath($transformed_start, $transformed_end, $maxRadius);
     if ($path) {
         $path->transform(+$minx, +$miny);
     }
     return $path;
 }
Пример #8
0
 public function getCheckpointSide(Neuron_GameServer_Map_Location $location)
 {
     $x = $location->x();
     $y = $location->y();
     $this->loadcheckpoints();
     if (isset($this->mappedcheckpoints[$x]) && isset($this->mappedcheckpoints[$x][$y])) {
         return $this->mappedcheckpoints[$x][$y];
     }
     return null;
 }
Пример #9
0
 public static function withdraw(Dolumar_Underworld_Models_Mission $mission, Neuron_GameServer_Player $player, Dolumar_Underworld_Models_Army $army, Neuron_GameServer_Map_Location $location)
 {
     $db = Neuron_DB_Database::getInstance();
     $missionId = self::getMissionId($mission);
     $armyId = self::getArmyId($mission, $army);
     $sql = "\n\t\t\tINSERT INTO\n\t\t\t\tunderworld_log_event\n\t\t\tSET\n\t\t\t\tul_m_id = '{$missionId}',\n\t\t\t\tplid = '{$player->getId()}',\n\t\t\t\tul_a_vid = '{$armyId}',\n\t\t\t\tul_e_action = 'WITHDRAW',\n\t\t\t\tul_e_x = '{$location->x()}',\n\t\t\t\tul_e_y = '{$location->y()}',\n\t\t\t\tul_e_date = NOW()\n\t\t";
     $db->query($sql);
 }