void Start() { shipRB = GetComponent <Rigidbody>(); shipGB = GetComponent <GravBody>(); if (playerExit == null) { Debug.LogError("ShipController: No player exit; set in the inspector"); } shipCamJib = GetComponentInChildren <ShipCam>(); flightHelp = FindObjectOfType <FlightHelp>(); if (!control) { Exit(false); } else { Enter(); } moduleSlots = GameObject.FindGameObjectsWithTag("ModuleSlot"); foreach (GameObject slot in moduleSlots) { slot.SetActive(false); } speedometer.enabled = false; RefreshModules(); }
public Vector2 AimLeap() { if (LeapAim.localPosition.y != .75f) { LeapAim.localPosition = new Vector3(0, .75f, 0); } if (!cancelled) { canMove = false; lineRenderer.enabled = true; RaycastHit2D hitInfo = Physics2D.Raycast(new Vector3(LeapAim.position.x, LeapAim.localPosition.y + aimExtend, LeapAim.position.z), LeapAim.up); if (hitInfo) { GameObject attck = hitInfo.transform.gameObject; GravAttractor wall = hitInfo.transform.GetComponent <GravAttractor>(); GravBody foe = hitInfo.transform.GetComponent <GravBody>(); if (wall != null) { lineRenderer.SetPosition(0, LeapAim.position); lineRenderer.SetPosition(1, hitInfo.point); storedTarget = wall; } if ((foe != null) && (foe != this.GetComponent <GravBody>())) { lineRenderer.SetPosition(0, LeapAim.position); lineRenderer.SetPosition(1, hitInfo.point); storedTarget = foe.GetComponent <GravBody>().attractor; } if (attck != null) { PlayerControl Oattack = attck.GetComponent <PlayerControl>(); Projectile ammo = attck.GetComponent <Projectile>(); if ((Oattack != null && Oattack.attack != null) || ammo != null) { storedTarget = Target; lineRenderer.SetPosition(0, LeapAim.position); lineRenderer.SetPosition(1, hitInfo.point); } } if (wall == null && foe == null) { storedTarget = Target; lineRenderer.SetPosition(0, LeapAim.position); lineRenderer.SetPosition(1, LeapAim.position + LeapAim.up * 1000); } LeapTarget = hitInfo.point; LeapAim.localEulerAngles = new Vector3(LeapAim.localRotation.x, LeapAim.localRotation.y, -aim); } return(LeapTarget); } else { storedTarget = Target; return(transform.position); } }