private void UpdateMapList() { chooseMapTexts.ForEach(c => Destroy(c.gameObject)); chooseMapTexts.Clear(); mapsCanvas.gameObject.SetActive(false); var maps = mapService.PlayerMaps.Where(map => map.type == mapType && map.favorite).ToList(); if (mapType == MapType.MINE) { maps.Sort(mineComparer); } if (maps.IsEmpty()) { var emptyMapList = Instantiate(chooseMapTextPrefab, mapsCanvas); emptyMapList.SetMap(null); chooseMapTexts.Add(emptyMapList); } else { maps.ForEach(map => { var mapNameInstance = Instantiate(chooseMapTextPrefab, mapsCanvas); mapNameInstance.SetMap(map); mapNameInstance.AddClickListener(() => { mapService.ChangeMapTo(map.mapId); Destroy(gameObject); }); chooseMapTexts.Add(mapNameInstance); }); } mapsCanvas.gameObject.SetActive(true); }
private void HandleTileTap(PlayerMapTile tile) { if (tile.discoverable) { if (resourcesService.EnoughResources(ResourceType.STEAM, currentMap.discoverySteamCost)) { mapService.DiscoverTile(currentMap.mapId, tile); } else { var error = popupCanvasController.OpenPopup(errorPopupPrefab); error.SetError("Insufficient resources", "Not enough steam to discover map tile"); } return; } if (tile.discovered) { if (tile.fightId != null && (tile.victoriousFight == false || tile.fightRepeatable == true)) { var mission = missionService.GetMission(currentMap.mapId, tile.posX, tile.posY); if (mission != null) { var missionPopup = popupCanvasController.OpenPopup(missionDetailPrefab); missionPopup.SetMission(mission); } else { var fightPopup = popupCanvasController.OpenPopup(startFightPrefab); fightPopup.SetMapTile(currentMap, tile); } } else if (tile.structure != null) { if (tile.portalToMapId != null) { mapService.ChangeMapTo((long)tile.portalToMapId); } else if (tile.buildingType != null) { var building = buildingService.Building((BuildingType)tile.buildingType); if (building != null) { metagameManager.OpenBuilding(building.type); } else { Debug.Log($"discover new building: {tile.buildingType}"); } } else if (!tile.chestOpened) { mapService.OpenChest(currentMap.mapId, tile, data => { if (data.looted != null) { var lootedPopup = popupCanvasController.OpenPopup(lootedPrefab); lootedPopup.SetLooted(data.looted); } }); } } } }