void repair_OnMouseRelease(object sender, Operation_Cronos.Input.MouseEventArgs e)
        {
            int price = GetRepairCost();

            //GameManager.BuildingProperties.BuildingBaseProperties(selectedConstruction.ConstructionName, selectedConstruction.ConstructionYear, selectedConstruction.UpgradeYear, GameManager.CurrentYear).Price;

            if (GameManager.GetMoney(GameManager.CurrentYear) >= price)
            {
                GameManager.SpendMoney(GameManager.CurrentYear, price);
                GameInterface.SetMoney(GameManager.GetMoney(GameManager.CurrentYear));

                //do repair
                BuildingsBaseProperties properties = new BuildingsBaseProperties();
                selectedConstruction.SelectConstruction = false;

                selectedConstruction.Slot.ProlongReservation(GameManager.CurrentYear);
                selectedConstruction.ConstructionLifetime = (GameManager.CurrentYear - selectedConstruction.ConstructionYear) + properties.BuildingBaseProperties(selectedConstruction.ConstructionName, selectedConstruction.ConstructionYear, selectedConstruction.UpgradeYear, GameManager.CurrentYear).Lifetime;
                GameMap.RefreshBuilding(selectedConstruction.Slot);

                Close();
                int year = GameManager.CurrentYear;
                GameManager.UpdateYear(year);
            }
            else
            {
                //Debug.AddToLog("Not enough cashcaval");
                textRepairCost.Text = "Can not afford to repair";
                textRepairCost.Tint = Color.Red;
            }
        }
        private int GetUpgradeCost()
        {
            BuildingsBaseProperties bp = new BuildingsBaseProperties();
            int upgradePrice           = 0;

            if (selectedConstruction.ConstructionType != ConstructionType.Population)
            {
                upgradePrice = bp.BuildingBaseProperties(selectedConstruction.ConstructionName, selectedConstruction.ConstructionYear, selectedConstruction.UpgradeYear, GameManager.CurrentYear).UpgradePrice;
            }
            else
            {
                switch (selectedConstruction.ConstructionName)
                {//gets the upgrade cost of the next stage population construction
                case Construction.PopulationVillage:
                    upgradePrice = bp.BuildingBaseProperties(Construction.PopulationTown, selectedConstruction.ConstructionYear, selectedConstruction.UpgradeYear, GameManager.CurrentYear).UpgradePricePopulation;
                    break;

                case Construction.PopulationTown:
                    upgradePrice = bp.BuildingBaseProperties(Construction.PopulationCity, selectedConstruction.ConstructionYear, selectedConstruction.UpgradeYear, GameManager.CurrentYear).UpgradePricePopulation;
                    break;

                case Construction.PopulationCity:
                    upgradePrice = bp.BuildingBaseProperties(Construction.PopulationMetropolis, selectedConstruction.ConstructionYear, selectedConstruction.UpgradeYear, GameManager.CurrentYear).UpgradePricePopulation;
                    break;
                }
            }

            int cost = upgradePrice;

            return(cost);
        }
Exemplo n.º 3
0
        public void UndoBuild(int year, Slot slot)
        {
            BuildingsBaseProperties properties = new BuildingsBaseProperties();
            int price = properties.BuildingBaseProperties(slot.GetReservation(year).ConstructionName,
                                                          slot.GetReservation(year).StartingYear, year, year).Price;

            GUI.SetMoney(GameManager.GetMoney(year) + price);
            changesMade = true;
        }
Exemplo n.º 4
0
        public void ProlongReservation(int year)
        {
            BuildingsBaseProperties properties = new BuildingsBaseProperties();

            Reservation prolongedReservation = GetReservation(year);

            prolongedReservation.Duration = (year - GetReservation(year).StartingYear) + properties.BuildingBaseProperties(this.CurrentConstruction.ConstructionName, this.CurrentConstruction.ConstructionYear, this.CurrentConstruction.UpgradeYear, year).Lifetime;
            MakeReservation(prolongedReservation);
        }
