Exemplo n.º 1
0
 public void SaveGame()
 {
     if (nextGameState == GameState.InGame)
     {
         manageStars.saveManageStars(manageProfiles.getActiveProfileName());
     }
 }
Exemplo n.º 2
0
        public GameState Update(RenderWindow win, float deltaTime)
        {
            int index = -1;

            lastScreen.Update(deltaTime);
            nextScreen.Update(deltaTime);
            foreach (LevelSelectButton l in mainButtonList)
            {
                l.Update(deltaTime, win, currentScreenPosition);
            }
            SetCurrentLevelInfo();
            levelInfo.Update(deltaTime, currentScreenPosition);
            leftButton.Update(deltaTime, win, currentScreenPosition);
            rightButton.Update(deltaTime, win, currentScreenPosition);
            if (stopwatch.ElapsedMilliseconds > 500)
            {
                if (Keyboard.IsKeyPressed(Keyboard.Key.Escape))
                {
                    stars.lastSelectedLevel = currentLevel;
                    stars.saveManageStars(profiles.getActiveProfileName());
                    return(GameState.MainMenu);
                }
                if (sliding)
                {
                    SlideMap(deltaTime);
                    return(GameState.LoadLevelState);
                }
                bool soundactiv = false;
                if (KeyboardInputManager.Downward(Keyboard.Key.Up) || KeyboardInputManager.Downward(Keyboard.Key.Down))
                {
                    int bottomLength = 1;
                    if (KeyboardInputManager.Downward(Keyboard.Key.Up) && currentScreenPosition.Y != 0)
                    {
                        soundactiv = true;
                        currentScreenPosition.Y = 0;
                        currentScreenPosition.X = GetPositionOnCurrentLevelScreen();
                    }
                    if (KeyboardInputManager.Downward(Keyboard.Key.Down) && currentScreenPosition.Y != 1)
                    {
                        soundactiv = true;
                        currentScreenPosition.Y = 1;
                        float help = (float)currentScreenPosition.X * (float)bottomLength / (float)(mainButtonList.Count - 1);
                        currentScreenPosition.X = (int)Math.Round(help);
                    }
                }

                if ((KeyboardInputManager.Downward(Keyboard.Key.Left) || KeyboardInputManager.Downward(Keyboard.Key.Right)) & currentScreenPosition.Y == 1)
                {
                    int bottomLength = 1;
                    if (KeyboardInputManager.Downward(Keyboard.Key.Right) && currentScreenPosition.X < bottomLength)
                    {
                        soundactiv = true;
                        currentScreenPosition.X += 1;
                    }
                    if (KeyboardInputManager.Downward(Keyboard.Key.Left) && currentScreenPosition.X > 0)
                    {
                        soundactiv = true;
                        currentScreenPosition.X -= 1;
                    }
                }
                if ((KeyboardInputManager.Downward(Keyboard.Key.Left) || KeyboardInputManager.Downward(Keyboard.Key.Right)) && currentScreenPosition.Y == 0)
                {
                    if (KeyboardInputManager.Downward(Keyboard.Key.Left))
                    {
                        if (currentLevel > 0)
                        {
                            soundactiv = true;
                            currentLevel--;
                            currentScreenPosition.X -= 1;
                            if (currentScreenPosition.X < 0)
                            {
                                InitiateSlide(false);
                                currentScreenPosition.X = GetPositionOnCurrentLevelScreen();
                            }
                        }
                    }
                    else
                    {
                        if (stars.levelIsUnlocked(currentLevel + 1))
                        {
                            soundactiv = true;
                            currentLevel++;
                            currentScreenPosition.X = GetPositionOnCurrentLevelScreen();
                            if (GetPositionOnCurrentLevelScreen() == 0)
                            {
                                InitiateSlide(true);
                            }
                        }
                    }
                    if (soundactiv)
                    {
                        MusicManager.PlaySound(AssetManager.SoundName.MenueClick);
                    }
                    else if (KeyboardInputManager.Downward(Keyboard.Key.Up) || KeyboardInputManager.Downward(Keyboard.Key.Down) || KeyboardInputManager.Downward(Keyboard.Key.Right) || KeyboardInputManager.Downward(Keyboard.Key.Left))
                    {
                        MusicManager.PlaySound(AssetManager.SoundName.Wall);
                    }

                    return(GameState.LoadLevelState);
                }

                if (soundactiv)
                {
                    MusicManager.PlaySound(AssetManager.SoundName.MenueClick);
                }
                else if (KeyboardInputManager.Downward(Keyboard.Key.Up) || KeyboardInputManager.Downward(Keyboard.Key.Down) || KeyboardInputManager.Downward(Keyboard.Key.Right) || KeyboardInputManager.Downward(Keyboard.Key.Left))
                {
                    MusicManager.PlaySound(AssetManager.SoundName.Wall);
                }



                if (KeyboardInputManager.Downward(Keyboard.Key.Return) && currentScreenPosition.Y == 0)
                {
                    return(StartLevelIfUnlocked());
                }
                if (KeyboardInputManager.Downward(Keyboard.Key.Return) && currentScreenPosition.Y == 1) //Wurde die LinkeMaustaste gedrückt?
                {
                    switch (currentScreenPosition.X)                                                    //Bin mit der Maus über den Index: SwitchCaseWeg
                    {                                                                                   //bearbeitet das aktuelle TextFeld
                    //
                    case 0:
                        CanSlide(false);
                        return(GameState.LoadLevelState);

                    case 1:
                        CanSlide(true);
                        return(GameState.LoadLevelState);

                    default:
                        return(GameState.LoadLevelState);
                    }
                }
                else
                {
                    if (index != -1)
                    {
                        IntRect curRect = rectList[index];
                        debugRect.Position  = new Vector2f(curRect.Left, curRect.Top);
                        debugRect.Size      = new Vector2f(curRect.Width, curRect.Height);
                        debugRect.FillColor = Color.Cyan;
                    }
                }
            }
            return(GameState.LoadLevelState);
        }