public void Awake() { Cursor.visible = false; move = player.GetComponent <Movement>(); _player = player.GetComponent <Player>(); _rimSpawner = rimHandler.GetComponent <RimSpawner>(); spawnedRims = _rimSpawner.ExistingRims(); rims = _rimSpawner.rims; }
private void Start() { uiControls = uiManager.GetComponent <InfoManager>(); if (Cursor.visible) { Cursor.visible = false; } mainCamera = primaryCamera.GetComponent <CameraLook>(); spawner = GetComponent <RimSpawner>(); CP = rimColorSelector.GetComponent <ColorPickerTriangle>(); }
// Update is called once per frame void FixedUpdate() { if (uiControls.CreateUIIsActive()) { return; } if (!carrying) { if (!Input.GetKey(KeyCode.E)) { return; } var ray = cam.ScreenPointToRay(middle); if (!Physics.Raycast(ray, out var hit)) { return; } if (hit.collider.CompareTag("Switch")) { //TO BE DONE return; } if (!(hit.distance < pickUpDistance)) { return; } var selection = hit; if (!selection.transform.CompareTag("Selection")) { return; } uiControls.SetActiveHoldUI(true); uiControls.SetActiveMainUI(false); uiControls.SetActiveChangeColor(true); uiControls.SetActiveConfirmColor(false); wheel = selection.transform.gameObject.GetComponent <WallSnapper>(); carried = selection; carrying = true; release = false; } else { if (!destroyed) { CarryObject(carried); //for some reason sometimes this statement does not react and it takes few clicks for it to work.... if (Input.GetKey(KeyCode.Mouse2)) { float rotx = Input.GetAxisRaw("Mouse X") * rotationSpeed * Mathf.Deg2Rad; float roty = Input.GetAxisRaw("Mouse Y") * rotationSpeed * Mathf.Deg2Rad; carried.transform.RotateAround(Vector3.up, -rotx); carried.transform.RotateAround(Vector3.right, roty); if (!lockedForRotation) { carried.rigidbody.freezeRotation = true; uiControls.SetActiveHoldUI(false); Cursor.lockState = CursorLockMode.None; camLook.LockCamera(true); lockedForRotation = true; } } else if (Input.GetKeyUp(KeyCode.Mouse1) && !isPainting) { camLook.LockCamera(true); rimColorSelector.SetActive(true); Cursor.visible = true; if (Cursor.lockState != CursorLockMode.None) { Cursor.lockState = CursorLockMode.None; } objectRenderer = carried.transform.gameObject.GetComponentsInChildren <Renderer>(); CP.SetNewColor(objectRenderer[0].material.color); isPainting = true; uiControls.SetActiveChangeColor(false); uiControls.SetActiveConfirmColor(true); } else if (Input.GetKeyUp(KeyCode.Mouse1) && isPainting) { camLook.LockCamera(false); rimColorSelector.SetActive(false); Cursor.visible = false; if (Cursor.lockState != CursorLockMode.Locked) { Cursor.lockState = CursorLockMode.Locked; } isPainting = false; } else if (Input.GetKey(KeyCode.Delete)) { uiControls.SetActiveHoldUI(false); if (ItemHandler.inRange) { uiControls.SetActiveMainUI(true); } RimSpawner.DestroyRim(carried.transform.gameObject); destroyed = true; } if (isPainting) { foreach (Renderer renderer in objectRenderer) { renderer.material.color = CP.TheColor; } } } if (!Input.GetKey(KeyCode.Mouse2) && lockedForRotation) { carried.rigidbody.freezeRotation = false; Cursor.lockState = CursorLockMode.Locked; camLook.LockCamera(false); lockedForRotation = false; uiControls.SetActiveHoldUI(true); } if (Input.GetKey(KeyCode.E)) { return; } if (release) { return; } camLook.LockCamera(false); lockedForRotation = true; rimColorSelector.SetActive(false); if (!Cursor.visible) { Cursor.visible = false; } if (Cursor.lockState != CursorLockMode.Locked) { Cursor.lockState = CursorLockMode.Locked; } isPainting = false; carrying = false; if (destroyed) { destroyed = false; return; } uiControls.SetActiveHoldUI(false); if (ItemHandler.inRange) { uiControls.SetActiveMainUI(true); } Cursor.visible = false; carried.rigidbody.useGravity = true; release = true; } }