Esempio n. 1
0
 public void load()
 {
     int AINum = mWorld.level < 3 ? 10 : 20;
     for (int i = 0; i < AINum; i++)
     {
         WorldObject bug = new WorldObject(AITexture);
         mAI.Add(bug);
     }
     mWorld.SetAIComponent(mAI);
 }
 public bool Intersects(WorldObject wo)
 {
     if ((wo.Right > Left && Right > wo.Left)
         && wo.Top < Bottom && Top < wo.Bottom)
     {
         return true;
     }
     return false;
 }
        private bool addPlatform(WorldObject newPlatform)
        {
            lastXPlatform += rand.Next(150, 300);
            int randYGap = rand.Next(90, 200);

            if (lastXPlatform > 10000)
                return false;

            mPlatform.Add(newPlatform);
            newPlatform.Position = new Vector2(lastXPlatform, lastYPlatform);
            addCoin(lastXPlatform, lastYPlatform, newPlatform.Width);
            bool up;
            if (lastYPlatform - randYGap < -mWorld.towerBounds.Bottom / 6)
            {
                up = false;
            }
            else if (lastYPlatform + randYGap > mWorld.towerBounds.Bottom * 5 / 6 - mWorld.groundHeight)
            {
                up = true;
            }
            else
            {
                up = rand.Next(0, 2) == 0;
            }

            randYGap = up ? -randYGap : randYGap;
            lastYPlatform += randYGap;
            return true;
        }
 private void addCoin(int x, int y, int width)
 {
     WorldObject newCoin = new WorldObject(coinTexture);
     newCoin.Position = new Vector2(x + width/2 - newCoin.Width/2, y - 80);
     coins.Add(newCoin);
 }
Esempio n. 5
0
 private bool landed(List<WorldObject> platformList)
 {
     foreach (WorldObject platform in platformList)
     {
         if (mPlayer.Middle >= platform.Left
                     && mPlayer.Middle <= platform.Right)
         {
             if (platform.above && mPlayer.Bottom >= platform.Top)
             {
                 mCurrentPlatform = platform;
                 platform.above = false;
                 landSound.Play();
                 mPlayer.Position = new Vector2(mPlayer.Position.X, platform.Top - mPlayer.Height);
                 return true;
             }
             else if (mPlayer.Bottom <= platform.Top)
             {
                 platform.above = true;
             }
         }
         if (mPlayer.Bottom >= platform.Top)
         {
             platform.above = false;
         }
     }
     return false;
 }
Esempio n. 6
0
        protected override void LoadContent()
        {
            mSpriteBatch = new SpriteBatch(Game.GraphicsDevice);
               font = Game.Content.Load<SpriteFont>(mConstants.ScoreFont);
               coinSound = Game.Content.Load<SoundEffect>("Bleep");
               landSound = Game.Content.Load<SoundEffect>("Click01");
               dieSound = Game.Content.Load<SoundEffect>("claps");
               fallSound = Game.Content.Load<SoundEffect>("bomb");
              // hills = Game.Content.Load<Texture2D>("hills");
               ground = Game.Content.Load<Texture2D>("ground");
               groundHeight = ground.Height;
               endTexture = Game.Content.Load<Texture2D>("house");
               endSpot = new WorldObject(endTexture);

               endSpot.Position = new Vector2(9000 - endSpot.Width, towerBounds.Bottom - ground.Height - endSpot.Height);
              // endSpot.Position = new Vector2(400, towerBounds.Bottom - ground.Height - endSpot.Height);
               load();
        }
Esempio n. 7
0
 internal void SetPlayerComponent(WorldObject player)
 {
     mPlayer = player;
     mPlayer.Position = new Vector2(80,  towerBounds.Bottom - ground.Height - mPlayer.Height);
     blood.Position = mPlayer.Position;
 }
Esempio n. 8
0
 public void load()
 {
     background = new List<Texture2D>();
     mainFrame = new List<Rectangle>();
     mainFrameGround = new List<Rectangle>();
     background.Add(Game.Content.Load<Texture2D>("1"));
     background.Add(Game.Content.Load<Texture2D>("2"));
     background.Add(Game.Content.Load<Texture2D>("3"));
     background.Add(Game.Content.Load<Texture2D>("4"));
     background.Add(Game.Content.Load<Texture2D>("5"));
     bloodTexture = Game.Content.Load<Texture2D>("blood");
     blood = new WorldObject(bloodTexture);
     for (int i = 0; i < frames; i++)
     {
         mainFrame.Add(new Rectangle(2000 * i, topOfBackGround, 2000, 2000));
         mainFrameGround.Add(new Rectangle(2000 * i, towerBounds.Bottom - ground.Height, 1293, 98));
     }
     die = false;
     die2 = false;
     mCurrentPlatform = new WorldObject();
     base.LoadContent();
 }