Esempio n. 1
0
 /// <summary>
 /// Creates a new Screen
 /// </summary>
 /// <param name="game">The instance of the game.</param>
 protected Screen(GammaDraconis game)
     : base(game)
 {
     gammaDraconis = game;
     screenScene = new Scene();
     screenInterface = new Interface(gammaDraconis);
     screenInterface.Visible = Visible;
 }
Esempio n. 2
0
        /// <summary>
        /// Construct a player at the specified PlayerIndex.
        /// </summary>
        /// <param name="index">The player's PlayerIndex.</param>
        public Player(PlayerIndex index)
            : base()
        {
            this.index = index;

            input = GammaDraconis.GetInstance().InputManager.GetPlayerInput(index);
            camera = new Coords();
            viewport = (Renderer.Viewports)index;
            Player.players[(int)index] = this;

            arrow = Proto.getThing("CheckpointArrow", new Coords());
            
            playerHUD = (Interface)GammaDraconis.GetInstance().GameLua.DoString("playerHudIndex = " + ((int)index + 1) + "\nreturn dofile( 'Interfaces/PlayerHUD/PlayerHUD.lua' )")[0];

            dust = new List<GameObject>();

            explosion = new Explosion();
            explosion.size = 2f;
            explosion.particles = 50;
        }
Esempio n. 3
0
        /// <summary>
        /// Render a frame of video containing the given Scene and Interface.
        /// The Scene manager includes the world, and all contained models.
        /// The interface is drawn last to show a Menu or HUD.
        /// </summary>
        /// <param name="gameTime">Game time</param>
        /// <param name="scene">The scene manager</param>
        /// <param name="drawHUD">Whether or not the HUD should be drawn.</param>
        public void render(GameTime gameTime, Scene scene, bool drawHUD)
        {
            renderBloom = false;

            // Render all players' viewports
            for (int playerIndex = 0; playerIndex < Player.players.Length; playerIndex++)
            {
                if (Player.players[playerIndex] != null)
                {
                    game.GraphicsDevice.Viewport = viewports[(int)Player.players[playerIndex].viewport];
                    game.GraphicsDevice.Clear(ClearOptions.DepthBuffer | ClearOptions.Target, Color.Black, 1.0f, 0);
                    game.GraphicsDevice.RenderState.DepthBufferEnable = true;
                    aspectRatio = game.GraphicsDevice.Viewport.AspectRatio;

                    List<GameObject> gameObjects = scene.visible(Player.players[playerIndex]);
                    renderObjects(gameObjects, Player.players[playerIndex]);
                }
                else
                {
                    if (MissingPlayerViewports[playerIndex] != Viewports.None)
                    {
                        game.GraphicsDevice.Viewport = viewports[(int)MissingPlayerViewports[playerIndex]];
                        game.GraphicsDevice.Clear(ClearOptions.DepthBuffer | ClearOptions.Target, Color.Black, 1.0f, 0);
                        Interface i = new Interface(game);
                        Text t = new Text(game);
                        t.SpriteFontName = "Resources/Fonts/Menu";
                        t.text = missingPlayerQuips[(gameTime.TotalRealTime.Seconds / secondsPerQuip) % missingPlayerQuips.Length];
                        t.center = true;
                        t.RelativePosition = new Vector2(game.GraphicsDevice.Viewport.Width / 2, game.GraphicsDevice.Viewport.Height / 2);
                        t.color = Color.WhiteSmoke;
                        i.AddComponent(t);
                        i.Draw(gameTime, Vector2.Zero, Vector2.One, 0);
                        // TODO: Draw something noteworthy in the empty slots?
                    }
                }
            }

            game.GraphicsDevice.Viewport = viewports[(int)Viewports.WholeWindow];

            // TODO: Render post-process shaders
            if (enableShaders)
            {
                renderBloom = true;
                bloomShader.Reset();

                // Render all players' viewports
                for (int playerIndex = 0; playerIndex < Player.players.Length; playerIndex++)
                {
                    if (Player.players[playerIndex] != null)
                    {
                        game.GraphicsDevice.Viewport = viewports[(int)Player.players[playerIndex].viewport];
                        game.GraphicsDevice.Clear(ClearOptions.DepthBuffer | ClearOptions.Target, Color.Black, 1.0f, 0);
                        game.GraphicsDevice.RenderState.DepthBufferEnable = true;
                        aspectRatio = game.GraphicsDevice.Viewport.AspectRatio;

                        List<GameObject> gameObjects = scene.visible(Player.players[playerIndex]);
                        renderObjects(gameObjects, Player.players[playerIndex]);
                    }
                    else
                    {
                        if (MissingPlayerViewports[playerIndex] != Viewports.None)
                        {
                            game.GraphicsDevice.Viewport = viewports[(int)MissingPlayerViewports[playerIndex]];
                            game.GraphicsDevice.Clear(ClearOptions.DepthBuffer | ClearOptions.Target, Color.Black, 1.0f, 0);
                            Interface i = new Interface(game);
                            Text t = new Text(game);
                            t.SpriteFontName = "Resources/Fonts/Menu";
                            t.text = missingPlayerQuips[(gameTime.TotalRealTime.Seconds / secondsPerQuip) % missingPlayerQuips.Length];
                            t.center = true;
                            t.RelativePosition = new Vector2(game.GraphicsDevice.Viewport.Width / 2, game.GraphicsDevice.Viewport.Height / 2);
                            t.color = Color.WhiteSmoke;
                            i.AddComponent(t);
                            i.Draw(gameTime, Vector2.Zero, Vector2.One, 0);
                            // TODO: Draw something noteworthy in the empty slots?
                        }
                    }
                }

                bloomShader.Render();
            }

            // Render players' HUDs
            if (drawHUD)
            {
                for (int playerIndex = 0; playerIndex < Player.players.Length; playerIndex++)
                {
                    if (Player.players[playerIndex] != null)
                    {
                        game.GraphicsDevice.Viewport = viewports[(int)Player.players[playerIndex].viewport];

                        Vector2 scale = new Vector2(game.GraphicsDevice.Viewport.Width / 1024.0f, game.GraphicsDevice.Viewport.Height / 768.0f);
                        Player.players[playerIndex].playerHUD.Draw(gameTime, Vector2.Zero, scale, 0);
                    }
                }
            }

            // Reset viewports
            game.GraphicsDevice.Viewport = viewports[(int)Viewports.WholeWindow];
        }