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 Pipe(Game game, Rectangle rect, SosEngine.Level level, PipeTypes pipeType, string destination) :
     base(game, "", 0, 0)
 {
     this.rect = rect;
     if (rect.Width > rect.Height)
     {
         this.Orientation = PipeOrientation.Horizontal;
         if (pipeType == PipeTypes.Entrance)
         {
             this.rect.Inflate(-4, -4);
             this.rect.Offset(0, -8);
         }
     }
     else
     {
         this.Orientation = PipeOrientation.Vertical;
         if (pipeType == PipeTypes.Entrance)
         {
             this.rect.Inflate(-4, -4);
             this.rect.Offset(-4, 0);
         }
     }
     this.level       = level;
     this.PipeType    = pipeType;
     this.destination = destination;
 }
Exemple #3
0
 public BulletSpawner(Game game, SosEngine.Level level, int x, int y) :
     base(game)
 {
     this.level = level;
     this.X     = x;     // Center
     this.Y     = y - 8; // Top
 }
 public Editor(Game game, SosEngine.Level level) : base(game, null)
 {
     this.font        = SosEngine.Core.GetBitmapFont("font");
     this.level       = level;
     this.mouseCursor = new SosEngine.MouseCursor(game, "mouse_pointer", "mouse_grab");
     this.Visible     = false;
 }
Exemple #5
0
 public Player(Game game, string spriteFrameName, SosEngine.Level level = null) :
     base(game, spriteFrameName)
 {
     this.level  = level;
     this.isTiny = true;
     this.pipes  = new List <Pipe>();
     Reset();
 }
 public Enemy(Game game, string spriteFrameName, int x, int y, Vector2 speed, SosEngine.Level level, int delay = 0) :
     base(game, spriteFrameName, x, y, speed, level, delay)
 {
     IsActive = false;
     IsKilled = false;
     CanBeKilledByFireball    = true;
     CanCollideWithOtherEnemy = true;
 }
Exemple #7
0
 public BaseEntity(Game game, string spriteFrameName, int x, int y, Vector2 speed, SosEngine.Level level, int delay = 0)
     : base(game, spriteFrameName, delay)
 {
     this.Position         = new Vector2(x, y);
     this.speed            = speed;
     this.level            = level;
     this.fallSpeed        = 1f;
     this.maxJumpCount     = 8;
     this.initialJumpSpeed = 3f;
 }
Exemple #8
0
        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 Flower(Game game, int x, int y, SosEngine.Level level) :
     base(game, "flower_0", x, y, new Vector2(1, 0), level, 20)
 {
     SosEngine.Core.PlaySound("ItemSprout");
     AddFrame("flower_1", 20);
     AddFrame("flower_2", 20);
     AddFrame("flower_3", 20);
     this.isAppearing = true;
     this.hasGravity  = false;
     this.Position    = new Vector2(Position.X, Position.Y - 4);
 }
Exemple #10
0
        /// <summary>
        /// Get player start position in pixels.
        /// </summary>
        /// <param name="level"></param>
        /// <param name="playerName">Name of object</param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        public static void GetPlayerStartPosition(SosEngine.Level level, string playerName, out int x, out int y)
        {
            x = 0;
            y = 0;
            List <SosEngine.LevelObject> players = level.GetLevelObjects("Objects", "Player");

            if (players.Exists(p => p.Name == playerName))
            {
                SosEngine.LevelObject player = players.Find(p => p.Name == playerName);
                x = player.X;
                y = player.Y;
            }
        }
 public Bullet(Game game, int x, int y, int playerX, SosEngine.Level level) :
     base(game, "bullet_1", x, y, Vector2.Zero, level, 80)
 {
     AddFrame("bullet_2", 80);
     AddFrame("bullet_3", 80);
     AddFrame("bullet_2", 80);
     if (playerX < x + level.GetScrollX())
     {
         Position += new Vector2(-24, 0);
         speed     = new Vector2(-1.8f, 0);
     }
     else
     {
         Position += new Vector2(8, 0);
         speed     = new Vector2(1.8f, 0);
         Flipped   = true;
     }
     IsActive = true;
 }
        public PlayScene(Game game)
            : base(game)
        {
            // Create player with default sprite frame
            player = new Player(game, "down_0");
            // Center player on screen
            player.CenterOnScreen();

            // Create level and load tiles
            level = new SosEngine.Level(game, "test", 0, 0);

            // Add components (in correct draw order)
            AddGameComponent(level);
            AddGameComponent(player);

            /*
             * var editor = new SosEngine.Editor(game, level);
             * editor.Visible = true;
             * AddGameComponent(editor);
             */
        }
        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));
                    }
                }
            }
        }
