public BrickBlock(IFactory spriteFactory, Point positionInGame) : base(spriteFactory, positionInGame, new Vector2()) { this.sprite = this.spriteFactory.CreateProduct(BlockTypes.Brick); State = new BrickStillState(this); BlockUpdateEvent.GetInstance().AbovegroundBlockUpdate += this.OnAbovegroundBlobkUpdate; BlockUpdateEvent.GetInstance().UndergroundBlockUpdate += this.OnUndergroundBlockUpdate; }
public override void Update() { this.mario.IsCollidable = false; this.mario.gravity.Disable(); this.mario.YSpeed = 1.0f; this.mario.XSpeed = 0.0f; this.mario.ChangeActionState(new MarioJumpState(this.mario, false, lastAction)); if (this.mario.IsFacingLeft) { this.mario.Sprite = this.mario.SpriteFactory.CreateProduct(MarioTypes.IdleLeft); } else { this.mario.Sprite = this.mario.SpriteFactory.CreateProduct(MarioTypes.IdleRight); } if (this.mario.PositionInGame.Y >= this.descendDistance) { this.mario.gravity.Enable(); this.mario.PositionInGame = new Point(warpX, warpY); if (warpX > Camera.AquireInstance().LevelWidth + 512) { int width = Camera.AquireInstance().VirtualWidth; int height = Camera.AquireInstance().VirtualHeight; Camera.AquireInstance().Limits = new Rectangle(Camera.AquireInstance().LevelWidth + width, 0, width * 10, height); BlockUpdateEvent.GetInstance().ChangeBlocksToUndergroundBlocks(); PortalGun.ResetPortals(); } else if (warpX > Camera.AquireInstance().LevelWidth) { int width = Camera.AquireInstance().VirtualWidth; int height = Camera.AquireInstance().VirtualHeight; Camera.AquireInstance().Limits = new Rectangle(Camera.AquireInstance().LevelWidth, 0, width, height); BlockUpdateEvent.GetInstance().ChangeBlocksToUndergroundBlocks(); PortalGun.ResetPortals(); } else { int height = Camera.AquireInstance().VirtualHeight; Camera.AquireInstance().Limits = new Rectangle(0, 0, Camera.AquireInstance().LevelWidth, height); BlockUpdateEvent.GetInstance().ChangeBlocksToAbovegroundBlocks(); PortalGun.ResetPortals(); } this.mario.ChangeActionState(new MarioJumpState(this.mario, false, lastAction)); this.mario.ChangePowerUpState(new PipeExitState(this.mario, lastAction, lastPower)); this.mario.IsCollidable = true; } }
public FloorBlock(IFactory spriteFactory, Point positionInGame) : base(spriteFactory, positionInGame, new Vector2()) { this.sprite = this.spriteFactory.CreateProduct(BlockTypes.Floor); BlockUpdateEvent.GetInstance().AbovegroundBlockUpdate += this.OnAbovegroundBlobkUpdate; BlockUpdateEvent.GetInstance().UndergroundBlockUpdate += this.OnUndergroundBlockUpdate; }