Beispiel #1
0
        private bool GenerateMapByStrings(List <int> stringList)
        {
            try {
                Texture2D tileTex   = socket.Content.Load <Texture2D>("Image/tile");
                var       totalRows = stringList[0];

                int PADDING = 160 + tileTex.Height;

                const int OFFSET     = 1;
                const int BLOCK_SIZE = 2;

                _tiles = new JumperTile[totalRows];
                for (int i = 0; i < totalRows; i++)
                {
                    int     posInPercent = stringList[OFFSET + i * BLOCK_SIZE];
                    int     type         = stringList[OFFSET + i * BLOCK_SIZE + 1];
                    Vector2 position     = new Vector2((stage.X - tileTex.Width) / 100 * posInPercent,
                                                       (stage.Y - tileTex.Height) - (i * PADDING) - PADDING);

                    _tiles[i] = new JumperTile(socket, _spriteBatch, tileTex, position, stage, (JumperTile.TileType)type);
                }

                _tiles.Last().isLast = true;

                return(true);
            } catch (Exception e) {
                MessageBox.Show("Error occurred when generating map, file may corrupted", "Jumper", MessageBoxButtons.OK, MessageBoxIcon.Error);
                _tiles = null;
                return(false);
            }
        }
Beispiel #2
0
 public CollisionManager(Game game, JumperMain main, JumperMan man, JumperTile tile, Vector2 stage) : base(game)
 {
     this.man   = man;
     this.tile  = tile;
     this.stage = stage;
     this.game  = game;
     this.main  = main;
     jumpEffect = game.Content.Load <SoundEffect>("Sound/jump");
 }