Exemplo n.º 1
0
        public void Draw()
        {
            lightingEffect.LightPos.SetValue(this.lighting.Position);
            lightingEffect.CameraPos.SetValue(this.camera.Position);

            DrawHelper.SetState();

            // For each board location
            for (int y = 0; y < Height; y++)
            {
                for (int x = 0; x < Width; x++)
                {
                    Chip chip = layout[x, y];

                    // Nothing to draw for the empty space
                    if (chip == null)
                    {
                        continue;
                    }

                    // Determine the base transformation matrix for this chip. Only
                    // translation is accounted for here, orientation is added by the
                    // chip itself in its Draw method.
                    Matrix transform;
                    if (shiftingChips.Contains(chip))
                    {
                        // When a chip is shifted, it is put in its new location in the
                        // layout, but its rendered location is linearly interpolated
                        // back to its previous location.
                        Matrix.Lerp(ref boardPositionMatrices[x - shiftX, y - shiftY],
                                    ref boardPositionMatrices[x, y],
                                    currentShiftTime / ShiftDuration,
                                    out transform);
                    }
                    else
                    {
                        transform = boardPositionMatrices[x, y];
                    }

                    chip.Draw(this, chipModel, transform, chipTransforms);
                }
            }
        }
Exemplo n.º 2
0
        public override void Draw(Microsoft.Xna.Framework.GameTime gameTime)
        {
            // Let the previous screen transition fully off before drawing anything
            if (ScreenState == ScreenState.TransitionOn)
            {
                return;
            }

            // When this screen transitions off, the fog rolls in closer to the camera.
            // This causes all of the photographs to fade to black behind the menu.
            float fogEnd = -ResetZValue * (1 - TransitionPosition);

            DrawHelper.SetState();

            foreach (Photograph photograph in photographs)
            {
                foreach (ModelMesh mesh in photographModel.Meshes)
                {
                    // Set effect parameters for the picture and its frame
                    foreach (BasicEffect basicEffect in mesh.Effects)
                    {
                        basicEffect.World                  = photograph.WorldTransform;
                        basicEffect.View                   = viewMatrix;
                        basicEffect.Projection             = projectionMatrix;
                        basicEffect.Texture                = photograph.Texture;
                        basicEffect.PreferPerPixelLighting = true;
                        basicEffect.EnableDefaultLighting();

                        // Fog is used to make distant photographs gradually
                        // fade to black
                        basicEffect.FogEnabled = true;
                        basicEffect.FogEnd     = fogEnd;
                    }

                    // Enable the texture on the picture part
                    ((BasicEffect)mesh.Effects[1]).TextureEnabled = true;

                    mesh.Draw();
                }
            }
        }