Пример #1
0
        public GameField(GamefieldItems[,] gamefield, Vector2 totalSize, Vector2 fieldSize, Vector2 position)
        {
            Gamefield = gamefield;
            _fieldSize = fieldSize;
            _totalSize = totalSize;
            _position = position;
            float tempfieldScale = fieldSize.X / (WidthOfOneBlock * gamefield.GetLength(0));
            FieldScale = fieldSize.Y / (HeigthOfOneBlock * gamefield.GetLength(1));
            if (Math.Abs(tempfieldScale - FieldScale) > 0.2f)
            {
                MessageBox(new IntPtr(0), "OH no, The fields ratio's are off, this might look ugly", "Made a new gamefield", 0);
            }

            XLenght = gamefield.GetLength(0);
            YLenght = gamefield.GetLength(1);
        }
Пример #2
0
        private void BuildGameField()
        {
            int sizeX = 15;
            int sizeY = 11;

            GamefieldItems[,] buildingField = new GamefieldItems[sizeX, sizeY];
            for (int i = 0; i < sizeX; i++)
            {
                for (int j = 0; j < sizeY; j++)
                {
                    List<GamefieldItem> items = new List<GamefieldItem>();
                    if ((!(i == 1 && j == 1) ^ !(i == 1 && j == 2) ^ !(i == 2 && j == 1)))
                    {
                        if ((!(i == sizeX - 2 && j == sizeY - 2) ^ !(i == sizeX - 3 && j == sizeY - 2) ^ !(i == sizeX - 2 && j == sizeY - 3)))
                        {
                            if (i % 2 == 0 && j % 2 == 0)
                                items.Add(new BrickSollid());
                            else
                                items.Add(new BrickBreakAble());
                        }

                    }
                    GamefieldItems gamefieldItems = new GamefieldItems(items);
                    buildingField[i, j] = gamefieldItems;
                }
            }
            List<GamefieldItem> brickBorderItem = new List<GamefieldItem>();
            brickBorderItem.Add(new InvisableBlick());
            GamefieldItems brickBorderItems = new GamefieldItems(brickBorderItem);

            for (int i = 0; i < sizeX; i++)
            {
                buildingField[i, 0] = brickBorderItems;
                buildingField[i, sizeY - 1] = brickBorderItems;
            }
            for (int i = 0; i < sizeY; i++)
            {
                buildingField[0, i] = brickBorderItems;
                buildingField[sizeX - 1, i] = brickBorderItems;
            }
            _gameField = new GameField(buildingField, _totalSize, _fieldSize, _fieldPosition);
        }