Exemplo n.º 1
0
        public void Update(GameTime gameTime)
        {
            game.background.CurrentSprite.Update(gameTime);
            foreach (KeyValuePair <IAnimatedSprite, Vector2> backgroundObject in levelBackgroundObjects)
            {
                backgroundObject.Key.Update(gameTime);
            }
            foreach (Enemy enemy in levelEnemies)
            {
                if (game.gameCamera.InCameraView(enemy.GetBoundingBox()))
                {
                    enemy.Update(gameTime);
                }
            }

            /*foreach (House pipeUpdater in levelPipe)
             * {
             *  if(game.gameCamera.InCameraView(pipeUpdater.getBoundingBox()))
             *  {
             *      pipeUpdater.Update(gameTime);
             *  }
             * }
             */
            foreach (ICollectable item in levelItems)
            {
                if (game.gameCamera.InCameraView(item.GetBoundingBox()))
                {
                    item.Update(gameTime);
                }
            }
            foreach (Block blockUpdater in levelBlock)
            {
                if (game.gameCamera.InCameraView(blockUpdater.GetBoundingBox()))
                {
                    blockUpdater.Update(gameTime);
                }
            }

            if (game.gameCamera.InCameraView(exitPole.GetBoundingBox(exitPosition)))
            {
                exitPole.Update(gameTime);
            }

            collision.Detect(teno, levelEnemies, levelBlock, levelHouses, levelItems);
            teno.Update(gameTime);
            if (teno.position.X < 0)
            {
                teno.position.X = 0;
            }
            if (teno.position.X > exitPosition.X && !isVictory && !isUnderGround)
            {
                game.gameState = new VictoryGameState(game);
                isVictory      = true;
            }
            game.gameCamera.LookAt(teno.position);
        }
Exemplo n.º 2
0
        public void Update(GameTime gameTime)
        {
            game.background.CurrentSprite.Update(gameTime);
            foreach (KeyValuePair <IAnimatedSprite, Vector2> backgroundObject in levelBackgroundObjects)
            {
                backgroundObject.Key.Update(gameTime);
            }

            foreach (House pipeUpdater in levelPipe)
            {
                if (game.gameCamera.InCameraView(pipeUpdater.getBoundingBox()))
                {
                    pipeUpdater.Update(gameTime);
                }
            }

            foreach (Block blockUpdater in levelBlock)
            {
                if (game.gameCamera.InCameraView(blockUpdater.getBoundingBox()))
                {
                    blockUpdater.Update(gameTime);
                }
            }

            if (game.gameCamera.InCameraView(exitPole.GetBoundingBox()))
            {
                exitPole.Update(gameTime);
            }

            collision.Detect(teno, levelEnemies, levelBlock, levelHouses, levelItems);
            teno.Update(gameTime);
            if (teno.position.X < 0)
            {
                teno.position.X = 0;
            }
            if (teno.position.X > exitPosition.X && !isVictory && !isUnderGround)
            {
                game.gameState = new VictoryGameState();
                exitPole       = new GateSprite(Game1.gameContent.Load <Texture2D>("gateBroken"), 1, 1);
                isVictory      = true;
            }
            game.gameCamera.LookAt(teno.position);
        }