public void Drive() { ///acquiring the player handling script to get distance as well as SetUp the player for flight if (this.playerHandling == null) { this.playerHandling = this.referenceBuffer.PlayerHandling; if (this.playerHandling == null) { Debug.Log("Ship Can Not Find Player Handling!"); return; } } ///... ///If too far do not engage var currentDistance = (playerHandling.GetCurrentPosition - gameObject.transform.position).magnitude; if (currentDistance > this.MaxEntranceDistance) { Debug.Log($"You are too far away to enter the vehicle\nMaxDistance: {this.MaxEntranceDistance} - your Distance: {currentDistance}"); return; } ///... ///setting up the ship this.nutonianVelocity = Vector3.zero; this.combatVelocityMagnitude = 0; this.mainCamera.SetActive(false); this.myCamera.SetActive(true); this.active = true; ///... ///Clearing the UI this.referenceBuffer.ShowActions.Close(); this.referenceBuffer.ShowAvailableCSFiles.Close(); ///setting up the player this.playerHandling.EnterVehicle(); ///... ///Invoking the HasActivated event this.HasActivated?.Invoke(); Cursor.lockState = CursorLockMode.Locked; }
public GameObject Player(Vector3 position, bool kinematic, bool rigidBody, bool isTarget, params Type[] scripts) { GameObject player = null; if (kinematic) { player = GameObject.Instantiate(ReferenceBuffer.Instance.EditorInput.playerKinematicPrefab); } else { player = GameObject.Instantiate(ReferenceBuffer.Instance.EditorInput.playerPrefab); } /// the ignore raycast layer player.layer = 2; player.name = "Player"; player.AddComponent <PlayerFailure>(); PlayerHandling2 ph = player.AddComponent <PlayerHandling2>(); this.rb.RegisterPlayerHandling(ph); if (isTarget) { var tb = player.AddComponent <TargetBehaviour>(); //tb.SetUp(99, TargetType.Standard); this.ms.registry.RegisterTarget(player, TargetType.Standard); } if (rigidBody == false) { GameObject.Destroy(player.GetComponent <Rigidbody>()); } position.y += 1; player.transform.position = position; ReferenceBuffer.Instance.PlayerObject = player; return(player); }
public void RegisterPlayerHandling(PlayerHandling2 playerHandling) { this.PlayerHandling = playerHandling; }