Exemplo n.º 1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            theCamera = new Camera(new Vector3(0.5f, 0.5f, 0.5f), 0, GraphicsDevice.Viewport.AspectRatio, 0.05f, 100f);
            theEffect = new BasicEffect(GraphicsDevice);
            theMaze = new Maze(GraphicsDevice);

            base.Initialize();
        }
Exemplo n.º 2
0
        // Draw Method
        public void Draw(Camera camera, BasicEffect effect)
        {
            effect.VertexColorEnabled = true;
            effect.World = Matrix.Identity;
            effect.View = camera.View;
            effect.Projection = camera.Projection;
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                // Draw the floor
                graphics.SetVertexBuffer(floorBuffer);
                graphics.DrawPrimitives(PrimitiveType.TriangleList, 0, floorBuffer.VertexCount / 3);

                // Draw the walls
                graphics.SetVertexBuffer(wallBuffer);
                graphics.DrawPrimitives(PrimitiveType.TriangleList, 0, wallBuffer.VertexCount / 3);
            }
        }
Exemplo n.º 3
0
        // Draw Method
        public void Draw(Camera camera)
        {
            Vector3 offset = new Vector3(0.5f, 0f, 0.5f);

            Matrix[] bones = player.GetSkinTransforms();

            Matrix scale = Matrix.CreateScale(0.01f);
            Matrix translate = Matrix.CreateTranslation(Location + offset);

            foreach(ModelMesh m in model.Meshes)
            {
                foreach(SkinnedEffect effect in m.Effects)
                {
                    effect.SetBoneTransforms(bones);

                    effect.World = scale * translate;
                    effect.View = camera.View;
                    effect.Projection = camera.Projection;
                }
                m.Draw();
            }
        }
Exemplo n.º 4
0
        // Draw Method
        public void Draw(Camera camera, BasicEffect effect)
        {
            applyAmbientLight(effect);
            applySpotLight(effect, camera);

            effect.FogEnabled = fogOn;
            effect.FogColor = new Vector3(245, 245, 245);
            effect.FogStart = 0;
            effect.FogEnd = 1000f;

            effect.World = Matrix.Identity;
            effect.View = camera.View;
            effect.Projection = camera.Projection;

            // Setup the effect
            effect.VertexColorEnabled = false;
            effect.TextureEnabled = true;

            // Draw floor tiles A
            effect.Texture = floorTileA;
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                graphics.SetVertexBuffer(floorTilesA);
                graphics.DrawPrimitives(PrimitiveType.TriangleList, 0, floorTilesA.VertexCount / 3);
            }

            // Draw floor tiles B
            effect.Texture = floorTileB;
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                graphics.SetVertexBuffer(floorTilesB);
                graphics.DrawPrimitives(PrimitiveType.TriangleList, 0, floorTilesB.VertexCount / 3);
            }

            // Draw the North walls
            effect.Texture = wallNorth;
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                graphics.SetVertexBuffer(northWalls);
                graphics.DrawPrimitives(PrimitiveType.TriangleList, 0, northWalls.VertexCount / 3);
            }

            // Draw the South walls
            effect.Texture = wallSouth;
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                graphics.SetVertexBuffer(southWalls);
                graphics.DrawPrimitives(PrimitiveType.TriangleList, 0, southWalls.VertexCount / 3);
            }

            // Draw the East walls
            effect.Texture = wallEast;
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                graphics.SetVertexBuffer(eastWalls);
                graphics.DrawPrimitives(PrimitiveType.TriangleList, 0, eastWalls.VertexCount / 3);
            }

            // Draw the North walls
            effect.Texture = wallWest;
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                graphics.SetVertexBuffer(westWalls);
                graphics.DrawPrimitives(PrimitiveType.TriangleList, 0, westWalls.VertexCount / 3);
            }
        }
Exemplo n.º 5
0
 protected void applySpotLight(BasicEffect effect, Camera c)
 {
     effect.DirectionalLight1.DiffuseColor = new Vector3(1.0f, 0.9f, 0.6f); // a yellow light
     effect.DirectionalLight1.Direction = new Vector3(c.lookAt.Y+c.position.X, c.lookAt.Y, c.lookAt.Z);
     effect.DirectionalLight1.Enabled = flashOn;
 }
Exemplo n.º 6
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            #if WINDOWS
                Mouse.SetPosition(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height / 2);
            #endif

            // TODO: Add your initialization logic here
            collisionToggle = true;

            theCamera = new Camera(new Vector3(0.5f, 0.5f, 0.5f), 0, GraphicsDevice.Viewport.AspectRatio, 0.05f, 100f);
            theEffect = new BasicEffect(GraphicsDevice);
            theMaze = new Maze(GraphicsDevice);
            bgm = true;
            isDay = true;
            isFoggy = false;
            base.Initialize();

            npc = new NPC(theMaze);
        }