Пример #1
0
        private void CreateGameBoard(GameController gameController)
        {
            for (int i = 0; i < m_gameBoard.Size; ++i)
            {
                E_GameBoard.ColumnDefinitions.Add(new ColumnDefinition());
            }

            for (int i = 0; i < m_gameBoard.Size; ++i)
            {
                E_GameBoard.RowDefinitions.Add(new RowDefinition());
            }

            for (int x = 0; x < m_gameBoard.Size; ++x)
            {
                for (int y = 0; y < m_gameBoard.Size; ++y)
                {
                    Bomberman.Field field = m_gameBoard.Fields[x][y] as Bomberman.Field;
                    if (field != null)
                    {
                        UIElements.BombermanField fieldToAdd = new UIElements.BombermanField(field, gameController);
                        E_GameBoard.Children.Add(fieldToAdd);
                        Grid.SetColumn(fieldToAdd, x);
                        Grid.SetRow(fieldToAdd, y);
                    }
                }
            }
        }
Пример #2
0
        private void ResetButton_Click(object sender, RoutedEventArgs e)
        {
            m_gameController.Finish();
            m_gameController.Initialize();
            for (int i = 0; i < E_GameBoard.Children.Count; ++i)
            {
                UIElements.BombermanField uiField = E_GameBoard.Children[i] as UIElements.BombermanField;
                if (uiField != null)
                {
                    Field oldField = uiField.FieldP;
                    Field newField = m_gameController.gameBoard.getField(oldField.X, oldField.Y) as Field;
                    if (newField != null)
                    {
                        uiField.ReInit(newField, m_gameController);
                    }
                }
            }

            E_GameBoard.ColumnDefinitions.Clear();
            E_GameBoard.RowDefinitions.Clear();
            E_GameBoard.Children.Clear();

            E_TeamsContainer.RowDefinitions.Clear();
            E_TeamsContainer.Children.Clear();

            GC.Collect();

            Initialize();
        }