Exemple #14
0
        public static void SetupTileAnimation(SosEngine.Level level)
        {
            var tileAnimationDefinitions = new List <SosEngine.TileAnimationDefinition>();

            // [?]
            tileAnimationDefinitions.Add(new SosEngine.TileAnimationDefinition
            {
                Block    = 97,
                Sequence = new int[] { 97, 98, 99 },
            });
            // Lava
            tileAnimationDefinitions.Add(new SosEngine.TileAnimationDefinition
            {
                Block    = 100,
                Sequence = new int[] { 100, 101, 102, 103, 104, 105, 106, 107 },
            });
            // Grass
            tileAnimationDefinitions.Add(new SosEngine.TileAnimationDefinition
            {
                Block    = 108,
                Sequence = new int[] { 108, 140, 172, 140 },
            });
            // Grass
            tileAnimationDefinitions.Add(new SosEngine.TileAnimationDefinition
            {
                Block    = 109,
                Sequence = new int[] { 109, 141, 173, 141 },
            });
            // Grass
            tileAnimationDefinitions.Add(new SosEngine.TileAnimationDefinition
            {
                Block    = 110,
                Sequence = new int[] { 110, 142, 174, 142 },
            });

            level.TileAnimationDefinitions = tileAnimationDefinitions;
        }
Exemple #15
0
 public Fireball(Game game, int x, int y, Vector2 speed, SosEngine.Level level)
     : base(game, "fireball", x, y, speed, level)
 {
     hasGravity = true;
 }
 public Goomba(Game game, int x, int y, SosEngine.Level level) :
     base(game, "goomba", x, y, new Vector2(0.6f, 0), level, 100)
 {
     this.hasGravity      = true;
     this.movingDirection = MovingDirection.Left;
 }
 public Mushroom(Game game, string spriteFrameName, MushroomTypes mushroomType, int x, int y, SosEngine.Level level) :
     base(game, spriteFrameName, x, y, new Vector2(1, 0), level)
 {
     SosEngine.Core.PlaySound("ItemSprout");
     this.MushroomType    = mushroomType;
     this.isAppearing     = true;
     this.movingDirection = MovingDirection.Right;
     this.hasGravity      = true;
     this.Position        = new Vector2(Position.X, Position.Y - 4);
 }
        public PlayScene(Game game, string levelName, PlayerStats playerStats = null, PlayScene mainScene = null)
            : base(game)
        {
            this.levelName = levelName;

            replay = new SosEngine.Replay("C:\\Temp\\mario.rec", SosEngine.Replay.Mode.Standby);

            BackgroundColor = new Color(0, 128, 240);
            font            = SosEngine.Core.GetBitmapFont("font");

            //
            // Level
            //
            level = new SosEngine.Level(game, levelName, 0, 0);
            Mario.Helpers.LevelHelper.SetupTileAnimation(level);
            level.SetupAnimatedTiles("Block");
            level.HideLayer("Items");

            var backgroundImage = level.GetCustomProperty("BackgroundImage");

            if (backgroundImage != "")
            {
                background = SosEngine.Core.LoadTextureWithoutCache("bg_sky");
                SetBackground(background);
            }
            else
            {
                BackgroundColor = new Color(0, 0, 0);
            }

            var parallax2Objects = level.GetLevelObjects("Objects", "Parallax2");

            foreach (var levelObject in parallax2Objects)
            {
                level.AddParallaxSprite(new SosEngine.Sprite(game, levelObject.Name, levelObject.X, levelObject.Y), 4);
            }

            var parallax1Objects = level.GetLevelObjects("Objects", "Parallax1");

            foreach (var levelObject in parallax1Objects)
            {
                level.AddParallaxSprite(new SosEngine.Sprite(game, levelObject.Name, levelObject.X, levelObject.Y), 2);
            }

            //
            // Entities
            //
            entityManager = new EntityManager(game, level);

            //
            // Player
            //
            player = new Objects.Player(game, "mario_move_0", level);
            player.MainPlayScene = mainScene;
            player.CenterOnScreen();
            int playerX;
            int playerY;

            Helpers.LevelHelper.GetPlayerStartPosition(level, "Player", out playerX, out playerY);
            player.Position      = new Vector2(playerX - 8, playerY);
            player.EntityManager = entityManager;
            if (playerStats != null)
            {
                player.Stats = playerStats;
            }

            //
            // Hud
            //
            hud                 = new Hud(game);
            hud.ShowFps         = false;
            hud.ShowSpecialKeys = true;
            hud.SetData(1, 1, 100);

            //
            // Editor
            //
            editor         = new SosEngine.Editor(game, level);
            editor.Visible = true;

            gameComponents.Add(level);
            gameComponents.Add(hud);
            gameComponents.Add(entityManager);
            gameComponents.Add(player);
            gameComponents.Add(editor);

            var pipeIns = level.GetLevelObjects("Objects", "PipeIn");

            foreach (var pipeIn in pipeIns)
            {
                var pipe = new Pipe(game, pipeIn.Bounds, level, Pipe.PipeTypes.Entrance, pipeIn.Name);
                AddGameComponent(pipe);
                player.AddPipe(pipe);
            }

            var pipeOuts = level.GetLevelObjects("Objects", "PipeOut");

            foreach (var pipeOut in pipeOuts)
            {
                var pipe = new Pipe(game, pipeOut.Bounds, level, Pipe.PipeTypes.Exit, pipeOut.Name);
                AddGameComponent(pipe);
                player.AddPipe(pipe);
            }
        }