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; }
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; }
/// <summary> /// Refresh the building associated with a slot. /// </summary> /// <param name="slot"></param> public void RefreshBuilding(Slot slot) { //if the slot has a building already attached to it if (slot.CurrentConstruction != null) { //if the slot has a reservation in the current year if (slot.GetReservation(GameManager.CurrentYear) != null) { //if the current building doesn't match the current reservation if ((slot.GetReservation(GameManager.CurrentYear).StartingYear != slot.CurrentConstruction.ConstructionYear) || (slot.GetReservation(GameManager.CurrentYear).EndingYear != slot.CurrentConstruction.DestructionYear)) { RemoveChild(slot.CurrentConstruction); slot.CurrentConstruction = null; SetNewBuilding(slot); } //if the building matches the current reservation else { slot.CurrentConstruction.ChangeGraphics(); } } //if the slot has no reservation else { RemoveChild(slot.CurrentConstruction); slot.CurrentConstruction = null; } } //if the slot has no construction attached else { //if the slot has a reservation if (slot.GetReservation(GameManager.CurrentYear) != null) { SetNewBuilding(slot); } } }
/// <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(); }