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));
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <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);
        }