Beispiel #1
0
        private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            xScale = ((float)e.NewSize.Width) / 800.0f;
            yScale = ((float)e.NewSize.Height) / 650.0f;

            JumpToFinalQuestionTextBlock.FontSize    = 12 * yScale;
            JumpToFinalQuestionOkButton.FontSize     = 12 * yScale;
            JumpToFinalQuestionCancelButton.FontSize = 12 * yScale;

            CloseQuizTextBlock.FontSize    = 12 * yScale;
            CloseQuizOkButton.FontSize     = 12 * yScale;
            CloseQuizCancelButton.FontSize = 12 * yScale;

            QuitTextBlock.FontSize    = 12 * yScale;
            QuitOkButton.FontSize     = 12 * yScale;
            QuitCancelButton.FontSize = 12 * yScale;

            CorrectAnswerPointsTextBlock.FontSize = 12 * yScale;
            CorrectPointsTextBox.FontSize         = 12 * yScale;
            CorrectPointsOkButton.FontSize        = 12 * yScale;
            CorrectPointsCancelButton.FontSize    = 12 * yScale;

            WrongPointsTextBlock.FontSize    = 12 * yScale;
            WrongPointsTextBox.FontSize      = 12 * yScale;
            WrongPointsOkButton.FontSize     = 12 * yScale;
            WrongPointsCancelButton.FontSize = 12 * yScale;

            QuestionTimerTextBlock.FontSize    = 12 * yScale;
            QuestionTimerTextBox.FontSize      = 12 * yScale;
            QuestionTimerOkButton.FontSize     = 12 * yScale;
            QuestionTimerCancelButton.FontSize = 12 * yScale;

            ControlsTextBlock.FontSize        = 12 * yScale;
            ControlsExplainTextBlock.FontSize = 12 * yScale;
            ControlsOkButton.FontSize         = 12 * yScale;

            AboutTextBlock.FontSize = 12 * yScale;
            AboutOkButton.FontSize  = 12 * yScale;

            FailedTextBlock.FontSize       = 16 * yScale;
            FailedReasonTextBlock.FontSize = 12 * yScale;
            FailedOkButton.FontSize        = 12 * yScale;

            ParticleGenerator.setScale(xScale, yScale);
            QuizControl.setScale(xScale, yScale);
            TeamKPlayerControl.resize(xScale, yScale);
            Team1PlayerControl.resize(xScale, yScale);
            Team2PlayerControl.resize(xScale, yScale);
            Team3PlayerControl.resize(xScale, yScale);
            Team4PlayerControl.resize(xScale, yScale);

            InvalidateArrange();
        }
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            previouslyVisible = new Boolean[5];

            shineRandom      = new Random();
            shineTimers      = new int[5];
            shineAnimations  = new DoubleAnimation[5];
            shineStoryboards = new Storyboard[5];

            int winners  = 0;
            int topScore = int.MinValue;

            for (int index = 0; index < 5; index++)
            {
                PlayerControl playerControl = getController(index);
                if (playerControl.inGame && playerControl.score > topScore)
                {
                    topScore = playerControl.score;
                }
                else
                {
                }
            }

            for (int i = 0; i < 5; i++)
            {
                PlayerControl control = getController(i);
                if (control.score == topScore)
                {
                    winners++;
                    control.showCrown();
                    getGrid(i).Width = 180 * MainWindow.getInstance().getXScale();
                }
                else
                {
                }
                shineTimers[i]              = (shineRandom.Next() % MAX_SHINE_TIME) + MIN_SHINE_TIME;
                shineAnimations[i]          = new DoubleAnimation();
                shineAnimations[i].Duration = new Duration(new TimeSpan(0, 0, 0, SHINE_DURATION));
                shineAnimations[i].From     = -100.0f;
                shineAnimations[i].To       = 100.0f;
                shineStoryboards[i]         = new Storyboard();
                Storyboard.SetTarget(shineAnimations[i], getShineTransform(i));
                Storyboard.SetTargetProperty(shineAnimations[i], new PropertyPath(TranslateTransform.XProperty));
                shineStoryboards[i].Children.Add(shineAnimations[i]);
            }

            for (int i = 0; i < 5; i++)
            {
                PlayerControl control = getController(i);
                if (control.inGame && control.score == topScore)
                {
                    Point controlPoint = MainWindow.getInstance().TranslatePoint(new Point(0.0f, 0.0f), control);
                    Point borderPoint  = MainWindow.getInstance().TranslatePoint(new Point(0.0f, 0.0f), getGrid(i));
                    Point point        = new Point(-borderPoint.X + controlPoint.X, -borderPoint.Y + controlPoint.Y);
                    displayWinner(i);
                }
                else
                {
                }
            }

            if (winners == 1)
            {
                WinnerTextBlock.Text = "Winner:";
            }
            else
            {
                WinnerTextBlock.Text = "Winners:";
            }

            particleGenerator        = new ParticleGenerator(MainWindow.getInstance().ParticleCanvas);
            particleGenerator.active = true;

            playersReady = false;

            victorySound = new MediaPlayer();
            victorySound.ScrubbingEnabled = false;
            if (!Settings.Mute)
            {
                victorySound.Open(new Uri(@"assets/victory.mp3", UriKind.Relative));
                victorySound.Play();
            }
            else
            {
            }

            initialTimer          = new DispatcherTimer();
            initialTimer.Interval = new TimeSpan(0, 0, INITIAL_WAIT);
            initialTimer.Tick    += InitialTimer_Tick;
            initialTimer.Start();

            lastNow = DateTimeOffset.Now.ToUnixTimeMilliseconds();

            setScale(MainWindow.getInstance().getXScale(), MainWindow.getInstance().getYScale());

            App.getInstance().xKeyboard.OnSpacePressed += () => finish();
        }