Exemple #1
0
        internal SaveFile(GameBase _game, string _path)
            : this(_game)
        {
            MekaItem file = MekaItem.LoadFromFile(_path);

            this.PlayTime = file["Play Time"].Content.To <int>();

            int[] ds = file["Last Played"].Content.Split('.').ToArray().Select(item => item.To <int>()).ToArray();
            this.LastPlayed = new DateTime(ds[2], ds[1], ds[0]);

            this._PositionRegion   = file["Position Region"].Content;
            this._PositionEntrance = file["Position Entrance"].Content;

            foreach (MekaItem level in file["Levels"].Children)
            {
                this._Levels[level.Name] = new Bunch <SavedEntity>();
                foreach (MekaItem entity in level.Children)
                {
                    this._Levels[level.Name].Add(new SavedEntity(entity));
                }
            }

            foreach (MekaItem achievement in file["Achievements"].Children)
            {
                this.Achievements[achievement.Name] = achievement.Children[0];
            }

            this.CustomInfo = file["Custom Info"];

            string n = File.GetName(_path);
            n        = n.Substring(n.IndexOf('#') + 1);
            this._Id = n.To <int>();
        }
Exemple #2
0
 internal void _CheckRegions()
 {
     foreach (File f in File.GetAllFiles(this._Game.Path + "\\" + this._Game.LevelFolder))
     {
         if (f.Name == "_Region")
         {
             this._Regions[f.Path] = MekaItem.LoadFromFile(f.Path).Children.Select(item => File.GetFolder(f.Path) + "\\" + item.Name).ToBunch();
         }
     }
 }
Exemple #3
0
        public Areaset(string _path, Point _tilesize, Point _tilecollisionresolution)
            : this(MekaItem.LoadFromFile(_path + "\\Areaset.meka"), _tilesize, _tilecollisionresolution)
        {
            this.Name = _path.Substring(_path.LastIndexOf('\\') + 1);

            if (File.Exists(_path + "\\Decorations"))
            {
                foreach (File f in File.GetAllFiles(_path + "\\Decorations"))
                {
                    this.Decorations[f.Name] = GameBase.LoadImageSource(f.Bytes);
                }
            }
        }
Exemple #4
0
        public PixelFont(string _path)
        {
            MekaItem file = MekaItem.LoadFromFile(_path);

            MekaItem chars = file["Characters"].Children[0];

            ImageSource src = new ImageSource(chars.Data);

            ImageSource[,] cs = src.Split(chars["Count"].To <Point>());

            foreach (ImageSource c in cs)
            {
                for (int x = 0; x < c.Width; x++)
                {
                    for (int y = 0; y < c.Height; y++)
                    {
                        if (c[x, y].A > 0 && c[x, y] != Color.White)
                        {
                            c[x, y] = Color.White;
                        }
                    }
                }
            }

            {
                int y = 0;
                foreach (MekaItem line in file["Characters"].Children.Where(item => item.Name == "Line"))
                {
                    for (int x = 0; x < line.Content.Length; x++)
                    {
                        this.Chars[line.Content[x]] = cs[x, y];
                    }
                    y++;
                }
            }

            if (file.Contains("Character Size"))
            {
                this.CharSize = file["Character Size"].To <Point>();
            }
            else
            {
                this.CharSize = this.Chars.ToArray()[0].Value.Size;
            }

            if (file.Contains("Default"))
            {
                this._DefaultChar = file["Default"].Content[0];
            }
        }
Exemple #5
0
 public AnimationSource(string _path) : this(MekaItem.LoadFromFile(_path))
 {
 }
Exemple #6
0
        public RegionBase(GameBase _game, string _path, bool _usebank = true)
        {
            this.Physical = true;

            this._Game = _game;
            this._Path = _path.Substring(_game.LevelFolder.Length + 1);

            Point?topleft  = null;
            Point?botright = null;

            if (File.Exists(_path + "\\_Region.meka"))
            {
                MekaItem file = MekaItem.LoadFromFile(_path + "\\_Region.meka");
                foreach (MekaItem level in file.Children)
                {
                    Point       pos = this._LevelPositions[level.Name] = level.Content.To <Point>();
                    LevelSource s   = this._LevelSources[level.Name] = (_usebank ? _game.LevelBank.GetLevel(_path.Substring(_game.LevelFolder.Length) + "\\" + level.Name) : new LevelSource(_game, _path + "\\" + level.Name + ".meka"));

                    if (!topleft.HasValue)
                    {
                        topleft  = pos;
                        botright = pos + s.Size;
                    }
                    else
                    {
                        if (pos.X < topleft.Value.X)
                        {
                            topleft = new Point(pos.X, topleft.Value.Y);
                        }
                        if (pos.Y < topleft.Value.Y)
                        {
                            topleft = new Point(topleft.Value.X, pos.Y);
                        }

                        if (pos.X + s.Size.X > botright.Value.X)
                        {
                            botright = new Point(pos.X + s.Size.X, botright.Value.Y);
                        }
                        if (pos.Y + s.Size.Y > botright.Value.Y)
                        {
                            botright = new Point(botright.Value.X, pos.Y + s.Size.Y);
                        }
                    }
                }
            }
            else
            {
                this._ThisLevel = File.GetName(_path);
                this._LevelPositions["this"] = new Point(0, 0);
                LevelSource s = this._LevelSources["this"] = (_usebank ? _game.LevelBank.GetLevel(File.GetFolder(_path.Substring(_game.LevelFolder.Length)) + "\\" + File.GetName(_path)) : new LevelSource(_game, _path));
                topleft  = new Point(0, 0);
                botright = s.Size;
            }

            topleft  = topleft.Value * this._Game.TileCollisionResolution;
            botright = botright.Value * this._Game.TileCollisionResolution;

            this.Collisions = new bool[botright.Value.X - topleft.Value.X + 2, botright.Value.Y - topleft.Value.Y + 2];
            topleft         = topleft.Value - 1;
            foreach (KeyValuePair <string, LevelSource> s in this._LevelSources)
            {
                Point p = this._LevelPositions[s.Key];
                for (int x = 0; x < s.Value.Collisions.GetLength(0); x++)
                {
                    for (int y = 0; y < s.Value.Collisions.GetLength(1); y++)
                    {
                        this.Collisions[x + p.X * this._Game.TileCollisionResolution.X - topleft.Value.X, y + p.Y * this._Game.TileCollisionResolution.Y - topleft.Value.Y] = s.Value.Collisions[x, y];
                    }
                }
            }

            this.CreateColliders();

            foreach (KeyValuePair <string, Point> p in this._LevelPositions.ToArray())
            {
                this._LevelPositions[p.Key] -= (topleft.Value + 1) / this._Game.TileCollisionResolution;
            }
        }
Exemple #7
0
 public LevelSource(GameBase _game, string _path, bool _delayload = false) : this(_game, MekaItem.LoadFromFile(_path))
 {
 }