void Update() { float enter = 0; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); //Vector3 mousePosition = Camera.main.ScreenToViewportPoint(Input.mousePosition); //Ray ray = Camera.main.ScreenPointToRay(Camera.main.projectionMatrix.inverse.MultiplyPoint(mousePosition)); //Ray ray = Camera.main.ViewportPointToRay(Input.mousePosition); cursor = ray.GetPoint(enter); MovementLockout(); if (destructionLockOut || movementLockOut) { interactable = false; } else { interactable = true; } if (interactable) { if (Input.GetMouseButtonDown(0)) { RaycastHit hit; if (Physics.Raycast(ray, out hit, Mathf.Infinity)) { if (hit.collider.gameObject.tag == "InteractableTile") { BaseTile tile = hit.collider.transform.parent.parent.gameObject.GetComponent <BaseTile>(); if (tile) { Debug.Log("tile at " + tile.GetCell().position.x + " | " + tile.GetCell().position.y); tile.selected = true; activeTile = tile; attemptedTumble.Clear(); } } else if (hit.collider.gameObject.tag == "SuperRowButton") { Debug.Log("superrowbutton clicked"); Transform cellTransform = hit.collider.transform.parent; string tag = cellTransform.tag; List <Cell> rowCells = GetRowCells(ConvertTagToRowNumber(tag)); foreach (Cell cell in rowCells) { cell.tile.Destroy(1); } for (int w = 0; w < config.goalArray.Length; w++) { if (config.goalArray[w] is SuperRow_Goal) { SuperRow_Goal goal = config.goalArray[w] as SuperRow_Goal; goal.currentAmount++; goal.UpdateText(); } } Destroy(hit.collider.gameObject); Debug.Log("superrowbutton handled"); } } } if (Input.GetMouseButtonUp(0)) { if (activeTile != null) { activeTile.selected = false; activeTile = null; } } if (activeTile != null) { float cursorDeltaZ = (cursor.z - lastCursorPos.z); float cursorDeltaX = (cursor.x - lastCursorPos.x); activeTile.TurnTowards(cursorDeltaZ, -cursorDeltaX); if (Mathf.Abs(activeTile.rotationPivot.localRotation.y) > Constants.flickThresholdHorizontal) { //activeTile.TumbleRow(activeTile.rotationPivot.localRotation.y, this, 999); activeTile.Swap(activeTile.rotationPivot.localRotation.y, this); activeTile = null; } else if (Mathf.Abs(activeTile.rotationPivot.localRotation.x) > Constants.flickThresholdVertical) { activeTile.TumbleColumn(activeTile.rotationPivot.localRotation.x, this, activeTile.size); activeTile = null; } } } if (goMad) { transform.localPosition = Vector3.MoveTowards(transform.localPosition, new Vector3(Random.Range(-10f, 10f), Random.Range(-10f, 10f), Random.Range(-10f, 10f)), 10f); } }