Exemplo n.º 1
0
        private void LoadLevel(LevelTemplate level, Vector2 at)
        {
            Save();

            KeyboardState keys = Keyboard.GetState();

            Session session = keys.IsKeyDown(Keys.LeftControl) || keys.IsKeyDown(Keys.RightControl) ? null : CurrentSession;

            if (session == null)
            {
                if (AreaData.GetCheckpoint(area, level.Name) != null)
                {
                    session = new Session(area, level.Name)
                    {
                        StartCheckpoint = null
                    };
                }
                else
                {
                    session = new Session(area);
                }
            }
            session.FirstLevel           = false;
            session.StartedFromBeginning = false;
            session.Level        = level.Name;
            session.RespawnPoint = keys.IsKeyDown(Keys.LeftShift) || keys.IsKeyDown(Keys.RightShift) ? at : (Vector2?)null;

            Engine.Scene = new LevelLoader(session, at);
        }
Exemplo n.º 2
0
        // Better support for loading checkpoint room and fix vanilla game crashes when the bside/cside level does not exist
        private static void LoadIdLevel(AreaMode areaMode, int id = 0, string level = null)
        {
            SaveData.InitializeDebugMode();
            AreaKey areaKey = new AreaKey(id, areaMode);

            ((patch_SaveData)SaveData.Instance).LastArea_Safe = areaKey;
            Session session = new Session(areaKey);

            if (level != null && session.MapData.Get(level) != null)
            {
                if (AreaData.GetCheckpoint(areaKey, level) != null)
                {
                    session = new Session(areaKey, level)
                    {
                        StartCheckpoint = null
                    };
                }
                else
                {
                    session.Level = level;
                }
                bool firstLevel = level == session.MapData.StartLevel().Name;
                session.FirstLevel           = firstLevel;
                session.StartedFromBeginning = firstLevel;
            }
            Engine.Scene = new LevelLoader(session);
        }
Exemplo n.º 3
0
        private void LoadLevel(LevelTemplate level, Vector2 at)
        {
            Save();

            KeyboardState kbState            = Keyboard.GetState();
            bool          createSession      = kbState.IsKeyDown(Keys.LeftControl) || kbState.IsKeyDown(Keys.RightControl);
            bool          customRespawnPoint = kbState.IsKeyDown(Keys.LeftShift) || kbState.IsKeyDown(Keys.RightShift);

            Session session;

            if (createSession || CurrentSession == null)
            {
                if (AreaData.GetCheckpoint(area, level.Name) != null)
                {
                    session = new Session(area, level.Name)
                    {
                        StartCheckpoint = null
                    };
                }
                else
                {
                    session = new Session(area);
                }
            }
            else
            {
                session = CurrentSession;
            }

            session.Level                = level.Name;
            session.RespawnPoint         = customRespawnPoint ? at : null;
            session.FirstLevel           = false;
            session.StartedFromBeginning = false;

            if (createSession && !customRespawnPoint)
            {
                bool firstLevel = level.Name == session.MapData.StartLevel().Name;
                session.FirstLevel = firstLevel;
                if (firstLevel)
                {
                    Vector2 defaultSpawnPoint;
                    if (session.Area.GetLevelSet() == "Celeste")
                    {
                        Rectangle bounds = session.LevelData.Bounds;
                        defaultSpawnPoint = session.GetSpawnPoint(new Vector2(bounds.Left, bounds.Bottom));
                    }
                    else
                    {
                        defaultSpawnPoint = session.LevelData.Spawns[0];
                    }
                    session.StartedFromBeginning = session.GetSpawnPoint(at) == defaultSpawnPoint;
                }
            }

            Engine.Scene = new LevelLoader(session, at);
        }
Exemplo n.º 4
0
        private static void Load(AreaMode mode, int levelId, Vector2 spawnPoint, Vector2 remainder, Vector2 speed)
        {
            AreaKey areaKey = new(levelId, mode);
            Session session = new(areaKey);

            session.Level = session.MapData.GetAt(spawnPoint)?.Name;
            if (AreaData.GetCheckpoint(areaKey, session.Level) != null)
            {
                session = new Session(areaKey, session.Level);
            }

            session.FirstLevel           = false;
            session.StartedFromBeginning = false;
            session.RespawnPoint         = spawnPoint;
            resetRemainder = remainder;
            initSpeed      = speed;
            Engine.Scene   = new LevelLoader(session);
        }
Exemplo n.º 5
0
        private static void Load(AreaMode mode, int levelId, string screen = null, int?spawnPoint = null)
        {
            AreaKey areaKey = new(levelId, mode);
            Session session = AreaData.GetCheckpoint(areaKey, screen) != null ? new Session(areaKey, screen) : new Session(areaKey);

            if (screen != null)
            {
                session.Level      = screen;
                session.FirstLevel = session.LevelData == session.MapData.StartLevel();
            }

            Vector2?startPosition = null;

            if (spawnPoint != null)
            {
                LevelData levelData = session.MapData.Get(screen);
                startPosition = levelData.Spawns[spawnPoint.Value];
            }

            session.StartedFromBeginning = spawnPoint == null && session.FirstLevel;
            Engine.Scene = new LevelLoader(session, startPosition);
        }