Beispiel #1
0
        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            font                  = Content.Load <SpriteFont>("Basic_font");
            background            = Content.Load <Texture2D>("background_edited");
            cursor                = Content.Load <Texture2D>("cursor");
            target                = Content.Load <Texture2D>("sphere");
            hitButtonStart        = Content.Load <Texture2D>("hittingButton");
            trackButtonStart      = Content.Load <Texture2D>("trackingButton");
            board                 = Content.Load <Texture2D>("board");
            mouseMenuPointer      = Content.Load <Texture2D>("mousePointer");
            resumeButton          = Content.Load <Texture2D>("resumebutton");
            menuButton            = Content.Load <Texture2D>("menubutton");
            goButton              = Content.Load <Texture2D>("ceppo");
            freccia               = Content.Load <Texture2D>("cone2");
            pentagono             = Content.Load <Texture2D>("pentagonorec");
            triangolo             = Content.Load <Texture2D>("triangoloTracker");
            sphereAtlas           = Content.Load <Texture2D>("atlasSphere");
            explosionAtlas        = Content.Load <Texture2D>("explosionAtlas");
            backgroundResult      = Content.Load <Texture2D>("sfondoResult");
            knob                  = Content.Load <Texture2D>("steelKnob");
            slide                 = Content.Load <Texture2D>("slider");
            help                  = Content.Load <Texture2D>("help");
            help_info             = Content.Load <Texture2D>("help_info");
            help_info_stats       = Content.Load <Texture2D>("help_info_stats");
            title                 = Content.Load <Texture2D>("title_aim_trainer");
            backgroundStatsInGame = Content.Load <Texture2D>("background_stats_ingame");
            for (int i = 0; i < glassBreak.Length; i++)
            {
                glassBreak[i] = Content.Load <SoundEffect>("audio\\breakingLightBulb" + i);
            }
            menuSong        = Content.Load <Song>("audio\\menuSong");
            gameSong        = Content.Load <Song>("audio\\gameSongCut");
            onButton        = Content.Load <SoundEffect>("audio\\OnButton");
            clickButton     = Content.Load <SoundEffect>("audio\\ClickButton");
            ticking         = Content.Load <SoundEffect>("audio\\singleTick");
            dialog          = Content.Load <Texture2D>("exitBoard");
            quitButtonExit  = Content.Load <Texture2D>("quitButtonExit");
            backButtonExit  = Content.Load <Texture2D>("backButtonExit");
            exit            = Content.Load <Texture2D>("exit-button");
            menuButtonLarge = Content.Load <Texture2D>("menubuttonLarge");

            //Shared Initialization
            backgroundStart = new Point((background.Width - screenDim.X) / 2, (background.Height - screenDim.Y) / 2); //view in the middle of background texture
            viewDest        = new Rectangle(0, 0, screenDim.X, screenDim.Y);
            viewSource      = new Rectangle(backgroundStart.X, backgroundStart.Y, screenDim.X, screenDim.Y);
            cursorRect      = new Rectangle((screenDim.X - cursor.Width / 2) / 2, (screenDim.Y - cursor.Height / 2) / 2, cursor.Width / 2, cursor.Height / 2);

            trackerGame = new TrackerGame(viewSource, viewDest, cursorRect, screenDim, middleScreen, background, cursor, target, font, sphereAtlas, explosionAtlas, ticking, goButton, onButton, clickButton, gameSong, backgroundStatsInGame);
            hittingGame = new HittingGame(viewSource, viewDest, cursorRect, screenDim, middleScreen, background, cursor, target, sphereAtlas, explosionAtlas, goButton, glassBreak, onButton, clickButton, gameSong, backgroundStatsInGame);
            startMenu   = new StartMenu(screenDim, GraphicsDevice, background, hitButtonStart, trackButtonStart, mouseMenuPointer, knob, slide, font, volume, menuSong, onButton, clickButton, help, help_info, title, board, exit);
            pause       = new Pause(screenDim, GraphicsDevice, resumeButton, menuButtonLarge, exit, mouseMenuPointer, knob, slide, font, mouseSens, volume, onButton, clickButton);
            results     = new Results(screenDim, GraphicsDevice, exit, menuButtonLarge, mouseMenuPointer, hittingGame, trackerGame, freccia, pentagono, triangolo, font, backgroundResult, help, help_info_stats, onButton, clickButton);
        }
