Esempio n. 1
0
        protected override void Execute(LocalPlayer player)
        {
            if (player.ActiveUnit.CurrentLocation.IsCityPresent)
            {
                player.ActiveTile.CityHere.GrowCity(_game);
                var unit = player.ActiveUnit;
                unit.Dead           = true;
                unit.MovePointsLost = unit.MovePoints;
                _game.ChooseNextUnit();
            }
            else
            {
                var box = _mainForm.popupBoxList["NAMECITY"];
                if (box.Options is not null)
                {
                    box.Text    = box.Options;
                    box.Options = null;
                }

                var name           = CityActions.GetCityName(player.Civ, _game);
                var cityNameDialog = new Civ2dialog(_mainForm, box,
                                                    textBoxes: new List <TextBoxDefinition>
                {
                    new()
                    {
                        index        = 0,
                        InitialValue = name,
                        Name         = "CityName",
                        Width        = 225
                    }
                });
Esempio n. 2
0
        private void cmdGuardar_Click(object sender, EventArgs e)
        {
            var codCiudad = this.txtCodCiudad.Text.Trim();
            var nomCiudad = this.txtNombreCiudad.Text.Trim();

            if (codCiudad.Equals(string.Empty) || nomCiudad.Equals(string.Empty))
            {
                MessageBox.Show("Debe ingresar Código y nombre de ciudad", Enumerations.GlobalInformation.CompanyName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            var city = new City()
            {
                CityCode = codCiudad,
                CityName = nomCiudad
            };

            var insertCity = new CityActions().InsertCity((int)Enumerations.GlobalActions.Insertar, city);

            if (!insertCity)
            {
                MessageBox.Show("Se generó error al almacenar", Enumerations.GlobalInformation.CompanyName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            MessageBox.Show("Ciudad almacenada con éxito", Enumerations.GlobalInformation.CompanyName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Esempio n. 3
0
        // GET: api/City/5
        public IEnumerable <MCity> Get(int id)
        {
            CityActions CA = new CityActions();

            return(CA.GetCitiesById(id));
        }
Esempio n. 4
0
        // GET: api/City
        public IEnumerable <MCity> Get()
        {
            CityActions CA = new CityActions();

            return(CA.GetCities());
        }
Esempio n. 5
0
        private void AiTurn()
        {
            foreach (var unit in _activeCiv.Units.Where(u => !u.Dead).ToList())
            {
                var currentTile = unit.CurrentLocation;
                switch (unit.AIrole)
                {
                case AIroleType.Attack:
                    break;

                case AIroleType.Defend:
                    if (currentTile.CityHere != null)
                    {
                        if (currentTile.UnitsHere.Count(u => u != unit && u.AIrole == AIroleType.Defend) <
                            2 + currentTile.CityHere.Size / 3)
                        {
                            if (unit.Order == OrderType.Fortify || unit.Order == OrderType.Fortified)
                            {
                                unit.Order = OrderType.Fortified;
                            }
                            else
                            {
                                unit.Order = OrderType.Fortify;
                            }
                            unit.MovePointsLost = unit.MovePoints;
                        }
                    }
                    else
                    {
                    }
                    break;

                case AIroleType.NavalSuperiority:
                    break;

                case AIroleType.AirSuperiority:
                    break;

                case AIroleType.SeaTransport:
                    break;

                case AIroleType.Settle:
                    if (currentTile.Fertility == -2)
                    {
                        CityActions.AIBuildCity(unit, this);
                    }
                    var cityTile = CurrentMap.CityRadius(currentTile)
                                   .FirstOrDefault(t => t.CityHere != null);
                    if (cityTile == null)
                    {
                        var moreFertile = MovementFunctions.GetPossibleMoves(this, currentTile, unit)
                                          .Where(n => n.Fertility > currentTile.Fertility).OrderByDescending(n => n.Fertility)
                                          .FirstOrDefault();
                        if (moreFertile == null)
                        {
                            CityActions.AIBuildCity(unit, this);
                        }
                        else
                        {
                            if (MovementFunctions.UnitMoved(this, unit, moreFertile, currentTile))
                            {
                                currentTile = moreFertile;
                                if (unit.MovePoints > 0)
                                {
                                    CityActions.AIBuildCity(unit, this);
                                }
                            }
                        }
                    }

                    break;

                case AIroleType.Diplomacy:
                    break;

                case AIroleType.Trade:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                while (unit.MovePoints > 0)
                {
                    var possibleMoves = MovementFunctions.GetPossibleMoves(this, currentTile, unit).ToList();
                    if (unit.AttackBase == 0)
                    {
                        possibleMoves = possibleMoves
                                        .Where(m => m.UnitsHere.Count == 0 || m.UnitsHere[0].Owner == unit.Owner).ToList();
                    }
                    if (possibleMoves.Count == 0)
                    {
                        unit.SkipTurn();
                    }
                    else
                    {
                        var destination = Random.ChooseFrom(possibleMoves);
                        if (destination.UnitsHere.Count > 0 && destination.UnitsHere[0].Owner != unit.Owner)
                        {
                            unit.Order = OrderType.NoOrders;
                            MovementFunctions.AttackAtTile(unit, this, destination);
                        }
                        else if (MovementFunctions.UnitMoved(this, unit, destination, currentTile))
                        {
                            currentTile = destination;
                        }
                    }
                }
            }
            ChoseNextCiv();
        }