private static void NotifyFacilityConstructionComplete(Base @base, Facility facility)
 {
     GameState.Current.Notifications.Enqueue(() =>
     {
         Screen.Geoscape.ResetGameSpeed();
         new FacilityConstructionCompleted(@base.Name, facility.FacilityType.Metadata().Name).DoModal(GameState.Current.ActiveScreen);
     });
 }
Beispiel #2
0
 public Dismantle(Facility facility)
 {
     this.facility = facility;
     AddControl(new Border(60, 20, 152, 80, ColorScheme.LightMagenta, Backgrounds.Funds, 9));
     AddControl(new Label(75, Label.CenterOf(20, 152), "Dismantle", Font.Normal, ColorScheme.Blue));
     AddControl(new Label(85, Label.CenterOf(20, 152), facility.FacilityType.Metadata().Name, Font.Normal, ColorScheme.Blue));
     AddControl(new Button(115, 36, 44, 16, "OK", ColorScheme.Purple, Font.Normal, OnOk));
     AddControl(new Button(115, 112, 44, 16, "CANCEL", ColorScheme.Purple, Font.Normal, EndModal));
 }
Beispiel #3
0
 private static void RenderHangarBridges(GraphicsBuffer buffer, Facility facility)
 {
     var topRow = facility.Row * 32 + 8;
     var leftColumn = facility.Column * 32;
     if (IsFacilityAt(facility.Row + 2, facility.Column, false))
         verticalBridge.Render(buffer, topRow + 32 + 29, leftColumn + 12);
     if (IsFacilityAt(facility.Row + 2, facility.Column + 1, false))
         verticalBridge.Render(buffer, topRow + 32 + 29, leftColumn + 32 + 12);
     if (IsFacilityAt(facility.Row, facility.Column + 2, false))
         horizontalBridge.Render(buffer, topRow + 12, leftColumn + 32 + 29);
     if (IsFacilityAt(facility.Row + 1, facility.Column + 2, false))
         horizontalBridge.Render(buffer, topRow + 32 + 12, leftColumn + 32 + 29);
 }
Beispiel #4
0
        private static void RenderFacility(GraphicsBuffer buffer, Facility facility)
        {
            var topRow = facility.Row * 32 + 8;
            var leftColumn = facility.Column * 32;

            var metadata = facility.FacilityType.Metadata();
            if (metadata.Shape != FacilityShape.Hangar)
                metadata.Image.Render(buffer, topRow + metadata.RowOffset, leftColumn + metadata.ColumnOffset);

            if (facility.DaysUntilConstructionComplete == 0)
                return;

            var daysRemaining = facility.DaysUntilConstructionComplete.ToString(CultureInfo.InvariantCulture);
            var size = metadata.Shape.Size() * 32;
            var textTopRow = topRow + (size - Font.Large.Height) / 2;
            var textLeftColumn = leftColumn + (size - Font.Large.MeasureString(daysRemaining)) / 2;
            Font.Large.DrawString(buffer, textTopRow, textLeftColumn, daysRemaining, ColorScheme.Yellow);
        }
Beispiel #5
0
 private static void RenderCraft(GraphicsBuffer buffer, Facility hangar, Craft craft)
 {
     var metadata = craft.CraftType.Metadata();
     var topRow = hangar.Row * 32 + 8 + metadata.RowOffset;
     var leftColumn = hangar.Column * 32 + metadata.ColumnOffset;
     metadata.Image.Render(buffer, topRow, leftColumn);
 }
Beispiel #6
0
        private static void RenderBuilding(GraphicsBuffer buffer, Facility facility)
        {
            var topRow = facility.Row * 32 + 9;
            var leftColumn = facility.Column * 32 + 1;
            var metadata = facility.FacilityType.Metadata();

            if (facility.DaysUntilConstructionComplete > 0)
                metadata.Shape.ConstructionImage().Render(buffer, topRow, leftColumn);
            else if (metadata.Shape == FacilityShape.Hangar)
                metadata.Image.Render(buffer, topRow, leftColumn);
            else
                metadata.Shape.BuildingImage().Render(buffer, topRow, leftColumn);
        }
