Example #1
0
        public void SetGameDefinition(GameDefinition gameDefinition)
        {
            IsGameOver  = false;
            IsHighScore = false;
            Definition  = gameDefinition;
            SelectedCells.Clear();

            StartTime  = DateTime.Now;
            Grid       = new SquareDataViewModel[Definition.Width, Definition.Height];
            GridStates = new Stack <GridState>();
            Color      = Definition.GameSet.Color;

            for (int x = 0; x < Definition.Width; x++)
            {
                for (int y = 0; y < Definition.Height; y++)
                {
                    Grid[x, y] = new SquareDataViewModel
                    {
                        MarkerVisible = true,
                        //HighColor = Color,
                        //MedColor = "#ADD8E6",
                    };
                }
            }

            int index = 0;

            foreach (var gameLine in Definition.Lines)
            {
                int startX, startY;
                int endX, endY;

                index++;
                //if (string.IsNullOrWhiteSpace(gameLine.Key))
                //    gameLine.Key = index.ToString();

                Definition.GetStartXY(gameLine, out startX, out startY);
                Definition.GetEndXY(gameLine, out endX, out endY);

                var square = Grid[startX, startY];
                square.Fixed        = true;
                square.PaletteIndex = index;
                square.Text         = gameLine.Text;
                square.GameLine     = gameLine;

                square              = Grid[endX, endY];
                square.Fixed        = true;
                square.Text         = gameLine.Text;
                square.PaletteIndex = index;
                square.GameLine     = gameLine;
            }

            Level = string.Format("Level {0}", Definition.Index + 1);

            GetHighScore();
        }