private void OnSelectCraft(Craft craft) { if (craft.Status != CraftStatus.Ready) return; EndModal(); GameState.Current.SetScreen(new SelectDestination(craft)); }
public EquipCraft(Craft craft) { this.craft = craft; var metadata = craft.CraftType.Metadata(); AddControl(new Border(0, 0, 320, 200, ColorScheme.Blue, Backgrounds.EquipCraft, 9)); AddControl(new Label(8, Label.Center, craft.Name, Font.Large, ColorScheme.Blue)); AddControl(new Label(24, 24, "DAMAGE>", Font.Normal, ColorScheme.Blue)); AddControl(new Label(24, 59, craft.DamagePercent.FormatPercent(), Font.Normal, ColorScheme.White)); AddControl(new Label(24, 232, "FUEL>", Font.Normal, ColorScheme.Blue)); AddControl(new Label(24, 255, craft.FuelPercent.FormatPercent(), Font.Normal, ColorScheme.White)); AddControl(new Picture(35 + metadata.RowOffset, 125 + metadata.ColumnOffset, metadata.Image)); if (metadata.WeaponCount >= 1) AddControl(new Button(48, 24, 24, 36, "1", ColorScheme.Blue, Font.Normal, OnWeapon1)); if (metadata.WeaponCount >= 2) AddControl(new Button(48, 271, 24, 36, "2", ColorScheme.Blue, Font.Normal, OnWeapon2)); AddControl(new CraftWeaponPreview(craft)); if (metadata.Space > 0) { AddControl(new Button(96, 24, 64, 16, "CREW", ColorScheme.Blue, Font.Normal, OnClickCrew)); AddControl(new Button(120, 24, 64, 16, "EQUIPMENT", ColorScheme.Blue, Font.Normal, OnClickEquipment)); AddControl(new Button(144, 24, 64, 16, "ARMOR", ColorScheme.Blue, Font.Normal, OnClickArmor)); } AddControl(new CraftCargoPreview(craft)); AddControl(new Button(168, 128, 64, 24, "OK", ColorScheme.Blue, Font.Normal, OnOk)); }
private void MoveSoldierToCraft(Soldier soldier, Craft soldierCraft) { if (craft.SpaceAvailable == 0) return; soldierCraft.SoldierIds.Remove(soldier.Id); craft.SoldierIds.Add(soldier.Id); }
public LowFuel(Craft craft) { AddControl(new Border(40, 16, 224, 120, ColorScheme.Aqua, Backgrounds.Craft, 10)); AddControl(new Label(60, Label.CenterOf(16, 224), craft.Name, Font.Large, ColorScheme.Yellow)); AddControl(new Label(90, Label.CenterOf(16, 224), "is low on fuel,", Font.Normal, ColorScheme.Yellow)); AddControl(new Label(98, Label.CenterOf(16, 224), "returning to base", Font.Normal, ColorScheme.Yellow)); AddControl(new Button(120, 30, 90, 18, "OK", ColorScheme.Aqua, Font.Normal, EndModal)); AddControl(new Button(120, 135, 90, 18, "OK - 5 secs", ColorScheme.Aqua, Font.Normal, OnOkFiveSeconds)); }
public NotEnoughStoresToRefuelCraft(Data.Base @base, Craft craft) { AddControl(new Border(20, 32, 256, 160, ColorScheme.Green, Backgrounds.Craft, 10)); AddControl(new Label(66, Label.Center, "Not enough Elerium-115", Font.Large, ColorScheme.Green)); AddControl(new Label(82, Label.Center, $"to refuel {craft.Name}", Font.Large, ColorScheme.Green)); AddControl(new Label(98, Label.Center, $"at {@base.Name}", Font.Large, ColorScheme.Green)); AddControl(new Button(150, 48, 100, 16, "OK", ColorScheme.Green, Font.Normal, EndModal)); AddControl(new Button(150, 172, 100, 16, "OK - 5 secs", ColorScheme.Green, Font.Normal, OnOkFiveSeconds)); }
public NotEnoughStoresToRearmCraft(Data.Base @base, Craft craft, ItemType ammo) { AddControl(new Border(20, 32, 256, 160, ColorScheme.Green, Backgrounds.Craft, 10)); AddControl(new Label(66, Label.Center, "Not enough", Font.Large, ColorScheme.Green)); AddControl(new Label(82, Label.Center, ammo.Metadata().Name, Font.Large, ColorScheme.Green)); AddControl(new Label(98, Label.Center, $"to rearm {craft.Name}", Font.Large, ColorScheme.Green)); AddControl(new Label(114, Label.Center, $"at {@base.Name}", Font.Large, ColorScheme.Green)); AddControl(new Button(150, 48, 100, 16, "OK", ColorScheme.Green, Font.Normal, EndModal)); AddControl(new Button(150, 172, 100, 16, "OK - 5 secs", ColorScheme.Green, Font.Normal, OnOkFiveSeconds)); }
public ReachedWaypoint(Craft craft, Waypoint waypoint) { this.craft = craft; AddControl(new Border(16, 16, 224, 168, ColorScheme.Green, Backgrounds.Craft, 10)); AddControl(new Label(48, Label.CenterOf(16, 224), craft.Name, Font.Large, ColorScheme.Green)); AddControl(new Label(64, Label.CenterOf(16, 224), "has reached", Font.Large, ColorScheme.Green)); AddControl(new Label(80, Label.CenterOf(16, 224), "Destination", Font.Large, ColorScheme.Green)); AddControl(new Label(96, Label.CenterOf(16, 224), waypoint.Name, Font.Large, ColorScheme.Green)); AddControl(new Label(120, Label.CenterOf(16, 224), "Now patrolling", Font.Large, ColorScheme.Green)); AddControl(new Button(144, 58, 140, 12, "OK", ColorScheme.Aqua, Font.Normal, EndModal)); AddControl(new Button(160, 58, 140, 12, "REDIRECT CRAFT", ColorScheme.Aqua, Font.Normal, OnRedirectCraft)); }
public ReadyToLand(Craft craft) { this.craft = craft; var centerOf = Label.CenterOf(20, 216); AddControl(new Border(20, 20, 216, 160, ColorScheme.Aqua, Backgrounds.Ufo, 9)); AddControl(new Label(40, centerOf, craft.Name, Font.Large, ColorScheme.Yellow)); AddControl(new Label(56, centerOf, "ready to", Font.Large, ColorScheme.Aqua)); AddControl(new Label(72, centerOf, "land near", Font.Large, ColorScheme.Aqua)); AddControl(new Label(88, centerOf, craft.Destination.Name, Font.Large, ColorScheme.Yellow)); AddControl(new Label(130, centerOf, "Begin Mission?", Font.Large, ColorScheme.Aqua)); AddControl(new Button(150, 40, 80, 20, "YES", ColorScheme.Aqua, Font.Normal, OnYes)); AddControl(new Button(150, 136, 80, 20, "NO", ColorScheme.Aqua, Font.Normal, OnNo)); }
public SelectDestination(Craft craft) { this.craft = craft; AddControl(new Background(Backgrounds.Geoscape, 0)); worldView = new WorldView(OnChooseDestination); AddControl(worldView); AddControl(new WorldControls(worldView)); AddControl(new Border(0, 0, 256, 28, ColorScheme.Green, Backgrounds.Title, 0)); AddControl(new Label(10, 8, "SELECT DESTINATION", Font.Normal, ColorScheme.Green)); AddControl(new Button(8, 110, 53, 12, "CANCEL", ColorScheme.Aqua, Font.Normal, OnCancel)); AddControl(new TimeDisplay()); }
public CraftArmor(Craft craft) { this.craft = craft; AddControl(new Border(0, 0, 320, 200, ColorScheme.Blue, Backgrounds.EquipCraft, 10)); AddControl(new Label(8, 16, $"Select Armor for {craft.Name}", Font.Large, ColorScheme.Blue)); AddControl(new Label(32, 16, "NAME", Font.Normal, ColorScheme.Blue)); AddControl(new Label(32, 130, "CRAFT", Font.Normal, ColorScheme.Blue)); AddControl(new Label(32, 200, "ARMOR", Font.Normal, ColorScheme.Blue)); var selectionColor = Palette.GetPalette(10).GetColor(230); AddControl(new ListView<Soldier>(40, 8, 16, GameState.SelectedBase.Soldiers, ColorScheme.Blue, selectionColor, OnSelectSoldier) .AddColumn(8, Alignment.Left, soldier => "") .AddColumn(114, Alignment.Left, soldier => soldier.Name, GetSoldierColor) .AddColumn(70, Alignment.Left, soldier => soldier.CraftName, GetSoldierColor) .AddColumn(96, Alignment.Left, soldier => soldier.ArmorName, GetSoldierColor)); AddControl(new Button(176, 16, 288, 16, "OK", ColorScheme.Blue, Font.Normal, OnOk)); }
public SelectCraftWeapon(Craft craft, int weaponSlot) { this.craft = craft; this.weaponSlot = weaponSlot; AddControl(new Border(20, 50, 220, 160, ColorScheme.Purple, Backgrounds.EquipCraft, 10)); AddControl(new Label(28, Label.Center, "Select Armament", Font.Large, ColorScheme.Purple)); AddControl(new Label(52, 66, "ARMAMENT", Font.Normal, ColorScheme.Purple)); AddControl(new Label(52, 145, "QUANTITY", Font.Normal, ColorScheme.Purple)); AddControl(new Label(44, 195, "AMMUNITION", Font.Normal, ColorScheme.Purple)); AddControl(new Label(52, 195, "AVAILABLE", Font.Normal, ColorScheme.Purple)); AddControl(new ListView<CraftWeaponType>(68, 58, 10, AvailableCraftWeapons, ColorScheme.Blue, Palette.GetPalette(10).GetColor(230), OnSelectCraftWeapon) .AddColumn(8, Alignment.Left, item => "") .AddColumn(94, Alignment.Left, GetName) .AddColumn(50, Alignment.Left, item => GetAvailableQuantity(item).FormatNumber()) .AddColumn(36, Alignment.Left, item => GetAvailableAmmo(item)?.FormatNumber() ?? "N.A.")); AddControl(new Button(156, 90, 140, 16, "CANCEL", ColorScheme.Purple, Font.Normal, EndModal)); }
public CraftEquipment(Craft craft) { this.craft = craft; AddControl(new Border(0, 0, 320, 200, ColorScheme.LightMagenta, Backgrounds.Battle, 8)); AddControl(new Label(8, 16, $"Equipment for {craft.Name}", Font.Large, ColorScheme.LightMagenta)); AddControl(new Label(24, 16, "SPACE AVAILABLE>", Font.Normal, ColorScheme.LightMagenta)); AddControl(new DynamicLabel(24, 94, () => craft.SpaceAvailable.FormatNumber(), Font.Normal, ColorScheme.White)); AddControl(new Label(24, 130, "SPACE USED>", Font.Normal, ColorScheme.LightMagenta)); AddControl(new DynamicLabel(24, 184, () => craft.SpaceUsed.FormatNumber(), Font.Normal, ColorScheme.White)); AddControl(new Label(32, 16, "ITEM", Font.Normal, ColorScheme.LightMagenta)); AddControl(new Label(32, 160, "Stores", Font.Normal, ColorScheme.LightMagenta)); AddControl(new ListView<ItemType>(40, 8, 16, AvailableItems, ColorScheme.LightMagenta, Palette.GetPalette(8).GetColor(230), OnIncreaseItem) .ConfigureUpDown(210, OnDecreaseItem) .AddColumn(8, Alignment.Left, item => "") .AddColumn(154, Alignment.Left, item => GetName(item), GetColor) .AddColumn(86, Alignment.Left, item => GetStoreQuantity(item).FormatNumber(), GetColor) .AddColumn(40, Alignment.Left, item => GetCraftQuantity(item).FormatNumber(), GetColor)); AddControl(new Button(176, 16, 288, 16, "OK", ColorScheme.LightMagenta, Font.Normal, OnOk)); }
public static Battle CreateFromCraft(Craft craft) { return new Battle { Turn = 1, CraftId = craft.Id, Soldiers = craft.SoldierIds.Select(BattleSoldier.Create).ToList(), Stores = craft.Stores.Items.SelectMany(BattleItem.Create).ToList(), SelectedUnitId = new SelectedUnitId { UnitType = UnitType.Soldier, Id = craft.SoldierIds.First() }, //TODO: Create alien base, terror, or craft recovery based on craft destination Map = MapFactory.CreateFromCraft(craft) }; //TODO: Initial unit placement //TODO: Placement of remaining store items }
public CraftSoldiers(Craft craft) { this.craft = craft; AddControl(new Border(0, 0, 320, 200, ColorScheme.Purple, Backgrounds.Soldier, 8)); AddControl(new Label(8, 16, $"Select Squad for {craft.Name}", Font.Large, ColorScheme.Purple)); AddControl(new Label(24, 16, "SPACE AVAILABLE>", Font.Normal, ColorScheme.Purple)); AddControl(new DynamicLabel(24, 94, () => craft.SpaceAvailable.FormatNumber(), Font.Normal, ColorScheme.White)); AddControl(new Label(24, 130, "SPACE USED>", Font.Normal, ColorScheme.Purple)); AddControl(new DynamicLabel(24, 183, () => craft.SpaceUsed.FormatNumber(), Font.Normal, ColorScheme.White)); AddControl(new Label(32, 16, "NAME", Font.Normal, ColorScheme.Purple)); AddControl(new Label(32, 130, "RANK", Font.Normal, ColorScheme.Purple)); AddControl(new Label(32, 232, "CRAFT", Font.Normal, ColorScheme.Purple)); var selectionColor = Palette.GetPalette(8).GetColor(230); AddControl(new ListView<Soldier>(40, 16, 16, GameState.SelectedBase.Soldiers, ColorScheme.Purple, selectionColor, OnClickSoldier) .AddColumn(114, Alignment.Left, soldier => soldier.Name, GetSoldierColor) .AddColumn(102, Alignment.Left, soldier => $"{soldier.Rank}", GetSoldierColor) .AddColumn(64, Alignment.Left, soldier => soldier.CraftName, GetSoldierColor)); AddControl(new Button(176, 16, 288, 16, "OK", ColorScheme.Blue, Font.Normal, OnOk)); }
public RedirectCraft(Craft craft) { this.craft = craft; AddControl(new Border(8, 8, 240, 184, ColorScheme.Green, Backgrounds.Craft, 10)); AddControl(new Label(20, 32, craft.Name, Font.Large, ColorScheme.Green)); AddControl(new LabeledValue(36, 32, "STATUS>", craft.MissionStatus, Font.Normal, ColorScheme.Green, ColorScheme.Yellow)); AddControl(new LabeledValue(52, 32, "BASE>", craft.Base.Name, Font.Normal, ColorScheme.Green, ColorScheme.Aqua)); AddControl(new LabeledValue(60, 32, "SPEED>", ((int)craft.Speed).FormatNumber(), Font.Normal, ColorScheme.Green, ColorScheme.Aqua)); AddControl(new LabeledValue(68, 32, "MAXIMUM SPEED>", craft.CraftType.Metadata().Speed.FormatNumber(), Font.Normal, ColorScheme.Green, ColorScheme.Aqua)); AddControl(new LabeledValue(76, 32, "ALTITUDE>", craft.Altitude, Font.Normal, ColorScheme.Green, ColorScheme.Aqua)); AddControl(new LabeledValue(84, 32, "FUEL>", craft.FuelPercent.FormatPercent(), Font.Normal, ColorScheme.Green, ColorScheme.Aqua)); AddControl(new LabeledValue(92, 32, "WEAPON-1>", craft.Weapon1Name, Font.Normal, ColorScheme.Green, ColorScheme.Aqua)); if (craft.Weapons.Count >= 1) AddControl(new LabeledValue(92, 164, "ROUNDS>", craft.Weapons[0].Ammunition.FormatNumber(), Font.Normal, ColorScheme.Green, ColorScheme.Aqua)); AddControl(new LabeledValue(100, 32, "WEAPON-2>", craft.Weapon2Name, Font.Normal, ColorScheme.Green, ColorScheme.Aqua)); if (craft.Weapons.Count == 2) AddControl(new LabeledValue(100, 164, "ROUNDS>", craft.Weapons[1].Ammunition.FormatNumber(), Font.Normal, ColorScheme.Green, ColorScheme.Aqua)); AddControl(new Button(116, 32, 192, 12, "RETURN TO BASE", ColorScheme.Aqua, Font.Normal, OnReturnToBase)); AddControl(new Button(132, 32, 192, 12, "SELECT NEW TARGET", ColorScheme.Aqua, Font.Normal, OnSelectNewTarget)); AddControl(new Button(148, 32, 192, 12, "PATROL", ColorScheme.Aqua, Font.Normal, OnPatrol)); AddControl(new Button(164, 32, 192, 12, "CANCEL", ColorScheme.Aqua, Font.Normal, EndModal)); }
private static Map CreateTerrorSiteMap(Craft craft) { var tilesets = new Tileset[5, 5]; PlaceRoads(tilesets); PlaceCraft(tilesets, craft.CraftType.Metadata().Tileset, cityMetadata.FlatTilesets); FillTerrain(tilesets, cityMetadata); return new Map { Levels = CreateLevels(tilesets, 4) }; }
public static Map CreateMarsMap(Craft avenger) { var tilesets = new Tileset[5, 5]; PlaceCraft(tilesets, avenger.CraftType.Metadata().Tileset, marsMetadata.FlatTilesets); var exitPyramid = Tileset.Mars10; PlaceTileset(tilesets, exitPyramid); FillTerrain(tilesets, marsMetadata); return new Map { Levels = CreateLevels(tilesets, 4) }; }
private static Map CreateLandingSiteMap(Craft craft) { var mapLocation = World.Map.Instance[craft.Destination.Location]; var category = mapLocation.TerrainType?.Metadata().Category; var ufo = GameState.Current.Data.GetUfo(craft.Destination.Number); return CreateUfoMap( craft.CraftType.Metadata().Tileset, ufo.UfoType.Metadata().Tileset, category?.Metadata(mapLocation.Location.Latitude)); }
private static string GetCraftWeaponText(Craft craft) { return $"{craft.Weapons.Count}\t/{craft.CraftType.Metadata().WeaponCount}"; }
private static void RepairCraft(Craft craft) { --craft.Damage; if (craft.Damage == 0) craft.TransitionStatus(); }
private static void ReturnCraftToBaseDueToLowFuel(Craft craft) { craft.LowFuel = true; craft.StartToReturnToBase(); GameState.Current.Notifications.Enqueue(() => { new LowFuel(craft).DoModal(GameState.Current.ActiveScreen); }); }
private static void RefuelCraft(Base @base, Craft craft) { var metadata = craft.CraftType.Metadata(); switch (metadata.FuelType) { case FuelType.Normal: craft.Fuel += 50; break; case FuelType.Elerium115: if (@base.Stores[ItemType.Elerium115] == 0) { NotifyNotEnoughStoresToRefuelCraft(@base, craft); return; } @base.Stores.Remove(ItemType.Elerium115); craft.Fuel += 5; break; } if (craft.Fuel < metadata.Fuel) return; craft.Fuel = metadata.Fuel; craft.TransitionStatus(); }
private static void RearmCraft(Base @base, Craft craft) { var weapon = craft.Weapons.FirstOrDefault(craftWeapon => !craftWeapon.IsFullyArmed); if (weapon == null) { craft.TransitionStatus(); return; } var metadata = weapon.WeaponType.Metadata(); if (metadata.Ammo == null) weapon.Reload(100); else { foreach (var ammo in Enumerable.Range(0, metadata.AmmoPerHour)) { if (@base.Stores[metadata.Ammo.Value] == 0) { NotifyNotEnoughStoresToRearmCraft(@base, craft, metadata.Ammo.Value); return; } @base.Stores.Remove(metadata.Ammo.Value); weapon.Reload(metadata.RoundsInAmmo); if (weapon.IsFullyArmed) break; } } }
private void SelectWorldObject(Craft craft) { new RedirectCraft(craft).DoModal(this); }
private static void OnSelectCraft(Craft craft) { if (craft.Status != CraftStatus.Out) GameState.Current.SetScreen(new EquipCraft(craft)); }
public CraftCargoPreview(Craft craft) { this.craft = craft; }
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); }
private static void CraftArrivalAtDestination(Craft craft) { switch (craft.Destination.WorldObjectType) { case WorldObjectType.XcomBase: craft.ReturnToBase(); break; case WorldObjectType.Waypoint: var waypoint = craft.Patrol(); GameState.Current.Notifications.Enqueue(() => { new ReachedWaypoint(craft, waypoint).DoModal(GameState.Current.ActiveScreen); }); break; case WorldObjectType.Ufo: //TODO: check if interceptor has weapons, engage enemy break; case WorldObjectType.LandingSite: case WorldObjectType.CrashSite: GameState.Current.Notifications.Enqueue(() => { new ReadyToLand(craft).DoModal(GameState.Current.ActiveScreen); }); break; default: throw new NotImplementedException(); } }
private static void NotifyNotEnoughStoresToRefuelCraft(Base @base, Craft craft) { if (craft.AlreadyNotified) return; craft.AlreadyNotified = true; GameState.Current.Notifications.Enqueue(() => { new NotEnoughStoresToRefuelCraft(@base, craft).DoModal(GameState.Current.ActiveScreen); }); }
public static Map CreateFromCraft(Craft craft) { switch (craft.Destination.WorldObjectType) { case WorldObjectType.AlienBase: return CreateAlienBaseMap(Tileset.AlienBase0, alienBaseMetadata); case WorldObjectType.CrashSite: return CreateLandingSiteMap(craft); case WorldObjectType.TerrorSite: return CreateTerrorSiteMap(craft); case WorldObjectType.LandingSite: return CreateLandingSiteMap(craft); } throw new InvalidOperationException("Invalid craft destination for map."); }