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); } }
public void LaunchShipOnPath(PathScript path, Transform from, AbstractPlanet targetPlanet) { this.targetPlanet = targetPlanet; ManagerScript.Instance.audioManager.PlaySound("shipMove"); switch (shipOwnership) { case AbstractPlanet.Ownership.Player: dockedPlanet.ships[Indices.SHIP_PLAYER] = null; break; case AbstractPlanet.Ownership.Enemy: dockedPlanet.ships[Indices.SHIP_ENEMY] = null; break; case AbstractPlanet.Ownership.Neutral: break; } isShipMoving = true; this.travelPath = path.GetDirectionStartingFrom(from); this.transform.position = travelPath.shipStart; this.transform.rotation = Quaternion.LookRotation(travelPath.shipEnd - travelPath.shipStart); this.transform.localScale = Vector3.zero; }