コード例 #1
0
        public override void Draw(GameTime gameTime)
        {
            FinalBomber.Instance.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, Matrix.Identity);

            base.Draw(gameTime);

            ControlManager.Draw(FinalBomber.Instance.SpriteBatch);

            Color textColor = Color.Black;

            if (_indexPlayer >= 0)
            {
                string text = "Changement des touches\nde " + Config.PlayersName[_indexPlayer];
                FinalBomber.Instance.SpriteBatch.DrawString(BigFont, text,
                                                            new Vector2(MenuPosition.X / 1.5f, (BigFont.MeasureString(text).Y) / 2), textColor);

                FinalBomber.Instance.SpriteBatch.DrawString(BigFont, _instructions[0],
                                                            new Vector2(MenuPosition.X / 1.5f, 2 * (BigFont.MeasureString(_instructions[0]).Y)), Color.Black);
                FinalBomber.Instance.SpriteBatch.DrawString(BigFont, _instructions[1],
                                                            new Vector2(MenuPosition.X / 1.5f + 250 - BigFont.MeasureString(_instructions[1]).X / 2,
                                                                        6 * (BigFont.MeasureString(_instructions[1]).Y)), Color.Black);
            }
            else
            {
                for (int i = 0; i < MenuString.Length; i++)
                {
                    textColor = i == IndexMenu ? Color.Green : Color.Black;

                    FinalBomber.Instance.SpriteBatch.DrawString(BigFont, MenuString[i],
                                                                new Vector2(MenuPosition.X, MenuPosition.Y + (BigFont.MeasureString(MenuString[i]).Y) * i), textColor);
                }
            }

            FinalBomber.Instance.SpriteBatch.End();
        }
コード例 #2
0
        public override void Draw(GameTime gameTime)
        {
            FinalBomber.Instance.SpriteBatch.Begin();

            base.Draw(gameTime);

            ControlManager.Draw(FinalBomber.Instance.SpriteBatch);

            for (int i = 0; i < MenuString.Length; i++)
            {
                Color textColor = Color.Black;
                if (i == IndexMenu)
                {
                    textColor = Color.Green;
                }

                FinalBomber.Instance.SpriteBatch.DrawString(BigFont, MenuString[i],
                                                            new Vector2(MenuPosition.X - BigFont.MeasureString(MenuString[i]).X / 2,
                                                                        MenuPosition.Y + BigFont.MeasureString(MenuString[i]).Y *i - BigFont.MeasureString(MenuString[i]).Y / 2), textColor);
            }

            FinalBomber.Instance.SpriteBatch.End();
        }
