Пример #1
0
        protected override bool Confront(int relX, int relY)
        {
            ITile moveTarget = Map[X, Y][relX, relY];
            City  city       = moveTarget.City;

            if (city == null || city == Home || (city.Owner == Owner && Home != null && moveTarget.DistanceTo(Home) < 10))
            {
                Movement       = new MoveUnit(relX, relY);
                Movement.Done += MoveEnd;
                GameTask.Insert(Movement);
                return(true);
            }

            if (city.Owner != Owner)
            {
                EstablishTradeRoute(moveTarget.City);
                return(true);
            }

            if (Game.Human == Owner)
            {
                GameTask.Enqueue(Show.CaravanChoice(this, city));
            }

            return(true);
        }
Пример #2
0
        private void StealTechnology(object sender, EventArgs args)
        {
            IAdvance advance = _diplomat.GetAdvanceToSteal(_enemyCity.Player);

            if (advance == null)
            {
                GameTask.Insert(Message.General($"No new technology found"));
            }
            else
            {
                GameTask task = new Tasks.GetAdvance(_diplomat.Player, advance);

                task.Done += (s1, a1) =>
                {
                    Game.DisbandUnit(_diplomat);
                    if (_diplomat.Player == Human || _enemyCity.Player == Human)
                    {
                        GameTask.Insert(Message.Spy("Spies report:", $"{_diplomat.Player.TribeName} steal", $"{advance.Name}"));
                    }
                };

                GameTask.Enqueue(task);
            }

            Cancel();
        }
Пример #3
0
 protected void MovementTo(int relX, int relY)
 {
     MovementStart(Tile);
     Movement       = new MoveUnit(relX, relY);
     Movement.Done += MoveEnd;
     GameTask.Insert(Movement);
 }
Пример #4
0
        private void Incite(object sender, EventArgs args)
        {
            Player previousOwner = Game.GetPlayer(_cityToIncite.Owner);

            Show captureCity = Show.CaptureCity(_cityToIncite);

            captureCity.Done += (s1, a1) =>
            {
                Game.DisbandUnit(_diplomat);
                _cityToIncite.Owner = _diplomat.Owner;

                // remove half the buildings at random
                foreach (IBuilding building in _cityToIncite.Buildings.Where(b => Common.Random.Next(0, 1) == 1).ToList())
                {
                    _cityToIncite.RemoveBuilding(building);
                }

                _diplomat.Player.Gold -= (short)_inciteCost;

                previousOwner.IsDestroyed();

                if (Human == _cityToIncite.Owner || Human == _diplomat.Owner)
                {
                    GameTask.Insert(Tasks.Show.CityManager(_cityToIncite));
                }
            };

            if (Human == _cityToIncite.Owner || Human == _diplomat.Owner)
            {
                GameTask.Insert(captureCity);
            }

            Cancel();
        }
Пример #5
0
 private void TribalHutMessage(EventHandler method, params string[] message)
 {
     if (Player.IsHuman)
     {
         Message msgBox = Message.General(message);
         msgBox.Done += method;
         GameTask.Insert(msgBox);
         return;
     }
     method(this, null);
 }
Пример #6
0
        internal void EstablishTradeRoute(City city)
        {
            string homeName = Home?.Name ?? "NONE";
            string ware     = WARES[Common.Random.Next(8)];
            int    revenue  = TradeGoldBonus(city);

            if (revenue <= 0)
            {
                revenue = 1;                           // revenue should at least be 1, I think (needs to be checked)
            }
            GameTask.Insert(Message.General(
                                $"{ware} caravan from {homeName}",
                                $"arrives in {city.Name}",
                                "Trade route established",
                                $"Revenue: ${revenue}."));
            Game.GetPlayer(Owner).Gold += (short)revenue;
            Game.DisbandUnit(this);
        }
