public void TryPlaceCard() { var mousePos = Input.mousePosition; //mousePos.z = GameCamera.GetGameCamera( 0 ).currentViewDistance - 1.1f; // select distance from the camera //mousePos = GameCamera.GetCamera( 0 ).ScreenToWorldPoint( mousePos ); mousePos.z = (Camera.main.farClipPlane - Camera.main.nearClipPlane) * .5f; // select distance from the camera mousePos = Camera.main.ScreenToWorldPoint(mousePos); Ray r = new Ray(mousePos, Vector3.right); RaycastHit[] hits; hits = Physics.RaycastAll(r, 1000f); for (int i = 0; i < hits.Length; ++i) { CardPlacement cplace = hits[i].collider.GetComponent <CardPlacement>(); if (cplace != null) { if (cplace.TryPlaceCardHere(this) == false) { break; } } } ClearHeldStatus(); }
int CanPlaceACard(int x, int y) { CardPlacement cplace = gameBoard.GetPlacement(x, y); if (cplace == null) { return(-1); } if (cplace.HasCard) { return(-1); } for (int i = 0; i < hand.HandSize; ++i) { if (usedCards.Contains(i)) { continue; } bool result = cplace.TryPlaceCardHere(hand.currentHand[i]); if (result) { usedCards.Add(i); return(i); } } return(-1); }