Exemplo n.º 5
0
        public void Upgrade(Slot slot, int year)
        {
            BuildingsBaseProperties properties = new BuildingsBaseProperties();
            int price = properties.BuildingBaseProperties(slot.GetReservation(year).ConstructionName,
                                                          slot.GetReservation(year).StartingYear, year, year).Price;

            GameManager.SpendMoney(year, price / 10);
            GUI.SetMoney(GameManager.GetMoney(year));
            changesMade = true;
        }
 private int GetRepairCost()
 {
     if (selectedConstruction.ConstructionType != ConstructionType.Population)
     {
         BuildingsBaseProperties bp = new BuildingsBaseProperties();
         int price = bp.BuildingBaseProperties(selectedConstruction.ConstructionName, selectedConstruction.ConstructionYear, selectedConstruction.UpgradeYear, GameManager.CurrentYear).Price;
         int lifetimeLeftPercentage = (int)(((double)(selectedConstruction.DestructionYear - GameManager.CurrentYear) * 100) / (double)(selectedConstruction.ConstructionLifetime));
         int repairCost             = (int)((100 - lifetimeLeftPercentage) * ((double)price / 100));
         return(repairCost);
     }
     else
     {
         return(0);
     }
 }
        public Reservation(int year, int d, Construction constructionName)
        {
            startingYear = year;
            duration     = d;
            construction = constructionName;

            upgradeYear          = 0;
            isUpgraded           = false;
            isPopulationUpgraded = false;
            isDestroyed          = false;

            buildingProperties = new BuildingsBaseProperties();

            constructionStatus = ConstructionStatus.None;
        }
 /// <summary>
 ///Determines if the construction was already repaired in the current year
 /// </summary>
 private bool AlreadyRepairedInCurrentYear()
 {
     if (selectedConstruction.ConstructionType != ConstructionType.Population)
     {
         BuildingsBaseProperties properties = new BuildingsBaseProperties();
         if (selectedConstruction.ConstructionLifetime == ((GameManager.CurrentYear - selectedConstruction.ConstructionYear) + properties.BuildingBaseProperties(selectedConstruction.ConstructionName, selectedConstruction.ConstructionYear, selectedConstruction.UpgradeYear, GameManager.CurrentYear).Lifetime))
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     return(false);
 }
Exemplo n.º 9
0
        public void CreateBuilding(Slot slot, Construction building, int year)
        {
            BuildingsBaseProperties properties = new BuildingsBaseProperties();

            BaseConstruction newBuilding;

            if (slot.ConstructionType != ConstructionType.Population)
            {
                newBuilding = new BaseConstruction(this.Game, slot.XSlotCenter, slot.YSlotCenter, false, false);
            }
            else
            {
                newBuilding = new BaseConstruction(this.Game, slot.XSlotCenter, slot.YSlotCenter, true, false);
            }

            newBuilding.ConstructionName     = building;
            newBuilding.ConstructionYear     = year;
            newBuilding.ConstructionType     = slot.ConstructionType;
            newBuilding.ConstructionLifetime = properties.BuildingBaseProperties(building, year, 0, year).Lifetime;
            newBuilding.ConstructingPeriod   = properties.BuildingBaseProperties(building, year, 0, year).ConstructingPeriod;
            newBuilding.DegradationPeriod    = properties.BuildingBaseProperties(building, year, 0, year).DestructionPeriod;
            newBuilding.StackOrder           = stackOrder_slots + 1;
            newBuilding.ChangeGraphics();
            newBuilding.Slot = slot;

            AddChild(newBuilding);

            slot.CurrentConstruction = newBuilding;
            slot.MakeReservation(year, newBuilding.ConstructionLifetime, building);

            changesMade = true;

            GUI.ClearSelectedBuildingIcon();

            newBuilding.OnSelected += new EventHandler(Building_OnSelected);
            RemoveConstructionPanel();
        }
Exemplo n.º 10
0
        /// <summary>
        /// Attach a new building to a slot.
        /// </summary>
        /// <param name="slot"></param>
        private void SetNewBuilding(Slot slot)
        {
            BuildingsBaseProperties properties = new BuildingsBaseProperties();
            BaseConstruction        building;

            if (slot.ConstructionType != ConstructionType.Population)
            {
                building = new BaseConstruction(this.Game, slot.XSlotCenter, slot.YSlotCenter, false, false);
            }
            else
            {
                building = new BaseConstruction(this.Game, slot.XSlotCenter, slot.YSlotCenter, true, slot.GetReservation(GameManager.CurrentYear).IsPopulationUpgraded);
            }

            building.ConstructionName     = slot.GetReservation(GameManager.CurrentYear).ConstructionName;
            building.ConstructionYear     = slot.GetReservation(GameManager.CurrentYear).StartingYear;
            building.ConstructionLifetime = slot.GetReservation(GameManager.CurrentYear).Duration;
            building.ConstructionType     = slot.ConstructionType;
            if (slot.GetReservation(GameManager.CurrentYear).IsDestroyed)
            {
                building.DegradationPeriod = 0;
            }
            else
            {
                building.DegradationPeriod = 1; //properties.BuildingBaseProperties(building.ConstructionName, building.ConstructionYear, building.UpgradeYear, GameManager.CurrentYear).DestructionPeriod;
            }
            building.ConstructingPeriod = properties.BuildingBaseProperties(building.ConstructionName, building.ConstructionYear, building.UpgradeYear, GameManager.CurrentYear).ConstructingPeriod;
            building.StackOrder         = stackOrder_slots + 1;
            AddChild(building);
            building.ChangeGraphics();
            slot.CurrentConstruction = building;
            building.Slot            = slot;

            building.OnSelected += new EventHandler(Building_OnSelected);
            RemoveConstructionPanel();
        }
        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();
            }
        }