public GrowingMarioTransitionDecorator(IMario mario) { this.mario = mario; SoundEffectManager.PowerPlayerUpEffect(); WorldManager.SetPlayer(this); frame = 0; }
public ThrowFireLeftDecorator(IMario mario, Game1 game) { this.mario = mario; this.myGame = game; WorldManager.SetPlayer(this); sprite = MarioSpriteFactory.CreateFireThrowLeft(); }
public PacMarioDeadState(IMario mario) { this.mario = mario; BackgroundThemeManager.PlayPacMarioDeathTheme(); mario.Sprite = SpriteFactories.PacMarioSpriteFactory.CreateDeadPacMarioSprite(); mario.Physics.ResetPhysics(); }
public SmallToFireMarioState(bool facingRight, int row, IMario mario) : base(facingRight, row, mario) { delay = Utility.STATE_CHANGE_DELAY; SprintFourGame.GetInstance().Pause(mario); velocity = mario.Velocity; mario.Velocity = Vector2.Zero; }
public void Collect(IMario player) { if(Spawning) return; Game.Components.Add(new HUD.TempMessage(Utility.UP, Position)); ++HUD.Overlay.Lives; Remove(); }
public StarMarioDecorator(IMario mario, Game1 game) { this.mario = mario; this.myGame = game; WorldManager.SetPlayer(this); BackgroundThemeManager.PlayStarTheme(); factory = new FireBallSpawner(game); }
public void Collect(IMario player) { if(Spawning) return; if(!player.IsBig()) player.SetBig(); Remove(); Game.Components.Add(new TempMessage(Utility.ITEM_SCORE.ToString(), Position)); Overlay.Score += Utility.ITEM_SCORE; }
public void Collect(IMario player) { if (persist) SoundManager.PlayItemSound(this); Remove(); Game.Components.Add(new TempMessage(Utility.COIN_SCORE.ToString(), Position)); ++Overlay.CoinCount; Overlay.Score += Utility.COIN_SCORE; }
protected MarioStateBase(bool facingRight, int row, IMario mario) { Mario = mario; Row = row; FacingRight = facingRight; if (mario == null) return; mario.Sprite.FrameCounter = Utility.ZERO; }
public DeadMarioState(IMario mario) { this.mario = mario; this.mario.IsDead = true; BackgroundThemeManager.PlayDeathTheme(); mario.Sprite = SpriteFactories.MarioSpriteFactory.CreateDeadSprite(); mario.Physics.ResetPhysics(); mario.Physics.Velocity = new Vector2(0, MarioStateConstants.DEADMARIOYVELOCITY); }
public void Collect(IMario player) { if(Spawning)return; Game.Components.Add(new Guns.Recticle()); SoundManager.PlayItemSound(this); Game.Components.Add(new TempMessage(Utility.ITEM_SCORE.ToString(), Position)); Overlay.Score += Utility.ITEM_SCORE; Remove(); }
public void PlayerTrigger(IMario mario) { if (!(mario.CurrentState is CrouchingMarioState) || playerTransitioning) return; playerTransitioning = true; player = mario; timer = Utility.ZERO; playerY = mario.Position.Y; mario.IsInWarpPipe = true; SoundManager.Pause(); SoundManager.PlayDamageOrPipeSound(); }
public void PlayerTrigger(IMario mario) { if (!(mario.CurrentState is RunningMarioState) || !(mario.Velocity.X > Utility.ZERO) || playerTransitioningIn || playerTransitioningOut) return; playerTransitioningIn = true; player = mario; timer = Utility.ZERO; playerX = mario.Position.X; SoundManager.Pause(); SoundManager.PlayDamageOrPipeSound(); }
public NormalLeftJumpingState(IMario mario) { this.mario = mario; mario.Sprite = SpriteFactories.MarioSpriteFactory.CreateNormalLeftJumpingSprite(); if (!mario.MarioState.IsJumping()) { Vector2 velocity = this.mario.Physics.Velocity; velocity.Y = MarioStateConstants.INITIALJUMPVELOCITY; this.mario.Physics.Velocity = velocity; SoundEffectManager.SuperMarioJumpEffect(); } }
public static void PlayerEnemyCollision(IMario player, IEnemy enemy) { if (player.CurrentState is DeadMarioState) return; Vector2 direction = GetCollisionDirection(player.Bounds, enemy.Bounds); player.Position += direction * GetPenetration(player.Bounds, enemy.Bounds, direction); enemy.CurrentState.Hit(player, direction); if (!(direction.Y < Utility.ZERO)) return; player.Velocity *= Vector2.UnitX; player.Velocity -= Vector2.UnitY * Utility.VELOCITY_SCALER; }
public virtual void Hit(IMario player, Vector2 direction) { if (player.HasStar()) { Enemy.Kill(); SoundManager.PlayKickSound(); } else if (direction.Y < Utility.ZERO) { Enemy.CurrentState = Enemy is Koopa ? (EnemyStateBase)new KoopaKnockedOutState(Enemy) : new GoombaStompedState(Enemy); player.InvincibilityPulse(Utility.DELAY); SoundManager.PlayStompSound(); } else { player.TakeDamage(); } }
public MarioBlockCollisionHandler(CollisionData collision) { this.collision = collision; collisionSide = (ICollisionSide)collision.CollisionSide; if (collision.GameObjectA is IMario) { collidingMario = (IMario)collision.GameObjectA; collidingBlock = (Block)collision.GameObjectB; } else { collidingMario = (IMario)collision.GameObjectB; collidingBlock = (Block)collision.GameObjectA; collisionSide = collisionSide.FlipSide(); } }
public static void MarioVsTeleportPipeRightCollision(IMario mario, IPipe pipe, Direction direction) { if (!(pipe.Teleported)) { bool isMoving = mario.MovementState is LeftMoving; if (direction == pipe.TeleportDirection && isMoving && MarioInHorizontalSidePipeRange(mario, pipe)) { pipe.Teleported = true; mario.Teleport(pipe.TransferedLocation, ReverseDirection(direction)); } else { MoverHorizontallyBlock(mario, pipe, direction); } } }
public MarioItemCollisionHandler(CollisionData collision, IGameState gameState) { this.gameState = gameState; if (collision.GameObjectA is IMario) { collidingMario = (IMario)collision.GameObjectA; collidingItem = (IItem)collision.GameObjectB; } else { collidingMario = (IMario)collision.GameObjectB; collidingItem = (IItem)collision.GameObjectA; } }
public MarioFlagPoleCollisionHandler(CollisionData collision, IGameState gameState) { this.collision = collision; this.gameState = gameState; if (collision.GameObjectA is IFlagPole) { collidingFlagPole = (IFlagPole)collision.GameObjectA; collidingMario = (IMario)collision.GameObjectB; } else { collidingFlagPole = (IFlagPole)collision.GameObjectB; collidingMario = (IMario)collision.GameObjectA; } }
private static void BlockCollide(IMario mario, IBlock block, Direction direction) { if (direction == Direction.none) { return; } mario.Obstacle(); if (direction == Direction.bottom) { block.Used(); } if (direction == Direction.top) { mario.OnGround(); } }
public MarioBlockHandler(CollisionObject collision, Level level) { if (collision.LeftSlot is IMario) { mario = (IMario)collision.LeftSlot; block = (IBlock)collision.RightSlot; } else { mario = (IMario)collision.RightSlot; block = (IBlock)collision.LeftSlot; } direction = (int)collision.CollisionType; commandList = new List <ICommand>(); Rectangle MarioRectangle = new Rectangle(mario.XCoordinate, mario.YCoordinate, mario.Width, mario.Height); Rectangle BrickBlockRectangle = new Rectangle(block.XCoordinate, block.YCoordinate, block.Width, block.Height); Rectangle result = Rectangle.Intersect(MarioRectangle, BrickBlockRectangle); int deltaX = result.Right - result.Left; int deltaY = result.Bottom - result.Top; if (direction == 0) { commandList.Add(new PushMarioRightCommand(mario, deltaX)); } else if (direction == 1) { commandList.Add(new PushMarioLeftCommand(mario, deltaX)); } else if (direction == 2 && !GlobalVariables.FlipGravity) { commandList.Add(new PushMarioUpCommand(mario, deltaY)); } else if (direction == 3 && !GlobalVariables.FlipGravity) { commandList.Add(new PushMarioDownCommand(mario, deltaY)); commandList.Add(new BumpBlockCommand(block)); } else if (direction == 2 && GlobalVariables.FlipGravity) { commandList.Add(new PushMarioUpCommand(mario, deltaY)); commandList.Add(new BumpBlockCommand(block)); } else if (direction == 3 && GlobalVariables.FlipGravity) { commandList.Add(new PushMarioDownCommand(mario, deltaY)); } }
public IdleMario(IMario mario, bool rightFacing, MarioPowerLevel powerLevel) { switch (powerLevel) { case MarioPowerLevel.Fire: case MarioPowerLevel.Metal: this.Texture = SpriteHolder.FireMario; break; case MarioPowerLevel.Big: this.Texture = SpriteHolder.BigMario; break; case MarioPowerLevel.Small: this.Texture = SpriteHolder.SmallMario; break; } if (powerLevel == MarioPowerLevel.Metal) { this.Color = MarioConfig.MetalMarioColor; OriginalColor = this.Color; } this.Mario = mario; this.Frame = SpriteHolder.IdleMarioFrame; this.Mario.CurrentVelocity = new Vector2(0, 0); if (rightFacing) { this.Flip = SpriteEffects.None; } else { this.Flip = SpriteEffects.FlipHorizontally; } if (MarioPowerLevelGeneralizer.IsBig(powerLevel)) { this.Width = SpriteHolder.BigMarioWidth; } else { this.Width = SpriteHolder.SmallMarioWidth; } this.Height = this.Texture.Height; }
public void StarMario(IMario mario) { for (int i = 0; i < Marios.Count; i++) { if (mario == Marios[i]) { if (mario is StarMario starMario) { starMario.ResetStarTimer(); } else { Marios[i] = new StarMario(mario); } } } }
public void Execute(IGameObject gameObject1, IGameObject gameObject2) { IMario mario = (IMario)gameObject1; if (mario.State.MarioShape == MarioState.MarioShapeEnums.Dead) { return; } IEnemy koopa = (IEnemy)gameObject2; if (koopa.State.GetType() == typeof(KoopaSideDeathState)) { return; } ScoringSystem.PlayerScore(mario.Player).AddPointsForStompingEnemy(gameObject2); koopa.Terminate("DOWN"); }
public void Warp(IMario mario) { if (canWarp) { Camera2D.SetCamera(new Vector2(teleLocation.X - 16 * 2, 0)); mario.Location = teleLocation; SoundManager.Instance.PlayPipeSound(); if (MarioAttributes.Time <= 100) { SoundManager.Instance.PlayHurryUnderworldSong(); } else { SoundManager.Instance.PlayUnderworldSong(); } } }
public MarioEnemyCollisionHandler(CollisionData collision) { this.collision = collision; side = collision.CollisionSide; if (collision.GameObjectA is IMario) { mario = (IMario)collision.GameObjectA; enemy = (IEnemy)collision.GameObjectB; } else { mario = (IMario)collision.GameObjectB; enemy = (IEnemy)collision.GameObjectA; side = side.FlipSide(); } }
public void Execute() { if (secondEntity.BlockState is ActivatedBlockState) { firstEntity.Location = new Vector2(firstEntity.Location.X, firstEntity.Location.Y - collision.Overlap.Height); IPhysics physicsFirstEntity = (IPhysics)firstEntity; physicsFirstEntity.Velocity = new Vector2(physicsFirstEntity.Velocity.X, 0); if (firstEntity is IMario) { IMario player = (IMario)firstEntity; if (player.MovementState is MarioLeftJumpState || player.MovementState is MarioRightJumpState) { player.Idle(); } } } }
public void Update() { if (Game1.Instance.CurrentState == Game1.GameState.Transition) { LookAt(new Point(0, 0)); } else if (Game1.Instance.GameVariables.CurrentlyAlive == 1) { Player1 = Game1.Instance.Marios[0]; if ((Point.X + leftWindowBuffer) > Player1.Location.X) { if (Player1.Location.X - leftWindowBuffer < Game1.Instance.Level.BeginningOfLevel) { LookAt(new Point(Game1.Instance.Level.BeginningOfLevel, 0)); } else { LookAt(new Point((int)Player1.Location.X - (int)leftWindowBuffer, 0)); } } else if ((Point.X + halfPoint) < Player1.Location.X) { LookAt(new Point((int)Player1.Location.X - (int)halfPoint, 0)); } } //If there's a second player, also let that player edit the camera else if (Game1.Instance.GameVariables.CurrentlyAlive == 2) { Player1 = Game1.Instance.Marios[0]; Player2 = Game1.Instance.Marios[1]; double middlePoint = (Player1.Location.X + Player2.Location.X) / 2; double startPoint = middlePoint - Game1.Instance.GameVariables.ScreenWidth / 2; if (startPoint > Game1.Instance.Level.BeginningOfLevel) { LookAt(new Point((int)startPoint, 0)); } else { LookAt(new Point(Game1.Instance.Level.BeginningOfLevel, 0)); } } //else if everyone is dead, point back at the start else { LookAt(new Point(0, 0)); } }
public void Warp(IMario Mario) { if (IsTelable) { if (Mario.IsLevel2) { Mario.IsInWater = true; SoundManager.Instance.PlayPipeSound(); SoundManager.Instance.PlayUnderwaterSong(); switch (Mario.State.MarioShape) { case Shape.Small: Mario.State = new SwimmingRightSmallMarioState(Mario); break; case Shape.Big: Mario.State = new SwimmingRightBigMarioState(Mario); break; case Shape.Fire: Mario.State = new SwimmingRightFireMarioState(Mario); break; } Mario.Velocity = Vector2.Zero; Mario.Location = new Vector2(50, 200); Camera.SetCamera(new Vector2(50 - 16 * 5, 0)); } else { SoundManager.Instance.PlayPipeSound(); random = rd.Next(0, pipeList.Count - 1); IPipe pipe = (IPipe)pipeList[random]; while (pipe.Location.Y > 420) { random = rd.Next(0, pipeList.Count - 1); pipe = (IPipe)pipeList[random]; } Camera.SetCamera(new Vector2(pipe.Destination.X - 16 * 5, 0)); Mario.Velocity = Vector2.Zero; Mario.Location = new Vector2(pipe.Destination.X - 8, pipe.Destination.Y - Mario.Destination.Height); SoundManager.Instance.PlayOverWorldSong(); } } }
public void Warp(IMario mario) { if (IsTelable) { random = rd.Next(0, pipeList.Count - 1); IPipe pipe = (IPipe)pipeList[random]; while (pipe.Location.Y > 420) { random = rd.Next(0, pipeList.Count - 1); pipe = (IPipe)pipeList[random]; } Camera.SetCamera(new Vector2(pipe.Destination.X - 16 * 5, 0)); mario.Velocity = Vector2.Zero; mario.Location = new Vector2(pipe.Destination.X - 8, pipe.Destination.Y - mario.Destination.Height); SoundManager.Instance.PlayPipeSound(); SoundManager.Instance.PlayOverWorldSong(); } }
public static void HandleCollision(IMario mario, IEnemy enemy, CollisionSide side) { if (!(mario.MarioAnimatedState is MarioDeadState) && !mario.Invincible) { if (enemy is Goomba) { MarioGoombaCollision(mario, enemy, side); } else if (enemy is Koopa) { MarioKoopaCollision(mario, enemy, side); } else if (enemy is Jellyfish || enemy is Fish) { mario.TakeDamage(); } } }
public void MarioLandHandling(IMario mario) { if (mario.IsJump()) { if (mario.Physics.XVelocityResponse() >= CollisionUtil.marioMinVelocity) { mario.GoRight(); } else if (mario.Physics.XVelocityResponse() <= -CollisionUtil.marioMinVelocity) { mario.GoLeft(); } else { mario.NoInput(); } } }
public MarioPipeCollisionHandler(CollisionData collision, IGameState gameState) { this.collision = collision; this.gameState = gameState; side = collision.CollisionSide; if (collision.GameObjectA is IMario) { mario = (IMario)collision.GameObjectA; pipe = (IPipe)collision.GameObjectB; } else { mario = (IMario)collision.GameObjectB; pipe = (IPipe)collision.GameObjectA; side = side.FlipSide(); } }
private void buttonDano_Click(object sender, EventArgs e) { estado = objPersonagem.RetornarTipo(); textBoxStatus.Text = Convert.ToString(estado); objPersonagem = objPersonagem.ReceberDano(); estado = "ATINGIDO"; textBoxAção.Text = Convert.ToString(estado); estado = objPersonagem.RetornarTipo(); textBoxNovoStatus.Text = Convert.ToString(estado); if (textBoxNovoStatus.Text == "MARIO MORTO") { estado = "GAME OVER"; textBoxStatus.Text = Convert.ToString(estado); textBoxAção.Text = Convert.ToString(estado); textBoxNovoStatus.Text = Convert.ToString(estado); MessageBox.Show("GAME OVER"); } }
public void Handle(ICollidable player, ICollidable pipe, CollisionDirection.DirectionTag direction) { if (typeof(IMario).IsInstanceOfType(player) && typeof(AbstractPipe).IsInstanceOfType(pipe)) { this.player = (IMario)player; this.pipe = (AbstractPipe)pipe; switch (direction) { case CollisionDirection.DirectionTag.Top: this.player.SetYPosition(this.pipe.GetTopSide() - player.GetHeight()); if (typeof(TeleportationPipe).IsInstanceOfType(pipe) && this.player.IsCrouching()) { ((TeleportationPipe)pipe).Teleport(); } else { this.player.Ground(); } break; case CollisionDirection.DirectionTag.Bottom: this.player.SetYPosition(this.pipe.GetBottomSide() + 1); break; case CollisionDirection.DirectionTag.Left: this.player.SetXPosition(this.pipe.GetLeftSide() - player.GetWidth()); if (typeof(LeftFacingPipe).IsInstanceOfType(this.pipe) && this.player.IsCrouching()) { //IsCrouching need to be changed to IsMovingRight ((LeftFacingPipe)pipe).Teleport(); } break; case CollisionDirection.DirectionTag.Right: this.player.SetXPosition(this.pipe.GetRightSide() + 1); break; default: Console.WriteLine(Config.GetCollisionResolutionException() + GetType().ToString()); break; } } }
public MarioGravityOrb(CollisionObject collision, Level level) { if (collision.LeftSlot is IMario) { mario = (IMario)collision.LeftSlot; orb = (GravityOrb)collision.RightSlot; } else { mario = (IMario)collision.RightSlot; orb = (GravityOrb)collision.LeftSlot; } commandListMario = new List <ICommand>(); commandListMario.Add(new GravityPowerUp(mario)); MusicPlayer.EffectList("powerup").Play(); commandListMario.Add(new DeleteObjectCommand(level, orb)); commandListMario.Add(new ItemScoreCommand(orb)); }
public MarioFireFlowerHandler(CollisionObject collision, Level level) { if (collision.LeftSlot is Mario) { mario = (IMario)collision.LeftSlot; fireflower = (FireFlower)collision.RightSlot; } else { mario = (IMario)collision.RightSlot; fireflower = (FireFlower)collision.LeftSlot; } commandListMario = new List <ICommand>(); commandListMario.Add(new MarioPowerUpCommand(mario)); MusicPlayer.EffectList("powerup").Play(); commandListMario.Add(new DeleteObjectCommand(level, fireflower)); commandListMario.Add(new ItemScoreCommand(fireflower)); }
public void Execute(IGameObject gameObject1, IGameObject gameObject2) { IMario mario = (IMario)gameObject1; IEnemy goomba = (IEnemy)gameObject2; if (mario.State.MarioShape == MarioState.MarioShapeEnums.Dead || !goomba.Alive) { return; } mario.Location = new Vector2(mario.Location.X, goomba.Location.Y - mario.Destination.Height + GameUtilities.SinglePixel); if (goomba.Alive) { mario.Velocity = new Vector2(mario.Velocity.X, GameUtilities.MarioBounceVelocity); ScoringSystem.PlayerScore(mario.Player).AddPointsForStompingEnemy(gameObject2); goomba.Terminate("TOP"); SoundManager.Instance.PlayStompSound(); } }
public void Update(IMario mario, IEnemy enemy) { bool SmartX = Math.Abs(mario.XCoordinate - enemy.XCoordinate) < 64; bool SmartY = Math.Abs((mario.YCoordinate + mario.Height) - (enemy.YCoordinate + enemy.Height)) < 48; if (!SmartX) { if (enemy.MovementState is EnemyLeftMovementState) { enemy.Left(); } else { enemy.Right(); } } else { if (!SmartY) { enemy.Jump(); if (mario.Velocity[0] > 0) { enemy.RightRun(); } else { enemy.LeftRun(); } } else { if (enemy.MovementState is EnemyLeftMovementState) { enemy.Left(); } else { enemy.Right(); } } } }
public override void Hit(IMario player, Vector2 direction) { if (damageDelay > Utility.ZERO) return; if (player.HasStar()) { Enemy.Kill(); SoundManager.PlayKickSound(); } else if (direction.Y < Utility.ZERO || !CanHarmPlayer()) { if (!CanHarmPlayer()) { Enemy.Velocity = player.Bounds.Center.X <= Enemy.Bounds.Center.X ? new Vector2(Utility.KOOPA_HIT_VELOCITY, Enemy.Velocity.Y) : new Vector2(-Utility.KOOPA_HIT_VELOCITY, Enemy.Velocity.Y); SoundManager.PlayKickSound(); } else Enemy.Velocity = Vector2.Zero; player.InvincibilityPulse(Utility.DELAY); } else { player.TakeDamage(); Enemy.Velocity *= -Utility.ONE; } damageDelay = Utility.DELAY; }
public GamePadController(SuperMarioBros gameClass) { SuperMarioBros superMarioBros = gameClass; IMario mario = superMarioBros.World.Mario; gamePadControllerMap = new Dictionary <Buttons, ICommand> { { Buttons.Start, new QuitCommand(superMarioBros) }, { Buttons.LeftThumbstickUp, new MarioUpCommand(mario) }, { Buttons.LeftThumbstickDown, new MarioCrouchCommand(mario) }, { Buttons.LeftThumbstickLeft, new MarioLeftCommand(mario) }, { Buttons.LeftThumbstickRight, new MarioRightCommand(mario) }, { Buttons.A, new MarioSmallCommand(mario) }, { Buttons.B, new MarioBigCommand(mario) }, { Buttons.X, new MarioFireCommand(mario) }, { Buttons.Y, new MarioDeadCommand(mario) }, // { Buttons.Back, new ResetCommand(superMarioBros)}, }; }
public static void BigOrFireMarioVsQuestionOrItemBrickBlock(IMario mario, IBlock block, Direction direction) { if (block.ItemType != null) { block.Bumped(); GenerateItemInBlock(block.ItemType, block.Position); AudioFactory.Instance.CreateSound(Bump).Play(); } else { block.Used(); GenerateFlower(block.Position); } if (block.ObjState == ObjectState.Destroy) { GenerateUsedBlock(block.Position); } MoverVerticallyBounce(mario, block, direction); }
public MarioMushroomHandler(CollisionObject collision, Level level) { if (collision.LeftSlot is IMario) { mario = (IMario)collision.LeftSlot; mushroom = (Mushroom)collision.RightSlot; } else { mario = (IMario)collision.RightSlot; mushroom = (Mushroom)collision.LeftSlot; } commandListMario = new List <ICommand>(); commandListMario.Add(new MarioPowerUpCommand(mario)); MusicPlayer.EffectList("powerup").Play(); commandListMario.Add(new DeleteObjectCommand(level, mushroom)); commandListMario.Add(new ItemScoreCommand(mushroom)); }
public MarioSuperCrown(CollisionObject collision, Level level) { if (collision.LeftSlot is Mario) { mario = (IMario)collision.LeftSlot; crown = (SuperCrown)collision.RightSlot; } else { mario = (IMario)collision.RightSlot; crown = (SuperCrown)collision.LeftSlot; } commandListMario = new List <ICommand>(); commandListMario.Add(new DoubleJumpPowerUpCommand(mario)); MusicPlayer.EffectList("powerup").Play(); commandListMario.Add(new DeleteObjectCommand(level, crown)); commandListMario.Add(new ItemScoreCommand(crown)); }
private static void BrickBlockMarioCollision(IMario mario, IBlock block, CollisionSide side) { if (mario != null) { if (!block.Collided) { if (side == CollisionSide.Bottom) { block.Collided = true; block.StateMachine.BecomeBroken(); SoundFactory.Instance.CreateBreakBlockSound(); } else { NewLocation(block, mario, side); } } } }
public void Draw(SpriteBatch spriteBatch) { Rectangle coinDestination = new Rectangle(256, 40, 15, 24); Rectangle storedItemDestination = new Rectangle(400, 40, 15, 24); Rectangle fireFlowerDestination = new Rectangle(109, 64, 16, 16); Rectangle iceFlowerDestination = new Rectangle(52, 64, 16, 16); Rectangle redMushroomDestination = new Rectangle(71, 43, 16, 16); spriteBatch.DrawString(font, "Mario", new Vector2(20, 10), Color.White, 0, new Vector2(0, 0), 1.8f, SpriteEffects.None, 0); spriteBatch.DrawString(font, score.ToString().PadLeft(6, '0'), new Vector2(10, 40), Color.White, 0, new Vector2(0, 0), 1.8f, SpriteEffects.None, 0); spriteBatch.Draw(coinSprite, coinDestination, coinSource[3 * frame / cycleLength], Color.White); spriteBatch.DrawString(font, "x" + coins.ToString().PadLeft(2, '0'), new Vector2(280, 35), Color.White, 0, new Vector2(0, 0), 1.8f, SpriteEffects.None, 0); spriteBatch.DrawString(font, "World", new Vector2(700, 10), Color.White, 0, new Vector2(0, 0), 1.8f, SpriteEffects.None, 0); spriteBatch.DrawString(font, "1-1", new Vector2(720, 40), Color.White, 0, new Vector2(0, 0), 1.8f, SpriteEffects.None, 0); spriteBatch.DrawString(font, "Time", new Vector2(950, 10), Color.White, 0, new Vector2(0, 0), 1.8f, SpriteEffects.None, 0); spriteBatch.DrawString(font, time.ToString().PadLeft(3, '0'), new Vector2(955, 40), Color.White, 0, new Vector2(0, 0), 1.8f, SpriteEffects.None, 0); try { mario = Game1.Instance.currentState.Level.Player; if (mario.hasStoredItem) { if (mario.storedItemInt == 1) { spriteBatch.Draw(coinSprite, storedItemDestination, fireFlowerDestination, Color.White); } else if (mario.storedItemInt == 2) { spriteBatch.Draw(coinSprite, storedItemDestination, redMushroomDestination, Color.White); } else if (mario.storedItemInt == 3) { spriteBatch.Draw(coinSprite, storedItemDestination, iceFlowerDestination, Color.Blue); } } } catch { } foreach (FloatingStat stat in screenStats) { stat.Draw(spriteBatch, font); } }
public void Execute(IGameObject gameObject1, IGameObject gameObject2) { IMario mario = (IMario)gameObject1; if (mario.State.MarioShape == MarioState.MarioShapeEnums.Dead) { return; } if (gameObject2.GetType() == typeof(HiddenBlock) && mario.Velocity.Y >= GameUtilities.StationaryVelocity) { return; } IBlock block = (IBlock)gameObject2; mario.Location = new Vector2(mario.Destination.X, block.Destination.Y + block.Destination.Height - GameUtilities.SinglePixel); if (mario.Velocity.Y < GameUtilities.StationaryVelocity) { mario.Velocity = new Vector2(mario.Velocity.X, GameUtilities.StationaryVelocity); if (!((mario.State.MarioShape == MarioState.MarioShapeEnums.Small || mario.State.MarioShape == MarioState.MarioShapeEnums.StarSmall) && (block.GetType() == typeof(BrickBlock) || block.GetType() == typeof(UndergroundBrickBlock)))) { block.Trigger(); } if ((mario.State.MarioShape == MarioState.MarioShapeEnums.Small || mario.State.MarioShape == MarioState.MarioShapeEnums.StarSmall) && (block.GetType() == typeof(BrickBlock) || block.GetType() == typeof(UndergroundBrickBlock))) { int verticalDisplacement = 5 * GameUtilities.SinglePixel; block.Location = new Vector2(block.Location.X, block.Location.Y - verticalDisplacement); SoundManager.Instance.PlayBumpSound(); } if ((mario.State.MarioShape == MarioState.MarioShapeEnums.Big || mario.State.MarioShape == MarioState.MarioShapeEnums.Fire || mario.State.MarioShape == MarioState.MarioShapeEnums.StarBig) && block.GetType() == typeof(QuestionmarkBlock)) { SoundManager.Instance.PlayBumpSound(); } } }
private void RespondToCollisionWithMario(Side side, IMario mario, Rectangle intersectRect) { mario.OnTransPipe = false; mario.TouchingTransPipe = false; if (this.Pipe is PipeTop) { PipeTop pipeTop = (PipeTop)this.Pipe; if (pipeTop.IsTransitional) { if (IsAbleToEnterPipe(side, pipeTop, intersectRect)) { mario.OnTransPipe = true; } else if ((SideGeneralizer.IsLeft(side) || SideGeneralizer.IsRight(side)) && pipeTop.Side) { mario.TouchingTransPipe = true; } } } }
public void Execute(IGameObject gameObject1, IGameObject gameObject2) { IMario mario = (IMario)gameObject1; if (mario.State.MarioShape == MarioState.MarioShapeEnums.Dead) { return; } IItem star = (IItem)gameObject2; if (!star.IsCollected) { star.Collect(); if (mario.State.MarioShape != MarioState.MarioShapeEnums.StarSmall && mario.State.MarioShape != MarioState.MarioShapeEnums.StarBig) { GameUtilities.GameObjectManager.MarioTransition(mario.State.MarioShape, MarioState.MarioShapeEnums.StarSmall, mario); } } }
public MarioFlagHandler(CollisionObject collision, Level level) { if (collision.LeftSlot is IMario) { mario = (IMario)collision.LeftSlot; flag = (Flag)collision.RightSlot; } else { mario = (IMario)collision.RightSlot; flag = (Flag)collision.LeftSlot; } Rectangle MarioRectangle = new Rectangle(mario.XCoordinate, mario.YCoordinate, mario.Width, mario.Height); Rectangle FlagRectangle = new Rectangle(flag.XCoordinate, flag.YCoordinate, flag.Width, flag.Height); Rectangle result = Rectangle.Intersect(MarioRectangle, FlagRectangle); deltaX = result.Right - result.Left; GlobalVariables.FlagDescend = false; }
public InfiniteLevel() { Seed = System.DateTime.Now.Millisecond; rand = new Random(Seed); previousChunk = new Chunk(Vector2.Zero, Utility.STARTING_HEIGHT, rand); currentChunk = new Chunk(Vector2.Zero, Utility.STARTING_HEIGHT, rand); currentChunk.ForceEnemiesOff(); //Having enemies spawn in the first chunk is really annoying while (currentChunk.ChunkXValue < Utility.ChunkLength) currentChunk.Update(); InstantiateNextChunk(); player = SprintFourGame.GetInstance().Mario; player.Position = Utility.MarioStartPos; Level.LevelHeight = Utility.WorldHeight; Level.LevelWidth = int.MaxValue; chunkEndPos = Utility.ChunkLength * Utility.BLOCK_POSITION_SCALE; }
public static void Update(IMario mario) { if (--spawnCounter > Utility.ZERO || instance.CurrentGameState == SprintFourGame.GameState.Winning) return; int cachedPosition = (int)mario.Position.X; Vector2 cachedVelocity = mario.Velocity; int minimumPosition = cachedPosition + (cachedVelocity.X > ActivationVelocity ? LeftDisplacementFast : LeftDisplacementSlow); int maximumPosition = cachedPosition + (cachedVelocity.X > ActivationVelocity ? RightDisplacementFast : RightDisplacementSlow); int componentX; do { componentX = random.Next(minimumPosition, maximumPosition); } while (Math.Abs(componentX - lastPosition) <= BulletDisplacement); lastPosition = componentX; IProjectile currentBill = new BulletBill(new Vector2(componentX, Utility.ZERO)); instance.Components.Add(currentBill); SoundManager.PlayCannonSound(); spawnCounter = CounterDuration; }
public NormalLeftIdleState(IMario mario) { this.mario = mario; mario.Sprite = SpriteFactories.MarioSpriteFactory.CreateNormalLeftIdleSprite(); }
public PacMarioLeftState(IMario mario) { this.mario = mario; mario.Sprite = SpriteFactories.PacMarioSpriteFactory.CreateLeftPacMarioSprite(); }
public JumpingMarioState(bool facingRight, int row, IMario mario) : base(facingRight, row, mario) { }
public void Update() { tempMario = (IMario)WorldManager.ReturnPlayer(); if(updateDelay == IGameStateConstants.UPDATEDELAY){ if (slidingDownPole){ tempMario.MarioState.PoleSlide(); tempMario.Physics.Velocity = new Vector2(0, IGameStateConstants.POLESLIDEVELOCITY); if (tempMario.VectorCoordinates.Y > IGameStateConstants.ENDPOLESLIDECOORDINATE) { slidingDownPole = false; tempMario.MarioState.FlipAroundPole(); } } else if (timer >= IGameStateConstants.FLAGPOLESTATETIMERJUMPMIN && timer < IGameStateConstants.FLAGPOLESTATETIMERJUMPMAX && !(hasJumpedOffPole)) { tempMario.MarioState.Jump(); tempMario.Physics.Velocity = new Vector2(IGameStateConstants.FLAGPOLESTATEMARIOJUMPXVELOCITY, IGameStateConstants.FLAGPOLESTATEMARIOJUMPYVELOCITY); if ((tempMario.VectorCoordinates.Y + tempMario.Sprite.SpriteDimensions.Y) > IGameStateConstants.FLAGPOLESTATEMARIOHASJUMPEDYCOORDINATE) { hasJumpedOffPole = true; tempMario.MarioState.FlipAroundPole(); } } else if (hasJumpedOffPole && !(slidingDownPole) && !(hasWalkedIntoCastle)) { tempMario.Physics.Velocity = new Vector2(IGameStateConstants.FLAGPOLESTATEMARIOWALKINGTOWARDSCASTLEXVELOCITY, 0); tempMario.Physics.Acceleration = new Vector2(0, 0); if (tempMario.VectorCoordinates.X >= IGameStateConstants.FLAGPOLESTATECASTLEDOORXCOORDINATE) { hasWalkedIntoCastle = true; tempMario.Physics.Velocity = new Vector2(0, 0); tempMario.Physics.Acceleration = new Vector2(0, 0); } if (!haveAddedTimePoints) { ScoreManager.HandleRemainingTime(); HUDManager.SetTimeToZero(); haveAddedTimePoints = true; } } else if (hasJumpedOffPole && !(slidingDownPole) && hasWalkedIntoCastle) { tempMario.ToIdle(); tempMario.Physics.Velocity = new Vector2(0, 0); tempMario.Physics.Acceleration = new Vector2(0, 0); int victoryWaitTimer = IGameStateConstants.FLAGPOLESTATEVICTORYWAITTIMER; while (victoryWaitTimer > 0) victoryWaitTimer--; game.gameState = new VictoryScreenGameState(game); game.gameState.LoadContent(); } updateDelay = 0; WorldManager.Update(camera); CollisionManager.Update(this); camera.Update(tempMario); } foreach (IController controller in controllerList) controller.Update(); timer++; updateDelay++; }
public FireLeftTwistState(IMario mario) { this.mario = mario; mario.Sprite = SpriteFactories.MarioSpriteFactory.CreateFireLeftTwistSprite(); }
public PacMarioDownState(IMario mario) { this.mario = mario; mario.Sprite = SpriteFactories.PacMarioSpriteFactory.CreateDownPacMarioSprite(); }