private string GetConstructionParameters()
        {
            if (selectedConstruction.ConstructionType != ConstructionType.Population)
            {
                BuildingsBaseBonuses parameters = new BuildingsBaseBonuses();
                string text = "Production and consumption:";
                int    year = 0;
                if (selectedConstruction.ConstructionYear < (int)HistoricalPeriod.HP2_FirstYear)
                {
                    if (selectedConstruction.UpgradeYear >= (int)HistoricalPeriod.HP2_FirstYear)
                    {
                        if (GameManager.CurrentYear < selectedConstruction.UpgradeYear)
                        {
                            year = (int)HistoricalPeriod.HP1_FirstYear;
                        }
                        else
                        {
                            year = (int)HistoricalPeriod.HP2_FirstYear;
                        }
                    }
                    else
                    {
                        year = (int)HistoricalPeriod.HP1_FirstYear;
                    }
                }
                else
                {
                    year = (int)HistoricalPeriod.HP2_FirstYear;
                }

                Debug.AddToLog(selectedConstruction.UpgradeYear.ToString() + " " + year.ToString());

                float Economy     = parameters.BuildingMilleniumGoalSet(selectedConstruction.ConstructionName, year).Economy;
                float Health      = parameters.BuildingMilleniumGoalSet(selectedConstruction.ConstructionName, year).Health;
                float Education   = parameters.BuildingMilleniumGoalSet(selectedConstruction.ConstructionName, year).Education;
                float Energy      = parameters.BuildingMilleniumGoalSet(selectedConstruction.ConstructionName, year).Energy;
                float Food        = parameters.BuildingMilleniumGoalSet(selectedConstruction.ConstructionName, year).Food;
                float Environment = parameters.BuildingMilleniumGoalSet(selectedConstruction.ConstructionName, year).Environment;

                string pozitiveParams = "";
                string negativeParams = "";

                if (Economy > 0)
                {
                    pozitiveParams += "\n Economy              +" + Economy.ToString();
                }
                else if (Economy < 0)
                {
                    negativeParams += "\n Economy               " + Economy.ToString();
                }
                if (Health > 0)
                {
                    pozitiveParams += "\n Health                  +" + Health.ToString();
                }
                else if (Health < 0)
                {
                    negativeParams += "\n Health                   " + Health.ToString();
                }
                if (Education > 0)
                {
                    pozitiveParams += "\n Education            +" + Education.ToString();
                }
                else if (Education < 0)
                {
                    negativeParams += "\n Education             " + Education.ToString();
                }
                if (Energy > 0)
                {
                    pozitiveParams += "\n Energy                  +" + Energy.ToString();
                }
                else if (Energy < 0)
                {
                    negativeParams += "\n Energy                   " + Energy.ToString();
                }
                if (Food > 0)
                {
                    pozitiveParams += "\n Food                     +" + Food.ToString();
                }
                else if (Food < 0)
                {
                    negativeParams += "\n Food                      " + Food.ToString();
                }
                if (Environment > 0)
                {
                    pozitiveParams += "\n Environment       +" + Environment.ToString();
                }
                else if (Environment < 0)
                {
                    negativeParams += "\n Environment        " + Environment.ToString();
                }

                text += pozitiveParams + negativeParams;
                return(text);
            }
            else //population
            {
                return("");
            }
        }
Esempio n. 2
0
        public GameManager(Game game)
            : base(game)
        {
            timeManager = new TimeManager(game);
            Game.Services.AddService(typeof(GameManager), this);
            Game.Components.Add(this);
            timeMachine = new TimeMachine(game);
            //money
            AllocateMemoryForMoney();

            //properties, bonuses etc.
            properties = new BuildingsBaseProperties();
            bonuses = new BuildingsBaseBonuses();
            modifier = new Modifier(game);
        }
