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); } }
private void setNeighbours(WindowTile clone) { if (inBounds(windowTiles, clone.id - clone.tilesPerRow)) { clone.tileUp = windowTiles[clone.id - clone.tilesPerRow]; clone.adjacentList.Add(clone.tileUp); } if (inBounds(windowTiles, clone.id + clone.tilesPerRow)) { clone.tileDown = windowTiles[clone.id + clone.tilesPerRow]; clone.adjacentList.Add(clone.tileDown); } if (inBounds(windowTiles, clone.id - 1) && clone.id % clone.tilesPerRow != 0) { clone.tileLeft = windowTiles[clone.id - 1]; clone.adjacentList.Add(clone.tileLeft); } if (inBounds(windowTiles, clone.id + 1) && (clone.id + 1) % clone.tilesPerRow != 0) { clone.tileRight = windowTiles[clone.id + 1]; clone.adjacentList.Add(clone.tileRight); } if (inBounds(windowTiles, clone.id - clone.tilesPerRow - 1) && clone.id % clone.tilesPerRow != 0) { clone.tileUpLeft = windowTiles[clone.id - clone.tilesPerRow - 1]; clone.adjacentList.Add(clone.tileUpLeft); } if (inBounds(windowTiles, clone.id - clone.tilesPerRow + 1) && (clone.id + 1) % clone.tilesPerRow != 0) { clone.tileUpRight = windowTiles[clone.id - clone.tilesPerRow + 1]; clone.adjacentList.Add(clone.tileUpRight); } if (inBounds(windowTiles, clone.id + clone.tilesPerRow - 1) && clone.id % clone.tilesPerRow != 0) { clone.tileDownLeft = windowTiles[clone.id + clone.tilesPerRow - 1]; clone.adjacentList.Add(clone.tileDownLeft); } if (inBounds(windowTiles, clone.id + clone.tilesPerRow + 1) && (clone.id + 1) % clone.tilesPerRow != 0) { clone.tileDownRight = windowTiles[clone.id + clone.tilesPerRow + 1]; clone.adjacentList.Add(clone.tileDownRight); } }
public void createWindow(string side) { int index = UnityEngine.Random.Range(0, windowNames.Length); string window = windowNames[index]; for (int i = 0; i < 20; i++) { WindowTile clone = Instantiate(baseTile) as WindowTile; clone.setFront(window, i); clone.id = i; clone.tag = "TileClone" + side; clone.tilesPerRow = 5; windowTiles.Add(clone); } foreach (WindowTile win in windowTiles) { setNeighbours(win); } difficulty = UnityEngine.Random.Range(0, 6); windowName = window; }
public static void TileWindows(List <IntPtr> handlesIntPtrs, WindowTile tileType = WindowTile.Horizontally, int xDivisions = 1, int ydivisions = 1, int monitorindex = 0, int xOrigin = 0, int yOrigin = 0) { Screen[] screens = Screen.AllScreens; var currentMonitor = screens[monitorindex]; int screenWidth = currentMonitor.Bounds.Width; int screenHeight = currentMonitor.Bounds.Height; int windowTileWidth = screenWidth / xDivisions; int windowTileHeight = screenHeight / ydivisions; int x = currentMonitor.Bounds.X; int y = currentMonitor.Bounds.Y; foreach (var handlesIntPtr in handlesIntPtrs) { MoveWindow(handlesIntPtr, x, y, windowTileWidth, windowTileHeight, true); switch (tileType) { case WindowTile.Horizontally: x += windowTileWidth; if (x + windowTileWidth >= screenWidth) { y += windowTileHeight; x = currentMonitor.Bounds.X; } break; case WindowTile.Vertically: y += windowTileHeight; if (y + windowTileHeight >= screenHeight) { y = currentMonitor.Bounds.Y; x += windowTileWidth; } break; default: break; } } }
// 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"); } } }
private void Awake() { windowTileGameObject = GameObject.Find("WindowTile"); baseTile = windowTileGameObject.GetComponent <WindowTile>(); }
public void setWindowTiles(WindowTile windowTile) { this.windowTiles.Add(windowTile); }