Пример #7
0
        public GamePlay()
        {
            OnResize += Resize;

            Palette = Resources["SP257"].Palette;

            _rightSideBar = Settings.RightSideBar;

            _menuBar = new MenuBar(Palette);
            _sideBar = new SideBar(Palette);
            _gameMap = new GameMap();

            CenterMapOnActiveHumanPlayerAsset();

            if (Width != 320 || Height != 200)
            {
                Resize(null, new ResizeEventArgs(Width, Height));
            }
            else
            {
                this.Clear(5);
            }

            _menuBar.GameSelected        += MenuBarGame;
            _menuBar.OrdersSelected      += MenuBarOrders;
            _menuBar.AdvisorsSelected    += MenuBarAdvisors;
            _menuBar.WorldSelected       += MenuBarWorld;
            _menuBar.CivilopediaSelected += MenuBarCivilopedia;

            while (Game.CurrentPlayer != Game.HumanPlayer)
            {
                Game.Instance.Update();
                while (GameTask.Update())
                {
                    ;
                }
            }

            if (!Common.AllowSaveGame)
            {
                GameTask.Insert(Message.General("The save game format", "is not compatible with the", "selected map size.", "The game can not be saved!"));
                Game.Settings.AutoSave = false;
            }
        }
Пример #8
0
        protected override bool Confront(int relX, int relY)
        {
            ITile moveTarget = Map[X, Y][relX, relY];

            if (moveTarget.City != null)
            {
                if (Human == Owner)
                {
                    GameTask.Enqueue(Show.DiplomatCity(moveTarget.City, this));
                    return(true);
                }
                else
                {
                    if (moveTarget.City.Player == Human)
                    {
                        GameTask.Enqueue(Tasks.Show.DiplomatSabotage(moveTarget.City, this));
                    }
                    else
                    {
                        Sabotage(moveTarget.City);
                    }

                    return(true);
                }
            }

            IUnit[] units = moveTarget.Units;

            if (units.Length == 1)
            {
                IUnit unit = units[0];

                if (unit.Owner != Owner && unit is BaseUnitLand)
                {
                    GameTask.Enqueue(Show.DiplomatBribe(unit as BaseUnitLand, this));
                    return(true);
                }
            }

            Movement       = new MoveUnit(relX, relY);
            Movement.Done += MoveEnd;
            GameTask.Insert(Movement);
            return(true);
        }
Пример #9
0
        public static Show Screens(IEnumerable <Type> types)
        {
            Queue <Type> screenTypeQueue = new Queue <Type>(types.Where(x => typeof(IScreen).IsAssignableFrom(x)));

            if (screenTypeQueue.Count == 0)
            {
                return(null);
            }
            Func <Show> nextTask = null;

            nextTask = () =>
            {
                if (screenTypeQueue.Count == 0)
                {
                    return(null);
                }
                Show showScreen = Show.Screen(screenTypeQueue.Dequeue());
                showScreen.Done += (s, a) => GameTask.Insert(nextTask());
                return(showScreen);
            };
            return(nextTask());
        }
Пример #10
0
        private void TribalHutMessage(EventHandler method, bool runFirst, params string[] message)
        {
            // fire-eggs 20190801 perform the side-effect FIRST so the barbarian units appear BEFORE the message
            if (runFirst)
            {
                method(this, null);
            }

            if (Player.IsHuman)
            {
                Message msgBox = Message.General(message);
                if (!runFirst)
                {
                    msgBox.Done += method;
                }
                GameTask.Insert(msgBox);
                return;
            }
            if (!runFirst)
            {
                method(this, null);
            }
        }
Пример #11
0
 private void CivilopediaClosed(object sender, EventArgs args)
 {
     _player.CurrentResearch = null;
     GameTask.Insert(new TechSelect(_player));
     EndTask();
 }
