예제 #1
0
        public void DrawGUI(GUI gui, float deltaTime)
        {
            map.DrawGUI(gui, deltaTime);
            player.DrawGUI(gui, deltaTime);

            // GUI
            // Score Box
            guiScoreBox.Position = new Vector2f(gui.view.Size.X - 30 - guiScoreBox.Texture.Size.X, 30);
            gui.Draw(guiScoreBox);
            guiScoreNumber.Position        = guiScoreBox.Position + new Vector2f(13, 0);
            guiScoreNumber.DisplayedString = (playerScore <= 999 ? "" + playerScore : "X_X");
            guiScoreNumber.Update(deltaTime);
            gui.Draw(guiScoreNumber);
            guiScore.Position = guiScoreNumber.Position + new Vector2f(0, guiScoreNumber.CharacterSize);
            guiScore.Update(deltaTime);
            gui.Draw(guiScore);
            // Level Box
            guiLevelBox.Position = gui.view.Size - new Vector2f(guiLevelBox.TextureRect.Width + 30, guiLevelBox.TextureRect.Height + 30);
            gui.Draw(guiLevelBox);
            guiLevelNumber.Position = guiLevelBox.Position + new Vector2f(13, 0);
            guiLevelNumber.Update(deltaTime);
            gui.Draw(guiLevelNumber);
            guiLevel.Position = guiLevelNumber.Position + new Vector2f(0, guiLevelNumber.CharacterSize);
            guiLevel.Update(deltaTime);
            gui.Draw(guiLevel);
        }
예제 #2
0
        private void UpdateSelectedProfileText(String currentInput, float deltaTime)
        {
            switch (ProfileConstants.activeProfile)
            {
            case MemoryMaze.profiles.one:
                profileOneText.DisplayedString = currentInput;
                profileOneText.Update(deltaTime);
                break;

            case MemoryMaze.profiles.two:
                profileTwoText.DisplayedString = currentInput;
                profileTwoText.Update(deltaTime);
                break;

            case MemoryMaze.profiles.three:
                profileThreeText.DisplayedString = currentInput;
                profileThreeText.Update(deltaTime);
                break;
            }
        }
예제 #3
0
 public void Update(float deltaTime)
 {
     if (currentTime >= 0)
     {
         if (currentTime > (duration * 0.9F))
         {
             GraphicHelper.SetAlpha((byte)(maxOpacity * (1F - (currentTime / duration)) / 0.1F), animSprite);
             GraphicHelper.SetAlpha((byte)((maxOpacity + 20) * (1F - (currentTime / duration)) / 0.1F), superText);
         }
         animSprite.UpdateFrame(deltaTime);
         superText.Update(deltaTime);
         currentTime -= deltaTime;
         if (currentTime < (duration / 2))
         {
             GraphicHelper.SetAlpha((byte)(maxOpacity * currentTime / (duration * 0.5f)), animSprite);
             GraphicHelper.SetAlpha((byte)((maxOpacity + 20) * currentTime / (duration * 0.5f)), superText);
         }
     }
     else
     {
         iShouldKillMyself = true;
     }
 }
