public function DistanceFrom(Coordinates $c) { global $NN_config; $distance = 0; if ($this->Galaxy() - $c->Galaxy() != 0) { $distance = abs($this->Galaxy() - $c->Galaxy()) * $NN_config["galaxy_distance"]; } elseif ($this->System() - $c->System() != 0) { $distance = abs($this->System() - $c->System()) * $NN_config["system_distance"]; } elseif ($this->Planet() - $c->Planet() != 0) { $distance = abs($this->Planet() - $c->Planet()) * $NN_config["planet_distance"]; } else { $distance = 5; } return $distance; }
if ($user == NULL) { return; } // Fill galaxy and system selection menu if ($_GET) { $system = $_GET['system']; if (isset($_GET['systemRight'])) { $system++; } elseif (isset($_GET['systemLeft'])) { $system--; } $galaxy = $_GET['galaxy']; if (isset($_GET['galaxyRight'])) { $galaxy++; } elseif (isset($_GET['galaxyLeft'])) { $galaxy--; } } else { $galaxy = $user->CurrentColony()->Coordinates()->Galaxy(); $system = $user->CurrentColony()->Coordinates()->System(); } $coordinates = new Coordinates($galaxy, $system, 1); // The Coordinates class automatically clamps values, so they're always within range $vars['current_galaxy'] = $coordinates->Galaxy(); $vars['current_system'] = $coordinates->System(); // Render new galaxy view $view = new GalaxyView($user, $coordinates); $vars['galaxy_view'] = $view->Render(); // Render galaxy page $page = new Page("galaxy/galaxy", $vars, "Galaxy View", "galaxy_view"); echo $page->Display();