Пример #12
0
        public virtual bool MoveTo(int relX, int relY)
        {
            if (Movement != null)
            {
                return(false);
            }

            ITile moveTarget = Map[X, Y][relX, relY];

            if (moveTarget == null)
            {
                return(false);
            }
            if (moveTarget.Units.Any(u => u.Owner != Owner))
            {
                if (Class == UnitClass.Land && Tile.IsOcean)
                {
                    GameTask.Enqueue(Message.Error("-- Civilization Note --", TextFile.Instance.GetGameText($"ERROR/AMPHIB")));
                    return(false);
                }
                return(Confront(relX, relY));
            }
            if (Class == UnitClass.Land && !(this is Diplomat || this is Caravan) && !new ITile[] { Map[X, Y], moveTarget }.Any(t => t.IsOcean || t.City != null) && moveTarget.GetBorderTiles().SelectMany(t => t.Units).Any(u => u.Owner != Owner))
            {
                if (!moveTarget.Units.Any(x => x.Owner == Owner))
                {
                    IUnit[] targetUnits = moveTarget.GetBorderTiles().SelectMany(t => t.Units).Where(u => u.Owner != Owner).ToArray();
                    IUnit[] borderUnits = Map[X, Y].GetBorderTiles().SelectMany(t => t.Units).Where(u => u.Owner != Owner).ToArray();

                    if (borderUnits.Any(u => targetUnits.Any(t => t.X == u.X && t.Y == u.Y)))
                    {
                        if (Human == Owner)
                        {
                            GameTask.Enqueue(Message.Error("-- Civilization Note --", TextFile.Instance.GetGameText($"ERROR/ZOC")));
                        }
                        return(false);
                    }
                }
            }
            if (moveTarget.City != null && Map[X, Y][relX, relY].City.Owner != Owner)
            {
                return(Confront(relX, relY));
            }

            if (!MoveTargets.Any(t => t.X == moveTarget.X && t.Y == moveTarget.Y))
            {
                // Target tile is invalid
                // TODO: For some tiles, display a message detailing why the move is illegal
                return(false);
            }

            // TODO: This implementation was done by observation, may need a revision
            if (MovesLeft == 0 && !moveTarget.Road && moveTarget.Movement > 1)
            {
                bool success;
                if (PartMoves >= 2)
                {
                    // 2/3 moves left? 50% chance of success
                    success = (Common.Random.Next(0, 2) == 0);
                }
                else
                {
                    // 2/3 moves left? 33% chance of success
                    success = (Common.Random.Next(0, 3) == 0);
                }

                if (!success)
                {
                    PartMoves = 0;
                    return(false);
                }
            }

            Movement       = new MoveUnit(relX, relY);
            Movement.Done += MoveEnd;
            GameTask.Insert(Movement);

            return(true);
        }
Пример #13
0
        protected virtual bool Confront(int relX, int relY)
        {
            if (Class == UnitClass.Land && (this is Diplomat || this is Caravan))
            {
                // TODO: Perform other unit action (confront)
                return(false);
            }

            Movement = new MoveUnit(relX, relY);

            ITile moveTarget = Map[X, Y][relX, relY];

            if (moveTarget == null)
            {
                return(false);
            }
            if (!moveTarget.Units.Any(u => u.Owner != Owner) && moveTarget.City != null)
            {
                if (Class != UnitClass.Land)
                {
                    GameTask.Enqueue(Message.Error("-- Civilization Note --", TextFile.Instance.GetGameText($"ERROR/OCCUPY")));
                    Movement = null;
                    return(false);
                }

                City capturedCity = moveTarget.City;
                if (!capturedCity.HasBuilding <CityWalls>())
                {
                    capturedCity.Size--;
                }
                Movement.Done += (s, a) =>
                {
                    Show captureCity = Show.CaptureCity(capturedCity);
                    captureCity.Done += (s1, a1) =>
                    {
                        Player previousOwner = Game.GetPlayer(capturedCity.Owner);

                        if (capturedCity.HasBuilding <Palace>())
                        {
                            capturedCity.RemoveBuilding <Palace>();
                        }
                        capturedCity.Food    = 0;
                        capturedCity.Shields = 0;
                        while (capturedCity.Units.Length > 0)
                        {
                            Game.DisbandUnit(capturedCity.Units[0]);
                        }
                        capturedCity.Owner = Owner;

                        if (previousOwner.IsDestroyed)
                        {
                            GameTask.Enqueue(Message.Advisor(Advisor.Defense, false, previousOwner.Civilization.Name, "civilization", "destroyed", $"by {Game.GetPlayer(Owner).Civilization.NamePlural}!"));
                        }

                        if (capturedCity.Size == 0)
                        {
                            return;
                        }
                        GameTask.Insert(Show.CityManager(capturedCity));
                    };
                    GameTask.Insert(captureCity);
                    MoveEnd(s, a);
                };
            }
            else if (AttackOutcome(this, Map[X, Y][relX, relY]))
            {
                Movement.Done += (s, a) =>
                {
                    GameTask.Insert(Show.DestroyUnit(Map[X, Y][relX, relY].Units.First(), true));
                    if (MovesLeft == 0)
                    {
                        PartMoves = 0;
                    }
                    else if (MovesLeft > 0)
                    {
                        if (this is Bomber)
                        {
                            SkipTurn();
                        }
                        else
                        {
                            MovesLeft--;
                        }
                    }
                    Movement = null;
                };
            }
            else
            {
                Movement.Done += (s, a) =>
                {
                    GameTask.Insert(Show.DestroyUnit(this, false));
                    Movement = null;
                };
            }
            GameTask.Insert(Movement);
            return(false);
        }