예제 #4
0
        public int Update(float deltaTime, ManageStars.Rating rating, int curIndex, List <Tutorial> tutorials)
        {
            if (finished)
            {
                endAnimation.UpdateFrame(deltaTime);
                endText.Update(deltaTime);
                if (KeyboardInputManager.Downward(Keyboard.Key.Space))
                {
                    mapStatus = 1;
                }
            }
            else
            {
                background          = new Sprite(AssetManager.backgroundTextures[0]);
                background.Position = new Vector2f(0, 0);
                getBackground(curIndex);
                mapStatus   = 0;
                playerScore = player.scoreCounter;
                map.Update(deltaTime, player.keyCounter);
                player.Update(deltaTime, map);
                itemList.Update(map, player, deltaTime);
                trapHandler.Update(map, player, deltaTime);
                levelution.Update(player, map, deltaTime);
                transporterHandler.Update(player, deltaTime);
                checkTutorialNeed(rating, curIndex, tutorials);
                if (currentTutorial != null)
                {
                    currentTutorial.Update(deltaTime);
                }
                if (KeyboardInputManager.Upward(Keyboard.Key.T))
                {
                    return(3);
                }
                if (KeyboardInputManager.IsPressed(Keyboard.Key.LShift) && KeyboardInputManager.IsPressed(Keyboard.Key.LControl) && KeyboardInputManager.Upward(Keyboard.Key.Y))
                {
                    mapStatus = 1;
                }
                if (map.CellIsGoal(player.mapPosition) && player.keyCounter >= keysToUnlock)
                {
                    endSprite          = new Sprite(AssetManager.GetTexture(AssetManager.TextureName.LevelInfo));
                    endSprite.Position = new Vector2f(450, 220);
                    GraphicHelper.SetAlpha(200, endSprite);
                    SetEndMedal();
                    endMedal.Position     = endSprite.Position + new Vector2f(150, 100);
                    endAnimation          = new AnimatedSprite(AssetManager.GetTexture(AssetManager.TextureName.SpaceBar), 0.2f, 3);
                    endAnimation.Position = (Vector2)endSprite.Position + new Vector2(125, 200);
                    endText = new SuperText("Congratulations", FontLoader.Instance.LoadFont("Assets/Fonts/fixedsys.ttf"), 0.1f);
                    MusicManager.PlaySound(AssetManager.SoundName.Winning);
                    endText.Position      = (Vector2)endSprite.Position + new Vector2(20, 25);
                    endText.CharacterSize = 40;

                    finished = true;
                    addScoreFromBots();
                    CheckLevel();
                    Logger.Instance.Write("\n" + "Rating: " + playerScore + "\n" + "Bronze: " + ratingNumbers[0] + "\n" + "Silber: " + ratingNumbers[1] + "\n" + "Gold: " + ratingNumbers[2] + "\n" + "Sie haben " + CheckLevel() + " erreicht", Logger.level.Info);
                }
                if (KeyboardInputManager.Upward(Keyboard.Key.Back))
                {
                    MusicManager.StopSound();
                    foreach (Tutorial tut in tutorials)
                    {
                        if (tut.index == curIndex)
                        {
                            tut.shown = false;
                        }
                    }
                    mapStatus = 2;
                }
                guiLevelNumber.DisplayedString = "" + (curIndex + 1);
            }
            return(mapStatus);
        }
