Exemple #1
0
        //internal double _MainLayerZ;
        //public double MainLayerZ
        //{
        //	get { return this._MainLayerZ; }
        //}

        public LevelBase(LevelSource _source, double _friction)
        {
            this.Physical      = true;
            this.Source        = _source;
            this.LevelFriction = _friction;
        }
Exemple #2
0
 public Level(LevelSource _source)
 {
     this.Physical = true;
     this.Source   = _source;
 }
Exemple #3
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;
            }
        }