コード例 #1
0
ファイル: Level.cs プロジェクト: s2hd/S2HD-prototype
        private void LoadLayout(string path)
        {
            FileStream   fs = new FileStream(path, FileMode.Open);
            BinaryReader br = new BinaryReader(fs);

            br.ReadString();
            br.ReadString();

            // Chunk layout
            mChunkColumns = br.ReadInt32();
            mChunkRows    = br.ReadInt32();
            mChunkLayout  = new byte[mChunkColumns, mChunkRows];
            for (int y = 0; y < mChunkRows; y++)
            {
                for (int x = 0; x < mChunkColumns; x++)
                {
                    mChunkLayout[x, y] = br.ReadByte();
                }
            }

            // Objects
            mObjectDefinitions.Clear();
            int numObjects = br.ReadInt32();

            for (int i = 0; i < numObjects; i++)
            {
                LevelObjectDefinition definition = new LevelObjectDefinition();

                definition.Id            = br.ReadInt32();
                definition.SubType       = br.ReadInt32();
                definition.DisplacementX = br.ReadInt32();
                definition.DisplacementY = br.ReadInt32();
                definition.Respawn       = br.ReadBoolean();
                definition.FlipY         = br.ReadBoolean();
                definition.FlipX         = br.ReadBoolean();

                if (definition.Id == 1)
                {
                    mStartX = definition.DisplacementX;
                    mStartY = definition.DisplacementY;
                }

                LevelObject obj = LevelObject.Create(mGame, this, definition);
                if (obj != null)
                {
                    mObjects.Add(obj);
                }

                mObjectDefinitions.Add(definition);
            }

            br.Close();
            fs.Close();
        }
コード例 #2
0
ファイル: Level.cs プロジェクト: s2hd/S2HD-prototype
        public void Restart()
        {
            mObjects = new LevelObjectManager();
            mSounds.Clear();

            mPlayerBoundary  = new Microsoft.Xna.Framework.Rectangle(16, 0, 11264 - 16, 1024);
            mVisibleBoundary = new Microsoft.Xna.Framework.Rectangle(0, 0, 10976, 1024);

            mObjects.Clear();
            foreach (LevelObjectDefinition def in mObjectDefinitions)
            {
                LevelObject obj = LevelObject.Create(mGame, this, def);
                if (obj != null)
                {
                    mObjects.Add(obj);
                }
            }
        }