예제 #1
0
        public override void Draw(GameTime gameTime)
        {
            // Setup the effect parameters
            effect.Parameters["World"].SetValue(World);
            effect.Parameters["Projection"].SetValue(game.camera.Projection);
            effect.Parameters["View"].SetValue(game.camera.View);
            effect.Parameters["cameraPos"].SetValue(game.camera.Position);
            effect.Parameters["worldInvTrp"].SetValue(WorldInverseTranspose);
            effect.Parameters["ModelTexture"].SetResource(texture);

            // Change lights
            lightManager.SetLighting(effect);
            // Setup the vertices
            game.GraphicsDevice.SetVertexBuffer(vertices);
            game.GraphicsDevice.SetVertexInputLayout(inputLayout);

            // Apply the effect technique and draw the platform
            effect.CurrentTechnique.Passes[0].Apply();
            game.GraphicsDevice.Draw(PrimitiveType.TriangleList, vertices.ElementCount);
        }
예제 #2
0
        public Platform(ProjectGame game)
        {
            // Avoid null reference, it changes on the first update
            if (standing_platform == null)
            {
                standing_platform      = this;
                next_standing_platform = this;
            }

            // Less tiles if the difficulty is higher
            min_extra_tiles = (int)(max_extra_tiles - game.difficulty);
            type            = GameObjectType.Platform;

            //Load textures
            textureName = "Platform_Textures";
            texture     = game.Content.Load <Texture2D>(textureName);

            // Store information of the platform and create information for the next one
            platform      = next_platform;
            next_platform = create_platform(platform);

            // Create the vertices based on the platform information
            VertexPositionNormalTexture[] platform_vertices = create_vertices(platform, last_platform, next_platform);
            last_platform = platform;

            // Set the platform Z position of the intance and uptade the new Z position for the next one
            z_position_start = z_position;
            z_position      -= tile_depth;
            z_position_end   = z_position;

            // Calculates midpoint and base
            platfom_midpoint = (platform.GetLength(0) * tile_width) - tile_width / 2;
            platform_base    = Levels[0] - base_offset;

            //Load effects
            effect       = game.Content.Load <Effect>("Phong");
            lightManager = new LightManager(game);
            lightManager.SetLighting(effect);

            // Pass the vertices data
            vertices    = Buffer.Vertex.New(game.GraphicsDevice, platform_vertices);
            inputLayout = VertexInputLayout.FromBuffer(0, vertices);
            this.game   = game;
        }
예제 #3
0
        public Platform(ProjectGame game)
        {
            // Avoid null reference, it changes on the first update
            if (standing_platform == null)
            {
                standing_platform = this;
                next_standing_platform = this;
            }

            // Less tiles if the difficulty is higher
            min_extra_tiles = (int)(max_extra_tiles - game.difficulty);
            type = GameObjectType.Platform;

            //Load textures
            textureName = "Platform_Textures";
            texture = game.Content.Load<Texture2D>(textureName);

            // Store information of the platform and create information for the next one
            platform = next_platform;
            next_platform = create_platform(platform);

            // Create the vertices based on the platform information
            VertexPositionNormalTexture[] platform_vertices = create_vertices(platform, last_platform, next_platform);
            last_platform = platform;

            // Set the platform Z position of the intance and uptade the new Z position for the next one
            z_position_start = z_position;
            z_position -= tile_depth;
            z_position_end = z_position;

            // Calculates midpoint and base
            platfom_midpoint = (platform.GetLength(0) * tile_width) - tile_width/2;
            platform_base = Levels[0] - base_offset;

            //Load effects
            effect = game.Content.Load<Effect>("Phong");
            lightManager = new LightManager(game);
            lightManager.SetLighting(effect);

            // Pass the vertices data
            vertices = Buffer.Vertex.New(game.GraphicsDevice, platform_vertices);
            inputLayout = VertexInputLayout.FromBuffer(0, vertices);
            this.game = game;
        }