Пример #1
0
 public void Update(GameTime gameTime)
 {
     if (Coins == ValueHolder.maxCoins)
     {
         Coins = 0;
         Lives++;
     }
     if (Coins >= 20)
     {
         game.ach.AchievementAdjustment(AchievementsManager.AchievementType.Coins);
     }
     currentTime += (float)gameTime.ElapsedGameTime.TotalSeconds;
     if (currentTime >= countDuration && !game.isVictory)
     {
         Time--;
         currentTime -= countDuration;
     }
     if (Time == ValueHolder.hurryTime && !changedMusic && !gameEnded)
     {
         changedMusic = true;
         SoundManager.StopMusic();
         SoundManager.PlaySong(SoundManager.songs.overworldFast);
     }
     if (Time == 0 && !gameEnded)
     {
         game.level.mario.state.MakeDeadMario();
         Game1.GetInstance().gameState = new DeadGameState(game.level.mario);
     }
 }
Пример #2
0
 public void Update(GameTime gameTime)
 {
     fallAnimTimer--;
     if (fallAnimTimer < 0 && !isFallingSprite)
     {
         mario.state.Fall();
         isFallingSprite = true;
     }
     if (mario.velocity.Y < mario.maxVelocity.Y)
     {
         mario.velocity += fallingVelocity;
     }
     mario.position += mario.velocity * ((float)gameTime.ElapsedGameTime.Milliseconds / positionDtAdjust);
     mario.velocity *= fallingVelocityDecayRate;
     if (Game1.GetInstance().level.collision.standingBlocks.Count > 0 ||
         Game1.GetInstance().level.collision.standingPipes.Count > 0)
     {
         mario.physState = new GroundState(mario);
     }
     if (mario.position.Y > ValueHolder.fallingMarioBoundary)
     {
         mario.state = new DeadMS(mario);
         Game1.GetInstance().ach.AchievementAdjustment(AchievementsManager.AchievementType.Death);
     }
 }
Пример #3
0
        public void Update(GameTime gameTime)
        {
            game.gameHUD.Update(gameTime);
            if (walkTimer > 0)
            {
                if (slowFrames == ValueHolder.slowdownRate)
                {
                    right.Execute();
                    game.level.Update(gameTime);
                    slowFrames = 0;
                }
                slowFrames++;
            }
            else
            {
                game.level.mario.MakeVictoryMario();
                if (walkTimer < -70)
                {
                    Game1.GetInstance().level = new Level(StringHolder.levelOne);
                    Game1.GetInstance().background.CurrentSprite = Game1.GetInstance().background.OverworldSprite;
                    Game1.GetInstance().gameState = new TitleScreenGameState();
                    Game1.GetInstance().isTitle = true;
                    Game1.GetInstance().gameHUD.Coins = 0;
                    Game1.GetInstance().gameHUD.Lives = 3;
                    Game1.GetInstance().gameHUD.Score = 0;
                }
            }
            walkTimer--;

            if (game.gameHUD.Time > 0)
            {
                game.gameHUD.Time--;
                game.gameHUD.Score += ValueHolder.remainingTimePoints;
            }
        }
Пример #4
0
 public void Spawn()
 {
     isSpawning = true;
     Game1.GetInstance().level.levelItems.Add(this);
     spawnTimer = ValueHolder.itemSpawnTimer;
     SoundManager.itemSpawn.Play();
 }
Пример #5
0
 public void Explode()
 {
     state       = new ExplodingBlockState();
     isExploding = true;
     Game1.GetInstance().gameHUD.Score += ValueHolder.brickBreakPoints;
     SoundManager.brickBreak.Play();
 }
Пример #6
0
 static void Main(string[] args)
 {
     using (Game1 game = Game1.GetInstance())
     {
         game.Run();
     }
 }
Пример #7
0
 public void Respawn()
 {
     state            = new RightIdleSmallMS(this);
     physState        = new VVVVVVGroundState(this, 1);
     gravityDirection = 1;
     position         = Game1.GetInstance().level.checkpoint;
 }
 public PipeTransitionGameState(direction direction, Pipe pipe)
 {
     game          = Game1.GetInstance();
     game.isPaused = true;
     mode          = direction;
     this.pipe     = pipe;
     SoundManager.shrink.Play();
 }
Пример #9
0
 public DeadGameState(Mario mario)
 {
     game       = Game1.GetInstance();
     this.mario = mario;
     SoundManager.StopMusic();
     SoundManager.death.Play();
     mario.isDead = true;
 }
Пример #10
0
        public DeadFlipMS(Mario mario)
        {
            ISpriteFactory factory = new SpriteFactory();

            Sprite     = factory.build(SpriteFactory.sprites.deadMario);
            this.mario = mario;
            Game1.GetInstance().gameState = new DeadFlipGameState(mario);
        }
