Ejemplo n.º 1
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
#if PROFILE
            elapsedTime += gameTime.ElapsedGameTime;

            if (elapsedTime > TimeSpan.FromMilliseconds(1))
            {
                elapsedTime -= TimeSpan.FromSeconds(1);
                frameRate    = frameCounter;
                frameCounter = 0;
            }

            if (GamePad.GetState(PlayerIndex.One).DPad.Up == ButtonState.Pressed)
            {
                Thread.Sleep(5);
            }

            if (GamePad.GetState(PlayerIndex.One).DPad.Down == ButtonState.Pressed)
            {
                return;
            }
#endif

#if WINDOWS
#if DEBUG
            // Allows the game to exit; win32 only
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }
#endif
#endif

            if (exitGame)
            {
                this.Exit();
            }

            if (!(preloadedAssets && preloadedJSon))
            {
                InputDevice2.Update(gameTime);

                if (InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.RightDirection) != InputDevice2.PlayerPad.NoPad)
                {
                    shipRotation += 0.02f;
                }
                else if (InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.LeftDirection) != InputDevice2.PlayerPad.NoPad)
                {
                    shipRotation -= 0.02f;
                }

                if (InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.Confirm) != InputDevice2.PlayerPad.NoPad)
                {
                    shipVelocity += new Vector2((float)(Math.Cos(shipRotation)), (float)(Math.Sin(shipRotation))) * shipThrust;
                    shipVelocity  = Vector2.Clamp(shipVelocity, new Vector2(-0.91f), new Vector2(0.91f));
                }

                shipPosition += shipVelocity * gameTime.ElapsedGameTime.Milliseconds;
                shipVelocity *= 0.99f;

                if (shipPosition.X < -1850)
                {
                    shipPosition.X = 1850;
                }
                if (shipPosition.X > 1850)
                {
                    shipPosition.X = -1850;
                }
                if (shipPosition.Y < -1300)
                {
                    shipPosition.Y = 1300;
                }
                if (shipPosition.Y > 1300)
                {
                    shipPosition.Y = -1300;
                }

                return;
            }

            gameIsRunningSlowly = gameTime.IsRunningSlowly;

            if (currentGameScreen.IsComplete)
            {
                currentGameScreen = ScreenState.SwitchToNewScreen(currentGameScreen.nextLevelState());
            }

            InputDevice2.Update(gameTime);

            currentGameScreen.update(gameTime);

            base.Update(gameTime);
        }
Ejemplo n.º 2
0
        private void loadContent2()
        {
#if XBOX
            Thread.CurrentThread.SetProcessorAffinity(3);
#endif
            backGroundPic   = Content.Load <Texture2D>("titleScreenPic");
            frostTreeLogo   = Content.Load <Texture2D>("FrostTreeLogo");
            testArrow       = Content.Load <Texture2D>("gfx/testArrow");
            laserPic        = Content.Load <Texture2D>("gfx/laser");
            healthBar       = Content.Load <Texture2D>("bg");
            healthColor     = Content.Load <Texture2D>("healthTexture");
            energyColor     = Content.Load <Texture2D>("ammoTexture");
            energyOverlay   = Content.Load <Texture2D>("overlay");
            popUpBackground = Content.Load <Texture2D>("popUpBackground");
            greyBar         = Content.Load <Texture2D>("grayTexture");
            creditImage     = Content.Load <Texture2D>("EndCredits");
            heartPic        = Content.Load <Texture2D>("heartSheet");
            guardIcon       = Content.Load <Texture2D>("guard");
            prisonerIcon    = Content.Load <Texture2D>("prisoner");
            p2Icon          = Content.Load <Texture2D>("P2Icon");

            TextureLib ts = new TextureLib(GraphicsDevice);
            TextureLib.loadFromManifest();

            aspectRatio = graphics.GraphicsDevice.Viewport.AspectRatio;

            bloomFilter = Content.Load <Effect>("BloomShader");

            BackGroundAudio music = new BackGroundAudio(Content);

            music.addSong("Menu");
            music.addSong("RPG Game");
            AudioLib lb = new AudioLib();

            tenbyFive8       = Content.Load <SpriteFont>("tenbyFive/tenbyFive8");
            tenbyFive10      = Content.Load <SpriteFont>("tenbyFive/tenbyFive10");
            tenbyFive14      = Content.Load <SpriteFont>("tenbyFive/tenbyFive14");
            tenbyFive24      = Content.Load <SpriteFont>("tenbyFive/tenbyFive24");
            tenbyFive72      = Content.Load <SpriteFont>("tenbyFive/tenbyFive72");
            font             = tenbyFive14;
            testComputerFont = tenbyFive24;

            levelExitVideo          = Content.Load <Video>("fmv/elevatorExit");
            levelEnterVideo         = Content.Load <Video>("fmv/levelStart");
            titleScreenVideo        = Content.Load <Video>("fmv/menu");
            introCutScene           = Content.Load <Video>("fmv/intro");
            introCutSceneCoop       = Content.Load <Video>("fmv/intro COOP");
            levelEnterVideoCoop     = Content.Load <Video>("fmv/levelStartCOOP");
            levelExitVideoCoop      = Content.Load <Video>("fmv/elevatorExitCOOP");
            guardEndCutScene        = Content.Load <Video>("fmv/endGuardSingle");
            alienEndCutScene        = Content.Load <Video>("fmv/endAlienSingle");
            prisonerEndCutScene     = Content.Load <Video>("fmv/endPrisonerSingle");
            guardEndCutSceneCoop    = Content.Load <Video>("fmv/endGuardCoop");
            alienEndCutSceneCoop    = Content.Load <Video>("fmv/endAlienCoop");
            prisonerEndCutSceneCoop = Content.Load <Video>("fmv/endPrisonerCoop");
            videoPlayer             = new VideoPlayer();

            ChunkLib cs = new ChunkLib();

            AnimationLib.loadFrameFromManifest();

            GlobalGameConstants.WeaponDictionary.InitalizePriceData();

            GameCampaign.InitalizeCampaignData();
            GameCampaign.ResetPlayerValues("INIT", 0);

            // lol so many game screens
            currentGameScreen = new TitleScreen(TitleScreen.titleScreens.logoScreen);
            //currentGameScreen = new CutsceneVideoState(testVideo, ScreenState.ScreenStateType.LevelReviewState);
            //currentGameScreen = new CampaignLobbyState();
            //currentGameScreen = new HighScoresState(true);

            // DANIEL UNCOMMMENT THIS LINE BEFORE YOU MERGE WITH MASTER
            preloadedAssets = true;
        }