예제 #1
0
    public IEnumerator SetupRentTile(TileController_Country tile, PlayerController player)
    {
        if (!player.botController)
        {
            this.gameObject.SetActive(true);
        }

        clicked = false;

        var tileBuyable = tile.tile as TileBuyable_Country;

        int rentPrice = (int)MathDt.GetRentPrice(tileBuyable.price, tile.level) * (tile.Multiplier / 100);

        Transform payRent = rentPanel.transform.GetChild(0).Find("Pay");

        payRent.GetComponentInChildren <TextMeshProUGUI>().text = "Pagar aluguel de $" + MathDt.ConfigureMoney(rentPrice);

        var backgroundHeader = this.transform.Find("BackgroundHeader");

        backgroundHeader.GetComponent <Image>().color = tile.Owner.mainColor;
        backgroundHeader.GetChild(0).GetComponent <TextMeshProUGUI>().text = tile.tile.nameTile;

        Button rentButton = payRent.GetComponentInChildren <Button>();

        rentButton.onClick.RemoveAllListeners();
        rentButton.onClick.AddListener(() =>
        {
            clicked = true;
            player.walletController.TransferMoney(rentPrice, rentPrice, tile.Owner);
            player.LogMessagePlayer($"{player.name} pagou {rentPrice} para {tile.Owner.name} em: {tile.tile.nameTile}", true);
            this.gameObject.SetActive(false);
        });

        int hostilePrice = (int)MathDt.GetHostileTakeoverPrice((int)MathDt.GetContructionPrice(tileBuyable.price, tile.level));

        Transform payHostile = hostileTakeoverPanel.transform.GetChild(0).Find("Buy");

        payHostile.GetComponentInChildren <TextMeshProUGUI>().text = "Compra hostil por $" + MathDt.ConfigureMoney(hostilePrice);

        Button hostileButton = payHostile.GetComponentInChildren <Button>();

        hostileButton.onClick.RemoveAllListeners();
        hostileButton.onClick.AddListener(() =>
        {
            clicked         = true;
            int creditValue = (int)MathDt.GetContructionPrice(tileBuyable.price, tile.level);
            player.walletController.TransferMoney(hostilePrice, creditValue, tile.Owner);
            tile.Owner.properties.Remove(tile.Owner.properties.Find(n => n.index == tile.index));
            tile.BuyTile(player, $"{player.name} realizou uma aquisição hostil em: {tileBuyable.nameTile}. Sendo {creditValue} para {tile.Owner.name} e {creditValue} em impostos.", true);

            this.gameObject.SetActive(false);
        });

        if (player.walletController.currentMoney <= hostilePrice)
        {
            hostileButton.interactable = false;
        }
        else
        {
            hostileButton.interactable = true;
        }

        //BOT
        if (player.botController)
        {
            yield return(player.botController.ExecuteAction(() =>
            {
                clicked = true;
                player.walletController.TransferMoney(rentPrice, rentPrice, tile.Owner);
                player.LogMessagePlayer($"{player.name} pagou {rentPrice} para {tile.Owner.name} em: {tile.tile.nameTile}", true);
            }, null, () =>
            {
                clicked = true;
                int creditValue = (int)MathDt.GetContructionPrice(tileBuyable.price, tile.level);
                player.walletController.TransferMoney(hostilePrice, creditValue, tile.Owner);
                tile.Owner.properties.Remove(tile.Owner.properties.Find(n => n.index == tile.index));
                tile.BuyTile(player, $"{player.name} realizou uma aquisição hostil em: {tileBuyable.nameTile}. Sendo {creditValue} para {tile.Owner.name} e {creditValue} em impostos.", true);
            }));
        }

        yield return(new WaitUntil(() => clicked == true));
    }
예제 #2
0
    public IEnumerator SetupUpgradeTile(TileController_Country tile, PlayerController player)
    {
        var tileBuyable = tile.tile as TileBuyable_Country;
        int startValue  = tile.level;

        var backgroundHeader = this.transform.Find("BackgroundHeader");

        backgroundHeader.GetChild(0).GetComponent <TextMeshProUGUI>().text = tile.tile.nameTile;

        if (player.botController)
        {
            //BOT
            yield return(player.botController.ExecuteAction(() =>
            {
                int level = startValue + 1;

                if (level < 4)
                {
                    int fullPrice = (int)MathDt.GetContructionPrice(tileBuyable.price, level, tile.level);

                    player.walletController.DebitValue(fullPrice);
                    tile.BuyTile(player, $"{BabelDt.TileLevelName(level)} em: {tile.tile.nameTile}", false);
                    player.firstBuy = true;
                    tile.UpgradeLevel(level, player);
                }

                clicked = true;
            }, null, () =>
            {
                int randLevel = Random.Range(0, 100);
                int level = 3;
                if (randLevel < 30)
                {
                    level = startValue + 1;
                }
                else if (randLevel < 70)
                {
                    level = startValue + 2;
                }

                if (level > 3)
                {
                    level = 3;
                }


                int fullPrice = (int)MathDt.GetContructionPrice(tileBuyable.price, level, tile.level);

                clicked = true;
                player.walletController.DebitValue(fullPrice);
                tile.BuyTile(player, $"{BabelDt.TileLevelName(level)} em: {tile.tile.nameTile}", false);
                player.firstBuy = true;
                tile.UpgradeLevel(level, player);
            }));
        }
        else if (tile.level < 3)
        {
            this.gameObject.SetActive(true);

            clicked = false;

            if (tile.level < 3 && tile.Owner != null && tile.level > 0)
            {
                startValue++;
            }

            foreach (var aux in buyablePanel)
            {
                aux.SetActive(false);
            }

            for (int i = startValue; i < 4; i++)
            {
                buyablePanel[i].SetActive(true);
                var content = buyablePanel[i].transform.GetChild(0);

                int fullPrice = (int)MathDt.GetContructionPrice(tileBuyable.price, i, tile.level);

                Transform title    = content.transform.Find("Title");
                Transform icon     = content.transform.Find("Icon");
                Transform rentRate = content.transform.Find("Rent Rate");
                Transform buy      = content.transform.Find("Buy");

                title.GetComponent <TextMeshProUGUI>().text         = constructionName[i];
                icon.GetComponent <Image>().sprite                  = iconHouse[i];
                rentRate.GetComponent <TextMeshProUGUI>().text      = "Rent rate: <b>$" + MathDt.ConfigureMoney((int)MathDt.GetRentPrice(tileBuyable.price, i)) + "</b>";
                buy.GetComponentInChildren <TextMeshProUGUI>().text = "COMPRAR POR\n<size=32>$" + MathDt.ConfigureMoney(fullPrice) + "</size>";

                Button buyButton = buy.GetComponentInChildren <Button>();

                int level = i;

                buyButton.onClick.RemoveAllListeners();
                buyButton.onClick.AddListener(() =>
                {
                    clicked = true;
                    player.walletController.DebitValue(fullPrice);
                    tile.BuyTile(player, $"{BabelDt.TileLevelName(level)} em: {tile.tile.nameTile}", false);//Message casa
                    player.firstBuy = true;
                    tile.UpgradeLevel(level, player);

                    this.gameObject.SetActive(false);
                });

                if (player.walletController.currentMoney <= fullPrice)
                {
                    buyButton.interactable = false;
                }
                else
                {
                    buyButton.interactable = true;
                }
            }
        }
        else
        {
            clicked = true;
        }
        yield return(new WaitUntil(() => clicked == true));
    }