public IEnumerator UpdateMoney(int money)
 {
     exibedMoney           = money;
     this.playerMoney.text = "$" + MathDt.ConfigureMoney(money);
     yield return(true);
 }
Example #2
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));
    }
 public void ConfigureUI(string playerName, int money)
 {
     this.playerName.text  = playerName;
     this.playerMoney.text = "$" + MathDt.ConfigureMoney(money);
 }
Example #4
0
    public IEnumerator SetupWonderTile(TileController_Wonders tile, PlayerController player)
    {
        if (!player.botController)
        {
            this.gameObject.SetActive(true);
        }

        clicked = false;

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

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

        var tileWonder = tile.tile as TileBuyable_Wonder;

        var content = wonderPanel.transform.GetChild(0);

        int price = MathDt.wonderPrice;

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

        title.GetComponent <TextMeshProUGUI>().text         = tileWonder.nameTile;
        icon.GetComponent <Image>().sprite                  = tileWonder.icon;
        buy.GetComponentInChildren <TextMeshProUGUI>().text = "COMPRAR POR\n<size=32>$" + MathDt.ConfigureMoney(price) + "</size>";

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

        buyButton.onClick.RemoveAllListeners();
        buyButton.onClick.AddListener(() =>
        {
            clicked = true;
            player.walletController.DebitValue(price);
            tile.BuyTile(player, $"{tile.tile.nameTile} e agora possui {player.wondersInControl + 1} maravilhas!", false);//MESSAGE WONDER
            player.firstBuy = true;
            player.wondersInControl++;

            player.WonderWin();

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

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

        //BOT
        if (player.botController)
        {
            yield return(player.botController.ExecuteAction(() =>
            {
                clicked = true;
                player.walletController.DebitValue(price);
                tile.BuyTile(player, $"{tile.tile.nameTile} e agora possui {player.wondersInControl + 1} maravilhas!", false);//MESSAGE WONDER
                player.firstBuy = true;
                player.wondersInControl++;

                player.WonderWin();
            }, () => { }));
        }

        yield return(new WaitUntil(() => clicked == true));
    }
Example #5
0
    public IEnumerator ShowCanvasPlayer(PlayerController playerController)
    {
        objFreeBoat.SetActive(false);

        yield return(new WaitForSeconds(2.0f));

        if (playerController.freeBoat)
        {
            ConfigFreeBoat(playerController);
        }

        if (!playerController.botController)
        {
            this.transform.GetChild(0).gameObject.SetActive(true);
            LayoutRebuilder.ForceRebuildLayoutImmediate(this.GetComponent <RectTransform>());
        }

        clicked = false;

        btnPayJailPrice.GetComponentInChildren <TextMeshProUGUI>().text = MathDt.ConfigureMoney(MathDt.jailPrice);
        btnPayJailPrice.interactable = playerController.walletController.currentMoney >= MathDt.jailPrice;

        btnPayJailPrice.onClick.RemoveAllListeners();
        btnPayJailPrice.onClick.AddListener(() =>
        {
            clicked = true;
            playerController.walletController.DebitValue(MathDt.jailPrice);
            playerController.LogMessagePlayer($"{playerController.name} pagou por um resgate urgente para sair da prisão!", false);
            playerController.inJail = false;
            this.transform.GetChild(0).gameObject.SetActive(false);
        });

        btnTryDice.onClick.RemoveAllListeners();
        btnTryDice.onClick.AddListener(() =>
        {
            int dice1 = playerController.ThrowDice();
            int dice2 = playerController.ThrowDice();

            this.transform.GetChild(0).gameObject.SetActive(false);

            UnityEngine.Events.UnityAction afterEvent = () =>
            {
                if (dice1 == dice2)
                {
                    playerController.LogMessagePlayer($"{playerController.name} Saiu da prisao", true);//Pedro
                    playerController.inJail = false;
                }
                else
                {
                    playerController.LogMessagePlayer($"{playerController.name} está perdido no triângulo das bermudas! Restam {3 - playerController.jailRow} turnos para ser resgatado!", true);
                }

                clicked = true;
                this.transform.GetChild(0).gameObject.SetActive(true);
                this.transform.GetChild(0).gameObject.SetActive(false);
            };

            StartCoroutine(playerController.manager.RollDice(dice1, dice2, playerController.playerNumber, afterEvent));
        });

        //BOT
        if (playerController.botController)
        {
            if (playerController.freeBoat)
            {
                yield return(playerController.botController.ExecuteAction(() =>
                {
                    clicked = true;
                    playerController.inJail = false;
                    playerController.freeBoat = false;
                    playerController.LogMessagePlayer($"{playerController.name} utilizou um sinalizador para sair da prisão!", false);
                }));
            }
            else
            {
                yield return(playerController.botController.ExecuteAction(() =>
                {
                    clicked = true;
                    int dice1 = playerController.ThrowDice();
                    int dice2 = playerController.ThrowDice();

                    StartCoroutine(playerController.manager.RollDice(dice1, dice2, playerController.playerNumber));

                    if (dice1 == dice2)
                    {
                        playerController.LogMessagePlayer($"{playerController.name} ", true);//Pedro
                        playerController.inJail = false;
                    }
                    else
                    {
                        playerController.LogMessagePlayer($"{playerController.name} está perdido no triângulo das bermudas! Restam {3 - playerController.jailRow} turnos para ser resgatado!", true);
                    }
                }, null, () =>
                {
                    clicked = true;
                    playerController.walletController.DebitValue(MathDt.jailPrice);
                    playerController.LogMessagePlayer($"{playerController.name} pagou por um resgate urgente para sair da prisão!", false);
                    playerController.inJail = false;
                }));
            }
        }

        yield return(new WaitUntil(() => clicked == true));
    }
Example #6
0
    public IEnumerator SetupRentWonderTile(TileController_Wonders tile, PlayerController player)
    {
        if (!player.botController)
        {
            this.gameObject.SetActive(true);
        }

        clicked = false;

        var tileWonder = tile.tile as TileBuyable_Wonder;

        int price = (int)MathDt.GetWonderRentPrice(tile.Owner.wondersInControl);

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

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

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

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

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

        rentButton.onClick.RemoveAllListeners();
        rentButton.onClick.AddListener(() =>
        {
            clicked = true;
            player.walletController.DebitValue(price);
            tile.Owner.walletController.CreditValue(price);

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

        int hostilePrice = MathDt.hostileWonderTakeoverPrice;

        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;
            player.walletController.DebitValue(hostilePrice);
            tile.Owner.walletController.CreditValue(MathDt.wonderPrice);

            tile.BuyTile(player, $"{player.name} realizou uma aquisição hostil em: {tile.tile.nameTile}. Sendo {MathDt.wonderPrice} para {tile.Owner.name} e {hostilePrice} em impostos. e agora possui {player.wondersInControl + 1} maravilhas!", true);

            tile.Owner = player;

            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.DebitValue(price);
                tile.Owner.walletController.CreditValue(price);
            }, null, () =>
            {
                clicked = true;
                player.walletController.DebitValue(hostilePrice);
                tile.Owner.walletController.CreditValue(MathDt.wonderPrice);
                tile.Owner = player;
            }));
        }

        yield return(new WaitUntil(() => clicked == true));
    }
    public void LoadAllCountryDetails()
    { 
        foreach(Transform aux in this.transform)
        {
            
            if(aux.GetComponent<TileController>())
            {
                if (aux.name.EndsWith("Country"))
                {
                    foreach (var temp in countryChildPrefab)
                    {
                        while(aux.Find(temp.name))
                        {
                            DestroyImmediate(aux.Find(temp.name).gameObject);
                        }
                        GameObject obj = Instantiate(temp, aux);
                        obj.transform.name = temp.name;
                    }

                    var tile = aux.GetComponent<TileController>().tile as TileBuyable_Country;
                    if (tile != null)
                    {
                        ColorSettings colorSettings = settingsManager.colorSettings;
                        Color backcolor = colorSettings.tradingBlockColor.Find(n => n.tradingBlock == tile.tradingBlock).color;
                        
                        Material[] mtList = aux.Find("Base").GetComponent<MeshRenderer>().sharedMaterials;
                        List<Material> newList = new List<Material>();

                        foreach(var auxMaterial in mtList)
                        {
                            if (auxMaterial.name == "TileColor")
                            {
                                var mat = new Material(auxMaterial);
                                mat.color = backcolor;
                                newList.Add(mat);
                            }
                            else
                            {
                                newList.Add(auxMaterial);
                            }
                        }

                        aux.Find("Base").GetComponent<MeshRenderer>().sharedMaterials = newList.ToArray();

                        //aux.GetComponent<SpriteRenderer>().color = backcolor;
                        aux.Find("Price").GetComponent<TextMesh>().text = MathDt.ConfigureMoney((int)tile.price);
                        aux.Find("ExtraMaterials").GetComponent<SpriteRenderer>().sprite = tile.flag;
                    }

                }
                if (aux.name.EndsWith("Wonder"))
                {
                    foreach (var temp in wonderChildPrefab)
                    {
                        while(aux.Find(temp.name))
                        {
                            DestroyImmediate(aux.Find(temp.name).gameObject);
                        }
                        GameObject obj = Instantiate(temp, aux);
                        obj.transform.name = temp.name;
                    }

                    var tile = aux.GetComponent<TileController>().tile as TileBuyable_Wonder;
                    if (tile != null)
                    {
                        ColorSettings colorSettings = settingsManager.colorSettings;

                        Color backcolor = colorSettings.wonderBackColor;

                        Material[] mtList = aux.Find("Base").GetComponent<MeshRenderer>().sharedMaterials;
                        List<Material> newList = new List<Material>();

                        foreach (var auxMaterial in mtList)
                        {
                            if (auxMaterial.name == "TileColor")
                            {
                                auxMaterial.color = backcolor;
                            }
                            newList.Add(auxMaterial);
                        }

                        aux.Find("Base").GetComponent<MeshRenderer>().sharedMaterials = newList.ToArray();

                        //aux.GetComponent<SpriteRenderer>().color = backcolor;
                        aux.Find("Price").GetComponent<TextMesh>().text = MathDt.ConfigureMoney((int)tile.price);
                    }

                }
            }
        }
    }
Example #8
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));
    }