Exemplo n.º 1
0
        private void refresh(bool callRebuildDropDown)
        {
            table.Refresh();
            //if (Game.Player.movements != null)
            movementsText.text = Game.Player.movements.getString();
            if (movementsText.preferredHeight > 90 && movementsText.preferredHeight < 130)
            {
                movementsText.text += "\n\n\n\n";
            }


            movementsHorizontalScrollBar.value = 0;
            if (selectedReform == null)
            {
                voteButton.interactable = false;
                voteButton.GetComponentInChildren <Text>().text = "Select reform";
                descriptionText.text = "Select reform from left";
                forceDecisionButton.GetComponent <ToolTipHandler>().SetText("");
                voteButton.GetComponent <ToolTipHandler>().SetText("");
            } //did selected reform
            else
            {
                if (callRebuildDropDown) // meaning changed whole reform
                {
                    rebuildDropDown();
                }
                descriptionText.text = selectedReform + " reforms " + selectedReform.getDescription()
                                       + "\nCurrently: " + selectedReform.getValue() + " " + selectedReform.getValue().getDescription()
                                       + "\nSelected: ";

                //if (selectedReformValue != null)
                if (selectedReformValue != selectedReform.getValue())
                {
                    descriptionText.text += selectedReformValue + " " + selectedReformValue.getDescription();
                }
                else
                {
                    descriptionText.text += "current";
                }

                ////
                Procent procentPopulationSayedYes = new Procent(0f);
                Procent procentVotersSayedYes     = Game.Player.getYesVotes(selectedReformValue, ref procentPopulationSayedYes);

                Dictionary <PopType, int> divisionPopulationResult = new Dictionary <PopType, int>();
                Dictionary <PopType, int> divisionVotersResult     = Game.Player.getYesVotesByType(selectedReformValue, ref divisionPopulationResult);

                if (selectedReformValue != selectedReform.getValue())
                {
                    if (Game.Player.government.getValue() != Government.Despotism)
                    {
                        descriptionText.text += "\n" + procentVotersSayedYes + " of voters want this reform ( ";
                        foreach (PopType type in PopType.getAllPopTypes())
                        {
                            if (divisionVotersResult[type] > 0)
                            {
                                Procent res = new Procent(divisionVotersResult[type] / (float)Game.Player.getPopulationAmountByType(type));
                                descriptionText.text += res + " of " + type + "; ";
                            }
                        }
                        descriptionText.text += ")";
                    }
                    else
                    {
                        descriptionText.text += "\nNobody to vote - Despot rule everything";
                    }

                    descriptionText.text += "\n" + procentPopulationSayedYes + " of population want this reform ( ";
                    foreach (PopType type in PopType.getAllPopTypes())
                    {
                        if (divisionPopulationResult[type] > 0)
                        {
                            Procent res = new Procent(divisionPopulationResult[type] / (float)Game.Player.getPopulationAmountByType(type));
                            descriptionText.text += res + " of " + type + "; ";
                        }
                    }
                    descriptionText.text += ")";
                }

                if (selectedReformValue != null)// && selectedReformValue != selectedReform.getValue())
                {
                    if (procentVotersSayedYes.get() >= Options.votingPassBillLimit || Game.Player.government.getValue() == Government.Despotism)
                    { // has enough voters
                        voteButton.interactable = selectedReformValue.allowed.isAllTrue(Game.Player, selectedReformValue, out voteButton.GetComponent <ToolTipHandler>().text);
                        forceDecisionButton.GetComponent <ToolTipHandler>().SetText(voteButton.GetComponent <ToolTipHandler>().GetText());
                        forceDecisionButton.interactable = false;
                        voteButton.GetComponentInChildren <Text>().text = "Vote for " + selectedReformValue;
                    }
                    else // not enough voters
                    {
                        voteButton.interactable          = false;
                        forceDecisionButton.interactable = selectedReformValue.allowed.isAllTrue(Game.Player, selectedReformValue, out forceDecisionButton.GetComponent <ToolTipHandler>().text);
                        voteButton.GetComponent <ToolTipHandler>().SetText(forceDecisionButton.GetComponent <ToolTipHandler>().GetText());
                        voteButton.GetComponentInChildren <Text>().text           = "Not enough votes";
                        forceDecisionButton.GetComponent <ToolTipHandler>().text += "\n\nForcing decision against people's desires will drop loyalty!";
                    }
                }
            }
        }
