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); }
public void SelectBuildPosition(int barrackID) { AvaliableTileSelection.ChangeMask(tilemapHandler, true); if (buildPositionSelection != null) { StopCoroutine(buildPositionSelection); buildPositionSelection = null; } isPlaceSelected = false; this.barrackID = barrackID; buildPositionSelection = StartCoroutine(BuildPositionDetection()); }