예제 #5
0
        public GameState Update(RenderWindow win, float deltaTime)
        {
            gameName.Update(deltaTime);
            foreach (Button b in buttonList)
            {
                b.Update(deltaTime, win, currentScreenPosition);
            }
            UpdateButtonAlphas();
            if (stopwatch1.ElapsedMilliseconds > 200)
            {
                int index = -1;
                debugRect.Position = new Vector2f(-1000, -1000);                    // moves this out of the picture...
                if (settingNewProfile)
                {
                    List <char> charList = KeyboardInputManager.getCharInput();
                    if (newProfileName && KeyboardInputManager.getCharInput().Count > 0)
                    {
                        currentInput   = "";
                        newProfileName = false;
                    }
                    foreach (char c in charList)
                    {
                        if (currentInput.Length <= 16)
                        {
                            currentInput += c;
                        }
                    }
                    if (KeyboardInputManager.Downward(Keyboard.Key.Back))
                    {
                        if (currentInput != "")
                        {
                            currentInput = currentInput.Remove(currentInput.Length - 1);
                        }
                    }
                    UpdateSelectedProfileText(currentInput, deltaTime);
                    if ((KeyboardInputManager.IsPressed(Keyboard.Key.Escape) || Mouse.IsButtonPressed(Mouse.Button.Left)) && settingNewProfile)
                    {
                        settingNewProfile = false;
                        stopwatch.Restart();
                        UpdateActiveProfileText();
                        return(GameState.MainMenu);
                    }
                    if (KeyboardInputManager.Downward(Keyboard.Key.Return))
                    {
                        if (currentInput != "" && currentInput != "[Enter Name]" && profiles.GetProfileNames().Contains(currentInput) == false)
                        {
                            profiles.setProfile(currentInput, ProfileConstants.activeProfile);
                            settingNewProfile = false;
                            UpdateActiveProfileText();
                            return(GameState.LoadLevelState);
                        }
                        else
                        {
                            Logger.Instance.Write("ProfileName cannot be empty", Logger.level.Info);
                        }
                    }
                }
                else if (KeyboardInputManager.Downward(Keyboard.Key.Up) || KeyboardInputManager.Downward(Keyboard.Key.Down) || KeyboardInputManager.Downward(Keyboard.Key.Right) || KeyboardInputManager.Downward(Keyboard.Key.Left))
                {
                    bool soundactiv = false;
                    if (KeyboardInputManager.Downward(Keyboard.Key.Up) && currentScreenPosition.Y > 0)
                    {
                        soundactiv = true;
                        currentScreenPosition.Y -= 1;
                        if (currentScreenPosition.X == 2)
                        {
                            currentScreenPosition.X = 1;
                        }
                        else if (currentScreenPosition.X == 1 && currentScreenPosition.Y == 2)
                        {
                            currentScreenPosition.X = 0;
                        }
                    }
                    if (KeyboardInputManager.Downward(Keyboard.Key.Down) && currentScreenPosition.Y < 3)
                    {
                        soundactiv = true;
                        currentScreenPosition.Y += 1;
                        if (currentScreenPosition.Y == 3 && currentScreenPosition.X == 1)
                        {
                            currentScreenPosition.X = 2;
                        }
                    }
                    if (KeyboardInputManager.Downward(Keyboard.Key.Right) && currentScreenPosition.X < 1)
                    {
                        soundactiv = true;
                        currentScreenPosition.X += 1;
                    }
                    else if (KeyboardInputManager.Downward(Keyboard.Key.Right) && currentScreenPosition.X < 3 && currentScreenPosition.Y == 3)
                    {
                        soundactiv = true;
                        currentScreenPosition.X = 2;
                    }
                    if (KeyboardInputManager.Downward(Keyboard.Key.Left) && currentScreenPosition.X > 0)
                    {
                        soundactiv = true;
                        currentScreenPosition.X -= 1;
                    }

                    if (soundactiv)
                    {
                        MusicManager.PlaySound(AssetManager.SoundName.MenueClick);
                    }
                    else
                    {
                        MusicManager.PlaySound(AssetManager.SoundName.Wall);
                    }
                }
                else if (KeyboardInputManager.Downward(Keyboard.Key.Return))                       //Wurde die LinkeMaustaste gedrückt?
                {
                    //Console.WriteLine("Der Index in der SwitchAnweisung: " + index);
                    switch (IndexFromScreenPos())                                   //Bin mit der Maus über den Index: SwitchCaseWeg
                    {                                                               //bearbeitet das aktuelle TextFeld
                    //start
                    case 0:
                        ProfileConstants.activeProfile = MemoryMaze.profiles.one;
                        if (profiles.ProfileExists(MemoryMaze.profiles.one))
                        {
                            return(GameState.LoadLevelState);
                        }
                        else
                        {
                            currentInput      = "[Enter Name]";
                            settingNewProfile = true;
                            newProfileName    = true;
                            return(GameState.MainMenu);
                        }

                    case 3:
                        profiles.deleteProfile(MemoryMaze.profiles.one);
                        UpdateProfilePercentage();
                        break;

                    case 1:
                        ProfileConstants.activeProfile = MemoryMaze.profiles.two;
                        if (profiles.ProfileExists(MemoryMaze.profiles.two))
                        {
                            return(GameState.LoadLevelState);
                        }
                        else
                        {
                            currentInput      = "[Enter Name]";
                            settingNewProfile = true;
                            newProfileName    = true;
                            return(GameState.MainMenu);
                        }

                    case 4:
                        profiles.deleteProfile(MemoryMaze.profiles.two);
                        UpdateProfilePercentage();
                        break;

                    case 2:
                        ProfileConstants.activeProfile = MemoryMaze.profiles.three;
                        if (profiles.ProfileExists(MemoryMaze.profiles.three))
                        {
                            return(GameState.LoadLevelState);
                        }
                        else
                        {
                            currentInput      = "[Enter Name]";
                            settingNewProfile = true;
                            newProfileName    = true;
                            return(GameState.MainMenu);
                        }

                    case 5:
                        profiles.deleteProfile(MemoryMaze.profiles.three);
                        UpdateProfilePercentage();
                        break;

                    case 6: return(GameState.Tutorial);

                    case 7: return(GameState.Credits);

                    case 8:
                        profiles.saveManageProfiles();
                        return(GameState.None);

                    case 9:
                        funactivJoh = true; stopwatch.Restart();
                        break;

                    default: break;
                    }
                }
            }
            if (!settingNewProfile)
            {
                UpdateAllProfilesTexts();
            }
            UpdateMainTitle(deltaTime);

            foreach (SuperText s in superTextList)
            {
                s.Update(deltaTime);
            }
            return(GameState.MainMenu);
        }
예제 #6
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);
        }