Пример #14
0
        private void Incite(object sender, EventArgs args)
        {
            Player previousOwner = Game.GetPlayer(_cityToIncite.Owner);
            var    newOwner      = _diplomat.Owner;
            var    newPlayer     = Game.GetPlayer(newOwner);

            // Initial incite message
            var msg = Message.General($"{previousOwner.TribeNamePlural} rebel!",
                                      "Civil War in",
                                      $"{_cityToIncite.Name}.",
                                      $"{newPlayer.TribeName} influence",
                                      "suspected.");

            GameTask.Insert(msg);

            // TODO fire-eggs gold captured
            int plundered = 0;

            // TODO fire-eggs advance stolen

            string[] lines = { $"{newPlayer.TribeNamePlural} capture",
                               $"{_cityToIncite.Name}. {plundered} gold",
                               "pieces plundered." };

            Show         captureCity  = Show.CaptureCity(_cityToIncite, lines);
            EventHandler capture_done = (s1, a1) =>
            {
                Game.DisbandUnit(_diplomat);
                _cityToIncite.Owner = newOwner;

                // fire-eggs 20190701 city units must convert
                // TODO fire-eggs not all units _always_ convert, e.g. settlers ?
                foreach (var unit in _cityToIncite.Units)
                {
                    unit.Owner = newOwner;
                }

                // remove half the buildings at random
                foreach (IBuilding building in _cityToIncite.Buildings.Where(b => Common.Random.Next(0, 1) == 1).ToList())
                {
                    _cityToIncite.RemoveBuilding(building);
                }

                newPlayer.Gold -= (short)_inciteCost;
                newPlayer.Gold += (short)plundered;

                previousOwner.IsDestroyed();

                // TODO fire-eggs not sure if human-city being incited should be here [except incite of rebelling human city?]
                if (Human == _cityToIncite.Owner || Human == newOwner)
                {
                    GameTask.Insert(Tasks.Show.CityManager(_cityToIncite));
                }
            };

            captureCity.Done += capture_done;

            if (Human == _cityToIncite.Owner || Human == _diplomat.Owner)
            {
                // TODO fire-eggs not showing loses side-effects
                //if (!Game.Animations)
                GameTask.Insert(captureCity);
                //else
                //    capture_done(null, null);
            }
            else
            {
                capture_done(null, null); // non-human city incite
            }

            Cancel();
        }
