private void OnRightDown() { if (!modifiable) { return; } if (dragging) { return; } if (boardObject == null) { boardObject = GetComponent <BoardObject>(); } if (argumentLoader != null) { argumentLoader.SetBoardObject(boardObject); } boardObject.Rotate(1); string name = boardObject.GetName(); TrackerAsset.Instance.setVar("element_type", name.ToLower()); TrackerAsset.Instance.setVar("element_name", boardObject.GetNameWithIndex().ToLower()); TrackerAsset.Instance.setVar("position", lastPos.ToString()); TrackerAsset.Instance.setVar("rotation", boardObject.GetDirection().ToString().ToLower()); TrackerAsset.Instance.setVar("action", "rotate"); TrackerAsset.Instance.GameObject.Interacted(boardObject.GetID()); }
public void RotateBoardObject(Vector2Int position, int direction) { if (IsInBoardBounds(position)) { BoardObject bObject = board[position.x, position.y].GetPlacedObject(); if (bObject == null) { return; } bObject.Rotate(direction); } }
private void MouseEvents() { RaycastHit hit; if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit)) { LaserLabObject target = hit.collider.GetComponent <LaserLabObject>(); if (target != null) { if (target != previousHover) { if (previousHover != null) { previousHover.OnHoverExit(); } target.OnHoverEnter(); previousHover = target; } if (target is BoardObject) { BoardObject boardObject = target as BoardObject; Vector2Int pos = boardObject.getPos(); if (Input.GetMouseButtonDown(0)) { if (boardObject.CanRotate) { boardObject.Rotate(); CalculateLaserPaths(); audioPlayer.PlayClip(rotateSound); } else { audioPlayer.PlayClip(dropSound); } SelectObject(-1); } else if (Input.GetMouseButtonDown(1)) { if (boardObject.CanMove) { boardObject.Pickup(); level.board.SetBoardObject(pos, null); AddToUnplaced(boardObject); audioPlayer.PlayClip(pickupSound); } else { SelectObject(-1); audioPlayer.PlayClip(dropSound); } } if (selectedObjectIndex > -1) { SelectedObject.SetPreview(false); } } else if (target is FloorTile) { FloorTile floor = target as FloorTile; Vector2Int pos = floor.getPos(); if (Input.GetMouseButtonDown(0)) { if (!level.board.GetBoardObject(pos) && selectedObjectIndex != -1) { Place(pos); audioPlayer.PlayClip(placeSound); } else { SelectObject(-1); } } else if (Input.GetMouseButtonDown(1)) { audioPlayer.PlayClip(dropSound); SelectObject(-1); } if (selectedObjectIndex > -1) { if (level.board.GetBoardObject(pos)) { SelectedObject.SetPreview(false); } else { SelectedObject.SetPreview(true); SelectedObject.Move(pos); } } } else if (target is WallObject) { WallObject wall = target as WallObject; Vector2Int pos = wall.getPos(); if ((Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1)) && selectedObjectIndex > -1) { audioPlayer.PlayClip(dropSound); SelectObject(-1); } if (selectedObjectIndex > -1) { SelectedObject.SetPreview(false); } } } else { if (previousHover != null) { previousHover.OnHoverExit(); previousHover = null; } if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1)) { SelectObject(-1); audioPlayer.PlayClip(dropSound); } if (selectedObjectIndex > -1) { SelectedObject.SetPreview(false); } } } else { if (previousHover != null) { previousHover.OnHoverExit(); previousHover = null; } if (selectedObjectIndex > -1) { SelectedObject.SetPreview(false); } if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1)) { SelectObject(-1); } } }