public EntityCollisionHandler(Level1 level) { handlers = new Dictionary <Type, ICollisionHandler>(); handlers[typeof(PlayerContext)] = new MarioCollisionHandler(); handlers[typeof(BlockContext)] = new BlockCollisionHandler(); handlers[typeof(CoinSprite)] = new ItemCollisionHandler(); handlers[typeof(FireFlowerSprite)] = new ItemCollisionHandler(); handlers[typeof(MushroomSprite)] = new ItemCollisionHandler(); handlers[typeof(StarmanSprite)] = new ItemCollisionHandler(); handlers[typeof(GreenKoopaSprite)] = new EnemyCollisionHandler(); handlers[typeof(RedKoopaSprite)] = new EnemyCollisionHandler(); handlers[typeof(RedGoombaSprite)] = new EnemyCollisionHandler(); this.level = level; }
protected override void Update(GameTime gameTime) { level.Update(gameTime); CollisionDetector c = new CollisionDetector(((Level1)level).entities, (Level1)level); c.Update(); ////Update enemy sprites //redGoombaSprite.Update(gameTime); //redKoopaSprite.Update(gameTime); //greenKoopaSprite.Update(gameTime); ////Update item sprites //blockCoinSprite.Update(gameTime); //staticCoinSprite.Update(gameTime); //fireFlowerSprite.Update(gameTime); //_1UpMushroomSprite.Update(gameTime); //superMushroomSprite.Update(gameTime); //starmanSprite.Update(gameTime); //Update states of controllers keyboardController.Update(); foreach (GamepadController controller in controllerArray) { controller.Update(); } //Temporary block command keys if (keyboardController.previousKeyboardState.IsKeyDown(Keys.X)) { Levels.Level1 levelController = (Levels.Level1)level; levelController.TestMarioLocation(); } //if (keyboardController.CurrentKeys.Contains(Keys.B)) //{ // grid.Remove(player); // grid.Add(player); // for (int i = 0; i < bunchOBlocks.Length; i++) // { // if (bunchOBlocks[i].GetBlockType().Equals(BlockContext.Blocks.BRICK)) // { // bunchOBlocks[i].HitFromBottom(playerController); // } // } //} //if (keyboardController.CurrentKeys.Contains(Keys.H)) //{ // for (int i = 0; i < bunchOBlocks.Length; i++) // { // if (bunchOBlocks[i].GetBlockType().Equals(BlockContext.Blocks.HIDDEN)) // { // bunchOBlocks[i].HitFromBottom(playerController); // } // } //} ////Update block states //for(int i = 0; i<bunchOBlocks.Length; i++) //{ // bunchOBlocks[i].Update(gameTime); //} ////Update player state //playerController.Update(gameTime); base.Update(gameTime); }