/// <summary>
        /// Save the position
        /// </summary>
        public void SavePosition()
        {
            var coords = new Rayman2Manager().PlayerCoordinates;

            SavedXPosition = coords.Item1;
            SavedYPosition = coords.Item2;
            SavedZPosition = coords.Item3;
        }
Exemplo n.º 2
0
        public void OnKeyPressed(object sender, GlobalKeyboardHookEventArgs e)
        {
            var manager = new Rayman2Manager();

            if (!AppVM.HotkeysEnabled || Application.Current.Windows.Count > 1 || manager.IsRayman2Paused() || !manager.IsRayman2Focused() && !Application.Current.MainWindow.IsActive)
            {
                e.Handled = false;
                return;
            }

            // Only handle key down
            if (e.KeyboardState != GlobalKeyboardHook.KeyboardState.KeyDown)
            {
                return;
            }

            // O to load position
            if (e.KeyboardData.VirtualCode == 0x4F)
            {
                GameManagerVM.LoadSavedPosition();
            }

            // P to save position
            else if (e.KeyboardData.VirtualCode == 0x50)
            {
                GameManagerVM.SavePosition();
            }

            // K for previous level
            else if (e.KeyboardData.VirtualCode == 0x4B)
            {
                GameManagerVM.LoadOffsetLevel(-1);
            }

            // L for next level
            else if (e.KeyboardData.VirtualCode == 0x4C)
            {
                GameManagerVM.LoadOffsetLevel(1);
            }

            // R for reload level
            else if (e.KeyboardData.VirtualCode == 0x52)
            {
                manager.ReloadLevel();
            }

            // B to add bookmark
            else if (e.KeyboardData.VirtualCode == 0x42)
            {
                BookmarksVM.AddBookmark();
            }
        }
        /// <summary>
        /// Loads the level from the offset of the current level
        /// </summary>
        /// <param name="offset">The offset</param>
        public void LoadOffsetLevel(int offset)
        {
            var manager = new Rayman2Manager();

            int processHandle = manager.GetRayman2ProcessHandle();

            if (processHandle < 0)
            {
                return;
            }

            string levelName = manager.GetCurrentLevelName(processHandle);

            var lvls = App.Levels.ToList();

            int currentIndex = lvls.FindIndex(x => string.Equals(x.FileName, levelName, StringComparison.CurrentCultureIgnoreCase));

            if (currentIndex < 0)
            {
                return;
            }

            int newIndex = currentIndex + offset;

            if (newIndex < 0)
            {
                newIndex = lvls.Count - 1;
            }

            if (newIndex >= lvls.Count)
            {
                newIndex = 0;
            }

            string levelToLoad = lvls[newIndex].FileName;

            manager.ChangeLevel(levelToLoad);
        }