示例#1
0
        public Board(int sizeX, int sizeY, bool twoSided)
        {
            this.twoSided = twoSided;
            this.width    = sizeX;
            this.height   = sizeY;

            camera =
                new Camera((float)Math.Max(sizeX, sizeY) * 400.0f / 5.0f);

            nextPictureSet = PictureDatabase.GetNextPictureSet(twoSided ? 2 : 1);

            this.layout = new Chip[Width, Height];
            this.boardPositionMatrices = new Matrix[Width, Height];

            // Create all the chips
            for (int y = 0; y < Height; y++)
            {
                for (int x = 0; x < Width; x++)
                {
                    Chip chip = new Chip();
                    chips.Add(chip);

                    chip.XPosition = x;
                    chip.YPosition = y;
                    layout[x, y]   = chip;

                    Vector2 chipTexCoordFactor =
                        new Vector2(1.0f / Width, 1.0f / Height);

                    chip.TexCoordScale            = chipTexCoordFactor;
                    chip.TexCoordTranslationFront =
                        new Vector2((x * chipTexCoordFactor.X),
                                    ((Height - 1) - y) * chipTexCoordFactor.Y);
                    chip.TexCoordTranslationBack =
                        new Vector2(((Width - 1) - x) * chipTexCoordFactor.X,
                                    ((Height - 1) - y) * chipTexCoordFactor.Y);
                }
            }

            // Remove one random chip
            emptyX = RandomHelper.Random.Next(0, Width);
            emptyY = RandomHelper.Random.Next(0, Height);
            Chip removed = layout[emptyX, emptyY];

            chips.Remove(removed);
            layout[emptyX, emptyY] = null;
        }
示例#2
0
        public void Update(GameTime gameTime)
        {
            this.camera.Update(gameTime);
            this.lighting.Update(gameTime, camera);

            // When there is a "next picture set" animate a cross fade to it
            if (nextPictureSet != null)
            {
                textureRotationTime += (float)gameTime.ElapsedRealTime.TotalSeconds;
                if (textureRotationTime >= textureRotationDuration)
                {
                    // The current textures are no longer needed
                    if (currentPictureSet != null)
                    {
                        currentPictureSet.Unload();
                    }

                    // because the next texture set are now current
                    currentPictureSet = nextPictureSet;
                    nextPictureSet    = null;

                    textureRotationTime = 0.0f;
                }
            }

            if (IsShifting)
            {
                // Animate shift time
                currentShiftTime += (float)gameTime.ElapsedGameTime.TotalSeconds;

                if (currentShiftTime > ShiftDuration)
                {
                    // Stop shifting
                    shiftingChips.Clear();
                    shiftX = 0;
                    shiftY = 0;
                }
            }

            // Update all chips
            foreach (Chip chip in chips)
            {
                chip.Update(gameTime);
            }
        }
示例#3
0
        /// <summary>
        /// Constructs an instance of Completed screen with the set of pictures to put
        /// onto the photographs.
        /// </summary>
        public CompletedScreen(PictureSet pictureSet)
        {
            this.pictureSet = pictureSet;

            Audio.Play("Puzzle Completed");
            photographs = new List <Photograph>();

            int photographCount = 40;

            for (int i = 0; i < photographCount; i++)
            {
                Photograph newphotograph = new Photograph();
                ResetPhotograph(newphotograph);
                photographs.Add(newphotograph);
            }

            TransitionOnTime  = Pickture.TransitionTime;
            TransitionOffTime = TimeSpan.FromSeconds(0.75f);
        }