コード例 #3
0
        public override void Draw(GameTime gameTime)
        {
            FinalBomber.Instance.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, Matrix.Identity);

            base.Draw(gameTime);

            ControlManager.Draw(FinalBomber.Instance.SpriteBatch);

            int xLag = 0;
            int yLag = 0;

            for (int i = 0; i < MenuString.Length; i++)
            {
                if (i < 2)
                {
                    yLag = i;
                }
                else if (i >= 2 && i <= 3)
                {
                    xLag = Config.MapSize.X >= 10 ? 70 : 60;
                    if (i == 3)
                    {
                        if (Config.MapSize.Y >= 10)
                        {
                            if (Config.MapSize.X >= 10)
                            {
                                xLag += 70;
                            }
                            else
                            {
                                xLag += 60;
                            }
                        }
                        else
                        {
                            if (Config.MapSize.X >= 10)
                            {
                                xLag += 60;
                            }
                            else
                            {
                                xLag += 50;
                            }
                        }
                    }
                }
                else if (i > 3)
                {
                    yLag = i - 2;
                    xLag = 0;
                }

                if (i >= 1 && i <= 3)
                {
                    xLag -= 50;
                }
                else if (i >= 4 && i <= 7)
                {
                    xLag -= 50;
                }
                else if (i == 0)
                {
                    xLag -= 30;
                }

                string text = MenuString[i];

                Color textColor = Color.Black;
                if (i == IndexMenu)
                {
                    textColor = Color.Green;
                }
                else if (i == 5 && _disabledArrows)
                {
                    textColor = Color.Gray;
                }

                FinalBomber.Instance.SpriteBatch.DrawString(BigFont, text,
                                                            new Vector2(MenuPosition.X - BigFont.MeasureString(text).X / 2 + xLag,
                                                                        MenuPosition.Y + BigFont.MeasureString(text).Y *yLag - BigFont.MeasureString(text).Y / 2), textColor);

                switch (i)
                {
                case 0:
                    FinalBomber.Instance.SpriteBatch.DrawString(BigFont, ": " + Config.PlayersNumber,
                                                                new Vector2(MenuPosition.X - BigFont.MeasureString(text).X / 2 + xLag + BigFont.MeasureString(text).X,
                                                                            MenuPosition.Y + BigFont.MeasureString(text).Y *yLag - BigFont.MeasureString(text).Y / 2), Color.Black);
                    break;

                case 1:
                    FinalBomber.Instance.SpriteBatch.DrawString(BigFont, ": ",
                                                                new Vector2(MenuPosition.X - BigFont.MeasureString(text).X / 2 + xLag + BigFont.MeasureString(text).X,
                                                                            MenuPosition.Y + BigFont.MeasureString(text).Y *yLag - BigFont.MeasureString(text).Y / 2), Color.Black);
                    break;

                case 2:
                    FinalBomber.Instance.SpriteBatch.DrawString(BigFont, "x",
                                                                new Vector2(MenuPosition.X - BigFont.MeasureString(text).X / 2 + xLag + BigFont.MeasureString(text).X,
                                                                            MenuPosition.Y + BigFont.MeasureString(text).Y *yLag - BigFont.MeasureString(text).Y / 2), Color.Black);
                    break;

                case 4:
                    FinalBomber.Instance.SpriteBatch.DrawString(BigFont, ": " + Config.ActiveTeleporters,
                                                                new Vector2(MenuPosition.X - BigFont.MeasureString(text).X / 2 + xLag + BigFont.MeasureString(text).X,
                                                                            MenuPosition.Y + BigFont.MeasureString(text).Y *yLag - BigFont.MeasureString(text).Y / 2), Color.Black);
                    break;

                case 5:
                    if (!_disabledArrows)
                    {
                        textColor = Color.Black;
                    }
                    FinalBomber.Instance.SpriteBatch.DrawString(BigFont, ": " + Config.ActiveArrows,
                                                                new Vector2(MenuPosition.X - BigFont.MeasureString(text).X / 2 + xLag + BigFont.MeasureString(text).X,
                                                                            MenuPosition.Y + BigFont.MeasureString(text).Y *yLag - BigFont.MeasureString(text).Y / 2), textColor);
                    break;

                case 6:
                    FinalBomber.Instance.SpriteBatch.DrawString(BigFont, ": " + GameConfiguration.WallPercentage + "%",
                                                                new Vector2(MenuPosition.X - BigFont.MeasureString(text).X / 2 + xLag + BigFont.MeasureString(text).X,
                                                                            MenuPosition.Y + BigFont.MeasureString(text).Y *yLag - BigFont.MeasureString(text).Y / 2), Color.Black);
                    break;

                case 7:
                    FinalBomber.Instance.SpriteBatch.DrawString(BigFont, ": " + Config.ItemNumber + "%",
                                                                new Vector2(MenuPosition.X - BigFont.MeasureString(text).X / 2 + xLag + BigFont.MeasureString(text).X,
                                                                            MenuPosition.Y + BigFont.MeasureString(text).Y *yLag - BigFont.MeasureString(text).Y / 2), Color.Black);
                    break;
                }
            }

            FinalBomber.Instance.SpriteBatch.End();
        }
コード例 #4
0
        public override void Draw(GameTime gameTime)
        {
            FinalBomber.Instance.SpriteBatch.Begin();

            base.Draw(gameTime);

            ControlManager.Draw(FinalBomber.Instance.SpriteBatch);

            string str = "Lobby Screen !";

            FinalBomber.Instance.SpriteBatch.DrawString(BigFont, str,
                                                        new Vector2(
                                                            Config.Resolutions[Config.IndexResolution, 0] / 2f -
                                                            BigFont.MeasureString(str).X / 2,
                                                            20),
                                                        Color.Black);

            var strColor = Color.Black;

            GameServer.Instance.Clients.Sort(new BasicClientSorter());
            for (var i = 0; i < GameServer.Instance.Clients.Count; i++)
            {
                strColor = Color.Black;
                if (GameServer.Instance.Clients[i].IsReady)
                {
                    strColor = Color.Green;
                }

                str = GameServer.Instance.Clients[i].Username;
                if (GameServer.Instance.Clients[i].Id == GameServer.Instance.Clients.Me.Id)
                {
                    str += " (you)";
                }

                if (GameServer.Instance.Clients[i].IsHost)
                {
                    str = "[*] " + str;
                }

                // Ping
                str += " | Ping: " + GameServer.Instance.Clients[i].Ping;

                FinalBomber.Instance.SpriteBatch.DrawString(ControlManager.SpriteFont, str,
                                                            new Vector2(0, 60 + (20 * i)), strColor);
            }

            // Connecting message
            strColor = Color.Orange;
            if (GameServer.Instance.Connected)
            {
                str      = "Connected ! :)";
                strColor = Color.Green;
            }
            else if (GameServer.Instance.FailedToConnect)
            {
                str      = "Failed to connect :'( (Press space to try again)";
                strColor = Color.Red;
            }
            else
            {
                str = "Connecting to server...";
            }

            FinalBomber.Instance.SpriteBatch.DrawString(BigFont, str,
                                                        new Vector2(
                                                            Config.Resolutions[Config.IndexResolution, 0] / 2f -
                                                            BigFont.MeasureString(str).X / 2,
                                                            Config.Resolutions[Config.IndexResolution, 1] / 2f -
                                                            BigFont.MeasureString(str).Y / 2),
                                                        strColor);

            if (GameServer.Instance.Clients.Me != null)
            {
                // Start game message
                if (GameServer.Instance.Clients.TrueForAll(client => client.IsReady))
                {
                    var missingPlayerNumber = GameConfiguration.MinimumPlayerNumber - GameServer.Instance.Clients.Count;
                    if (missingPlayerNumber > 0)
                    {
                        str      = "Not enough players :'(\n(" + missingPlayerNumber + " more player(s) to play)";
                        strColor = Color.Red;
                    }
                    else
                    {
                        if (GameServer.Instance.Clients.Me.IsHost)
                        {
                            str      = "Press Space to launch the game !";
                            strColor = Color.Green;
                        }
                        else
                        {
                            str      = "Please wait that the host starts the game...";
                            strColor = Color.Orange;
                        }
                    }

                    FinalBomber.Instance.SpriteBatch.DrawString(BigFont, str,
                                                                new Vector2(
                                                                    Config.Resolutions[Config.IndexResolution, 0] / 2f -
                                                                    BigFont.MeasureString(str).X / 2,
                                                                    Config.Resolutions[Config.IndexResolution, 1] / 2f -
                                                                    BigFont.MeasureString(str).Y / 2 + 80),
                                                                strColor);
                }
            }

            // Available maps list
            for (int i = 0; i < GameServer.Instance.Maps.Count; i++)
            {
                str = GameServer.Instance.Maps.Keys.ElementAt(i);

                strColor = Color.Black;

                if (!MapLoader.MapFileDictionary.Values.Contains(GameServer.Instance.Maps.Values.ElementAt(i)))
                {
                    str += " (need to be downloaded)";
                }

                if (GameServer.Instance.Maps.Values.ElementAt(i) == GameServer.Instance.SelectedMapMd5)
                {
                    strColor = Color.White;
                }

                FinalBomber.Instance.SpriteBatch.DrawString(ControlManager.SpriteFont, str,
                                                            new Vector2(
                                                                Config.Resolutions[Config.IndexResolution, 0] / 2f -
                                                                ControlManager.SpriteFont.MeasureString(str).X / 2,
                                                                Config.Resolutions[Config.IndexResolution, 1] / 2f -
                                                                ControlManager.SpriteFont.MeasureString(str).Y / 2 + 140 + (20 * i)),
                                                            strColor);
            }

            FinalBomber.Instance.SpriteBatch.End();
        }
