private Barrack BuildBarrack(Vector2 position, GoldReserve goldReserve) { Node clickedCell = tilemapHandler.ScreenPositionToTilemapNode(position); if (clickedCell.tile.isSlot && clickedCell.isAvailable) { Vector2 clickPosition = Camera.main.ScreenToWorldPoint(position); Barrack barrack = barrackFactory.CreateBarrack(barrackID, false, playerObjective); if (goldReserve.SpendGold(barrack.ValCost)) { barrack.GameObject.transform.position = new Vector3(clickPosition.x, clickPosition.y, 0); slotService.BlockSlot(slotService.GetSlotTilesFromTile(clickedCell)); AvaliableTileSelection.ChangeMask(tilemapHandler, false); return(barrack); } else { alertManager.ShowWarningModal("Você não tem dinheiro suficiente para comprar essa caserna!"); Destroy(barrack.GameObject); } } else { AvaliableTileSelection.ChangeMask(tilemapHandler, false); alertManager.ShowWarningModal("Esse slot está bloqueado!"); } return(null); }
private void Start() { bobAIGoldReserve = goldManager.BobAIGoldReserve; // TO:DO --> Use barracks in RuntimeData barracksPriorityList = new PriorityList <BarrackScriptableObject>(); foreach (BarrackScriptableObject barrack in barracks) { barracksPriorityList.Add(barrack, barrack.valCost); } // TO:DO --> Use the phaseData in RuntimeData RunTimePhaseData phaseData = GetComponent <RunTimePhaseData>(); if (phaseData.idtPhaseType == PhaseObjectives.ATTACK) { bobAIObjective = PhaseObjectives.DEFEND; } else { bobAIObjective = PhaseObjectives.ATTACK; } waveStartEvent.RegisterListener(HandleWaveStartEvent); towerDestroyedEvent.RegisterListener(HandleTowerDestroyedEvent); }
private void Awake() { phaseData = GetComponent <RunTimePhaseData>(); playerGoldReserve = new PlayerGoldReserve(phaseData.valIniPlayerMoney, troopDeathEvent, removedTroopOnWaveEnd, goldChangeEvent); BobAIGoldReserve = new AIGoldReserve(phaseData.valIniIAMoney, troopDeathEvent, removedTroopOnWaveEnd); }
// ---AUX --- private void upgradeBuilding(BUILDINGS buildingType) { Building b = BuildingsManager.GetInstance().getBuilding(buildingType); GoldReserve goldReserve = UserDataManager.GetInstance().gold; goldReserve.espendGold(b.getNextLevelCost()); b.upgrade(); }
private UserDataManager() { gold = new GoldReserve(0); rice = new RiceCounter(); }