protected void Update() { if (Input.GetMouseButtonDown(0) && holdPiece == null) { Debug.Log("a"); Grid mouseGrid = new Grid(Input.mousePosition); if (mouseGrid.row >= 0 && mouseGrid.row < Board.Size.row && mouseGrid.col >= 0 && mouseGrid.col < Board.Size.col) { if (pieces[mouseGrid.row, mouseGrid.col] != null) { holdPiece = new HoldPiece(); holdPiece.grid = mouseGrid; } } } if (Input.GetMouseButton(0) && holdPiece != null) { Debug.Log("b"); pieces[holdPiece.grid.row, holdPiece.grid.col].position = Input.mousePosition + new Vector3(-Board.gridSize / 2f, Board.gridSize / 2f); holdPiece.index = pieces[holdPiece.grid.row, holdPiece.grid.col].rectTransform.GetSiblingIndex(); pieces[holdPiece.grid.row, holdPiece.grid.col].rectTransform.SetAsLastSibling(); } if (Input.GetMouseButtonUp(0) && holdPiece != null) { Debug.Log("c"); Grid mouseGrid = new Grid(Input.mousePosition); pieces[holdPiece.grid.row, holdPiece.grid.col].grid = mouseGrid; pieces[holdPiece.grid.row, holdPiece.grid.col].rectTransform.SetSiblingIndex(holdPiece.index); if (holdPiece.grid != mouseGrid) { pieces[mouseGrid.row, mouseGrid.col] = pieces[holdPiece.grid.row, holdPiece.grid.col]; pieces[holdPiece.grid.row, holdPiece.grid.col] = null; } holdPiece = null; } }
// public SteamVR_Input_Sources leftHand; // public SteamVR_Input_Sources rightHand; // public SteamVR_Action_Boolean leftAction; // public SteamVR_Action_Boolean downAction; // public SteamVR_Action_Boolean backwardAction; // public SteamVR_Action_Boolean rightAction; // public SteamVR_Action_Boolean forwardAction; // public SteamVR_Action_Boolean holdAction; // public SteamVR_Action_Boolean rotateX; // public SteamVR_Action_Boolean rotateY; // public SteamVR_Action_Boolean rotateZ; // public SteamVR_Action_Boolean rotateXNeg; // public SteamVR_Action_Boolean rotateYNeg; // public SteamVR_Action_Boolean rotateZNeg; // public SteamVR_Action_Vector2 trackpadLeftPosition; // public SteamVR_Action_Vector2 trackpadRightPosition; // public SteamVR_Action_Boolean leftActionJoy; // //public SteamVR_Action_Boolean downActionJoy; // public SteamVR_Action_Boolean backwardActionJoy; // public SteamVR_Action_Boolean rightActionJoy; // public SteamVR_Action_Boolean forwardActionJoy; // public SteamVR_Action_Boolean rotateXJoy; // public SteamVR_Action_Boolean rotateZJoy; // public SteamVR_Action_Boolean rotateZNegJoy; // public SteamVR_Action_Boolean rotateXNegJoy; // public SteamVR_Action_Vector2 leftJoyPosition; // public SteamVR_Action_Vector2 rightJoyPosition; // Use this for initialization void Start() { wallOff = 4; hasHeldBool = false; yOffset = 5; randomScript = this.gameObject.GetComponent <RandomPiece>(); holdScript = this.gameObject.GetComponent <HoldPiece>(); currentSpeed = 2.5f; currentScore = 0; currentPieces = 0; allPieces = new HashSet <PieceObject>(); sizeDim = 7; actualField = new PieceObject[sizeDim, sizeDim + yOffset, sizeDim]; boolField = new bool[sizeDim, sizeDim + yOffset, sizeDim]; shouldSpawn = true; spawnTop = new Vector3((int)Mathf.Floor(sizeDim / 2), sizeDim - 2 + yOffset, (int)Mathf.Floor(sizeDim / 2)); setBoolFieldToAllFalse(); InvokeRepeating("decreaseCurrentSpeed", 0f, currentDecrementRate); Invoke("timedDownMovement", currentSpeed); }