Пример #1
0
        public PointSquare(PointSquareData data, Vector2 position, Sprite spriteSheet, Coordinate coordinate)
            : base(data, position, spriteSheet, coordinate)
        {
            point    = spriteSheet.GetSubSprite(new Rectangle(144, 0, 13, 13));
            line     = spriteSheet.GetSubSprite(new Rectangle(104, 0, 13, 13));
            square   = spriteSheet.GetSubSprite(new Rectangle(118, 0, 13, 13));
            triangle = spriteSheet.GetSubSprite(new Rectangle(131, 0, 13, 13));

            emptySquare   = spriteSheet.GetSubSprite(new Rectangle(50, 0, 13, 13));
            displaySprite = emptySquare;
        }
Пример #2
0
 private void InitializePointGridData()
 {
     for (int n = 0; n < pointWidth; n++)
     {
         for (int m = 0; m < height; m++)
         {
             SquareData s = new PointSquareData();
             pointDataGrid[n, m] = s;
         }
     }
 }
        protected void ClearDataGrid(SquareData[,] newData)
        {
            int localWidth  = newData.GetLength(0);
            int localHeight = newData.GetLength(1);

            for (int n = 0; n < localWidth; n++)
            {
                for (int m = 0; m < localHeight; m++)
                {
                    SquareData sd = new PointSquareData();
                    sd.Initialize();
                    newData[n, m] = sd;
                }
            }
        }
Пример #4
0
        private void LoadPoints(List <String> dataTransfer, int localGridWidth, int localGridHeight)
        {
            dataTransfer.RemoveAt(0);
            for (int m = 0; m < localGridHeight; m++)
            {
                String dataLine = dataTransfer[0];
                dataTransfer.RemoveAt(0);
                MatchCollection gridMatches = Regex.Matches(dataLine, @"(\w):([^:]+):");

                foreach (Match match in gridMatches)
                {
                    switch (match.Groups[1].Value)
                    {
                    case "T":
                    {
                        String time = match.Groups[2].Value;
                        timeVector[m] = Convert.ToSingle(time, CultureInfo.InvariantCulture);
                        break;
                    }

                    case "E":
                    {
                        String          gridLineMatch = match.Groups[2].Value;
                        MatchCollection lineMatches   = Regex.Matches(gridLineMatch, @" (\w+)");

                        int position = 0;
                        foreach (Match match_ in lineMatches)
                        {
                            String     elementData = match_.Groups[1].Value;
                            SquareData sd          = new PointSquareData(elementData);
                            pointDataGrid[position, m] = sd;
                            position++;
                        }
                        break;
                    }

                    default:
                        break;
                    }
                }
            }
        }
        public override void UpdateGridSize(int newWidth, int newHeight)
        {
            SquareData[,] newData = new PointSquareData[newWidth, newHeight];
            ClearDataGrid(newData);

            for (int n = 0; n < newWidth; n++)
            {
                for (int m = 0; m < newHeight; m++)
                {
                    if (n < data.GetLength(0) && m < data.GetLength(1))
                    {
                        newData[n, m] = data[n, m];
                    }
                    else
                    {
                        newData[n, m] = new PointSquareData();
                    }
                }
            }
            data   = newData;
            width  = newWidth;
            height = newHeight;
            CreateSquareGrid(data);
        }