public PickupManager(Game game, SosEngine.Level level, GameComponentCollection gameComponents) : base(game) { spriteFrameCache = new SosEngine.SpriteFrameCache(); for (int y = 0; y < level.Height; y++) { for (int x = 0; x < level.Width; x++) { int block = level.GetBlock("Pickups", x, y); if (block > 0) { string spriteFrameName = GetSpriteFrameNameForBlock(block); Pickup pickup = new Pickup(game, spriteFrameName, block, x * 16, y * 16, animationDelay, 100, spriteFrameCache); if (IsHiddenItem(block)) { pickup.Visible = false; } if (IsAnimatedItem(block)) { string spriteFrameName2 = GetSpriteFrameNameForBlock(block + 1); pickup.AddFrame(spriteFrameName2, animationDelay); pickup.AddFrame(GetSpriteFrameNameForBlock(block + 2), animationDelay); pickup.AddFrame(GetSpriteFrameNameForBlock(block + 3), animationDelay); } pickup.DrawOffsetX = 0; gameComponents.Add(pickup); AddSprite(pickup); } } } }
public static void SpawnLadderPart(SosEngine.Level level) { int y = 8; while (level.GetBlock("Block", 32, y) != 0) { y--; } level.PutBlock("Block", 32, y, 284); level.PutBlock("Block", 33, y, 285); }
public EntityManager(Game game, SosEngine.Level level) : base(game) { this.newEntitiesQueue = new List <BaseEntity>(); this.game = game; this.level = level; this.bulletSpawnerManager = new BulletSpawnerManager(game, level, this); for (int y = 0; y < level.Height; y++) { for (int x = 0; x < level.Width; x++) { int block = level.GetBlock("Items", x, y); if (block == EntityManager.GoombaBlock) { level.RemoveBlock("Items", x, y); AddEntity(new Goomba(game, x * 16, y * 16, level)); } } } }
/// <summary> /// Handles block hitting. /// </summary> /// <returns></returns> protected bool HandleHitBlock() { var stopJumping = false; int x = BoundingBox.X + (BoundingBox.Width / 2); int y = BoundingBox.Y + 4; var bx = 0; var by = 0; var block = level.GetBlockAtPixel("Block", x - 2, y, out bx, out by); if (block == 0) { block = level.GetBlockAtPixel("Block", x + 2, y, out bx, out by); } var item = level.GetBlock("Items", bx, by); if (Helpers.LevelHelper.IsWall(block)) { if (Helpers.LevelHelper.IsQuestionBlock(block)) { level.StopTileAnimationAt("Block", bx, by); level.PutBlock("Block", bx, by, 67); level.BounceBlock("Block", bx, by); } else if (Helpers.LevelHelper.IsBreakableBlock(block)) { if (item != 0) { level.PutBlock("Block", bx, by, 67); level.BounceBlock("Block", bx, by); } else { if (isTiny) { level.BounceBlock("Block", bx, by); } else { level.RemoveBlock("Block", bx, by); EntityManager.AddEntity(new BreakBlockEffect(this.Game, "break_block_1", (bx * 16), (by * 16), BreakBlockEffect.Placement.UpperLeft)); EntityManager.AddEntity(new BreakBlockEffect(this.Game, "break_block_1", (bx * 16), (by * 16), BreakBlockEffect.Placement.UpperRight)); EntityManager.AddEntity(new BreakBlockEffect(this.Game, "break_block_1", (bx * 16), (by * 16), BreakBlockEffect.Placement.LowerLeft)); EntityManager.AddEntity(new BreakBlockEffect(this.Game, "break_block_1", (bx * 16), (by * 16), BreakBlockEffect.Placement.LowerRight)); SosEngine.Core.PlaySound("BrickShatter"); } } } stopJumping = true; } if (item > 0) { level.RemoveBlock("Items", bx, by); switch (item) { case 1: if (isTiny) { EntityManager.AddEntity(new Mushroom(this.Game, "mushroom", Mushroom.MushroomTypes.Mushroom, bx * 16, (by * 16), level)); } else { EntityManager.AddEntity(new Flower(this.Game, bx * 16, (by * 16), level)); } break; case 2: EntityManager.AddEntity(new Mushroom(this.Game, "1up_mushroom", Mushroom.MushroomTypes.OneUp, bx * 16, (by * 16), level)); break; case 3: EntityManager.AddEntity(new Mushroom(this.Game, "deadly_mushroom", Mushroom.MushroomTypes.Deadly, bx * 16, (by * 16), level)); break; case 4: EntityManager.AddEntity(new CoinEffect(this.Game, bx * 16, (by - 1) * 16)); AddScore(200, true, (bx * 16) + 8, (by - 1) * 16); level.PutBlock("Block", bx, by, 67); level.BounceBlock("Block", bx, by); break; } if (block == 0) { level.PutBlock("Block", bx, by, 67); level.BounceBlock("Block", bx, by); } stopJumping = true; } return(stopJumping); }