Пример #15
0
        protected virtual bool Confront(int relX, int relY)
        {
            if (Class == UnitClass.Land && (this is Diplomat || this is Caravan))
            {
                // TODO: Perform other unit action (confront)
                return(false);
            }

            Movement = new MoveUnit(relX, relY);

            ITile moveTarget = Map[X, Y][relX, relY];

            if (moveTarget == null)
            {
                return(false);
            }
            if (!moveTarget.Units.Any(u => u.Owner != Owner) && moveTarget.City != null && moveTarget.City.Owner != Owner)
            {
                if (Class != UnitClass.Land)
                {
                    GameTask.Enqueue(Message.Error("-- Civilization Note --", TextFile.Instance.GetGameText($"ERROR/OCCUPY")));
                    Movement = null;
                    return(false);
                }

                City capturedCity = moveTarget.City;
                Movement.Done += (s, a) =>
                {
                    Action changeOwner = delegate()
                    {
                        Player previousOwner = Game.GetPlayer(capturedCity.Owner);

                        if (capturedCity.HasBuilding <Palace>())
                        {
                            capturedCity.RemoveBuilding <Palace>();
                        }
                        capturedCity.Food    = 0;
                        capturedCity.Shields = 0;
                        while (capturedCity.Units.Length > 0)
                        {
                            Game.DisbandUnit(capturedCity.Units[0]);
                        }
                        capturedCity.Owner = Owner;

                        if (!capturedCity.HasBuilding <CityWalls>())
                        {
                            capturedCity.Size--;
                        }

                        previousOwner.IsDestroyed();
                    };

                    IList <IAdvance> advancesToSteal = GetAdvancesToSteal(capturedCity.Player);

                    if (Human == capturedCity.Owner || Human == Owner)
                    {
                        Show captureCity = Show.CaptureCity(capturedCity);
                        captureCity.Done += (s1, a1) =>
                        {
                            changeOwner();

                            if (capturedCity.Size == 0 || Human != Owner)
                            {
                                return;
                            }
                            GameTask.Insert(Show.CityManager(capturedCity));
                        };
                        GameTask.Insert(captureCity);

                        if (advancesToSteal.Any())
                        {
                            GameTask.Enqueue(Tasks.Show.SelectAdvanceAfterCityCapture(Player, advancesToSteal));
                        }
                    }
                    else
                    {
                        changeOwner();
                        if (advancesToSteal.Any())
                        {
                            Player.AddAdvance(advancesToSteal.First());
                        }
                    }
                    MoveEnd(s, a);
                };
            }
            else if (this is Nuclear)
            {
                int  xx   = (X - Common.GamePlay.X + relX) * 16;
                int  yy   = (Y - Common.GamePlay.Y + relY) * 16;
                Show nuke = Show.Nuke(xx, yy);

                if (Map[X, Y][relX, relY].City != null)
                {
                    PlaySound("airnuke");
                }
                else
                {
                    PlaySound("s_nuke");
                }

                nuke.Done += (s, a) =>
                {
                    foreach (ITile tile in Map.QueryMapPart(X + relX - 1, Y + relY - 1, 3, 3))
                    {
                        while (tile.Units.Length > 0)
                        {
                            Game.DisbandUnit(tile.Units[0]);
                        }
                    }
                };
                GameTask.Enqueue(nuke);
            }
            else if (AttackOutcome(this, Map[X, Y][relX, relY]))
            {
                Movement.Done += (s, a) =>
                {
                    if (this is Cannon)
                    {
                        PlaySound("cannon");
                    }
                    else if (this is Musketeers || this is Riflemen || this is Armor || this is Artillery || this is MechInf)
                    {
                        PlaySound("s_land");
                    }
                    else
                    {
                        PlaySound("they_die");
                    }

                    IUnit unit = Map[X, Y][relX, relY].Units.FirstOrDefault();
                    if (unit != null)
                    {
                        GameTask.Insert(Show.DestroyUnit(unit, true));
                    }

                    if (MovesLeft == 0)
                    {
                        PartMoves = 0;
                    }
                    else if (MovesLeft > 0)
                    {
                        if (this is Bomber)
                        {
                            SkipTurn();
                        }
                        else
                        {
                            MovesLeft--;
                        }
                    }
                    Movement = null;
                    if (Map[X, Y][relX, relY].City != null)
                    {
                        if (!Map[X, Y][relX, relY].City.HasBuilding <CityWalls>())
                        {
                            Map[X, Y][relX, relY].City.Size--;
                        }
                    }
                };
            }
            else
            {
                Movement.Done += (s, a) =>
                {
                    if (this is Cannon)
                    {
                        PlaySound("cannon");
                    }
                    else if (this is Musketeers || this is Riflemen || this is Armor || this is Artillery || this is MechInf)
                    {
                        PlaySound("s_land");
                    }
                    else
                    {
                        PlaySound("we_die");
                    }
                    GameTask.Insert(Show.DestroyUnit(this, false));
                    Movement = null;
                };
            }
            GameTask.Insert(Movement);
            return(false);
        }
