예제 #1
0
        public void Save(string _path)
        {
            Bunch <string> _areasets = new Bunch <string>();

            foreach (LayerSource l in this.Layers)
            {
                foreach (string areaset in l._GetAreasets())
                {
                    if (!_areasets.Contains(areaset))
                    {
                        _areasets.Add(areaset);
                    }
                }
            }

            MekaItem file = new MekaItem("File", new List <MekaItem>());

            MekaItem info = new MekaItem("Info", new List <MekaItem>());

            info.Children.Add(new MekaItem("Title", this.Title));
            info.Children.Add(new MekaItem("Author", this.Author));
            info.Children.Add(new MekaItem("Width", this.Size.X.ToString()));
            info.Children.Add(new MekaItem("Height", this.Size.Y.ToString()));
            info.Children.Add(new MekaItem("OnLoad", this.OnLoad.SourceCode));
            info.Children.Add(new MekaItem("OnEnter", this.OnEnter.SourceCode));
            info.Children.Add(new MekaItem("OnExit", this.OnEnter.SourceCode));
            file.Children.Add(info);

            file.Children.Add(new MekaItem("Properties", this._Properties));

            file.Children.Add(new MekaItem("Areasets", _areasets.Select(item => new MekaItem("Areaset", item))));

            MekaItem layers = new MekaItem("Layers", new List <MekaItem>());

            foreach (LayerSource l in this.Layers)
            {
                MekaItem item = l._Export(_areasets);
                if (this.MainLayer == l)
                {
                    item.Children.Add(new MekaItem("Main"));
                }
                layers.Children.Add(item);
            }
            file.Children.Add(layers);

            file.SaveToFile(_path);
        }
예제 #2
0
        internal void _Save()
        {
            string path = this._Game.Path + "\\Internal\\Saves\\Save File #" + this._Id.ToString() + ".meka";

            MekaItem file = new MekaItem("Save File #" + this._Id.ToString(), new Bunch <MekaItem>());

            file.Children.Add(new MekaItem("Play Time", this.PlayTime.ToString()));
            file.Children.Add(new MekaItem("Last Played", DateTime.Now.Day.ToString() + "." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Year.ToString()));

            file.Children.Add(new MekaItem("Position Region", this.PositionRegion));
            file.Children.Add(new MekaItem("Position Entrance", this.PositionEntrance));

            MekaItem levels = new MekaItem("Levels", new List <MekaItem>());

            foreach (KeyValuePair <string, Bunch <SavedEntity> > level in this._Levels)
            {
                MekaItem l = new MekaItem(level.Key, new List <MekaItem>());
                foreach (SavedEntity e in level.Value)
                {
                    l.Children.Add(new MekaItem(e.Identifier, e.Properties));
                }
                levels.Children.Add(l);
            }
            file.Children.Add(levels);

            MekaItem achievements = new MekaItem("Achievements", new List <MekaItem>());

            foreach (KeyValuePair <string, MekaItem> achievement in this.Achievements)
            {
                achievements.Children.Add(new MekaItem(achievement.Key, new List <MekaItem>()
                {
                    achievement.Value
                }));
            }
            file.Children.Add(achievements);

            file.Children.Add(new MekaItem("Custom Info", this.CustomInfo));

            file.SaveToFile(path);
        }