Example #1
0
        // Implement planets as buttons?
        public override void Render(SpriteBatch spriteBatch, ViewController view)
        {
            World.System system = ChapterMaster.Sector.Systems[systemId];
            ((SystemScreenAlign)align).pinned = notInWorld;
            Rect = align.GetRect(view);
            exitButton.position = MathUtil.Add(Rect.Location, new Vector2(247, 261));
            //pinButton.position = new Vector2(247, 20);
            // TODO: replace with align
            spriteBatch.Draw(Assets.UITextures[backgroundTexture + system.Planets.Count], Rect, Color.White); // TODO: This will go awry if a system has 5 planets. Add a new System Screen. Most likely. Crashes when you have 0 planets. Need to implement minimum.
            Vector2 stringSize = Assets.CaslonAntiqueBold.MeasureString(system.name + " System");

            //Debug.WriteLine(stringSize.X);
            spriteBatch.DrawString(Assets.CaslonAntiqueBold, system.name + " System", MathUtil.Add(Rect.Location, new Vector2(80, 12)), Color.Gray);
            // TODO: replace with align component
            Point   position = Rect.Location + new Point(50 - Constants.SystemSize / 2, 120 - Constants.SystemSize / 2);
            Vector2 pos      = new Vector2(position.X, position.Y);

            // TODO: better way to pass the system's color
            RenderHelper.DrawStar(spriteBatch, pos, ChapterMaster.Sector.Systems[systemId].color);
            planetAligns.Clear();
            for (int noPlanet = 0; noPlanet < system.Planets.Count; noPlanet++)
            {
                // calculate orbit arc
                //float r = 40; // TODO: Implement.
                //float x = (float) Math.Sqrt(Math.Pow((double) r, 2) - Math.Pow((double) 20, 2));
                //float startAngle = (float) Math.Acos(x / r);
                //float endAngle = 2 * startAngle;
                PlanetAlign planetAlign = new PlanetAlign(noPlanet, pos, 80, 42, 120 - Constants.SystemSize);
                RenderHelper.DrawPlanet(spriteBatch, new Vector2(),
                                        Planet.TypeToTexture(system.Planets[noPlanet].Type), planetAlign, view);
                spriteBatch.DrawString(Assets.CaslonAntiqueBold, Constants.PlanetNames[system.Planets[noPlanet].planetId], planetAlign.planetPos + new Vector2(16, 32), Color.Gray);
                planetAligns.Add(planetAlign);
            }
            foreach (Button button in Buttons)
            {
                button.Render(spriteBatch, view);
            }
            foreach (Screen screen in Screens)
            {
                screen.Render(spriteBatch, view);
            }
        }
Example #2
0
        public override void Render(SpriteBatch spriteBatch, ViewController view)
        {
            World.System system = ChapterMaster.Sector.Systems[systemId];
            World.Planet planet = ChapterMaster.Sector.Systems[systemId].Planets[planetId];
            Rect = align.GetRect(view);
            // background
            spriteBatch.Draw(Assets.UITextures[backgroundTexture], Rect, Color.White);
            // disposition height
            string disposition = "Disposition ???/100 ";
            int    dH          = (int)Assets.CaslonAntiqueRegular.MeasureString(disposition).Y;
            // planet type texture
            Vector2 pos = MathUtil.Add(Rect.Location, new Vector2(8, 8 + dH + 2));

            spriteBatch.Draw(Assets.PlanetTypeTextures[planet.GetTypeTexture()], pos, Color.Gray);
            RenderHelper.PrimitiveBuddy.Rectangle(MathUtil.VectorToRectangle(pos, new Vector2(128, 128)), Color.Gray);
            //disposition
            spriteBatch.DrawString(Assets.CourierNew, disposition,
                                   MathUtil.Add(Rect.Location, new Vector2(123, 9)), Color.White);
            RenderHelper.PrimitiveBuddy.Rectangle(MathUtil.VectorToRectangle(new Vector2(pos.X, Rect.Location.Y + 8), new Vector2(290, dH)), Color.Gray);
            // title
            Vector2 titlePos = MathUtil.Add(Rect.Location, new Vector2(128 + 8 + 1, 8 + dH + 2 + 2));
            string  title    = planet.GetName();

            spriteBatch.DrawString(Assets.CaslonAntiqueBold, title, titlePos, Color.Gray);
            int     tH            = (int)Assets.CaslonAntiqueRegular.MeasureString(title).Y;               // title height
            int     cH            = (int)Assets.CaslonAntiqueRegular.MeasureString(planet.FactionOwner).Y; // controller name height
            Vector2 controllerPos = MathUtil.Offset(titlePos, 0, tH);

            spriteBatch.DrawString(Assets.CaslonAntiqueBold, planet.FactionOwner, controllerPos, Color.Gray);
            // population
            spriteBatch.DrawString(Assets.CaslonAntiqueRegular, "Population: " + planet.Population, MathUtil.Offset(controllerPos, 0, cH + 2), Color.Gray);
            // defense force
            spriteBatch.DrawString(Assets.CaslonAntiqueRegular, "Defense Force: " + planet.Population, MathUtil.Offset(controllerPos, 0, cH + cH + 2), Color.Gray);
            foreach (Button button in Buttons)
            {
                button.Render(spriteBatch, view);
            }
        }