public bool CanProduce(Base selectedBase) { return ValidateRequiredFunds() && ValidateRequiredHangarSpace(selectedBase) && ValidateRequiredMaterials(selectedBase) && ValidateRequiredStorageSpace(selectedBase); }
public ManufactureStatus BeginUnitProduction(Base @base) { if (!ValidateRequiredFunds()) return ManufactureStatus.InsufficientFunds; if (!ValidateRequiredHangarSpace(@base)) return ManufactureStatus.InsufficientHangarSpace; if (!ValidateRequiredMaterials(@base)) return ManufactureStatus.InsufficientMaterials; if (!ValidateRequiredStorageSpace(@base)) return ManufactureStatus.InfufficentStorageSpace; ConsumeRequiredFundsAndMaterials(@base); return ManufactureStatus.UnitStarted; }
public void CompleteUnit(Base @base) { var metadata = ManufactureType.Metadata(); @base.CraftUnderConstruction -= metadata.HangarSpaceRequired; var item = metadata.ItemProduced; switch (item) { case ItemType.Firestorm: @base.Crafts.Add(Craft.CreateNew(CraftType.Firestorm, GameState.Current.Data.NextFirestormNumber++)); break; case ItemType.Lightning: @base.Crafts.Add(Craft.CreateNew(CraftType.Lightning, GameState.Current.Data.NextLightningNumber++)); break; case ItemType.Avenger: @base.Crafts.Add(Craft.CreateNew(CraftType.Avenger, GameState.Current.Data.NextAvengerNumber++)); break; default: @base.Stores.Add(item); break; } }
private static void InitializeOriginalBase(Base originalBase) { var data = GameState.Current.Data; originalBase.ScientistCount = 10; originalBase.EngineerCount = 10; AddTestData(originalBase); var skyranger = Craft.CreateRefueled(CraftType.Skyranger, data.NextSkyrangerNumber++); originalBase.Crafts.Add(skyranger); for (var index = 0; index < 2; ++index) { var interceptor = Craft.CreateRefueled(CraftType.Interceptor, data.NextInterceptorNumber++); interceptor.Weapons.Add(CraftWeapon.CreateLoaded(CraftWeaponType.Stingray)); interceptor.Weapons.Add(CraftWeapon.CreateLoaded(CraftWeaponType.Cannon)); originalBase.Crafts.Add(interceptor); } for (var index = 0; index < 8; ++index) { var soldier = Soldier.Create(data.NextSoldierId++); originalBase.Soldiers.Add(soldier); skyranger.SoldierIds.Add(soldier.Id); } originalBase.Facilities.AddRange(new[] { Facility.CreateConstructed(2, 2, FacilityType.AccessLift), Facility.CreateConstructed(0, 2, FacilityType.Hangar), Facility.CreateConstructed(4, 0, FacilityType.Hangar), Facility.CreateConstructed(4, 4, FacilityType.Hangar), Facility.CreateConstructed(2, 3, FacilityType.LivingQuarters), Facility.CreateConstructed(3, 1, FacilityType.SmallRadarSystem), Facility.CreateConstructed(3, 2, FacilityType.GeneralStores), Facility.CreateConstructed(3, 3, FacilityType.Laboratory), Facility.CreateConstructed(3, 4, FacilityType.Workshop) }); }
private void ConsumeRequiredFundsAndMaterials(Base @base) { var metadata = ManufactureType.Metadata(); GameState.Current.Data.Funds -= metadata.Cost; @base.CraftUnderConstruction += metadata.HangarSpaceRequired; @base.Stores.Remove(ItemType.AlienAlloys, metadata.AlienAlloysRequired); @base.Stores.Remove(ItemType.Elerium115, metadata.EleriumRequired); @base.Stores.Remove(ItemType.UfoPowerSource, metadata.PowerSourcesRequired); @base.Stores.Remove(ItemType.UfoNavigation, metadata.NavigationRequired); }
private bool ValidateRequiredStorageSpace(Base @base) { var newItemSpaceRequired = ManufactureType.Metadata().ItemProduced.Metadata().StorageSpace; var spaceUsedWithNewItem = (@base.Stores.TotalItemSpaceRequired + newItemSpaceRequired + 99) / 100; return spaceUsedWithNewItem <= @base.TotalStorageSpace; }
private bool ValidateRequiredMaterials(Base @base) { var metadata = ManufactureType.Metadata(); return @base.Stores[ItemType.AlienAlloys] >= metadata.AlienAlloysRequired && @base.Stores[ItemType.Elerium115] >= metadata.EleriumRequired && @base.Stores[ItemType.UfoPowerSource] >= metadata.PowerSourcesRequired && @base.Stores[ItemType.UfoNavigation] >= metadata.NavigationRequired; }
private bool ValidateRequiredHangarSpace(Base @base) { return @base.HangarSpaceAvailable >= ManufactureType.Metadata().HangarSpaceRequired; }
private static void AddTestData(Base originalBase) { originalBase.Stores.Add(ItemType.PersonalArmor, 2); originalBase.Stores.Add(ItemType.PowerSuit, 2); originalBase.Stores.Add(ItemType.FlyingSuit, 2); }
private void SelectBase(Base @base) { SelectedBase = Bases.IndexOf(@base); }
private static Tileset[,] CreateXcomBaseTilesets(Base @base) { var tilesets = CreateEmptyXcomBaseTilesets(); var completedFacilities = @base.Facilities .Where(facility => facility.DaysUntilConstructionComplete == 0) .ToList(); FillFacilityTilesets(tilesets, completedFacilities); SetFacilityConnectors(tilesets); return tilesets; }
public static Map CreateXcomBaseMap(Base @base) { var tilesets = CreateXcomBaseTilesets(@base); return new Map { Levels = CreateLevels(tilesets, 2) }; }