protected override void Initialize() { keyboard = new KeyboardController(); gamepad = new GamepadController(this); camera = new Camera(UtilityClass.cameraHeight, UtilityClass.cameraWidth, new Vector2(UtilityClass.zero, UtilityClass.zero)); pipeTransition = new PipeTransition(); skytransition = new SkyWorldTransition(); gameover = new GameOver(this); loader = new LevelLoader(UtilityClass.levelFile, camera); levelStore = new LevelStorage(camera); keyNotPressed = new KeyNotPressed(this); fireBallCount = UtilityClass.fireballLimit; iceBallCount = UtilityClass.iceballLimit; pause = false; canPause = true; marioPause = false; stateTransistionPauseTimer = UtilityClass.stateTransistionTimer; time = new TimeStat(UtilityClass.LevelStartTime); gui = new GUI(); StatePuaseAlterationCall.setGame(this); AchievementPause.setGame(this); achievementManager = new AchievementManager(); AchievementEventTracker.setManager(achievementManager); base.Initialize(); tester = new TestingClass(this, levelStore); tester.runTests(); AchievementEventTracker.endRunningTesting(); pole = new Pole(); flag = new Flag(); hitFlagpole = false; levelWon = false; vine_box_hit = false; VineClimbBeginLocation = new Vector2(30, 0); }
public static void handleCollision(Mario mario, IEnemyObject enemy, ICollision side, LevelStorage levelStorage) { ICommand command; if (!(side.returnCollisionSide().Equals(CollisionSide.None))) { handleMarioMovement(mario, enemy, side); } if (side.returnCollisionSide().Equals(CollisionSide.Top) && enemy.canHurtMario()) { command = new MarioHitsEnemyCollision(enemy, mario); command.Execute(); levelStorage.decreaseEnemyCount(); } else if (!(side.returnCollisionSide().Equals(CollisionSide.None)) && enemy.canHurtMario()) { command = new EnemyHitsMarioCollision(mario, enemy); command.Execute(); if (!mario.Star) { StatePuaseAlterationCall.Execute(); } } if (enemy.canHurtOtherEnemies() && !(side.returnCollisionSide().Equals(CollisionSide.None)) && !enemy.canHurtMario()) { handleMarioMovement(mario, enemy, side); handleEnemyMovement(enemy, side); } handleAchievement(enemy, side); }
private static ICommand chooseCorrectCommand(IItemObjects item, IPlayer mario) { ICommand command; if (item.returnItemType().Equals(ItemType.Coin)) { command = new MarioCoinCollisionCommand(mario, item); } else if (item.returnItemType().Equals(ItemType.FireFlower)) { command = new MarioFireFlowerCollisionCommand(mario, item); if (!((Mario)mario).Fire) { StatePuaseAlterationCall.Execute(); } } else if (item.returnItemType().Equals(ItemType.IceFlower)) { command = new MarioIceFlowerCollisionCommand(mario, item); } else if (item.returnItemType().Equals(ItemType.OneUpMushroom)) { command = new MarioOneUpMushroomCollisionCommand(mario, item); } else if (item.returnItemType().Equals(ItemType.Star)) { command = new MarioStarCollisionCommand(mario, item); } else { command = new MarioSuperMushroomCollisionCommand(mario, item); if (((Mario)mario).Small) { StatePuaseAlterationCall.Execute(); } } return(command); }
public TestingClass(Game1 game, LevelStorage storage) { this.game = game; StatePuaseAlterationCall.setGame(game); levelStorage = storage; }
protected override void Update(GameTime gameTime) { if (!hitFlagpole) { keyboard.Update(); gamepad.Update(); } foreach (IBlock block in levelStore.blocksList) { if (block.returnBlockType() == BlockType.QuestionCoin) { if (((QuestionCoinBlock)block).returnVineDispense() && !vine_box_hit) { vine_box_hit = true; skytransition.seVineBoxHit(true); } } } float elapsedtime = (float)gameTime.ElapsedGameTime.TotalSeconds; levelWon = (mario.GetLocation().X >= UtilityClass.flagpoleLocation && mario.GetLocation().X < UtilityClass.aboveGroundEndLocation); if (!pause && !marioPause) { keyNotPressed.Execute(); if (!levelWon) { mario.Update(gameTime); } levelStore.Update(); levelStore.handleCollision(mario, this); cameraController.Update(); pipeTransition.Update((Mario)mario, elapsedtime, camera); skytransition.Update((Mario)mario, elapsedtime, this); gameover.Update((Mario)mario, elapsedtime, this); gui.Update(); if (time.UpdateTime(gameTime)) { resetCommand.Execute(); } base.Update(gameTime); } else if (marioPause && !pause) { if (!levelWon) { mario.Update(gameTime); } levelStore.handleCollision(mario, this); stateTransistionPauseTimer--; } if (stateTransistionPauseTimer == UtilityClass.zero) { StatePuaseAlterationCall.Execute(); } pole.Update(); flag.Update(); if (levelWon) { AchievementEventTracker.levelFinishAcievement(); if (!hitFlagpole) { endMario = new EndingSequenceMario(((Mario)mario), ((Mario)mario).Small, ((Mario)mario).Fire, ((Mario)mario).Ice, time); hitFlagpole = true; } flag.MoveDown(); endMario.FlagAtBottom = flag.FlagAtBottom(); endMario.Update(); if (endMario.EndSequenceFinished && Keyboard.GetState().GetPressedKeys().Length > 0) { resetCommand.Execute(); } } }