Пример #11
0
 public TransitionGameState(Mario mario, IMarioState prevState, IMarioState newState)
 {
     game           = Game1.GetInstance();
     this.mario     = mario;
     this.prevState = prevState;
     this.newState  = newState;
     currentState   = prevState;
 }
Пример #12
0
 public void Spawn()
 {
     Game1.GetInstance().level.levelItems.Add(this);
     SoundManager.coinCollect.Play();
     Game1.GetInstance().gameHUD.Coins++;
     position   = position - spawnAdjust;
     isSpawning = true;
 }
Пример #13
0
 public GameOverState()
 {
     game            = Game1.GetInstance();
     game.isGameOver = true;
     font            = game.Content.Load <SpriteFont>(StringHolder.bigTextFont);
     SoundManager.StopMusic();
     SoundManager.gameOver.Play();
 }
Пример #14
0
 public LivesScreenGameState()
 {
     game = Game1.GetInstance();
     game.gameHUD.Lives--;
     font = game.Content.Load <SpriteFont>(StringHolder.bigTextFont);
     game.keyboardController = new PauseMenuKeyController();
     game.gameHUD.Time       = ValueHolder.startingTime;
     game.gameHUD.textColor  = ValueHolder.blackScreenText;
 }
Пример #15
0
 public GroundState(Mario mario)
 {
     mario.state.Land();
     mario.velocity.Y = 0;
     this.mario       = mario;
     Game1.GetInstance().gameHUD.pointMultiplier = 1;
     mario.isJumping = false;
     mario.isFalling = false;
 }
Пример #16
0
 public PauseGameState()
 {
     game                    = Game1.GetInstance();
     game.isPaused           = true;
     game.keyboardController = new PauseMenuKeyController();
     game.gamepadController  = new PauseMenuGamepadController();
     SoundManager.pause.Play();
     game.gameHUD.PausedCheck = true;
 }
Пример #17
0
 public void Execute()
 {
     Game1.GetInstance().level = new Level(StringHolder.levelOne);
     Game1.GetInstance().background.CurrentSprite = Game1.GetInstance().background.OverworldSprite;
     Game1.GetInstance().gameState = new TitleScreenGameState();
     Game1.GetInstance().isTitle = true;
     Game1.GetInstance().gameHUD.Coins = 0;
     Game1.GetInstance().gameHUD.Lives = ValueHolder.startingLives;
     Game1.GetInstance().gameHUD.Score = 0;
 }
Пример #18
0
 public Level(string fileName)
 {
     this.game = Game1.GetInstance();
     builder   = new LevelBuilder(this);
     mario     = builder.Build(fileName);
     game.gameCamera.LookAt(mario.position);
     collision         = new CollisionDetector(mario, game);
     exitPole          = new GateSprite(Game1.gameContent.Load <Texture2D>("Items/gateFramedFinal"), 2, 23);
     game.gameHUD.Time = ValueHolder.startingTime;
 }
Пример #19
0
 public VictoryGameState()
 {
     game           = Game1.GetInstance();
     game.isVictory = true;
     SoundManager.StopMusic();
     SoundManager.clear.Play();
     right = new RightCommand(game.level.mario);
     game.gameHUD.gameEnded = true;
     game.ach.AchievementAdjustment(AchievementsManager.AchievementType.Level);
 }
Пример #20
0
 public void Update(GameTime gameTime)
 {
     mario.position.X += mario.velocity.X * ((float)gameTime.ElapsedGameTime.Milliseconds / positionDtAdjust);
     mario.velocity.X *= speedDecayRate;
     mario.position.Y += gravityStrength;
     if (Game1.GetInstance().level.collision.standingBlocks.Count > 0)
     {
         mario.physState = new VVVVVVGroundState(mario, mario.gravityDirection);
     }
 }
Пример #21
0
 public SuperMarioGameState()
 {
     game = Game1.GetInstance();
     game.keyboardController  = new KeyboardController(game.level.mario);
     game.gamepadController   = new GamepadController(game.level.mario);
     game.gameHUD.PausedCheck = false;
     game.gameHUD.gameEnded   = false;
     game.isVVVVVV            = false;
     game.isVictory           = false;
 }
Пример #22
0
 public void TakeDamage()
 {
     if (Game1.GetInstance().isVVVVVV)
     {
         mario.state = new DeadFlipMS(mario);
     }
     else
     {
         mario.state = new DeadMS(mario);
     }
 }
Пример #23
0
 public void Update(GameTime gameTime)
 {
     if (isExploding)
     {
         explosionTimer--;
     }
     if (explosionTimer < 0)
     {
         Game1.GetInstance().level.collision.destroyedBlocks.Add(this);
     }
     state.Update(gameTime, this);
 }
