private static void Main() { using (var game = new MarioGame()) { game.Run(); } }
public PlayingState(MarioGame game) { this.game = game; game.IsMouseVisible = false; if (game.IskeyboardController) { game.InitializeKeyBoard(); } else { game.InitializeGamePad(); } game.Player.DeathStateEvent += Die; StatsManager.Instance.TimeUpEvent += TimeUp; if (MediaPlayer.State == MediaState.Paused) { MediaPlayer.Resume(); } else if (game.Player.Position.Y > 0) { MediaPlayer.Play(AudioFactory.Instance.CreateSong(StringConsts.OverWorld)); game.SetFocus(game.Player); } else { MediaPlayer.Play(AudioFactory.Instance.CreateSong(StringConsts.UnderWorld)); backGroundColor = Color.Black; game.SetFocus(null); } }
public KeyboardController(MarioGame game) { this.game = game; downActions = new Dictionary <Keys, Action>(); pressActions = new Dictionary <Keys, Action>(); releaseActions = new Dictionary <Keys, Action>(); previous = Keyboard.GetState(); this.OnKeyPressed(Keys.Q, game.Exit); this.OnKeyPressed(Keys.R, game.LevelReset); this.OnKeyPressed(Keys.M, game.MenuReset); this.OnKeyPressed(Keys.Enter, InputActions.start); this.OnKeyPressed(Keys.Up, ActionUtil.Chain(InputActions.jump, InputActions.menuUp)); this.OnKeyPressed(Keys.W, ActionUtil.Chain(InputActions.jump, InputActions.menuUp)); this.OnKeyPressed(Keys.Space, ActionUtil.Chain(InputActions.jump, InputActions.menuUp)); this.OnKeyDownRelease(Keys.Left, InputActions.moveLeft, InputActions.halt); this.OnKeyDownRelease(Keys.A, InputActions.moveLeft, InputActions.halt); this.OnKeyDownRelease(Keys.Right, InputActions.moveRight, InputActions.halt); this.OnKeyDownRelease(Keys.D, InputActions.moveRight, InputActions.halt); this.OnKeyPressed(Keys.F, InputActions.fire); this.OnKeyDown(Keys.Down, InputActions.crouch); this.OnKeyDown(Keys.S, InputActions.crouch); this.OnKeyPressed(Keys.Down, InputActions.menuDown); this.OnKeyPressed(Keys.S, InputActions.menuDown); }
public static Level LoadLevel(MarioGame game, string levelFolder, Vector2 respawnPosition, PowerUpEnum powerUp) { if (creators.ContainsKey(levelFolder)) { return(creators[levelFolder](game, levelFolder, respawnPosition, powerUp)); } return(new Level(game, levelFolder, respawnPosition, powerUp)); }
public GameOverState(MarioGame game) { this.game = game; this.graphicsDevice = game.GraphicsDevice; spriteFont = game.Content.Load <SpriteFont>(StringConsts.MarioFont); MediaPlayer.Stop(); MediaPlayer.Play(AudioFactory.Instance.CreateSong(StringConsts.Gameover)); }
public FlagPoleState(MarioGame game) { graphicsDevice = game.GraphicsDevice; this.game = game; game.Player.ClearingScoresEvent += ClearScore; MediaPlayer.Stop(); AudioFactory.Instance.CreateSound(StringConsts.FlagPole).Play(); }
public PlayState(MarioGame game, IController<Keys> keys, IController<Buttons> gamePad) : base(game, keys, gamePad) { this.pausedTexture = game.Content.Load<Texture2D>("Textures/Paused"); this.ShouldUpdate = true; instance = this; }
protected Transition(MarioGame marioGame, float time) { Game = marioGame; Height = MarioGame.vResolution; Width = MarioGame.hResolution; this.time = (int)(time * 60); BackgroundColor = Color.Black; }
public ObjectsManager(ObjectLoader objectLoader, MarioGame game) { StaticObjects = new List <IStatic>(); DynamicObjects = new List <IDynamic>(); NonCollidableObjects = new List <IObject>(); ObjectLoader = objectLoader; Mario = objectLoader.Mario; dynamicLoader = new DynamicLoader(game, objectLoader, this); this.game = game; }
public PlayerStatusState(MarioGame game) { this.game = game; game.IsMouseVisible = false; game.DisableController(); graphicsDevice = game.GraphicsDevice; spriteFont = game.Content.Load <SpriteFont>(StringConsts.MarioFont); smallMarioSprite = SpriteFactory.CreateSprite(nameof(SmallMario) + nameof(RightIdle)); game.IsMouseVisible = false; }
public ChooseControllerState(MarioGame game) { this.game = game; graphics = game.GraphicsDevice; buttonFont = game.Content.Load <SpriteFont>(StringConsts.MarioFontForChoose); game.IsMouseVisible = true; buttons = new List <Buttons>(); AddKeyBoardButton(buttons); AddGamePadButton(buttons); }
public TitleScreen(MarioGame game) : base(game) { Manager.AddObserver(this, new[] { GameEvent.START, GameEvent.WARP }); theme = Theme.GetTheme("default"); theme.InitLayers((Level)Game.Level); floor = (Game.Level as Level).Factory.CreateSprite(typeof(BlockEntity), States.Floor, null); Title = (Game.Content.Load <Texture2D>("TitleScreen"));// new Rectangle(1, 60, 175, 87)); mario = (Game.Level as Level).Factory.CreateSprite(typeof(MarioContext), PowerUpEnum.NORMAL, ActionEnum.STANDING); mario.SpriteEffects = SpriteEffects.FlipHorizontally; BackgroundColor = Color.CornflowerBlue; }
public MenuState(MarioGame game) { this.game = game; game.IsMouseVisible = true; graphics = game.GraphicsDevice; spriteFont = game.Content.Load <SpriteFont>(StringConsts.MarioFontForChoose); background = game.Content.Load <Texture2D>(StringConsts.StartBackground); buttons = new List <Buttons>(); StatsManager.Instance.Reset(); AddNewGameButton(buttons); AddQuitGameButton(buttons); }
public void Start() { AbstractGameClass m = new MarioGame(); m.Start(); System.Console.WriteLine(); AbstractGameClass t = new TankGame(); t.Start(); System.Console.WriteLine(); }
public void CreateInstance_TwoTime_OnlyOneInstanceShouldbeCreated() { //Arrange MarioGame player1; MarioGame player2; //Act player1 = MarioGame.GetInstance(); player2 = MarioGame.GetInstance(); //Assert Assert.AreEqual(player1, player2, "Both the instances are equal"); }
public void MarioQuestionBlockRightCollision() { TestGame = new MarioGame(); TestWorld = TestGame.World; Content = TestGame.Content; TestMario = TestGame.World.Mario; //TestBlock = TestGame.World.QuestionBlockObject; TestCommand = new MarioRightCommand(TestGame); TestMario.PassCommand(TestCommand); //Check that question block is not changed //Assert.AreEqual(QuestionBlockSpriteState, TestBlock.SpriteState); }
public TeleportingState(MarioGame game, Vector2 Position) { game.DisableController(); this.game = game; graphicsDevice = game.GraphicsDevice; MediaPlayer.Stop(); AudioFactory.Instance.CreateSound(StringConsts.Pipe).Play(); if (game.Player.Position.Y < 0) { backGroundColor = Color.Black; } teleportPosition = Position; }
public void MarioQuestionBlockBottomCollision() { TestGame = new MarioGame(); TestWorld = TestGame.World; Content = TestGame.Content; TestMario = TestGame.World.Mario; //TestBlock = TestGame.World.QuestionBlockObject; TestCommand = new MarioUpCommand(TestGame); TestMario.PassCommand(TestCommand); //Check that question block is now used block //Assert.AreEqual(UsedBlockSpriteState, TestBlock.SpriteState); }
public void MarioGoombaBottomCollision() { TestGame = new MarioGame(); TestWorld = TestGame.World; Content = TestGame.Content; TestMario = TestGame.World.Mario; TestGoomba = TestGame.World.Goomba; TestCommand = new MarioUpCommand(TestGame); TestMario.PassCommand(TestCommand); //Check if Mario is dead //Assert.AreEqual(true, TestMario.SpriteState.IsDead()); //Check if Goomba is dead //Assert.AreEqual(GoombaSprite, TestGoomba.SpriteState); }
private void Image_MouseDown(object sender, MouseEventArgs e) { if (((Image)sender).Tag as string == "Erlich") { } else { MarioGame game = new MarioGame(); Hide(); game.Start(); Show(); } }
public PauseState(MarioGame game) { this.game = game; graphicsDevice = game.GraphicsDevice; if (game.IskeyboardController) { game.Controller = new KeyboardController((Keys.O, new PauseCommand(game), new EmptyCommand(), false)); } else { game.Controller = new JoyStickController(game.Player, (Microsoft.Xna.Framework.Input.Buttons.LeftShoulder, new PauseCommand(game), new EmptyCommand(), false)); } MediaPlayer.Pause(); AudioFactory.Instance.CreateSound(StringConsts.Pause).Play(); }
public void MarioKoopaTopCollision() { TestGame = new MarioGame(); TestWorld = TestGame.World; Content = TestGame.Content; TestMario = TestGame.World.Mario; TestKoopa = TestGame.World.Koopa; TestCommand = new MarioDownCommand(TestGame); TestMario.PassCommand(TestCommand); //Check if Mario is alive Assert.AreEqual(false, TestMario.Alive); //Check if Koopa is Shell //Assert.AreEqual("ShellKoopaSprite", TestKoopa.SpriteState); }
public void MarioKoopaBottomCollision() { TestGame = new MarioGame(); TestWorld = TestGame.World; Content = TestGame.Content; TestMario = TestGame.World.Mario; TestKoopa = TestGame.World.Koopa; TestCommand = new MarioUpCommand(TestGame); TestMario.PassCommand(TestCommand); //Check if Mario is dead Assert.AreEqual(true, TestMario.Alive); //Check if Koopa is Shell //Assert.AreEqual("WalkingKoopaSprite", TestKoopa.SpriteState); }
public GamePadController(MarioGame game) { this.game = game; previous = GamePad.GetState(PlayerIndex.One); downActions = new Dictionary <Buttons, Action>(); pressActions = new Dictionary <Buttons, Action>(); releaseActions = new Dictionary <Buttons, Action>(); this.OnButtonPressed(Buttons.Start, game.Quit); this.OnButtonPressRelease(Buttons.DPadUp, ActionUtil.Chain(InputActions.jump, InputActions.menuUp), InputActions.halt); this.OnButtonDownRelease(Buttons.DPadDown, InputActions.crouch, InputActions.halt); this.OnButtonDownRelease(Buttons.DPadLeft, InputActions.moveLeft, InputActions.halt); this.OnButtonDownRelease(Buttons.DPadRight, InputActions.moveRight, InputActions.halt); this.OnButtonPressed(Buttons.A, InputActions.fire); this.OnButtonPressed(Buttons.DPadDown, InputActions.menuDown); }
public Level2Beginning(MarioGame game, string levelFolder, Vector2 respawnPosition, PowerUpEnum powerUp) : base(game, levelFolder, respawnPosition, powerUp) { Mario.Velocity = new Vector2(1, 0); Mario.ActionStates.CurrentState = ActionEnum.WALKING; Sprite s = Mario.Sprite.Clone(); Mario.Commands += new Command[] { new Wait() .Until(e => e.CollidingWith.Any(b => b.entity is BlockEntity block && block.BlockStates.CurrentState == States.PipeSide)), new MethodCall <IEntity>((e) => s.Layer = 0.4f), new Move(0.6f, 0).Repeat(16), new MethodCall <IEntity>((e) => GoToNextLevel()) }; Mario.Commands += new Command[] { new SetSprite(s).Repeat(1000) }; }
public static void LoadSounds(MarioGame game) { SoundLoader.game = game; rng = new Random(); Songs = new Dictionary <string, SoundEffectInstance>(); Effects = new Dictionary <string, SoundEffect>(); listener = new AudioListener(); emitter = new AudioEmitter(); Effects.Add("1-up", game.Content.Load <SoundEffect>("Sound/smb_1-up")); Effects.Add("bowserFall", game.Content.Load <SoundEffect>("Sound/smb_bowserfall")); Effects.Add("bowserFire", game.Content.Load <SoundEffect>("Sound/smb_bowserfire")); Effects.Add("breakBlock", game.Content.Load <SoundEffect>("Sound/smb_breakblock")); Effects.Add("bump", game.Content.Load <SoundEffect>("Sound/smb_bump")); Effects.Add("coin", game.Content.Load <SoundEffect>("Sound/smb_coin")); Effects.Add("fireball", game.Content.Load <SoundEffect>("Sound/smb_fireball")); Effects.Add("fireworks", game.Content.Load <SoundEffect>("Sound/smb_fireworks")); Effects.Add("flagpole", game.Content.Load <SoundEffect>("Sound/smb_flagpole")); Effects.Add("gameOver", game.Content.Load <SoundEffect>("Sound/smb_gameover")); Effects.Add("jumpSmall", game.Content.Load <SoundEffect>("Sound/smb_jumpsmall")); Effects.Add("jumpBig", game.Content.Load <SoundEffect>("Sound/smb_jump-super")); Effects.Add("kick", game.Content.Load <SoundEffect>("Sound/smb_kick")); Effects.Add("marioDie", game.Content.Load <SoundEffect>("Sound/smb_mariodie")); Effects.Add("pause", game.Content.Load <SoundEffect>("Sound/smb_pause")); Effects.Add("pipe", game.Content.Load <SoundEffect>("Sound/smb_pipe")); Effects.Add("powerupAppears", game.Content.Load <SoundEffect>("Sound/smb_powerup_appears")); Effects.Add("stageClear", game.Content.Load <SoundEffect>("Sound/smb_stage_clear")); Effects.Add("stomp", game.Content.Load <SoundEffect>("Sound/smb_stomp")); Effects.Add("vine", game.Content.Load <SoundEffect>("Sound/smb_vine")); Effects.Add("warning", game.Content.Load <SoundEffect>("Sound/smb_warning")); Effects.Add("worldClear", game.Content.Load <SoundEffect>("Sound/smb_world_clear")); Effects.Add("explode1", game.Content.Load <SoundEffect>("Sound/Boom/explode1")); Effects.Add("explode2", game.Content.Load <SoundEffect>("Sound/Boom/explode2")); Effects.Add("explode3", game.Content.Load <SoundEffect>("Sound/Boom/explode3")); Effects.Add("explode4", game.Content.Load <SoundEffect>("Sound/Boom/explode4")); Songs.Add("starTheme", game.Content.Load <SoundEffect>("Sound/starTheme").CreateInstance()); }
public KeyboardController(MarioGame game) { lockedKeyCommands = new Dictionary <Keys, ICommand>(); lockedKeyCommands.Add(Keys.Q, new QuitGame(MarioGame.Instance)); lockedKeyCommands.Add(Keys.R, new Reset(MarioGame.Instance)); keyCommands = new Dictionary <Keys, ICommand>(); keyCommands.Add(Keys.Q, new QuitGame(game)); keyCommands.Add(Keys.W, new MarioJumpCommand(World.Instance.Mario)); keyCommands.Add(Keys.S, new MarioCrouchCommand(World.Instance.Mario)); keyCommands.Add(Keys.A, new MarioMoveLeftCommand(World.Instance.Mario)); keyCommands.Add(Keys.D, new MarioMoveRightCommand(World.Instance.Mario)); keyCommands.Add(Keys.R, new Reset(game)); currentBindings = keyCommands; bindingsSelector = new Dictionary <string, Dictionary <Keys, ICommand> >() { { "alive", keyCommands }, { "dead", lockedKeyCommands } }; }
public Reset(MarioGame Game) { game = Game; }
public void Initialize(MarioGame marioGame) { this.game = marioGame; objectsManager = marioGame.ObjectsManager; spriteFont = marioGame.Content.Load <SpriteFont>(StringConsts.Font); }
public ToggleFullscreenCommand(MarioGame game) : base(game) { }
public ResetLevelCommand(MarioGame game) : base(game) { }
public ToggleDrawHitboxesCommand(MarioGame game) : base(game) { }
/// <summary> /// Constructs a new command to exit the main game /// </summary> /// <param name="game">The main game class of the program</param> public ExitCommand(MarioGame game) : base(game) { }
public StatsScreen(MarioGame game) : base(game, 1.5F) { mario = (Game.Content.Load <Texture2D>("Sprites/marioSheet3")); }
public PlayerDeadState(MarioGame game) { this.game = game; game.Player.DestroyEvent += Die; }
public QuitGame(MarioGame Game) { game = Game; }