void Launch(PathScript path) { ShipScript ship = planetScript.ships [Indices.SHIP_PLAYER]; ship.gameObject.SetActive(true); AbstractPlanet targetPlanet = path.GetDirectionStartingFrom(transform).end.gameObject.GetComponent <AbstractPlanet>(); if (targetPlanet != null) { ship.LaunchShipOnPath(path, transform, targetPlanet); } }
void LaunchShip(AbstractPlanet planet, AbstractPlanet target, PathScript[] paths, ShipScript ship) { PathScript chosenPath = null; foreach (PathScript path in paths) { if ((path.start == planet.transform && path.end == target.transform) || (path.end == planet.transform && path.start == target.transform)) { chosenPath = path; break; } } ship.LaunchShipOnPath(chosenPath, planet.transform, target); }