Esempio n. 3
0
        public void RefreshTooltip()
        {
            tooltipText = GetDescription(building);


            BuildingsBaseBonuses parameters = new BuildingsBaseBonuses();
            BuildingsBaseProperties properties = new BuildingsBaseProperties();
            PopulationBuildingProperties popProp = new PopulationBuildingProperties();

            float Economy = parameters.BuildingMilleniumGoalSet(building, GameManager.CurrentYear).Economy;
            float Health = parameters.BuildingMilleniumGoalSet(building, GameManager.CurrentYear).Health;
            float Education = parameters.BuildingMilleniumGoalSet(building, GameManager.CurrentYear).Education;
            float Energy = parameters.BuildingMilleniumGoalSet(building, GameManager.CurrentYear).Energy;
            float Food = parameters.BuildingMilleniumGoalSet(building, GameManager.CurrentYear).Food;
            float Environment = parameters.BuildingMilleniumGoalSet(building, GameManager.CurrentYear).Environment;

            string pozitiveParams = "";
            string negativeParams = "";

            if (Economy > 0)
                pozitiveParams += "\n Economy             +" + Economy.ToString();
            else if (Economy < 0)
                negativeParams += "\n Economy             -" + Economy.ToString();
            if (Health > 0)
                pozitiveParams += "\n Health                  +" + Health.ToString();
            else if (Health < 0)
                negativeParams += "\n Health                  -" + Health.ToString();
            if (Education > 0)
                pozitiveParams += "\n Education          +" + Education.ToString();
            else if (Education < 0)
                negativeParams += "\n Education          -" + Education.ToString();
            if (Energy > 0)
                pozitiveParams += "\n Energy                  +" + Energy.ToString();
            else if (Energy < 0)
                negativeParams += "\n Energy                  -" + Energy.ToString();
            if (Food > 0)
                pozitiveParams += "\n Food                      +" + Food.ToString();
            else if (Food < 0)
                negativeParams += "\n Food                      -" + Food.ToString();
            if (Environment > 0)
                pozitiveParams += "\n Environment    +" + Environment.ToString();
            else if (Environment < 0)
                negativeParams += "\n Environment    -" + Environment.ToString();
            

            int price = properties.BuildingBaseProperties(building, GameManager.CurrentYear, 0, GameManager.CurrentYear).Price;
            
            bool canAfford = true;
            try
            {
            canAfford = (GameManager.GetMoney(GameManager.CurrentYear) >= price);
            }
            catch(Exception ex){}
            if (!canAfford)
            {
                //can afford
                tooltipText += "\n  - CAN NOT AFFORD - ";
                tooltipText += pozitiveParams;
                tooltipText += negativeParams;
            }
            else //can not afford
            {
                tooltipText += "\n" + pozitiveParams;
                tooltipText += negativeParams;
            }

            tooltipText += "\nPrice: $" + price.ToString();
            if (building == Construction.PopulationCity || building == Construction.PopulationMetropolis ||
                 building == Construction.PopulationTown || building == Construction.PopulationVillage)
            {
                tooltipText += "\nNormal capacity:\n   " + popProp.MaxCapacity(building, GameManager.CurrentYear, GameManager.CurrentYear).ToString();
            }
        }
        private string GetConstructionParameters()
        {
            if (selectedConstruction.ConstructionType != ConstructionType.Population)
            {
                BuildingsBaseBonuses parameters = new BuildingsBaseBonuses();
                string text = "Production and consumption:";
                int year = 0;
                if (selectedConstruction.ConstructionYear < (int)HistoricalPeriod.HP2_FirstYear)
                {
                    if (selectedConstruction.UpgradeYear >= (int)HistoricalPeriod.HP2_FirstYear)
                    {
                        if (GameManager.CurrentYear < selectedConstruction.UpgradeYear)
                            year = (int)HistoricalPeriod.HP1_FirstYear;
                        else
                            year = (int)HistoricalPeriod.HP2_FirstYear;
                    }
                    else
                        year = (int)HistoricalPeriod.HP1_FirstYear;
                }
                else
                    year = (int)HistoricalPeriod.HP2_FirstYear;

                Debug.AddToLog(selectedConstruction.UpgradeYear.ToString() + " " + year.ToString());

                float Economy = parameters.BuildingMilleniumGoalSet(selectedConstruction.ConstructionName, year).Economy;
                float Health = parameters.BuildingMilleniumGoalSet(selectedConstruction.ConstructionName, year).Health;
                float Education = parameters.BuildingMilleniumGoalSet(selectedConstruction.ConstructionName, year).Education;
                float Energy = parameters.BuildingMilleniumGoalSet(selectedConstruction.ConstructionName, year).Energy;
                float Food = parameters.BuildingMilleniumGoalSet(selectedConstruction.ConstructionName, year).Food;
                float Environment = parameters.BuildingMilleniumGoalSet(selectedConstruction.ConstructionName, year).Environment;

                string pozitiveParams = "";
                string negativeParams = "";

                if (Economy > 0)
                    pozitiveParams += "\n Economy              +" + Economy.ToString();
                else if (Economy < 0)
                    negativeParams += "\n Economy               " + Economy.ToString();
                if (Health > 0)
                    pozitiveParams += "\n Health                  +" + Health.ToString();
                else if (Health < 0)
                    negativeParams += "\n Health                   " + Health.ToString();
                if (Education > 0)
                    pozitiveParams += "\n Education            +" + Education.ToString();
                else if (Education < 0)
                    negativeParams += "\n Education             " + Education.ToString();
                if (Energy > 0)
                    pozitiveParams += "\n Energy                  +" + Energy.ToString();
                else if (Energy < 0)
                    negativeParams += "\n Energy                   " + Energy.ToString();
                if (Food > 0)
                    pozitiveParams += "\n Food                     +" + Food.ToString();
                else if (Food < 0)
                    negativeParams += "\n Food                      " + Food.ToString();
                if (Environment > 0)
                    pozitiveParams += "\n Environment       +" + Environment.ToString();
                else if (Environment < 0)
                    negativeParams += "\n Environment        " + Environment.ToString();

                text += pozitiveParams + negativeParams;
                return text;
            }
            else //population
            {
                return "";
            }
        }
        public void RefreshTooltip()
        {
            tooltipText = GetDescription(building);


            BuildingsBaseBonuses         parameters = new BuildingsBaseBonuses();
            BuildingsBaseProperties      properties = new BuildingsBaseProperties();
            PopulationBuildingProperties popProp    = new PopulationBuildingProperties();

            float Economy     = parameters.BuildingMilleniumGoalSet(building, GameManager.CurrentYear).Economy;
            float Health      = parameters.BuildingMilleniumGoalSet(building, GameManager.CurrentYear).Health;
            float Education   = parameters.BuildingMilleniumGoalSet(building, GameManager.CurrentYear).Education;
            float Energy      = parameters.BuildingMilleniumGoalSet(building, GameManager.CurrentYear).Energy;
            float Food        = parameters.BuildingMilleniumGoalSet(building, GameManager.CurrentYear).Food;
            float Environment = parameters.BuildingMilleniumGoalSet(building, GameManager.CurrentYear).Environment;

            string pozitiveParams = "";
            string negativeParams = "";

            if (Economy > 0)
            {
                pozitiveParams += "\n Economy             +" + Economy.ToString();
            }
            else if (Economy < 0)
            {
                negativeParams += "\n Economy             -" + Economy.ToString();
            }
            if (Health > 0)
            {
                pozitiveParams += "\n Health                  +" + Health.ToString();
            }
            else if (Health < 0)
            {
                negativeParams += "\n Health                  -" + Health.ToString();
            }
            if (Education > 0)
            {
                pozitiveParams += "\n Education          +" + Education.ToString();
            }
            else if (Education < 0)
            {
                negativeParams += "\n Education          -" + Education.ToString();
            }
            if (Energy > 0)
            {
                pozitiveParams += "\n Energy                  +" + Energy.ToString();
            }
            else if (Energy < 0)
            {
                negativeParams += "\n Energy                  -" + Energy.ToString();
            }
            if (Food > 0)
            {
                pozitiveParams += "\n Food                      +" + Food.ToString();
            }
            else if (Food < 0)
            {
                negativeParams += "\n Food                      -" + Food.ToString();
            }
            if (Environment > 0)
            {
                pozitiveParams += "\n Environment    +" + Environment.ToString();
            }
            else if (Environment < 0)
            {
                negativeParams += "\n Environment    -" + Environment.ToString();
            }


            int price = properties.BuildingBaseProperties(building, GameManager.CurrentYear, 0, GameManager.CurrentYear).Price;

            bool canAfford = true;

            try
            {
                canAfford = (GameManager.GetMoney(GameManager.CurrentYear) >= price);
            }
            catch (Exception ex) {}
            if (!canAfford)
            {
                //can afford
                tooltipText += "\n  - CAN NOT AFFORD - ";
                tooltipText += pozitiveParams;
                tooltipText += negativeParams;
            }
            else //can not afford
            {
                tooltipText += "\n" + pozitiveParams;
                tooltipText += negativeParams;
            }

            tooltipText += "\nPrice: $" + price.ToString();
            if (building == Construction.PopulationCity || building == Construction.PopulationMetropolis ||
                building == Construction.PopulationTown || building == Construction.PopulationVillage)
            {
                tooltipText += "\nNormal capacity:\n   " + popProp.MaxCapacity(building, GameManager.CurrentYear, GameManager.CurrentYear).ToString();
            }
        }