Exemple #1
0
        public CarStopper(Minigame game)
        {
            state = GAME_STATE.Intro;
            minigame = game;
            introTitle = minigame.getTitle();
            introDescription = minigame.getDescription();

            setupLabels();

            mainCanvas.Children.Add(introTitleLabel);
            mainCanvas.Children.Add(introDescriptionLabel);
            mainCanvas.Children.Add(instructionLabel);
            mainCanvas.Children.Add(exitLabel);

            this.transitionTimer = new System.Windows.Threading.DispatcherTimer();
            this.transitionTimer.Tick += moveToNextState;
            this.transitionTimer.Interval = TimeSpan.FromMilliseconds(2000);
            this.transitionTimer.Start();

            this.fadeTimer = new System.Windows.Threading.DispatcherTimer();
            this.fadeTimer.Tick += fadeToNextState;
            this.fadeTimer.Interval = TimeSpan.FromMilliseconds(40);
            this.fadeTimer.IsEnabled = false;

            this.carTimer = new System.Windows.Threading.DispatcherTimer();
            this.carTimer.Tick += moveCar;
            this.carTimer.Interval = TimeSpan.FromMilliseconds(20);

            rightHandCursor = new System.Windows.Controls.Image();
            rightHandCursor.Source = this.toBitmapImage(ShoopDoup.Properties.Resources.HandCursor);
            rightHandCursor.Width = 100;

            leftHandCursor = new System.Windows.Controls.Image();
            System.Drawing.Bitmap leftHandBitmap = ShoopDoup.Properties.Resources.HandCursor;
            leftHandBitmap.RotateFlip(RotateFlipType.RotateNoneFlipX);
            leftHandCursor.Source = this.toBitmapImage(leftHandBitmap);
            leftHandCursor.Width = 100;

            rightHandCursor.Opacity = 0;
            leftHandCursor.Opacity = 0;

            carBitmaps = new List<Bitmap>();
            carBitmaps.Add(ShoopDoup.Properties.Resources.CarStopperBus);
            carBitmaps.Add(ShoopDoup.Properties.Resources.CarStopperCar);
            carBitmaps.Add(ShoopDoup.Properties.Resources.CarStopperTruck);
            carBitmaps.Add(ShoopDoup.Properties.Resources.CarStopperMotorcycle);
            carBitmaps.Add(ShoopDoup.Properties.Resources.CarStopperSUV);

            mainCanvas.Children.Add(rightHandCursor);
            mainCanvas.Children.Add(leftHandCursor);
        }
        public WhackAMoleController(Minigame game)
        {
            state = GAME_STATE.Intro;
            minigame = game;
            introTitle = minigame.getTitle();
            introDescription = minigame.getDescription();

            setupLabels();

            mainCanvas.Children.Add(introTitleLabel);
            mainCanvas.Children.Add(introDescriptionLabel);
            mainCanvas.Children.Add(instructionLabel);

            this.transitionTimer = new System.Windows.Threading.DispatcherTimer();
            this.transitionTimer.Tick += moveToNextState;
            this.transitionTimer.Interval = TimeSpan.FromMilliseconds(2000);
            this.transitionTimer.Start();

            this.fadeTimer = new System.Windows.Threading.DispatcherTimer();
            this.fadeTimer.Tick += fadeToNextState;
            this.fadeTimer.Interval = TimeSpan.FromMilliseconds(40);
            this.fadeTimer.IsEnabled = false;

            this.popupTimer = new System.Windows.Threading.DispatcherTimer();
            this.popupTimer.Tick += changePopup;
            this.popupTimer.Interval = TimeSpan.FromMilliseconds(2500);

            rightHandCursor = new System.Windows.Controls.Image();
            rightHandCursor.Source = this.toBitmapImage(ShoopDoup.Properties.Resources.HandCursor);
            rightHandCursor.Width = 100;

            leftHandCursor = new System.Windows.Controls.Image();
            System.Drawing.Bitmap leftHandBitmap = ShoopDoup.Properties.Resources.HandCursor;
            leftHandBitmap.RotateFlip(RotateFlipType.RotateNoneFlipX);
            leftHandCursor.Source = this.toBitmapImage(leftHandBitmap);
            leftHandCursor.Width = 100;

            rightHandCursor.Opacity = 0;
            leftHandCursor.Opacity = 0;

            mainCanvas.Children.Add(rightHandCursor);
            mainCanvas.Children.Add(leftHandCursor);
        }
        public CarStopperController(Minigame game)
        {
            state = GAME_STATE.Instructions;
            minigame = game;
            introTitle = minigame.getTitle();
            introDescription = minigame.getDescription();
            this.sp = new System.Media.SoundPlayer(ShoopDoup.Properties.Resources.carexplosion);

            carDictionary = new Dictionary<String, Car>();

            Console.WriteLine(minigame.getData().Count);
            int randomElementIndex = randomGen.Next(minigame.getData().Count);
            baseItem = (String)minigame.getData().ElementAt(randomElementIndex).getElementValue();
            minigame.getData().RemoveAt(randomElementIndex);

            setupLabels();

            //mainCanvas.Children.Add(introTitleLabel);
            //mainCanvas.Children.Add(introDescriptionLabel);
            mainCanvas.Children.Add(instructionLabel);
            mainCanvas.Children.Add(exitLabel);
            mainCanvas.Children.Add(scoreLabel);
            mainCanvas.Children.Add(baseLabel);

            this.transitionTimer = new System.Windows.Threading.DispatcherTimer();
            this.transitionTimer.Tick += moveToNextState;
            this.transitionTimer.Interval = TimeSpan.FromMilliseconds(3000);

            this.fadeTimer = new System.Windows.Threading.DispatcherTimer();
            this.fadeTimer.Tick += fadeToNextState;
            this.fadeTimer.Interval = TimeSpan.FromMilliseconds(40);
            this.fadeTimer.IsEnabled = false;

            this.carTimer = new System.Windows.Threading.DispatcherTimer();
            this.carTimer.Tick += moveCars;
            this.carTimer.Interval = TimeSpan.FromMilliseconds(20);

            this.exitTimer = new System.Windows.Threading.DispatcherTimer();
            this.exitTimer.Tick += controllerFinished;
            this.exitTimer.Interval = TimeSpan.FromMilliseconds(10000);

            this.userExitedTimer = new System.Windows.Threading.DispatcherTimer();
            this.userExitedTimer.Tick += controllerFinished;
            this.userExitedTimer.Interval = TimeSpan.FromMilliseconds(2000);

            this.introCarTimer = new System.Windows.Threading.DispatcherTimer();
            this.introCarTimer.Tick += addNewInstructionCar;
            this.introCarTimer.Interval = TimeSpan.FromMilliseconds(2600);

            this.introCarAnimatorTimer = new System.Windows.Threading.DispatcherTimer();
            this.introCarAnimatorTimer.Tick += moveCars;
            this.introCarAnimatorTimer.Interval = TimeSpan.FromMilliseconds(20);

            this.addNewCarTimer = new System.Windows.Threading.DispatcherTimer();
            this.addNewCarTimer.Tick += addNewCar;
            this.addNewCarTimer.Interval = TimeSpan.FromMilliseconds(4000);

            rightHandCursor = new System.Windows.Controls.Image();
            rightHandCursor.Source = this.toBitmapImage(ShoopDoup.Properties.Resources.BlueHandCursor);
            rightHandCursor.Width = 100;

            leftHandCursor = new System.Windows.Controls.Image();
            System.Drawing.Bitmap leftHandBitmap = ShoopDoup.Properties.Resources.BlueHandCursor;
            leftHandBitmap.RotateFlip(RotateFlipType.RotateNoneFlipX);
            leftHandCursor.Source = this.toBitmapImage(leftHandBitmap);
            leftHandCursor.Width = 100;

            trafficBackgroundImage = new System.Windows.Controls.Image();
            trafficBackgroundImage.Source = this.toBitmapImage(ShoopDoup.Properties.Resources.TrafficLaneBackGround);
            trafficBackgroundImage.Width = 1280;
            trafficBackgroundImage.Height = 800;
            trafficBackgroundImage.Opacity = .8;

            qrCode = new System.Windows.Controls.Image();
            qrCode.Source = this.toBitmapImage(ShoopDoup.Properties.Resources.qr);
            qrCode.Height = 248;
            qrCode.Width = 248;

            baseLabelBox = new System.Windows.Controls.Image();
            baseLabelBox.Source = this.toBitmapImage(ShoopDoup.Properties.Resources.blueText);

            scoreBox = new System.Windows.Controls.Image();
            scoreBox.Source = this.toBitmapImage(ShoopDoup.Properties.Resources.TwoDigitBlue);
            scoreBox.Height = 100;
            scoreBox.Width = 200;

            ShoopDoupSpeakingImage = new System.Windows.Controls.Image();
            ShoopDoupSpeakingImage.Source = this.toBitmapImage(ShoopDoup.Properties.Resources.ThinkingUpgame);
            ShoopDoupSpeakingImage.Width = 1280;
            ShoopDoupSpeakingImage.Height = 800;
            ShoopDoupSpeakingImage.Opacity = 0;

            rightHandCursor.Opacity = 0;
            leftHandCursor.Opacity = 0;

            carBitmaps = new List<Bitmap>();
            carBitmaps.Add(ShoopDoup.Properties.Resources.CarStopperBus);
            carBitmaps.Add(ShoopDoup.Properties.Resources.CarStopperCar);
            carBitmaps.Add(ShoopDoup.Properties.Resources.CarStopperTruck);
            carBitmaps.Add(ShoopDoup.Properties.Resources.CarStopperMotorcycle);
            carBitmaps.Add(ShoopDoup.Properties.Resources.CarStopperSUV);

            mainCanvas.Children.Add(rightHandCursor);
            mainCanvas.Children.Add(leftHandCursor);
            mainCanvas.Children.Add(trafficBackgroundImage);
            mainCanvas.Children.Add(scoreBox);

            Canvas.SetZIndex(rightHandCursor, 4);
            Canvas.SetZIndex(leftHandCursor, 4);
            Canvas.SetLeft(trafficBackgroundImage, 0);
            Canvas.SetTop(trafficBackgroundImage, 0);
            Canvas.SetZIndex(trafficBackgroundImage, -5);

            Canvas.SetZIndex(scoreBox, -1);
            Canvas.SetLeft(scoreBox, 40);
            Canvas.SetTop(scoreBox, 8);

            runIntro();
        }