Exemple #1
0
        private void StartingState()
        {
            View.GameEndResultsTextBlockBorder.Visibility = Visibility.Hidden;
            View.GamePlayTextBlockBorder.Visibility       = System.Windows.Visibility.Visible;
            snake = new Snake(10, 10);


            Random = new Random();
            foods  = new Foods();

            foodsHaveEatenCount = 0;
            isReStarted         = true;
            StartPendulum();
        }
Exemple #2
0
        private void InitializeGame()
        {
            emptyArenaPositions = new List <ArenaPosition>();
            foods = new Foods();
            //az arena meretezeset atveszi a Window Gridbol (ArenaGrid)
            RowCount    = View.ArenaGrid.RowDefinitions.Count;
            ColumnCount = View.ArenaGrid.ColumnDefinitions.Count;

            emptyArenaPositions = GetEmptyArenaPositions(rowMin, rowMax, colMin, colMax);

            //Ha ujrajatszas van, akkor torolni kell a tablat, pl. ures elemekkel a Grid eseteben
            if (isGameOver)
            {
                for (int rowPosition = 0; rowPosition < RowCount; rowPosition++)
                {
                    for (int columnPosition = 0; columnPosition < ColumnCount; columnPosition++)
                    {
                        PaintOnGrid(rowPosition, columnPosition, VisibleElementTypeEnum.EmptyArenaPosition);
                    }
                }
                //es eltuntetni a gameover feliratot
                View.EndResultBorder.Visibility    = Visibility.Hidden;
                View.EndResultTextBlock.Visibility = Visibility.Hidden;
            }

            //A jatekszabalyok megjelenitese
            View.GamePlayTextBlock.Visibility = System.Windows.Visibility.Visible;
            View.GamePlayBorder.Visibility    = System.Windows.Visibility.Visible;

            snake = new Snake(RowCount / 2, ColumnCount / 2);

            becomeSick        = false;
            isSicknessTimerOn = false;
            StartPendulum();

            isStarted     = false;
            isGameOver    = false;
            playTime      = startPlayTime;
            pendulumClock = new DispatcherTimer(TimeSpan.FromSeconds(1), DispatcherPriority.Normal, Clockshock, Application.Current.Dispatcher);
            pendulumClock.Stop();

            score = 70;

            //megjelenitjuk, hogy mennyit ettunk
            View.NumberOfMealsTextBlock.Text = score.ToString();
        }