public void Show(SelectableTile tile) { currentTile = tile; transform.position = Camera.main.WorldToScreenPoint(currentTile.transform.position); scale = 0f; UpdateButtonList(); StartCoroutine(_Show()); }
public SelectableTile GetRandomFreeFloorTile() { SelectableTile tile = null; do { tile = cells.GeRandom(); } while (!tile.Selectable); return(tile); }
public void SpawnEnemy(GameObject enemyPrefab) { SelectableTile spawnTile = spawnTiles [Random.Range(0, spawnTiles.Count)]; /*do { * spawnTile = spawnTiles [Random.Range (0, spawnTiles.Count)]; * } while (!spawnTile.Selectable)*/ ; var pos = spawnTile.transform.position; AddEnemy(enemyPrefab.name, pos); }
private void HideOtherSelectableTiles(SelectableTile tileToKeep) { foreach (var tile in tiles) { if (!tile.Equals(tileToKeep)) { tile.ShowNormal(); } else { tile.ShowSelectable(); } } }
private void SetBounds(SelectableTile tile) { if (tile.Coordinates.X == enemySpawnArea.X && !playerXBounds [0].HasValue) { playerXBounds [0] = tile.transform.position.x; } else if (tile.Coordinates.X == (RoomSize.width - enemySpawnArea.X - 1) && !playerXBounds [1].HasValue) { playerXBounds [1] = tile.transform.position.x; } if (tile.Coordinates.Y == enemySpawnArea.Y && !playerYBounds [0].HasValue) { playerYBounds [0] = tile.transform.position.y; } else if (tile.Coordinates.Y == (RoomSize.height - enemySpawnArea.Y - 1) && !playerYBounds [1].HasValue) { playerYBounds [1] = tile.transform.position.y; } }
// Update is called once per frame void Update() { if (CashTotal.instance.CurrentCash < menu.cheapestPopupMenuItem) { if (Input.GetButtonUp("HighlightTiles")) { if (cannotAffordText) { StartCoroutine(UpdateTextForSeconds("Cannot Afford Turrets")); } } if (CashTotal.instance.CurrentCash == 0) { if (menu.IsMenuVisible()) { menu.HideAll(); if (_selectedTile != null) { _selectedTile.ShowNormal(); } } } return; } if (Input.GetButtonUp("HighlightTiles")) { if (!menu.IsMenuVisible()) { if (!selectableTilesShown) { foreach (var tile in tiles) { tile.ShowSelectable(); } selectableTilesShown = true; } else { foreach (var tile in tiles) { tile.ShowNormal(); } selectableTilesShown = false; } } else { menu.HideAll(); if (_selectedTile != null) { _selectedTile.ShowNormal(); } } } if (selectableTilesShown && Input.GetMouseButtonDown(0)) { var hit = GetTileHit(); if (hit.collider != null) { _selectedTile = hit.collider.GetComponent <SelectableTile> (); if (_selectedTile != null && _selectedTile.Selectable) { ShowPlacementMenu(_selectedTile); HideOtherSelectableTiles(_selectedTile); selectableTilesShown = false; } } } else if (Input.GetMouseButtonDown(0) && menu.IsMenuVisible()) { // menu.RegisterMenuToClose (); menu.HideAll(); if (_selectedTile != null) { _selectedTile.ShowNormal(); } } }
public void RegisterTile(SelectableTile tile) { tiles.Add(tile); }
public void ShowPlacementMenu(SelectableTile tile) { menu.Show(tile); }
private void PlaceInCentre() { _currentTile = FloorManager.instance.GetCentreTile(); _currentTile.Selectable = false; transform.position = _currentTile.transform.position; }
private void SetCentreTile() { var centre = new Vector2i((int)FloorManager.instance.RoomSize.width / 2, (int)FloorManager.instance.RoomSize.height / 2); centreTile = FloorManager.instance.GetFloorTile(centre); }
public void RegisterTile(SelectableTile tile) { spawnTiles.Add(tile); tile.transform.SetParent(transform); }
public void Show(SelectableTile tile) { popupMenus [currentMenu].Hide(); currentMenu = (currentMenu + 1) % popupMenus.Length; popupMenus [currentMenu].Show(tile); }