Пример #16
0
        internal virtual bool Confront(int relX, int relY)
        {
            Goto = Point.Empty;                         // Cancel any goto mode when Confronting

            if (Class == UnitClass.Land && (this is Diplomat || this is Caravan))
            {
                // TODO fire-eggs this should never happen? Diplomat/Caravan have overloads
                return(false);
            }

            Movement = new MoveUnit(relX, relY);

            ITile moveTarget = Map[X, Y][relX, relY];

            if (moveTarget == null)
            {
                return(false);
            }
            if (moveTarget.Units.Length == 0 && moveTarget.City != null && moveTarget.City.Owner != Owner)
            {
                if (Class != UnitClass.Land)                 // can't occupy city with sea/air unit
                {
                    GameTask.Enqueue(Message.Error("-- Civilization Note --", TextFile.Instance.GetGameText($"ERROR/OCCUPY")));
                    Movement = null;
                    return(false);
                }

                City capturedCity = moveTarget.City;
                Movement.Done += (s, a) =>
                {
                    Action changeOwner = delegate()
                    {
                        Player previousOwner = Game.GetPlayer(capturedCity.Owner);

                        if (capturedCity.HasBuilding <Palace>())
                        {
                            capturedCity.RemoveBuilding <Palace>();
                        }
                        capturedCity.Food    = 0;
                        capturedCity.Shields = 0;
                        while (capturedCity.Units.Length > 0)
                        {
                            Game.DisbandUnit(capturedCity.Units[0]);
                        }
                        capturedCity.Owner = Owner;

                        if (!capturedCity.HasBuilding <CityWalls>())
                        {
                            capturedCity.Size--;
                        }

                        previousOwner.IsDestroyed();
                    };

                    IList <IAdvance> advancesToSteal = GetAdvancesToSteal(capturedCity.Player);

                    if (Human == capturedCity.Owner || Human == Owner)
                    {
                        Player cityOwner = Game.GetPlayer(capturedCity.Owner);
                        float  totalSize = cityOwner.Cities.Sum(x => x.Size);
                        int    totalGold = cityOwner.Gold;

                        // Issue #56 : Gold formula from CivFanatics
                        int captureGold = (int)(totalGold * ((float)capturedCity.Size / totalSize));

                        Game.GetPlayer(capturedCity.Owner).Gold -= (short)captureGold;
                        Game.CurrentPlayer.Gold += (short)captureGold;

                        string[] lines = { $"{Game.CurrentPlayer.TribeNamePlural} capture",
                                           $"{capturedCity.Name}. {captureGold} gold",
                                           "pieces plundered." };

                        EventHandler doneCapture = (s1, a1) =>
                        {
                            changeOwner();

                            if (capturedCity.Size == 0 || Human != Owner)
                            {
                                return;
                            }
                            GameTask.Insert(Show.CityManager(capturedCity));

                            // fire-eggs 20190628 no 'select advance' dialog when non-human is doing the capturing!
                            if (advancesToSteal.Any() && Human == Owner)
                            {
                                GameTask.Enqueue(Show.SelectAdvanceAfterCityCapture(Player, advancesToSteal));
                            }
                        };

                        if (Game.Animations)
                        {
                            Show captureCity = Show.CaptureCity(capturedCity, lines);
                            captureCity.Done += doneCapture;
                            GameTask.Insert(captureCity);
                        }
                        else
                        {
                            IScreen captureNews = new Newspaper(capturedCity, lines, false);
                            captureNews.Closed += doneCapture;
                            Common.AddScreen(captureNews);
                        }
                    }
                    else
                    {
                        changeOwner();
                        if (advancesToSteal.Any())
                        {
                            Player.AddAdvance(advancesToSteal.First());
                        }
                    }
                    MoveEnd(s, a);
                };
            }
            else if (this is Nuclear)
            {
                int  xx   = (X - Common.GamePlay.X + relX) * 16;
                int  yy   = (Y - Common.GamePlay.Y + relY) * 16;
                Show nuke = Show.Nuke(xx, yy);

                if (Map[X, Y][relX, relY].City != null)
                {
                    PlaySound("airnuke");
                }
                else
                {
                    PlaySound("s_nuke");
                }

                nuke.Done += (s, a) =>
                {
                    foreach (ITile tile in Map.QueryMapPart(X + relX - 1, Y + relY - 1, 3, 3))
                    {
                        while (tile.Units.Length > 0)
                        {
                            Game.DisbandUnit(tile.Units[0]);
                        }
                    }
                };
                GameTask.Enqueue(nuke);
            }
            else if (AttackOutcome(this, Map[X, Y][relX, relY]))
            {
                Movement.Done += (s, a) =>
                {
                    if (this is Cannon)
                    {
                        PlaySound("cannon");
                    }
                    else if (this is Musketeers || this is Riflemen || this is Armor || this is Artillery || this is MechInf)
                    {
                        PlaySound("s_land");
                    }
                    else
                    {
                        PlaySound("they_die");
                    }

                    // fire-eggs 20190702 capture barbarian leader, get ransom
                    IUnit[] attackedUnits = moveTarget.Units;
                    if (attackedUnits.Length > 0 && attackedUnits.All(x => x is Diplomat) &&
                        attackedUnits[0] is Diplomat &&
                        ((BaseUnit)attackedUnits[0]).Player.Civilization is Barbarian)
                    {
                        Player.Gold += 100;
                        if (Human == Player)
                        {
                            Common.AddScreen(new MessageBox("Barbarian leader captured!", "100$ ransom paid."));
                        }
                    }

                    IUnit unit = attackedUnits.FirstOrDefault();
                    if (unit != null)
                    {
                        var task = Show.DestroyUnit(unit, true);

                        // fire-eggs 20190729 when destroying last city, check for civ destruction ASAP
                        if (unit.Owner != 0)
                        {
                            task.Done += (s1, a1) => { Game.GetPlayer(unit.Owner).IsDestroyed(); }
                        }
                        ;

                        GameTask.Insert(task);
                        //GameTask.Insert(Show.DestroyUnit(unit, true));
                    }

                    if (MovesLeft == 0)
                    {
                        PartMoves = 0;
                    }
                    else if (MovesLeft > 0)
                    {
                        if (this is Bomber)
                        {
                            SkipTurn();
                        }
                        else
                        {
                            MovesLeft--;
                        }
                    }
                    Movement = null;
                    if (Map[X, Y][relX, relY].City != null)
                    {
                        if (!Map[X, Y][relX, relY].City.HasBuilding <CityWalls>())
                        {
                            Map[X, Y][relX, relY].City.Size--;
                        }
                    }
                };
            }
            else
            {
                Movement.Done += (s, a) =>
                {
                    if (this is Cannon)
                    {
                        PlaySound("cannon");
                    }
                    else if (this is Musketeers || this is Riflemen || this is Armor || this is Artillery || this is MechInf)
                    {
                        PlaySound("s_land");
                    }
                    else
                    {
                        PlaySound("we_die");
                    }
                    GameTask.Insert(Show.DestroyUnit(this, false));
                    Movement = null;
                };
            }
            GameTask.Insert(Movement);
            return(false);
        }