示例#1
0
        public EditLevelDialog(
            int width,
            Point playerStartingPosition,
            LevelType levelType,
            Point exitPosition,
            double scrollSpeed,
            string song,
            bool stopSong,
            Func <EditLevelDialog, bool> validationFunc)
        {
            InitializeComponent();

            // Width
            this.widthTextBox.Text = width.ToString();

            // Starting position
            this.playerXTextBox.Text = playerStartingPosition.X.ToString();
            this.playerYTextBox.Text = playerStartingPosition.Y.ToString();

            // Level type
            this.levelTypeComboBox.Items.Clear();
            this.levelTypeComboBox.Items.Add(LevelType.Normal.ToString());
            this.levelTypeComboBox.Items.Add(LevelType.Jetpack.ToString());
            this.levelTypeComboBox.Items.Add(LevelType.Boss.ToString());
            this.levelTypeComboBox.SelectedItem = levelType.ToString();
            this.LevelTypeComboBoxSelectedIndexChanged(null, null);

            // Exit position
            this.exitXTextBox.Text = (exitPosition.X / Constants.BackgroundTileWidth).ToString();
            this.exitYTextBox.Text = (exitPosition.Y / Constants.BackgroundTileHeight).ToString();

            // Scroll speed
            this.scrollSpeedComboBox.SelectedItem = scrollSpeed.ToString();

            // Song
            this.songComboBox.Items.Clear();
            foreach (var item in SoundDataReader.GetSongs().Keys)
            {
                this.songComboBox.Items.Add(item);
            }

            this.songComboBox.SelectedItem = song;
            this.stopSongCheckBox.Checked  = stopSong;

            // Store the validation function
            this.validationFunc = validationFunc;
        }
示例#2
0
        private void Export(string fileName)
        {
            // Export format:
            // 1 byte: song to play
            // 1 byte: progress type story            
            // 1 byte: number of strings
            // then for each string:
            //   1 byte: x
            //   1 byte: y
            //   1 byte: string id            

            var payload = new List<byte>();            
            payload.Add(SoundDataReader.GetSongs()[this.story.Song]);
            payload.Add(Constants.ProgressStory);
            payload.Add((byte)this.story.Strings.Length);
            foreach (var str in this.story.Strings)
            {
                payload.Add((byte)str.X);
                payload.Add((byte)str.Y);
                payload.Add((byte)(str.StringId * 2)); // x2 because it's a pointer
            }

            File.WriteAllBytes(fileName, payload.ToArray());
        }