Beispiel #2
0
        public Results(Point screenDim, GraphicsDevice graphicsDevice, Texture2D quitButtonText, Texture2D menuButtonText, Texture2D mouseMenuPointer, HittingGame hittingGame, TrackerGame trackerGame, Texture2D freccia, Texture2D pentagono, Texture2D triangolo, SpriteFont font, Texture2D background, Texture2D help, Texture2D help_info, SoundEffect onButton, SoundEffect clickButton)
        {
            newMouse       = new MouseState(0, 0, 0, ButtonState.Released, ButtonState.Released, ButtonState.Released, ButtonState.Released, ButtonState.Released);
            quitRect       = new Rectangle(screenDim.X - quitButtonText.Width / 4, 0, quitButtonText.Width / 4, quitButtonText.Height / 4);
            menuRect       = new Rectangle(screenDim.X / 5 - menuButtonText.Width / 2, screenDim.Y / 4 - menuButtonText.Height / 2, menuButtonText.Width, menuButtonText.Height);
            helpRect       = new Rectangle(50, screenDim.Y - 3 * help.Height / 4 - 20, 3 * help.Width / 4, 3 * help.Height / 4);
            help_info_Rect = new Rectangle(-150, 450, help_info.Width, help_info.Height);           //position has to be changed, waiting for the new button
            graphicPos     = new Point(530 + screenDim.X / 2 - pentagono.Width / 2, screenDim.Y / 2 - 230);
            help_info_on   = false;

            helpButton = new Button(helpRect, help, Color.White, onButton, clickButton);
            quitButton = new Button(quitRect, quitButtonText, Color.White, onButton, clickButton);
            menuButton = new Button(menuRect, menuButtonText, Color.White, onButton, clickButton);

            filePath = @"SaveRecords.txt";

            Mouse.SetCursor(MouseCursor.FromTexture2D(mouseMenuPointer, mouseMenuPointer.Width / 2, mouseMenuPointer.Height / 2));
            hittingGame.endHittingGame += endHittingGameHandler;
            trackerGame.endTrackerGame += endTrackerGameHandler;
            this.freccia    = freccia;
            this.pentagono  = pentagono;
            this.triangolo  = triangolo;
            this.font       = font;
            this.background = background;
            this.help_info  = help_info;
        }
Beispiel #3
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape) && mode != SelectMode.exiting && mode != SelectMode.trackerGame && mode != SelectMode.hittingGame && mode != SelectMode.pause)
            {
                CheckExit();
            }

            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.P) || (mode == SelectMode.hittingGame && Keyboard.GetState().IsKeyDown(Keys.Escape)) || (mode == SelectMode.trackerGame && Keyboard.GetState().IsKeyDown(Keys.Escape)))
            {
                if (mode == SelectMode.hittingGame)
                {
                    MediaPlayer.Pause();
                    prevMode  = mode;
                    prevMouse = Mouse.GetState();
                    mode      = SelectMode.pause;
                    pause.FreezeScreen(GraphicsDevice, screenDim);
                    hittingGame.PauseSound();
                    hittingGame.oldMouse = new MouseState(0, 0, 0, ButtonState.Pressed, ButtonState.Released, ButtonState.Released, ButtonState.Released, ButtonState.Released);
                }
                if (mode == SelectMode.trackerGame)
                {
                    MediaPlayer.Pause();
                    prevMode  = mode;
                    prevMouse = Mouse.GetState();
                    mode      = SelectMode.pause;
                    pause.FreezeScreen(GraphicsDevice, screenDim);
                    trackerGame.PauseSound();
                    trackerGame.oldMouse = new MouseState(0, 0, 0, ButtonState.Pressed, ButtonState.Released, ButtonState.Released, ButtonState.Released, ButtonState.Released);
                }
            }

            switch (mode)
            {
            case SelectMode.menu:
                IsMouseVisible = true;
                startMenu.Update(ref mode, middleScreen, gameTime.ElapsedGameTime.TotalSeconds, ref volume, this);
                if (mode == SelectMode.hittingGame || mode == SelectMode.trackerGame)           //menu -> re-initialize games
                {
                    trackerGame = new TrackerGame(viewSource, viewDest, cursorRect, screenDim, middleScreen, background, cursor, target, font, sphereAtlas, explosionAtlas, ticking, goButton, onButton, clickButton, gameSong, backgroundStatsInGame);
                    hittingGame = new HittingGame(viewSource, viewDest, cursorRect, screenDim, middleScreen, background, cursor, target, sphereAtlas, explosionAtlas, goButton, glassBreak, onButton, clickButton, gameSong, backgroundStatsInGame);
                    results     = new Results(screenDim, GraphicsDevice, exit, menuButtonLarge, mouseMenuPointer, hittingGame, trackerGame, freccia, pentagono, triangolo, font, backgroundResult, help, help_info_stats, onButton, clickButton);
                }
                break;

            case SelectMode.trackerGame:
                IsMouseVisible = false;
                trackerGame.Update(gameTime, ref mode, mouseSens, volume);
                break;

            case SelectMode.hittingGame:
                IsMouseVisible = false;
                hittingGame.Update(gameTime, ref mode, mouseSens, volume);
                break;

            case SelectMode.pause:
                IsMouseVisible = true;
                pause.Update(ref mode, ref mouseSens, ref volume, prevMode, prevMouse, this);
                break;

            case SelectMode.results:
                IsMouseVisible = true;
                results.Update(ref mode, this);
                break;

            case SelectMode.exiting:
                IsMouseVisible = true;
                exitGame.Update(ref mode, volume, this);
                break;
            }

            //oldMode = mode;

            base.Update(gameTime);
        }