Ejemplo n.º 1
0
        public static string PlanetName(PlanetInfo planet)
        {
            string starName = planet.HostStar.Name.ToText(LocalizationManifest.Get.CurrentLanguage);

            var context  = LocalizationManifest.Get.CurrentLanguage["FormMain"];
            var textVars = new TextVar(
                "bodyName",
                starName + " " + RomanFromatter.Fromat(planet.Position)
                ).Get;

            switch (planet.Type)
            {
            case PlanetType.Asteriod:
                return(context["AsteriodName"].Text(textVars));

            case PlanetType.GasGiant:
                return(context["GasGiantName"].Text(textVars));

            case PlanetType.Rock:
                return(context["RockName"].Text(textVars));

            default:
                throw new NotImplementedException("Unimplemented planet type: " + planet.Type);
            }
        }
Ejemplo n.º 2
0
        //TODO(v0.8) bundle with movement simulation
        private void setupMovementEta()
        {
            if (this.SelectedFleet == null || !this.SelectedFleet.SimulationWaypoints().Any())
            {
                if (this.movementEtaText != null)
                {
                    this.RemoveFromScene(ref this.movementEtaText);
                }

                return;
            }

            var waypoints = this.SelectedFleet.SimulationWaypoints();

            var destination = waypoints[waypoints.Count - 1];
            var numVars     = new Var("eta", Math.Ceiling(this.SelectedFleet.SimulationEta)).Get;
            var textVars    = new TextVar("eta", new DecimalsFormatter(0, 1).Format(this.SelectedFleet.SimulationEta, RoundingMethod.Ceil, 0)).
                              And("fuel", new ThousandsFormatter().Format(this.SelectedFleet.SimulationFuel)).Get;

            this.UpdateScene(
                ref this.movementEtaText,
                new SceneObjectBuilder().
                PixelSize(this.pixelSize).
                StartText(
                    LocalizationManifest.Get.CurrentLanguage["FormMain"]["FleetEta"].Text(numVars, textVars),
                    -0.5f, 0, EtaZ, InterlayerZRange, Color.White
                    ).
                Scale(EtaTextScale / (float)Math.Pow(ZoomBase, zoomLevel)).
                Translate(destination.Position.X, destination.Position.Y + 0.5).
                Build()
                );
        }
Ejemplo n.º 3
0
        //TODO(v0.6) bundle with movement simulation
        private void setupMovementEta()
        {
            if (this.SelectedFleet != null && this.SelectedFleet.SimulationWaypoints.Count > 0 && this.SelectedFleet.Eta > 0)
            {
                var destination = this.SelectedFleet.SimulationWaypoints[this.SelectedFleet.SimulationWaypoints.Count - 1];
                var numVars     = new Var("eta", Math.Ceiling(this.SelectedFleet.Eta)).Get;
                var textVars    = new TextVar("eta", new DecimalsFormatter(0, 1).Format(this.SelectedFleet.Eta, RoundingMethod.Ceil, 0)).Get;
                var transform   =
                    Matrix4.CreateScale(EtaTextScale) *
                    Matrix4.CreateTranslation((float)destination.X, (float)destination.Y + 0.5f, 0);

                this.UpdateScene(
                    ref this.movementEtaText,
                    new SceneObject(new PolygonData(
                                        EtaZ,
                                        new SpriteData(transform, TextRenderUtil.Get.TextureId, Color.White),
                                        TextRenderUtil.Get.BufferText(
                                            LocalizationManifest.Get.CurrentLanguage["FormMain"]["FleetEta"].Text(numVars, textVars),
                                            -0.5f,
                                            Matrix4.Identity
                                            ).ToList()))
                    );
            }
            else if (this.movementEtaText != null)
            {
                this.RemoveFromScene(ref this.movementEtaText);
            }
        }
        public static string ConstructionEstimation(ConstructableInfo construction, IText neverText, IText perTurnText, IText etaText)
        {
            var textVars = new TextVar();

            if (construction.CompletedCount >= 1)
            {
                var overflow = construction.Overflow / construction.Cost;

                if (construction.CompletedCount < 10)
                {
                    //TODO(v0.9) overflow gives too big estimation
                    textVars.And("count", new DecimalsFormatter(0, 1).Format(construction.CompletedCount + overflow, RoundingMethod.Floor, 1));
                }
                else
                {
                    textVars.And("count", new ThousandsFormatter().Format(construction.CompletedCount));
                }

                return(perTurnText.Text(null, textVars.Get));
            }

            if (construction.Investment <= 0 || (construction.Investment / construction.Cost) < MinimumPerTurnDone)
            {
                return(neverText.Text());
            }

            var eta     = (construction.Cost - construction.FromStockpile) / construction.Investment;
            var numVars = new Var("eta", eta).Get;

            if (eta < 10)
            {
                textVars.And("eta", new DecimalsFormatter(0, 1).Format(eta, RoundingMethod.Ceil, 1));
            }
            else
            {
                textVars.And("eta", new ThousandsFormatter().Format(Math.Ceiling(eta)));
            }

            return(etaText.Text(numVars, textVars.Get));
        }
Ejemplo n.º 5
0
        public ColonizationTargetView(ColonizationController controller, PlayerController gameController) : this()
        {
            this.controller     = controller;
            this.gameController = gameController;
            var context = LocalizationManifest.Get.CurrentLanguage["FormColonization"];

            var infoFormatter = new ThousandsFormatter(controller.PopulationMax);
            var infoVars      = new TextVar("pop", infoFormatter.Format(controller.Population)).
                                And("max", infoFormatter.Format(controller.PopulationMax));

            this.targetName.Text = LocalizationMethods.PlanetName(controller.PlanetBody);
            this.targetInfo.Text = context["population"].Text(infoVars.Get);

            var enrouteShips      = gameController.EnrouteColonizers(controller.PlanetBody).SelectMany(x => x.Ships).ToArray();
            var enroutePopulation = enrouteShips.Length > 0 ?
                                    enrouteShips.Sum(x => x.Quantity * x.Design.ColonizerPopulation) :
                                    0;

            this.enrouteInfo.Text = context["enroute"].Text(
                new TextVar("count", new ThousandsFormatter().Format(enroutePopulation)).Get
                );
        }