Exemplo n.º 1
0
        public ArmyWindow CreateArmyWindow(Army army)
        {
            var window   = new ArmyWindow(_guiServices);
            var hasData  = false;
            var infoText = "";

            window.NameText = army.Name;
            window.Image    = _armyWindowImages[army.Owner.Id - 1];

            window.ButtonOkText = _texts.Get("ok");
            if (army.Owner.IsUserControlled)
            {
                window.ButtonMoreText = _texts.Get("commands");
                hasData = true;
            }
            else
            {
                window.ButtonMoreText = _texts.Get("interview");
                if (army.DaysToGetInfo > 28 && army.DaysToGetInfo < 100)
                {
                    hasData  = false;
                    infoText = _texts.Get("noInformation");
                }
                else
                {
                    infoText = army.DaysToGetInfo > 1 ?
                               _texts.Get("informationsInXDays", army.DaysToGetInfo) :
                               _texts.Get("informationsInOneDay");
                    hasData = false;
                }
                if (army.DaysToGetInfo == 0 || army.DaysToGetInfo == 100)
                {
                    hasData = true;
                    window.ButtonMoreText = _texts.Get("trace");
                }
            }

            if (!hasData && !_legionConfig.GoDmOdE)
            {
                window.InfoText = infoText;
            }
            else
            {
                var count = army.Characters.Count;
                window.CountText = count == 1 ?
                                   _texts.Get("oneWarrior") :
                                   _texts.Get("xWarriors", count);

                int foodCount = army.Food / army.Characters.Count;
                if (foodCount > 1)
                {
                    window.FoodText = _texts.Get("foodForXDays", foodCount);
                }
                else if (foodCount == 1)
                {
                    window.FoodText = _texts.Get("foodForOneDay");
                }
                else
                {
                    window.FoodText = _texts.Get("noMoreFood");
                }

                window.StrengthText = _texts.Get("strength") + ": " + army.Strength;
                window.SpeedText    = _texts.Get("speed") + ": " + army.Speed;

                window.ActionText = "";
                switch (army.CurrentAction)
                {
                case ArmyActions.Camping:
                    window.ActionText = _texts.Get("camping");

                    /* TODO:
                     * If TEREN>69
                     *  RO$=RO$+" w "+MIASTA$(TEREN-70)
                     * End If
                     */
                    break;

                case ArmyActions.Move:
                case ArmyActions.FastMove:
                    window.ActionText = _texts.Get("moving");
                    break;

                case ArmyActions.Attack:
                    window.ActionText = _texts.Get("attackingX", army.Target.Name);

                    /* TODO:
                     * If CELY=0
                     *  R2$=ARMIA$(CELX,0)
                     * Else
                     *  R2$=MIASTA$(CELX)
                     * End If
                     * RO$="Atakujemy "+R2$
                     */
                    break;

                case ArmyActions.Hunting:
                    window.ActionText = _texts.Get("hunting");
                    break;
                }
            }

            if (army.Owner.IsUserControlled)
            {
                window.MoreClicked += args =>
                {
                    var ordersWindow = CreateArmyOrdersWindow(army);
                    _modalLayer.Window = ordersWindow;

                    // TODO: implement all actions handling
                    ordersWindow.MoveClicked     += moveArgs => HandleMoveClick(army, ArmyActions.Move);
                    ordersWindow.FastMoveClicked += moveArgs => HandleMoveClick(army, ArmyActions.FastMove);
                    ordersWindow.AttackClicked   += moveArgs =>
                    {
                        _mapRouteDrawer.StartRouteDrawingForMapObject(army, (source, target) =>
                        {
                            ((Army)source).CurrentAction = ArmyActions.Attack;
                            ((Army)source).Target        = target;
                        });
                    };
                    ordersWindow.HuntClicked      += moveArgs => army.CurrentAction = ArmyActions.Hunting;
                    ordersWindow.CampClicked      += moveArgs => army.CurrentAction = ArmyActions.Camping;
                    ordersWindow.EquipmentClicked += _args =>
                    {
                        var equipmentWindow = new EquipmentWindow(_guiServices, _texts)
                        {
                            Army = army
                        };
                        _modalLayer.Window = equipmentWindow;
                    };
                };
            }
            else if (army.DaysToGetInfo > 0 && army.DaysToGetInfo < 100)
            {
                window.MoreClicked += args =>
                {
                    _modalLayer.Window = _commonMapGuiFactory.CreateBuyInformationWindow(army);
                };
            }

            return(window);
        }
Exemplo n.º 2
0
        public CityWindow CreateCityWindow(City city)
        {
            var window   = new CityWindow(_guiServices);
            var hasData  = false;
            var infoText = "";
            var daysText = "";

            window.Image = _cityWindowImages[city.WallType];

            window.ButtonOkText = _texts.Get("ok");
            if (city.Owner != null && city.Owner.IsUserControlled)
            {
                window.ButtonMoreText = _texts.Get("commands");
                hasData = true;
            }
            else
            {
                window.ButtonMoreText = _texts.Get("interview");
                if (city.DaysToGetInfo > 25)
                {
                    hasData  = false;
                    infoText = _texts.Get("noInformation");
                }
                else
                {
                    infoText = city.DaysToGetInfo > 1 ?
                               _texts.Get("informationsInXDays", city.DaysToGetInfo) :
                               _texts.Get("informationsInOneDay");
                    hasData = false;
                }
                if (city.DaysToGetInfo == 0)
                {
                    infoText = "";
                    hasData  = true;
                }
            }

            if (city.Population > 700)
            {
                window.NameText = _texts.Get("city") + " " + city.Name;
            }
            else
            {
                window.NameText = _texts.Get("village") + " " + city.Name;
            }

            if (!hasData && !_legionConfig.GoDmOdE)
            {
                window.InfoText = infoText;
            }
            else
            {
                window.CountText = _texts.Get("peopleCount", city.Population);
                window.TaxText   = _texts.Get("tax") + ": " + city.Tax;

                var morale2 = city.Morale / 20;
                if (morale2 > 4)
                {
                    morale2 = 4;
                }
                //TODO: handle morale texts better way
                var moraleTexts = new []
                {
                    _texts.Get("rebelious"),
                    _texts.Get("discontented"),
                    _texts.Get("serf"),
                    _texts.Get("loyal"),
                    _texts.Get("fanatics")
                };
                //Text OKX + 50,OKY + 45,"Morale :" + GUL$(MORALE2)
                window.MoraleText = _texts.Get("morale") + ": " + moraleTexts[morale2];

                var buildings = new List <string>();
                foreach (var name in city.Buildings.Where(b => b.Type.Type == BuildingType.Shop).Select(b => b.Type.Name))
                {
                    if (!buildings.Contains(name))
                    {
                        buildings.Add(name);
                    }
                }
                window.Buildings = buildings;
            }

            if (city.Owner != null && city.Owner.IsUserControlled)
            {
                window.MoreClicked += args =>
                {
                    args.Handled = true;
                    var ordersWindow = CreateCityOrdersWindow(city);
                    _modalLayer.Window = ordersWindow;
                };
            }
            else
            {
                window.MoreClicked += args =>
                {
                    _modalLayer.Window = _commonMapGuiFactory.CreateBuyInformationWindow(city);
                };
            }

            return(window);
        }