if (Input.GetMouseButtonDown(0)) //Sköter spelarens input { if (ActivePlayer is HumanPlayerScript && InputEnabled) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { switch (hit.transform.tag) { case "Marble": if (!jumping) { if (hit.transform.gameObject.GetComponent().owner is HumanPlayerScript) { if (activeMarble != null) { DeactivateMarble(); if (activeMarble == hit.transform.gameObject.GetComponent()) { activeMarble = null; break; } activeMarble = null; } activeMarble = hit.transform.gameObject.GetComponent(); activeMarble.Enlarge(true); foreach (TileScript legalMove in activeMarble.FindLegalMoves()) { legalMove.SetLight(true); } } } break; case "Tile": if (activeMarble != null) { TileScript tile = hit.transform.gameObject.GetComponent(); if (!jumping) { foreach (TileScript legalMove in activeMarble.LegalMoves) { if (legalMove == tile) { jumping = true; foreach (ConnectedTile neighbor in activeMarble.GetCurrentTile().connectedTiles) { if (neighbor.tile == tile) { jumping = false; break; } } foreach (TileScript t in activeMarble.LegalMoves) { if (t != tile) { t.SetLight(false); } } activeMarble.Move(tile, jumping); InputEnabled = false; } } } else { foreach (TileScript potentialJump in legalJumps) { if (tile == potentialJump) { foreach (TileScript otherTile in legalJumps) { if (otherTile != tile) otherTile.SetLight(false); } activeMarble.Move(tile, true); InputEnabled = false; } } } } break; default: if (!jumping) { if (activeMarble) { DeactivateMarble(); } activeMarble = null; } break; } } } }