public void ExecuteCommand() { if (Status == OrderStatus.Active) { Execute((LocalPlayer)_mainForm.CurrentPlayer); } else { var dialog = new Civ2dialog(_mainForm, ErrorPopup); dialog.ShowModal(); } }
private static Ruleset SelectGameToStart(Main main) { var rulesFiles = Helpers.LocateRules(Settings.SearchPaths); switch (rulesFiles.Count) { case 0: var warningDialog = new Civ2dialog(main, new PopupBox() { Title = "No game to start", Text = new List <string> { "Please check you search paths", "Could not locate a version of civ2 to start" }, Button = new List <string> { "OK" } }); warningDialog.ShowModal(main); return(null); case 1: return(rulesFiles[0]); default: var popupBox = new Civ2dialog(main, new PopupBox { Title = "Select game version", Options = rulesFiles.Select(f => f.Name).ToList(), Button = new List <string> { "Quick Start", "OK", Labels.Cancel } }); popupBox.ShowModal(main); if (popupBox.SelectedIndex == int.MinValue) { return(null); } var ruleset = rulesFiles[popupBox.SelectedIndex]; if (popupBox.SelectedButton == "Quick Start") { ruleset.QuickStart = true; } return(ruleset); } }
protected override void Execute(LocalPlayer player) { var improvements = player.ActiveTile.Improvements.Where(i => _game.TerrainImprovements.ContainsKey(i.Improvement) && !_game.TerrainImprovements[i.Improvement].Negative).ToList(); ConstructedImprovement improvementToPillage = null; if (improvements.Count > 1) { var popup = _mainForm.popupBoxList["PILLAGEWHAT"]; var dialog = new Civ2dialog(_mainForm, popup, listbox: new ListboxDefinition { LeftText = improvements .Select(i => _game.TerrainImprovements[i.Improvement].Levels[i.Level].Name).ToList() }); dialog.ShowModal(); if (dialog.SelectedButton == "OK") { improvementToPillage = improvements[dialog.SelectedIndex]; } } else { improvementToPillage = improvements.FirstOrDefault(); } if (improvementToPillage != null) { player.ActiveUnit.MovePointsLost += _game.Rules.Cosmic.MovementMultiplier; var improvement = _game.TerrainImprovements[improvementToPillage.Improvement]; player.ActiveTile.RemoveImprovement(improvement, improvementToPillage.Level); var tiles = new List <Tile> { player.ActiveTile }; if (improvement.HasMultiTile) { tiles.AddRange(player.ActiveTile.Neighbours()); } _game.TriggerMapEvent(MapEventType.UpdateMap, tiles); if (player.ActiveUnit.MovePoints <= 0) { _game.ChooseNextUnit(); } } }
protected override void Execute(LocalPlayer player) { //_mainForm.CurrentGameMode = new Goto(_game); var popup = _mainForm.popupBoxList["GOTO"]; var activeUnit = player.ActiveUnit; var islands = MovementFunctions.GetIslandsFor(activeUnit); var cities = player.Civ.Cities.Where(c => islands.Contains(c.Location.Island) || c.Location.Neighbours().Any(l => islands.Contains(l.Island))) .ToList(); var dialog = new Civ2dialog(_mainForm, popup, new List <string> { activeUnit.Name }, listbox: new ListboxDefinition { LeftText = cities.Select(c => c.Name).ToList() }); dialog.ShowModal(); if (dialog.SelectedButton == Labels.Ok) { var city = cities[dialog.SelectedIndex]; var path = Path.CalculatePathBetween(_game, player.ActiveTile, city.Location, activeUnit.Domain, activeUnit.MaxMovePoints, activeUnit.Owner, activeUnit.Alpine, activeUnit.IgnoreZonesOfControl); if (path != null) { activeUnit.Order = OrderType.GoTo; activeUnit.GoToX = city.Location.X; activeUnit.GoToY = city.Location.Y; path.Follow(_game, activeUnit); if (activeUnit.MovePoints <= 0) { _game.ChooseNextUnit(); } } } }