Example #1
0
        public Game1()
        {
            mGraphics = new GraphicsDeviceManager(this);
            mGraphics.PreferredBackBufferWidth  = 800;
            mGraphics.PreferredBackBufferHeight = 600;
            Content.RootDirectory = "Content";

            mCamera = new Camera(
                null, new Vector2(0, 0),
                new Vector2(mGraphics.PreferredBackBufferWidth, mGraphics.PreferredBackBufferHeight));

            mLifeWorld  = new LifeWorld(mCamera, "Content/lifeworld.txt", this);
            //puzzleChunks = graveyardMaker.generatePuzzleSections(8);
            mDeathWorld = new DeathWorld(mCamera);

            //
            mCurrentWorld = mLifeWorld;
            mDesiredWorld = mCurrentWorld;

            //FarseerPhysics.Settings.ContinuousPhysics = false;
        }
Example #2
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)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            mLifeWorld.Update(gameTime);
            mDeathWorld.Update(gameTime);
            mCamera.Update(gameTime);

            //mDesiredWorld

            // debug testing world switch
            /*
            KeyboardState keyState = Keyboard.GetState();
            if (GamePad.GetState(PlayerIndex.One).Buttons.A == ButtonState.Pressed ||
                keyState.IsKeyDown(Keys.Q))
            {
                mDesiredWorld = mDeathWorld;
            }
            if (GamePad.GetState(PlayerIndex.One).Buttons.B == ButtonState.Pressed ||
                keyState.IsKeyDown(Keys.W))
            {
                mDesiredWorld = mLifeWorld;
            }
            //*/

            // should we die?
            if (mCurrentWorld == mLifeWorld && mAlivePlayer.mHealth <= 0)
            {
                // player should die...
                mDesiredWorld = mDeathWorld;
            }

            if (mCurrentWorld != mDesiredWorld )//&& mCurrentWorld.ReadyToTransition() && mDesiredWorld.ReadyToTransition())
            {
                if (mDesiredWorld == mDeathWorld)
                {
                    // start transition to death world
                    mCamera.mTargetRot = new Vector3(90f - 15f, 0f, 0f);
                    mCurrentWorld = mDeathWorld;

                    mLifeThemeSEI.Stop();
                    mPlayerFallSnd.Play(.4f, 0f, 0f);
                    mDeathThemeSEI.Play();

                    // turn off/on players as appropriate
                    mDeadPlayer.SetPosition(mAlivePlayer.GetPosition());

                    // complete transition
                    mLifeWorld.GoToSleep();
                    mDeathWorld.WakeUp();
                }
                if (mDesiredWorld == mLifeWorld)
                {
                    mCamera.mTargetRot = new Vector3(0f, 0f, 0f);
                    mCurrentWorld = mLifeWorld;
                    mDeathThemeSEI.Stop();
                    mGongSnd.Play(mGongVolume, 0, 0);
                    mLifeThemeSEI.Play();

                    // turn off/on players as appropriate
                    mAlivePlayer.SetPosition(mDeadPlayer.GetPosition());

                    // complete transition
                    mDeathWorld.GoToSleep();
                    mLifeWorld.WakeUp();
                }
            }

            base.Update(gameTime);
        }