Exemplo n.º 2
0
    public void refresh(bool callRebuildDropDown)
    {
        hide();
        if (selectedReform != null)
        {
            if (callRebuildDropDown) // meaning changed whole reform
            {
                rebuildDropDown();
            }

            descriptionText.text = selectedReform + " reforms - " + selectedReform.getDescription()
                                   + "\n\nCurrently: " + selectedReform.getValue() + " - " + selectedReform.getValue().getDescription()
                                   + "\n\nSelected: ";

            //if (selectedReformValue != null)
            if (selectedReformValue != selectedReform.getValue())
            {
                descriptionText.text += selectedReformValue + " - " + selectedReformValue.getDescription();
            }
            else
            {
                descriptionText.text += "current";
            }


            ////
            Procent procentPopulationSayedYes = new Procent(0f);
            Procent procentVotersSayedYes     = Game.player.getYesVotes(selectedReformValue, ref procentPopulationSayedYes);

            Dictionary <PopType, uint> divisionPopulationResult = new Dictionary <PopType, uint>();
            Dictionary <PopType, uint> divisionVotersResult     = Game.player.getYesVotesByType(selectedReformValue, ref divisionPopulationResult);

            if (selectedReformValue != selectedReform.getValue())
            {
                if (Game.player.government.status != Government.Despotism)
                {
                    descriptionText.text += "\n\n" + procentVotersSayedYes + " of voters want this reform ( ";
                    foreach (PopType type in PopType.allPopTypes)
                    {
                        if (divisionVotersResult[type] > 0)
                        {
                            Procent res = new Procent(divisionVotersResult[type] / (float)Game.player.FindPopulationAmountByType(type));
                            descriptionText.text += res + " of " + type + "; ";
                        }
                    }
                    descriptionText.text += ")";
                }
                else
                {
                    descriptionText.text += "\n\nNobody to vote - Despot rule everything";
                }
                descriptionText.text += "\n" + procentPopulationSayedYes + " of population want this reform ( ";
                foreach (PopType type in PopType.allPopTypes)
                {
                    if (divisionPopulationResult[type] > 0)
                    {
                        Procent res = new Procent(divisionPopulationResult[type] / (float)Game.player.FindPopulationAmountByType(type));
                        descriptionText.text += res + " of " + type + "; ";
                    }
                }
                descriptionText.text += ")";
            }


            if (selectedReformValue != null && selectedReformValue != selectedReform.getValue())
            {
                if (procentVotersSayedYes.get() >= Game.votingPassBillLimit || Game.player.government.status == Government.Despotism)
                { // has enough voters
                    voteButton.interactable = selectedReformValue.allowed.isAllTrue(Game.player, out voteButton.GetComponentInChildren <ToolTipHandler>().tooltip);
                    forceDecisionButton.GetComponentInChildren <ToolTipHandler>().tooltip = voteButton.GetComponentInChildren <ToolTipHandler>().tooltip;
                    forceDecisionButton.interactable = false;
                    voteButton.GetComponentInChildren <Text>().text = "Vote " + selectedReformValue;
                }
                else // not enough voters
                {
                    voteButton.interactable          = false;
                    forceDecisionButton.interactable = selectedReformValue.allowed.isAllTrue(Game.player, out forceDecisionButton.GetComponentInChildren <ToolTipHandler>().tooltip);
                    voteButton.GetComponentInChildren <ToolTipHandler>().tooltip = forceDecisionButton.GetComponentInChildren <ToolTipHandler>().tooltip;
                    voteButton.GetComponentInChildren <Text>().text = "Not enough votes";
                }
            }
            else // this reform already enacted
            {
                voteButton.interactable          = false;
                forceDecisionButton.interactable = false;
                forceDecisionButton.GetComponentInChildren <ToolTipHandler>().tooltip = "";
                voteButton.GetComponentInChildren <ToolTipHandler>().tooltip          = "";
            }
        } //didnt selected reform
        else
        {
            voteButton.interactable = false;
            voteButton.GetComponentInChildren <Text>().text = "Select reform";
            descriptionText.text = "Select reform from left";
            forceDecisionButton.GetComponentInChildren <ToolTipHandler>().tooltip = "";
            voteButton.GetComponentInChildren <ToolTipHandler>().tooltip          = "";
        }

        show(false);
    }