Beispiel #7
0
 private static void RenderBridges(GraphicsBuffer buffer, Facility facility)
 {
     if (facility.DaysUntilConstructionComplete > 0)
         return;
     if (facility.FacilityType == FacilityType.Hangar)
         RenderHangarBridges(buffer, facility);
     else
         RenderBuildingBridges(buffer, facility);
 }
Beispiel #8
0
			private void MarkFacility(Facility facility, Status status)
			{
				var size = facility.FacilityType.Metadata().Shape.Size();
				foreach (var row in Enumerable.Range(facility.Row, size))
					foreach (var column in Enumerable.Range(facility.Column, size))
						facilities[row][column] = status;
			}
Beispiel #9
0
			public bool IsReachable(Facility facility)
			{
				return facilities[facility.Row][facility.Column] == Status.Visited;
			}
Beispiel #10
0
			public void Destroy(Facility facility)
			{
				MarkFacility(facility, Status.Dead);
			}
Beispiel #11
0
			public void Enter(Facility accessLift)
			{
				MarkFacility(accessLift, Status.Reachable);
			}
Beispiel #12
0
			private void MarkNeighbors(Facility facility)
			{
				var size = facility.FacilityType.Metadata().Shape.Size();
				foreach (var index in Enumerable.Range(0, size))
				{
					MarkNeighbor(facility.Row - 1, facility.Column + index);
					MarkNeighbor(facility.Row + size, facility.Column + index);
					MarkNeighbor(facility.Row + index, facility.Column - 1);
					MarkNeighbor(facility.Row + index, facility.Column + size);
				}
			}
Beispiel #13
0
		public bool CanDismantleFacility(Facility facility)
		{
			var facilityConnectivity = new FacilityConnectivity();
			facilityConnectivity.Enter(Facilities.Single(accessLift => accessLift.FacilityType == FacilityType.AccessLift));
			facilityConnectivity.Destroy(facility);
			facilityConnectivity.Explore();
			return Facilities
				.Where(remainingFacility => remainingFacility != facility)
				.All(remainingFacility => facilityConnectivity.IsReachable(remainingFacility));
		}
Beispiel #14
0
		public bool IsFacilityInUse(Facility facility)
		{
			if (facility.DaysUntilConstructionComplete > 0)
				return false;
			switch (facility.FacilityType)
			{
			case FacilityType.Hangar:
				return HangarSpaceAvailable < 1;

			case FacilityType.LivingQuarters:
				return LivingSpaceAvailable < 50;

			case FacilityType.Laboratory:
				return LaboratorySpaceAvailable < 50;

			case FacilityType.Workshop:
				return WorkshopSpaceAvailable < 50;

			case FacilityType.GeneralStores:
				return StorageSpaceAvailable < 50;

			case FacilityType.AccessLift:
				var otherFacilitiesAreAttached = Facilities.Count > 1;
				var isOnlyBase = GameState.Current.Data.Bases.Count == 1;
				return otherFacilitiesAreAttached || isOnlyBase;
			}
			return false;
		}
Beispiel #15
0
 private static Image GetFacilityPreviewImage(Facility facility)
 {
     var size = facility.FacilityType.Metadata().Shape.Size();
     if (facility.DaysUntilConstructionComplete > 0)
         return size == 1 ? construction1x1 : construction2x2;
     return size == 1 ? facility1x1 : facility2x2;
 }
Beispiel #16
0
 private static void FillFacilityTilesets(Tileset[,] tilesets, Facility facility)
 {
     var metadata = facility.FacilityType.Metadata();
     tilesets[facility.Row, facility.Column] = metadata.Tilesets[0];
     if (metadata.Shape != FacilityShape.Hangar)
         return;
     tilesets[facility.Row, facility.Column + 1] = metadata.Tilesets[1];
     tilesets[facility.Row + 1, facility.Column] = metadata.Tilesets[2];
     tilesets[facility.Row + 1, facility.Column + 1] = metadata.Tilesets[3];
 }