Ejemplo n.º 1
0
        /// <summary>
        /// Loads the level from the content manager
        /// </summary>
        /// <param name="content">Content Manager to load from</param>
        public void Load(ContentManager content)
        {
            mObjects.Clear();
            Reset();

            Importer importer = new Importer(content);
            importer.ImportLevel(this);

            mPlayer = new Player(content, ref mPhysicsEnvironment,
                mControls, .8f, EntityInfo.CreatePlayerInfo(GridSpace.GetGridCoord(StartingPoint)));

            mObjects.Add(mPlayer);
            mObjects.AddRange(importer.GetObjects(ref mPhysicsEnvironment));

            mPlayerEnd = importer.GetPlayerEnd();
            if (mPlayerEnd != null)
                mObjects.Add(mPlayerEnd);

            mObjects.AddRange(importer.GetWalls(this).Cast<GameObject>());

            mRails = importer.GetRails();

            mTrigger.AddRange(importer.GetTriggers());

            PrepareCollisionMatrix();

            mNumCollected = 0;
            mNumCollectable = 0;

            //Clear the collection lists
            mCollected.Clear();
            mRemoveCollected.Clear();

            foreach (GameObject gObject in mObjects)
            {
                if (gObject.CollisionType == XmlKeys.COLLECTABLE)
                    mNumCollectable++;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// TODO - ADD REAL HUD CODE
        /// </summary>
        /// <param name="gameTime"></param>
        private void DrawHUD(GameTime gameTime)
        {
            Rectangle titleSafeArea = GraphicsDevice.Viewport.TitleSafeArea;

            Player player = null;
            foreach(PhysicsObject obj in mObjects)
                if(obj is Player)
                    player = (Player)obj;

            Vector2 location = new Vector2(titleSafeArea.X+10,titleSafeArea.Y+5);

            mSpriteBatch.DrawString(mDefaultFont,"Gravity Force(G/H): " + mPhysicsEnvironment.GravityMagnitude, location,Color.Black);
            location = Vector2.Add(location, new Vector2(0, 20));
            mSpriteBatch.DrawString(mDefaultFont, "Terminal Speed(T/Y): " + mPhysicsEnvironment.TerminalSpeed, location, Color.Black);
            location = Vector2.Add(location, new Vector2(0, 20));
            mSpriteBatch.DrawString(mDefaultFont, "Erosion Factor(W/E): " + mPhysicsEnvironment.ErosionFactor, location, Color.Black);

            location = new Vector2(titleSafeArea.Right - 490, titleSafeArea.Y+5);
            mSpriteBatch.DrawString(mDefaultFont, "Up Force Magnifier(U/I): " +
                mPhysicsEnvironment.GetGravityMagnifier(GravityDirections.Up), location, Color.Black);
            location = Vector2.Add(location, new Vector2(-250, 20));
            mSpriteBatch.DrawString(mDefaultFont, "Left Force Magnifier(K/L): " +
                mPhysicsEnvironment.GetGravityMagnifier(GravityDirections.Left), location, Color.Black);
            location = Vector2.Add(location, new Vector2(+450, 0));
            mSpriteBatch.DrawString(mDefaultFont, "Right Force Magnifier(O/P): " +
                mPhysicsEnvironment.GetGravityMagnifier(GravityDirections.Right), location, Color.Black);
            location = Vector2.Add(location, new Vector2(-200, 20));
            mSpriteBatch.DrawString(mDefaultFont, "Down Force Magnifier(D/F): " +
                mPhysicsEnvironment.GetGravityMagnifier(GravityDirections.Down), location, Color.Black);

            location = new Vector2(titleSafeArea.X + 10, titleSafeArea.Height - 70);
            mSpriteBatch.DrawString(mDefaultFont, "Velocity X : " + (int)player.ObjectVelocity.X +
                " Velocity Y: " + (int)player.ObjectVelocity.Y, location, Color.Black);
            location = Vector2.Add(location, new Vector2(0, 20));
            mSpriteBatch.DrawString(mDefaultFont, "Total Force X: " + player.TotalForce.X +
                " Total Force Y: " + player.TotalForce.Y, location, Color.Black);
            location = Vector2.Add(location, new Vector2(0, 20));
            mSpriteBatch.DrawString(mDefaultFont, "Direction of Gravity: " + mPhysicsEnvironment.GravityDirection.ToString(), location, Color.Black);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            mSpriteBatch = new SpriteBatch(GraphicsDevice);
            mCurrentLevel.Load(Content,1);

            mDefaultFont = Content.Load<SpriteFont>("defaultFont");

            player = new Player(Content, "Player",
                new Vector2(1, 1), mCurrentLevel.GetStartingPoint(), ref mPhysicsEnvironment , new KeyboardControl());

            mObjects.Add(player);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// TODO - REMOVE WHEN NO LONGER A DEMONSTRACTION
 /// </summary>
 /// <param name="player"></param>
 /// <param name="keyboardState"></param>
 private void ChangeValues(Player player, KeyboardState keyboardState)
 {
     if (keyboardState.IsKeyDown(Keys.G)) mPhysicsEnvironment.GravityMagnitude += 1;
     if (keyboardState.IsKeyDown(Keys.H)) mPhysicsEnvironment.GravityMagnitude -= 1;
     if (keyboardState.IsKeyDown(Keys.T)) mPhysicsEnvironment.TerminalSpeed += 1;
     if (keyboardState.IsKeyDown(Keys.Y)) mPhysicsEnvironment.TerminalSpeed -= 1;
     if (keyboardState.IsKeyDown(Keys.W)) mPhysicsEnvironment.ErosionFactor += .01f;
     if (keyboardState.IsKeyDown(Keys.E)) mPhysicsEnvironment.ErosionFactor -= .01f;
     if (keyboardState.IsKeyDown(Keys.U))
         mPhysicsEnvironment.IncrementDirectionalMagnifier(GravityDirections.Up);
     if (keyboardState.IsKeyDown(Keys.I))
         mPhysicsEnvironment.DecrementDirectionalMagnifier(GravityDirections.Up);
     if (keyboardState.IsKeyDown(Keys.K))
         mPhysicsEnvironment.DecrementDirectionalMagnifier(GravityDirections.Left);
     if (keyboardState.IsKeyDown(Keys.L))
         mPhysicsEnvironment.IncrementDirectionalMagnifier(GravityDirections.Left);
     if (keyboardState.IsKeyDown(Keys.O))
         mPhysicsEnvironment.IncrementDirectionalMagnifier(GravityDirections.Right);
     if (keyboardState.IsKeyDown(Keys.P))
         mPhysicsEnvironment.DecrementDirectionalMagnifier(GravityDirections.Right);
     if (keyboardState.IsKeyDown(Keys.D))
         mPhysicsEnvironment.IncrementDirectionalMagnifier(GravityDirections.Down);
     if (keyboardState.IsKeyDown(Keys.F))
         mPhysicsEnvironment.DecrementDirectionalMagnifier(GravityDirections.Down);
 }