示例#1
0
 public void CreateMatrix(int xDimension, int yDimension)
 {
     matrix = new PixelModel[xDimension, yDimension];
     for (int x = 0; x < xDimension; x++)
     {
         for (int y = 0; y < yDimension; y++)
         {
             matrix[x, y] = new PixelModel();
         }
     }
 }
示例#2
0
        //methods for matrix and graphic
        private void InitializeMatrix(int xDim, int yDim)
        {
            _modelCalculated = false;

            _matrix = new PixelModel[xDimension, yDimension];
            for (var x = 0; x < xDim; x++)
            {
                for (var y = 0; y < yDim; y++)
                {
                    _matrix[x, y] = new PixelModel();
                }
            }
        }
示例#3
0
        private List <PixelModel> SearchWords(PixelModel pm, List <PixelModel> puzzle)
        {
            var pixelLs     = new List <PixelModel>();
            var regNum      = new Regex("[0-9]+");
            var num         = regNum.Match(pm.Letter);
            var direction   = Convert.ToInt32(num.Value);
            var cleanLetter = regNum.Replace(pm.Letter, string.Empty);

            cleanLetter = cleanLetter.Replace("^", string.Empty);
            //accrue.Append(cleanLettter);
            var theWord   = cleanLetter + ":" + pm.Position.x.ToString() + ":" + pm.Position.y.ToString() + "," + FindCharacters(direction, pm, puzzle);
            var firstWord = new PixelModel
            {
                Letter    = cleanLetter,
                Red       = pm.Red,
                Green     = pm.Green,
                Blue      = pm.Blue,
                Direction = direction,
                Position  = new PositionModel
                {
                    x = pm.Position.x,
                    y = pm.Position.y
                }
            };

            pixelLs.Add(firstWord);
            var words = theWord.Split(',');

            for (int i = 1; i < words.Length - 1; i++)
            {
                var wordSplit = words[i].Split(':');
                var charP     = new PixelModel
                {
                    Letter    = wordSplit[0],
                    Direction = direction,
                    Position  = new PositionModel
                    {
                        x = Convert.ToInt32(wordSplit[1]),
                        y = Convert.ToInt32(wordSplit[2])
                    }
                };
                pixelLs.Add(charP);
            }
            return(pixelLs);
        }
示例#4
0
        private void ResetMatrix(bool includeBlocked = false)
        {
            _modelCalculated = false;

            for (var x = 0; x < xDimension; x++)
            {
                for (var y = 0; y < yDimension; y++)
                {
                    var pixel = GetPixel(x, y);
                    if (pixel == null)
                    {
                        _matrix[x, y] = new PixelModel();
                    }
                    else if (pixel.Block && !includeBlocked)
                    {
                        continue;
                    }

                    _matrix[x, y].State = Metadata.PixelState.Default;
                    _matrix[x, y].Block = false;
                }
            }
        }
示例#5
0
        private string FindCharacters(int direction, PixelModel pm, List <PixelModel> puzzle)
        {
            double x = pm.Position.x;
            double y = pm.Position.y;

            if (direction == 1) //U
            {
                y -= 12;
            }
            else if (direction == 2) //RU
            {
                y -= 12;
                x += 12;
            }
            else if (direction == 3) //R
            {
                x += 12;
            }
            else if (direction == 4) //RD
            {
                x += 12;
                y += 12;
            }
            else if (direction == 5) //D
            {
                y += 12;
            }
            else if (direction == 6) //LD
            {
                x -= 12;
                y += 12;
            }
            else if (direction == 7) //L
            {
                x -= 12;
            }
            else if (direction == 8) //LU
            {
                x -= 12;
                y -= 12;
            }
            //Lets find new pixel
            var nextLetter = puzzle.Where(p => p.Position.x == x && p.Position.y == y).FirstOrDefault();

            if (nextLetter == null)
            {
                return(string.Empty);
            }
            var regEnd = new Regex(@"\$[0-9]+");

            if (nextLetter.Letter.IndexOf("$") >= 0)
            {
                var letter = nextLetter.Letter.Replace("$", string.Empty);
                // accrue.Append(letter);
                return(letter);
            }
            else
            {
                //accrue.Append(nextLetter.Letter);
                return(nextLetter.Letter + ":" + x.ToString() + ":" + y.ToString() + "," + FindCharacters(direction, nextLetter, puzzle));
            }
        }