예제 #1
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(ClearOptions.DepthBuffer | ClearOptions.Stencil | ClearOptions.Target, Color.CornflowerBlue, 1f, 0);

            if (player.AliveBoiiii == false)
            {
                //player.Position = _map._mapElementCollection.Find(x=>x.GetType() == typeof(SpawnPoint)).Position;
            }

            /* spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.Default);
             * spriteBatch.DrawString(font, $"Angle {gun.RotationZ} test ${player._controll.SideMultiplier}", Vector2.Zero, Color.Black);
             * spriteBatch.End();*/

            if (TEST == true)
            {
                foreach (ModelMesh mesh in model.Meshes)
                {
                    foreach (BasicEffect effect in mesh.Effects)
                    {
                        effect.World      = Matrix.CreateScale(2.0f) * Matrix.CreateTranslation(new Vector3(player.Position.X, 0, player.Position.Y));
                        effect.View       = Director.InstanceDirector.Camera.ViewMatrix;
                        effect.Projection = Director.InstanceDirector.Camera.ProjectionMatrix;
                        effect.EnableDefaultLighting();
                        effect.LightingEnabled    = true;
                        effect.VertexColorEnabled = true;
                    }

                    mesh.Draw();
                }
            }

            RasterizerState rs = new RasterizerState();

            rs.CullMode = CullMode.None;
            rs.FillMode = FillMode.Solid;
            GraphicsDevice.RasterizerState = rs;

            graphics.GraphicsDevice.BlendState = BlendState.Opaque;
            graphics.GraphicsDevice.BlendState = BlendState.AlphaBlend;

            gameEffect.CurrentTechnique = gameEffect.Techniques["Simplest"];
            gameEffect.Parameters["xView"].SetValue(Director.InstanceDirector.Camera.ViewMatrix);
            gameEffect.Parameters["xProjection"].SetValue(Director.InstanceDirector.Camera.ProjectionMatrix);
            gameEffect.Parameters["xWorld"].SetValue(Matrix.Identity);


            gameEffect.Parameters["xLightPos"].SetValue(Director.InstanceDirector.Camera.Position);
            gameEffect.Parameters["xLightPower"].SetValue(0.1f);
            gameEffect.Parameters["xAmbient"].SetValue(0.75f);


            _map.Draw(GraphicsDevice, gameEffect);


            base.Draw(gameTime);
        }