public Boolean OverlapsReservation(Reservation reservation) { if (startingYear < reservation.StartingYear) { if (EndingYear >= reservation.startingYear) { return true; } return false; } if (startingYear == reservation.StartingYear) { return true; } if (startingYear > reservation.StartingYear) { if (reservation.EndingYear >= startingYear) { return true; } return false; } return false; }
public void UpgradePopulationConstruction(Slot slot, Construction populationConstruction) { Reservation reservation = new Reservation(GameManager.CurrentYear, 500, populationConstruction); reservation.IsPopulationUpgraded = true; slot.MakeReservation(reservation); }
public void RemoveReservation(Reservation r) { foreach (Slot s in slotList) { if (s.HasReservation(r)) { s.CancelReservation(r); return; } } }
public void SetConstructionReservation(Slot slot, Reservation reservation) { }
public void MakeReservation(int year, int duration, Construction building) { Reservation newRes = new Reservation(year, duration, building); for (int i = 0; i < reservationList.Count; i++) { if (newRes.OverlapsReservation(reservationList[i])) { reservationList.Remove(reservationList[i]); i--; } } reservationList.Add(newRes); }
public Boolean HasReservation(Reservation r) { return reservationList.Contains(r); }
public void CancelReservation(Reservation r) { reservationList.Remove(r); }
public void MakeReservation(Reservation reservation) { for (int i = 0; i < reservationList.Count; i++) { if (reservation.OverlapsReservation(reservationList[i])) { reservationList.Remove(reservationList[i]); i--; } } reservationList.Add(reservation); }
public List<Slot> LoadZoneHistory(String profilePath) { List<Slot> slotList = new List<Slot>(); xmlLoader = XElement.Load(profilePath + "\\" + ZonesHistoryFile); IEnumerable<XElement> slotListData = from element in xmlLoader.Elements() select element; int xSlotCenter = 0; int ySlotCenter = 0; string constructionType = ""; Slot currentSlot = null; Reservation currentReservation = null; foreach (XElement slot in slotListData) { xSlotCenter = Convert.ToInt32(slot.Element("X").Value); ySlotCenter = Convert.ToInt32(slot.Element("Y").Value); constructionType = slot.Element("constructionType").Value.ToString(); currentSlot = new Slot(this.Game, (ConstructionType)Enum.Parse(typeof(ConstructionType), constructionType)); currentSlot.XSlotCenter = xSlotCenter; currentSlot.YSlotCenter = ySlotCenter; IEnumerable<XElement> slotReservations = from element in slot.Elements("reservation") select element; foreach (XElement reservation in slotReservations) { string constructionName = reservation.Element("constructionName").Value.ToString(); Construction construction = (Construction)Enum.Parse(typeof(Construction), constructionName); int startingYear = Convert.ToInt32(reservation.Element("startingYear").Value); int duration = Convert.ToInt32(reservation.Element("duration").Value); int upgradeYear = Convert.ToInt32(reservation.Element("upgradeYear").Value); bool isUpgraded = Convert.ToBoolean(reservation.Element("isUpgraded").Value); bool isPopulationUpgraded = Convert.ToBoolean(reservation.Element("isPopulationUpgraded").Value); bool isDestroyed = Convert.ToBoolean(reservation.Element("isDestroyed").Value); currentReservation = new Reservation(startingYear, duration, construction); currentReservation.UpgradeYear = upgradeYear; currentReservation.IsUpgraded = isUpgraded; currentReservation.IsPopulationUpgraded = isPopulationUpgraded; currentReservation.IsDestroyed = isDestroyed; currentSlot.MakeReservation(currentReservation); slotList.Add(currentSlot); } } return slotList; }