void PlanetSelection() { CursorUI.position = oraryCam.WorldToScreenPoint(selectedPlanet.GetPlanetPosition()); PlanetData viewedPlanet = null; int highestLevel = 0; foreach (PlanetData planet in Planets) { if (planet.GetDangerLvl() > highestLevel) { highestLevel = planet.GetDangerLvl(); nextTarget = planet; } Vector3 planetPosition = oraryCam.WorldToScreenPoint(planet.GetPlanetPosition()); float distance = (planetPosition - Input.mousePosition).magnitude; if (distance < 25) { viewedPlanet = planet; HoverPlanet(planet); } } if (viewedPlanet == null) { PlanetDataDisplay(selectedPlanet); } else { PlanetDataDisplay(viewedPlanet); } }
PlanetData ShipMovement(Transform shipTrans, PlanetData currentPlanet, PlanetData destination) { var line = shipTrans.GetComponent <LineRenderer>(); line.SetPosition(0, currentPlanet.GetPlanetPosition()); line.SetPosition(1, destination.GetPlanetPosition()); shipTrans.position = currentPlanet.GetPlanetPosition(); if (Input.GetKeyDown(KeyCode.Return)) { foreach (PlanetData planet in Planets) { planet.SetDangerLvl(Random.Range(0, 6)); } currentPlanet = destination; } return(currentPlanet); }
void HoverPlanet(PlanetData planet) { CursorUI.position = oraryCam.WorldToScreenPoint(planet.GetPlanetPosition()); if (Input.GetButtonDown("Fire1")) { selectedPlanet = planet; } }