private bool isOnEdge(WindowTile tile) { if (tile.getId() % 5 == 0 || tile.getId() == 1 || tile.getId() == 2 || tile.getId() == 3 || tile.getId() % 5 == 4 || tile.getId() == 16 || tile.getId() == 17 || tile.getId() == 18) { return(true); } else { return(false); } }
// Update is called once per frame void Update() { //Selecting Dice & Tile Vector3 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); mousePosition.z = 0.1f; if (Input.GetMouseButtonDown(0)) { foreach (Dice d in draftedDices) { if (d.getBounds().Contains(mousePosition) && d.CompareTag("clone")) { selectedDice = d; //Debug.Log("Selected dice value: " + selectedDice.getDiceValue() + " and color: " + selectedDice.getDiceColorName()); } } if (selectedDice != null) { foreach (WindowTile tile in playerWindow.getWindowTiles()) { if (tile.getBounds().Contains(mousePosition)) { if (placedDices.Count == 0) { if (isOnEdge(tile)) { selectedTile = tile; } else { Debug.Log("First dice must be placed on the edge of the window"); return; } } else { selectedTile = tile; } //Debug.Log("Selected tile value: " + selectedTile.getTileValue()); if (selectedTile.getTileValue() == selectedDice.getDiceColorName() || selectedTile.getTileValue() == selectedDice.getDiceValue() || selectedTile.getTileValue() == "white") { if (canBePlaced(selectedDice, selectedTile.getId())) { if (placedInTurn < 2) { Debug.Log("You can put that dice in here"); selectedDice.tag = "placed"; selectedDice.placedId = selectedTile.getId(); //Dice placed = selectedDice; draftedDices.Remove(selectedDice); placedDices.Add(selectedDice); placedInTurn++; moveDice(); } else { Debug.Log("You can't put more dice on the window this turn"); } } else { Debug.Log("Can't place dice next to the dice with same value and/or color"); } } else { Debug.Log("Try somewhere else"); } } } } else { Debug.Log("Select the dice first"); } } }