/// <summary> /// Builds tower at target location if conditions are met /// </summary> /// <param name="targetTileGO"></param> /// <param name="tower"></param> void BuildTower(GameObject targetTileGO, Tower tower) { if (IsTileBuildable(targetTileGO.transform.position)) { if (!DoesTileContainTower(targetTileGO.transform.position)) { GameObject go = InactivePoolObjects.Dequeue(); go.GetComponent <SpriteRenderer>().sprite = tower.TowerSprite; go.SetActive(true); go.transform.position = targetTileGO.transform.position; ActiveTowers.Add(go); Debug.Log("Built tower"); } } }
void BuildTower(Tile targetTile, Tower tower) { if (IsTileBuildable(targetTile.Position)) { if (!DoesTileContainTower(targetTile.Position)) { GameObject go = InactivePoolObjects.Dequeue(); go.GetComponent <SpriteRenderer>().sprite = tower.TowerSprite; go.SetActive(true); go.transform.position = targetTile.Position; ActiveTowers.Add(go); TileGenerator.ChangeTowerOnTile((int)targetTile.Position.x, (int)targetTile.Position.y, tower); Debug.Log("Built tower"); } } }