public override void Draw(GameTime gameTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
        {
            graphics.Clear(Color.Black);

            // screen space
            float backgroundZ = -50f; // Background distance.

            spriteBatch.Begin(sortMode: SpriteSortMode.Deferred, blendState: BlendState.AlphaBlend, samplerState: SamplerState.PointClamp, transformMatrix: Camera.GetViewMatrix(backgroundZ));
            {
                WorldManager.DrawScreen(spriteBatch, backgroundZ);
            }
            spriteBatch.End();

            // world space
            spriteBatch.Begin(sortMode: SpriteSortMode.Deferred, blendState: BlendState.AlphaBlend, samplerState: SamplerState.PointClamp, transformMatrix: Camera.GetViewMatrix());
            {
                WorldManager.DrawWorld(spriteBatch);
                UnitManager.DrawWorld(spriteBatch);
            }
            spriteBatch.End();

            // screen space
            spriteBatch.Begin(sortMode: SpriteSortMode.Deferred, blendState: BlendState.AlphaBlend, samplerState: SamplerState.PointClamp);
            {
                _menu.Draw(spriteBatch);
                UnitManager.DrawScreen(spriteBatch);
            }
            spriteBatch.End();
        }
Esempio n. 2
0
        public void DrawScreen(SpriteBatch spriteBatch)
        {
            SBSelection.Clear();
            foreach (var kvp in SelectedShipTypes)
            {
                SBSelection.Append("[" + kvp.Key.ToString() + " x" + kvp.Value.Count.ToString() + "] ");
            }

            Menu.GetWidget <PUIWLabel>("lblSelection").Text = SBSelection.ToString();

            if (Dragging)
            {
                spriteBatch.Draw(DragSelectTexture, DragRect, DragRect, Color.White);
            }

            Sprites.DefaultFont.Size = 18;

            for (var i = 0; i <= WorldManager.Asteroids.LastActiveIndex; i++)
            {
                var asteroid = WorldManager.Asteroids.Buffer[i];

                if (asteroid.ResourceType == ResourceType.None)
                {
                    continue;
                }

                var resourceString     = asteroid.ResourceType.ToString();
                var resourceStringSize = Sprites.DefaultFont.MeasureString(resourceString);
                var textPosition       = asteroid.Position - new Vector2(resourceStringSize.X / 2, resourceStringSize.Y / 2) - new Vector2(0, asteroid.Origin.Y + 50);
                textPosition = Vector2.Transform(textPosition, Camera.GetViewMatrix());

                spriteBatch.DrawString(Sprites.DefaultFont, resourceString, textPosition, Color.White);
            }

            WorldManager.Ships.Add(WorldManager.PlayerEntity);

            for (var i = 0; i < WorldManager.Ships.Count; i++)
            {
                var ship = WorldManager.Ships[i];

                var shipString = "";

                var armourPercent = ship.CurrentArmourHP / ship.BaseArmourHP * 100.0f;
                var shieldPercent = ship.CurrentShieldHP / ship.BaseShieldHP * 100.0f;

                if (armourPercent < 100.0f)
                {
                    shipString += "A: " + armourPercent.ToString("0") + "%";
                }
                if (shieldPercent < 100.0f)
                {
                    shipString += (shipString.Length > 0 ? " " : "") + "S: " + shieldPercent.ToString("0") + "%";
                }

                if (shipString.Length > 0)
                {
                    var shipStringSize = Sprites.DefaultFont.MeasureString(shipString);
                    var textPosition   = (ship.Position - new Vector2(shipStringSize.X / 2, shipStringSize.Y / 2) - new Vector2(0, ship.Origin.Y + 50));
                    textPosition = Vector2.Transform(textPosition, Camera.GetViewMatrix());

                    spriteBatch.DrawString(Sprites.DefaultFont, shipString, textPosition, Color.White);
                }
            }

            WorldManager.Ships.Remove(WorldManager.PlayerEntity);
        }
Esempio n. 3
0
        public override void Draw(GameTime gameTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
        {
            graphics.Clear(Color.Black);

            // screen space
            spriteBatch.Begin(sortMode: SpriteSortMode.Deferred, blendState: BlendState.AlphaBlend, samplerState: SamplerState.PointClamp);
            {
                WorldManager.DrawScreen(spriteBatch);
            }
            spriteBatch.End();

            // world space
            spriteBatch.Begin(sortMode: SpriteSortMode.Deferred, blendState: BlendState.AlphaBlend, samplerState: SamplerState.PointClamp, transformMatrix: Camera.GetViewMatrix());
            {
                WorldManager.DrawWorld(spriteBatch);
                UnitManager.DrawWorld(spriteBatch);
                ProjectileManager.Draw(spriteBatch);
            }
            spriteBatch.End();

            // screen space
            spriteBatch.Begin(sortMode: SpriteSortMode.Deferred, blendState: BlendState.AlphaBlend, samplerState: SamplerState.PointClamp);
            {
                UnitManager.DrawScreen(spriteBatch);
                Menu.Draw(spriteBatch);
                PUITooltipManager.Draw(spriteBatch);
            }
            spriteBatch.End();
        }