コード例 #5
0
        public override void Draw(GameTime gameTime)
        {
            FinalBomber.Instance.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, Matrix.Identity);

            base.Draw(gameTime);

            ControlManager.Draw(FinalBomber.Instance.SpriteBatch);

            var messages = new[] { "Game programmed by Noxalus", "", "The rights of graphics and sound resources", "belong to Hudson Soft Company,", " developers of the", " Bomberman game series." };
            int i        = 0;

            foreach (var s in messages)
            {
                FinalBomber.Instance.SpriteBatch.DrawString(BigFont, s,
                                                            new Vector2(
                                                                FinalBomber.Instance.GraphicsDevice.Viewport.Width / 2f - BigFont.MeasureString(s).X / 2,
                                                                FinalBomber.Instance.GraphicsDevice.Viewport.Height / 2f - BigFont.MeasureString(s).Y / 2 - 200 + (i * 60)),
                                                            Color.Black);

                i++;
            }

            FinalBomber.Instance.SpriteBatch.End();
        }
コード例 #6
0
ファイル: Game1.cs プロジェクト: KaraMc24/Shmup
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            _spriteBatch.Begin();

            backgroundSprite.Draw(_spriteBatch);
            if (playerSprite.playerLives > 0)
            {
                playerSprite.Draw(_spriteBatch);
            }
            foreach (MissileSprite missile in missileList)
            {
                missile.Draw(_spriteBatch);
            }
            foreach (ParticleSprite particle in particleList)
            {
                particle.Draw(_spriteBatch);
            }

            _spriteBatch.DrawString(
                UiFont,
                "Lives: " + playerSprite.playerLives,
                new Vector2(14, 14),
                Color.Black
                );

            _spriteBatch.DrawString(
                UiFont,
                "Lives: " + playerSprite.playerLives,
                new Vector2(10, 10),
                Color.White
                );

            _spriteBatch.DrawString(
                UiFont,
                "Time: " + Math.Round(playTime),
                new Vector2(14, 44),
                Color.Black
                );

            _spriteBatch.DrawString(
                UiFont,
                "Time: " + Math.Round(playTime),
                new Vector2(10, 40),
                Color.White
                );


            if (playerSprite.playerLives <= 0)
            {
                Vector2 textSize = BigFont.MeasureString("GAME OVER");
                _spriteBatch.DrawString(
                    BigFont,
                    "GAME OVER",
                    new Vector2((screenSize.X / 2) - (textSize.X / 2) + 8, (screenSize.Y / 2) - (textSize.Y / 2) + 8),
                    Color.Black
                    );


                _spriteBatch.DrawString(
                    BigFont,
                    "GAME OVER",
                    new Vector2((screenSize.X / 2) - (textSize.X) / 2, (screenSize.Y / 2) - (textSize.Y / 2)),
                    Color.White
                    );
            }


            _spriteBatch.End();


            base.Draw(gameTime);
        }