public void OpenBuilding(BuildingType buildingType)
        {
            if (buildingService.Building(buildingType) != null)
            {
                switch (buildingType)
                {
                case BuildingType.ACADEMY:
                    Debug.Log("goto academy");
                    break;

                case BuildingType.ARENA:
                    Debug.Log("goto arena");
                    break;

                case BuildingType.BARRACKS:
                    Debug.Log("goto barracks");
                    break;

                case BuildingType.BAZAAR:
                    Debug.Log("goto bazaar");
                    break;

                case BuildingType.FORGE:
                    Debug.Log("goto forge");
                    break;

                case BuildingType.GARAGE:
                    Debug.Log("goto garage");
                    break;

                case BuildingType.GUILD:
                    Debug.Log("goto guild");
                    break;

                case BuildingType.LABORATORY:
                    Debug.Log("goto laboratory");
                    break;

                case BuildingType.JEWELRY:
                    Debug.Log("goto jewelry");
                    break;

                case BuildingType.STORAGE:
                    buildingCanvasController.OpenBuilding(storagePrefab);
                    break;
                }
            }
        }
Exemplo n.º 2
0
        private void UpdateStorage()
        {
            var storage = buildingService.Building(BuildingType.STORAGE);
            var res     = resourcesService.Resources;

            levelImg.sprite             = generalAtlas.GetSprite($"level_{storage.level}");
            coinsAmount.text            = NumberUtil.RoundAmount(res.coins);
            rubiesAmount.text           = NumberUtil.RoundAmount(res.rubies);
            steamAmount.text            = $"{NumberUtil.RoundAmount(res.steam)} / {NumberUtil.RoundAmount(res.steamMax)}";
            premiumSteamAmount.text     = $"{NumberUtil.RoundAmount(res.premiumSteam)} / {NumberUtil.RoundAmount(res.premiumSteamMax)}";
            cogwheelsAmount.text        = $"{NumberUtil.RoundAmount(res.cogwheels)} / {NumberUtil.RoundAmount(res.cogwheelsMax)}";
            premiumCogwheelsAmount.text = $"{NumberUtil.RoundAmount(res.premiumCogwheels)} / {NumberUtil.RoundAmount(res.premiumCogwheelsMax)}";
            tokensAmount.text           = $"{NumberUtil.RoundAmount(res.tokens)} / {NumberUtil.RoundAmount(res.tokensMax)}";
            premiumTokensAmount.text    = $"{NumberUtil.RoundAmount(res.premiumTokens)} / {NumberUtil.RoundAmount(res.premiumTokensMax)}";
            metalAmount.text            = $"{NumberUtil.RoundAmount(res.metal)} / {NumberUtil.RoundAmount(res.metalMax)}";
            ironAmount.text             = $"{NumberUtil.RoundAmount(res.iron)} / {NumberUtil.RoundAmount(res.ironMax)}";
            steelAmount.text            = $"{NumberUtil.RoundAmount(res.steel)} / {NumberUtil.RoundAmount(res.steelMax)}";
            woodAmount.text             = $"{NumberUtil.RoundAmount(res.wood)} / {NumberUtil.RoundAmount(res.woodMax)}";
            brownCoalAmount.text        = $"{NumberUtil.RoundAmount(res.brownCoal)} / {NumberUtil.RoundAmount(res.brownCoalMax)}";
            blackCoalAmount.text        = $"{NumberUtil.RoundAmount(res.blackCoal)} / {NumberUtil.RoundAmount(res.blackCoalMax)}";
            woodenKeysAmount.text       = $"{NumberUtil.RoundAmount(res.woodenKeys)}";
            bronzeKeysAmount.text       = $"{NumberUtil.RoundAmount(res.bronzeKeys)}";
            silverKeysAmount.text       = $"{NumberUtil.RoundAmount(res.silverKeys)}";
            goldenKeysAmount.text       = $"{NumberUtil.RoundAmount(res.goldenKeys)}";
        }
Exemplo n.º 3
0
        public void SetBuildingType(BuildingType type)
        {
            buildingType = type;
            var building = buildingService.Building(buildingType);

            buildingName.text = StringUtil.Readable(buildingType.ToString());
            levelImg.sprite   = generalAtlas.GetSprite($"level_{building.level}");

            var lvl = 2;

            while (propertyService.Properties($"{buildingType}_BUILDING", lvl).IsEmpty() == false)
            {
                var btn = Instantiate(levelButtonPrefab, levelButtonCanvas);
                btn.buildingLevel = lvl;
                btn.SetLevelIcon(generalAtlas.GetSprite($"level_{lvl}"), lvl <= building.level);
                btn.AddClickListener(() =>
                {
                    SetLevel(btn.buildingLevel);
                });
                levelButtons.Add(btn);
                lvl++;
            }

            var maxLvl = lvl - 1;

            if (building.level == maxLvl)
            {
                SetLevel(maxLvl);
            }
            else
            {
                SetLevel(building.level + 1);
            }

            levelButtonCanvas.localPosition = new Vector3((building.level - 1) * -170f, 0, 0);
        }
Exemplo n.º 4
0
        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);
                            }
                        });
                    }
                }
            }
        }