Пример #24
0
 public VVVVVVGameState()
 {
     game = Game1.GetInstance();
     game.level.mario.physState    = new VVVVVVGroundState(game.level.mario, 1);
     game.keyboardController       = new VVVVVVKeyController(game.level.mario);
     game.gamepadController        = new VVVVVVPadController(game.level.mario);
     game.background.CurrentSprite = new NullSprite();
     game.gameHUD.PausedCheck      = false;
     game.gameHUD.gameEnded        = false;
     game.isVVVVVV = true;
     game.isTitle  = false;
 }
Пример #25
0
 public void Execute()
 {
     if (Game1.GetInstance().isPaused)
     {
         Game1.GetInstance().gameState = new SuperMarioGameState();
         Game1.GetInstance().isPaused  = false;
     }
     else
     {
         Game1.GetInstance().gameState = new PauseGameState();
     }
 }
Пример #26
0
        public void Update(GameTime gameTime)
        {
            mario.velocity.Y = 0;
            mario.position  += mario.velocity * ((float)gameTime.ElapsedGameTime.Milliseconds / positionDtAdjust);

            mario.velocity *= speedDecayRate;
            if (Game1.GetInstance().level.collision.standingBlocks.Count == 0 &&
                Game1.GetInstance().level.collision.standingPipes.Count == 0)
            {
                mario.physState = new FallingState(mario);
            }
        }
Пример #27
0
 public void Update(GameTime gameTime)
 {
     songTimer--;
     if (songTimer < 0)
     {
         Game1.GetInstance().level = new Level(StringHolder.levelOne);
         Game1.GetInstance().background.CurrentSprite = Game1.GetInstance().background.OverworldSprite;
         Game1.GetInstance().gameState = new TitleScreenGameState();
         Game1.GetInstance().isTitle = true;
         Game1.GetInstance().gameHUD.Coins = 0;
         Game1.GetInstance().gameHUD.Lives = 3;
         Game1.GetInstance().gameHUD.Score = 0;
     }
 }
Пример #28
0
 public void Execute()
 {
     Game1.GetInstance().level = new Level(levelName);
     if (levelName == StringHolder.levelOne)
     {
         Game1.GetInstance().gameState = new SuperMarioGameState();
         SoundManager.PlaySong(SoundManager.songs.overworld);
     }
     if (levelName == StringHolder.levelTwo)
     {
         Game1.GetInstance().gameState = new VVVVVVGameState();
         SoundManager.PlaySong(SoundManager.songs.vmusic);
     }
     Game1.GetInstance().isTitle = false;
 }
Пример #29
0
 public TitleScreenGameState()
 {
     factory = new SpriteFactory();
     logo    = factory.build(SpriteFactory.sprites.title);
     SoundManager.PlaySong(SoundManager.songs.title);
     game = Game1.GetInstance();
     menu = new GUI(game);
     menu.options.Add(new KeyValuePair <ICommands, String>(new LoadLevelCommand(StringHolder.levelOne), "Level 1"));
     menu.options.Add(new KeyValuePair <ICommands, String>(new LoadLevelCommand(StringHolder.levelTwo), "Level 2"));
     menu.options.Add(new KeyValuePair <ICommands, String>(new LoadAchPageCommand(), "Achievements"));
     menu.options.Add(new KeyValuePair <ICommands, String>(new QuitCommand(), "Quit"));
     menu.currentCommand     = menu.options[0].Key;
     game.keyboardController = new TitleKeyController(menu);
     game.gamepadController  = new TitlePadController(menu);
 }
 public AchievementMenuGameState()
 {
     game = Game1.GetInstance();
     menu = new GUI(game);
     menu.options.Add(new KeyValuePair <ICommands, String>(new LoadMenuCommand(), "Back"));
     menu.currentCommand     = menu.options[0].Key;
     game.keyboardController = new TitleKeyController(menu);
     game.gamepadController  = new TitlePadController(menu);
     achCoins    = Game1.gameContent.Load <Texture2D>("Achievements/achCoins");
     achFall     = Game1.gameContent.Load <Texture2D>("Achievements/achFall");
     achFireball = Game1.gameContent.Load <Texture2D>("Achievements/achFireball");
     achHitEnemy = Game1.gameContent.Load <Texture2D>("Achievements/achHitEnemy");
     achLife     = Game1.gameContent.Load <Texture2D>("Achievements/achLife");
     achLevel    = Game1.gameContent.Load <Texture2D>("Achievements/achLevel");
     achMushroom = Game1.gameContent.Load <Texture2D>("Achievements/achMushroom");
     font        = Game1.gameContent.Load <SpriteFont>("Fonts/SpriteFont1");
     menu.textStartingPosition.Y += 25;
     menu.coinStartingPosition.Y += 25;
 }