예제 #1
0
    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);
    }
예제 #2
0
    private void BuildBarrack(BarrackScriptableObject barrackToBuild)
    {
        // TO:DO --> Use RuntimeData to create the barrack
        Barrack barrack = barrackFactory.CreateBarrack(barrackToBuild.codBarrack, true, bobAIObjective);

        Vector2 buildPosition = PickBuildPosition();

        barrack.GameObject.transform.position = buildPosition;
        bobAIGoldReserve.SpendGold(barrack.ValCost);

        buildingPositions.Remove(buildPosition);
    }