Exemple #1
0
        public void Draw(SpriteBatch spriteBatch, string replace)
        {
            spriteBatch.Draw(texture, rectangle, Color.White);

            // Center text in the button
            Vector2 textOrigin = MoboUtils.textOrigin(replace, ContentStore.generic);

            spriteBatch.DrawString(ContentStore.generic, replace, position, Color.Black, 0.0f, textOrigin, 1f, SpriteEffects.None, 0.0f);
        }
Exemple #2
0
 public void Draw(SpriteBatch spriteBatch)
 {
     spriteBatch.Draw(texture, rectangle, color);
     if (!hidetext)
     {
         // Calculate the center of the text to center the text in the button
         Vector2 textOrigin = MoboUtils.textOrigin(name, ContentStore.generic);
         spriteBatch.DrawString(ContentStore.generic, name, position, Color.Black, 0.0f, textOrigin, 1f, SpriteEffects.None, 0.0f);
     }
 }
Exemple #3
0
        public void Draw(SpriteBatch spriteBatch)
        {
            background.Draw(spriteBatch);

            // Draw buttons
            foreach (Button button in menuButtons)
            {
                button.Draw(spriteBatch);
            }

            spriteBatch.Draw(ContentStore.help, MoboUtils.textureOrigin(ContentStore.help), Color.White);
        }
Exemple #4
0
        public void Draw(SpriteBatch spriteBatch)
        {
            // Draw background
            background.Draw(spriteBatch);

            // Draw logo in middle of screen
            spriteBatch.Draw(ContentStore.logo, MoboUtils.textureOrigin(ContentStore.logo) - new Vector2(0, 64), Color.White);

            // Draw buttons
            foreach (Button button in menuButtons)
            {
                button.Draw(spriteBatch);
            }
        }
Exemple #5
0
        public void Draw(SpriteBatch staticSpriteBatch, SpriteBatch cameraSpriteBatch)
        {
            // If the Network is starting display some basic connecting text
            if (firstRun)
            {
                Vector2 textOrigin = MoboUtils.textOrigin("Connecting...", ContentStore.generic);
                staticSpriteBatch.DrawString(ContentStore.generic, "Connecting...", ScreenManager.screenCenter, Color.White, 0.0f, textOrigin, 1f, SpriteEffects.None, 0.0f);
            }
            else
            {
                //Draw background
                background.Draw(cameraSpriteBatch);

                int i = 0;

                foreach (Player player in players.Values)
                {
                    foreach (Projectile projectile in player.projectiles.Values)
                    {
                        if (projectile != null)
                        {
                            projectile.Draw(cameraSpriteBatch);
                        }
                    }

                    player.Draw(staticSpriteBatch, cameraSpriteBatch);

                    // Print players for HUD
                    string name        = player.name + " (" + player.score + ")";
                    int    rightAlign2 = (int)ContentStore.generic.MeasureString(name).X;
                    staticSpriteBatch.DrawString(ContentStore.generic, name, new Vector2(SettingsManager.getResolutionWidth() - rightAlign2 - 4, (i + 1) * 16), Color.White, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
                    i++;
                }

                // Draw station
                spawner.Draw(cameraSpriteBatch);

                // Draw all players in the top right
                string str        = "Players";
                int    rightAlign = (int)ContentStore.generic.MeasureString(str).X;
                staticSpriteBatch.DrawString(ContentStore.generic, str, new Vector2(SettingsManager.getResolutionWidth() - rightAlign - 4, 0), Color.White, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);

                // Draw minimap
                minimap.Draw(staticSpriteBatch);
            }
        }
Exemple #6
0
        public void Draw(SpriteBatch staticSpriteBatch, SpriteBatch cameraSpriteBatch)
        {
            //Draw projectiles
            foreach (Projectile projectile in projectiles.Values)
            {
                if (projectile != null)
                {
                    // Draw projectiles
                    projectile.Draw(cameraSpriteBatch);
                }
            }

            // Ship
            if (!invulnerable)
            {
                cameraSpriteBatch.Draw(texture, position, null, Color.White, playerRotation, origin, 1f, SpriteEffects.None, 0f);
            }
            else
            {
                cameraSpriteBatch.Draw(texture, position, null, Color.Red, playerRotation, origin, 1f, SpriteEffects.None, 0f);
            }

            // Shield
            cameraSpriteBatch.Draw(shield, position, null, Color.White, sheildRotation++, origin + new Vector2(3, 3), 1f, SpriteEffects.None, 0f);

            Color healthColor = Color.White;

            // Health
            if (health > 67)
            {
                healthColor = Color.LightGreen;
            }
            else if (health > 34)
            {
                healthColor = Color.Yellow;
            }
            else
            {
                healthColor = Color.PaleVioletRed;
            }

            if (playerControlled)
            {
                staticSpriteBatch.Draw(ContentStore.debug, new Vector2(6, 6), healthBar, healthColor, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
                staticSpriteBatch.Draw(ContentStore.health_bar, new Vector2(4, 4), Color.White);

                // Name
                staticSpriteBatch.DrawString(ContentStore.generic, name, new Vector2(13, 7), Color.LightGray, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);

                // Debug
                if (SettingsManager.getShowDebug())
                {
                    staticSpriteBatch.DrawString(ContentStore.generic, "Health: " + health, Vector2.Zero, Color.White);
                    staticSpriteBatch.DrawString(ContentStore.generic, "Position: " + position.ToString(), new Vector2(0, 16), Color.White);
                    staticSpriteBatch.DrawString(ContentStore.generic, "Velocity: " + velocity.ToString(), new Vector2(0, 32), Color.White);
                    staticSpriteBatch.DrawString(ContentStore.generic, "Direction: " + playerRotation, new Vector2(0, 48), Color.White);
                }

                if (SettingsManager.getShowBounds())
                {
                    // Collision rectangle
                    cameraSpriteBatch.Draw(ContentStore.debug, bounds, Color.White);
                }
            }

            // Else draw a small health bar above player
            else
            {
                // Name
                Vector2 textOrigin = MoboUtils.textOrigin(name, ContentStore.generic);
                cameraSpriteBatch.DrawString(ContentStore.generic, name, position + new Vector2(0, -56), Color.White, 0.0f, textOrigin, 1f, SpriteEffects.None, 0.0f);

                // Health Bar
                cameraSpriteBatch.Draw(ContentStore.debug, position, new Rectangle(0, 0, fullBar.Width + 8, fullBar.Height + 8), Color.White, 0.0f, new Vector2(fullBar.Width / 2 + 4, 132), 0.25f, SpriteEffects.None, 0.0f);
                cameraSpriteBatch.Draw(ContentStore.debug, position, fullBar, Color.Black, 0.0f, new Vector2(fullBar.Width / 2, 128), 0.25f, SpriteEffects.None, 0.0f);
                cameraSpriteBatch.Draw(ContentStore.debug, position, healthBar, healthColor, 0.0f, new Vector2(healthBar.Width / 2, 128), 0.25f, SpriteEffects.None, 0.0f);
            }
        }