예제 #1
0
 void SwitchToGhostPlayer()
 {
     if (KeyboardInputManager.Downward(Keyboard.Key.Space))
     {
         controllid = 0;
     }
 }
예제 #2
0
        Vector2i GetMove()
        {
            Vector2i move = new Vector2i(0, 0);

            if (KeyboardInputManager.Downward(Keyboard.Key.W) || KeyboardInputManager.Downward(Keyboard.Key.Up))
            {
                move.Y = -1;
            }


            else if (KeyboardInputManager.Downward(Keyboard.Key.S) || KeyboardInputManager.Downward(Keyboard.Key.Down))
            {
                move.Y = 1;
            }

            else if (KeyboardInputManager.Downward(Keyboard.Key.A) || KeyboardInputManager.Downward(Keyboard.Key.Left))
            {
                move.X = -1;
            }

            else if (KeyboardInputManager.Downward(Keyboard.Key.D) || KeyboardInputManager.Downward(Keyboard.Key.Right))
            {
                move.X = 1;
            }

            return(move);
        }
예제 #3
0
        private void SwitchTarget()
        {
            if (!(KeyboardInputManager.IsPressed(Keyboard.Key.Space)) && (KeyboardInputManager.Downward(Keyboard.Key.Num2)) && redbot)
            {
                controllid = 1;
            }

            else if (!(KeyboardInputManager.IsPressed(Keyboard.Key.Space)) && (KeyboardInputManager.Downward(Keyboard.Key.Num4)) && bluebot)
            {
                controllid = 2;
            }

            else if (!(KeyboardInputManager.IsPressed(Keyboard.Key.Space)) && (KeyboardInputManager.Downward(Keyboard.Key.Num3)) && greenbot)
            {
                controllid = 3;
            }

            else
            {
                if ((!(KeyboardInputManager.IsPressed(Keyboard.Key.Space)) && (KeyboardInputManager.Downward(Keyboard.Key.Num1))))
                {
                    controllid = 0;
                }
            }
        }
예제 #4
0
 public GameState Update(RenderWindow win, float deltaTime)
 {
     if (KeyboardInputManager.Downward(Keyboard.Key.Escape))
     {
         return(GameState.MainMenu);
     }
     return(GameState.Tutorial);
 }
예제 #5
0
        Vector2i GetMove()
        {
            Vector2i move = new Vector2i(0, 0);

            if (KeyboardInputManager.Downward(Keyboard.Key.W) || KeyboardInputManager.Downward(Keyboard.Key.Up))
            {
                move.Y = -1;
            }
            else if (KeyboardInputManager.Downward(Keyboard.Key.S) || KeyboardInputManager.Downward(Keyboard.Key.Down))
            {
                move.Y = 1;
            }
            else if (KeyboardInputManager.Downward(Keyboard.Key.A) || KeyboardInputManager.Downward(Keyboard.Key.Left))
            {
                move.X = -1;
            }
            else if (KeyboardInputManager.Downward(Keyboard.Key.D) || KeyboardInputManager.Downward(Keyboard.Key.Right))
            {
                move.X = 1;
            }
            //Logger.Instance.Write("moveX: " + move.X + "moveY" + move.Y, Logger.level.Info);
            return(move);
        }
예제 #6
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);
        }
예제 #7
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);
        }
예제 #8
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);
        }
예제 #9
0
        public void Update(float deltaTime, Map map)
        {
            if (teleporting)
            {
                UpdateBots(deltaTime, map, getListOfBotPositions());
                UpdateSpritePosition(map);
                Teleporting(deltaTime);
                currentFocus = teleSpritePos;
            }
            else if (isAlive == true)
            {
                if (controllid != 0)
                {
                    SwitchToGhostPlayer();
                }
                UpdateBots(deltaTime, map, getListOfBotPositions());

                if (KeyboardInputManager.Downward(Keyboard.Key.Space))
                {
                    ghostaktiv = true;
                }

                if (iserstellt)
                {
                    ghostPlayer.Update(deltaTime, map, this);
                    currentFocus = new Vector2(ghostPlayer.mapPosition.X * sizePerCell + sizePerCell * 0.5f, ghostPlayer.mapPosition.Y * sizePerCell + sizePerCell * 0.5f);
                    UpdateSpritePosition(map);
                }
                else
                {
                    if (id == controllid)
                    {
                        Vector2i move = GetMove();
                        if (map.CellIsWalkable(mapPosition + move))
                        {
                            mapPosition = mapPosition + move;
                            if (move.X != 0 || move.Y != 0) //ProSchritt wird der Counter um 1 erhöht
                            {
                                scoreCounter++;
                            }
                        }
                        else if (map.MoveIsPossible(mapPosition, move, this.getListOfBotPositions()))
                        {
                            map.MoveBlock(mapPosition, move);
                            mapPosition = mapPosition + move;
                            scoreCounter++;
                        }
                        else
                        {
                            MusicManager.PlaySound(AssetManager.SoundName.Wall);
                        }
                        UpdateSpritePosition(map);
                        currentFocus = sprite.Position + new Vector2f(sprite.Size.X / 2f, sprite.Size.Y / 2f);
                    }
                }
                //Create GhostPlayer
                if (ghostaktiv && (!iserstellt) && controllid == 0)
                {
                    ghostPlayer = new GhostPlayer(mapPosition, map);
                    iserstellt  = true;
                }
                if (!ghostaktiv)
                {
                    ghostPlayer = null;
                    iserstellt  = false;
                }
                //Destroy GhostPlayer
                else if (KeyboardInputManager.Upward(Keyboard.Key.Space) || iserstellt && ghostPlayer.GetCount() == 0)
                {
                    ghostPlayer = null;
                    ghostaktiv  = false;
                    iserstellt  = false;
                }

                //Target controll manager
                SwitchTarget();
                UpdateSpritePosition(map);
            }
            else
            {
                //SPieler ist tod

                if (!_musicPlayed)
                {
                    MusicManager.PlaySound(AssetManager.SoundName.VirusDetected);
                    _musicPlayed = true;
                }
                playerdetected.Position = new Vector2f(235, 200);
                playerdetected.Color    = Color.Red;
                playerdetected.Style    = Text.Styles.Bold;
                restartGame.Position    = new Vector2f(285, 350);
                restartGame.Color       = Color.Red;
                restartGame.Style       = Text.Styles.Bold;
            }
        }
예제 #10
0
        public GameState Update(RenderWindow win, float deltaTime)
        {
            int index = -1;

            if (stopwatch.ElapsedMilliseconds > 500)
            {
                if (Keyboard.IsKeyPressed(Keyboard.Key.Escape) && selectingLevel)
                {
                    stopwatch.Restart();
                    selectingLevel = false;
                    currentNumberInputDisplay.DisplayedString = "";
                    numberInput = "";
                    return(GameState.ChooseLevelState);
                }
                if (Keyboard.IsKeyPressed(Keyboard.Key.Escape))
                {
                    return(GameState.LoadLevelState);
                }
                for (int e = 0; e < 4; e++)
                {
                    if (IsMouseInRectangle(list[e], win))                           //Geht die Liste mit rectInt duch!
                    {
                        index = e;                                                  //Maus war auf einem -> der index wird gespeichert! (nummer des Rectint)
                        break;
                    }
                }
                if (selectingLevel)
                {
                    if (KeyboardInputManager.Downward(Keyboard.Key.Back) && numberInput != "")
                    {
                        numberInput = numberInput.Remove(numberInput.Length - 1);
                    }
                    if (KeyboardInputManager.Downward(Keyboard.Key.Return) && numberInput != "")
                    {
                        int level = int.Parse(numberInput);
                        numberInput = "";
                        ManageProfiles manageProfiles = new ManageProfiles();
                        manageProfiles = manageProfiles.loadManageProfiles();

                        ManageStars manageStars = new ManageStars();
                        // TODO: find a freakin better way to do this... f*****g hax :(
                        manageStars = manageStars.unsafelyLoadManageStars(manageProfiles.getActiveProfileName());

                        if (manageStars.levelIsUnlocked(level))
                        {
                            Logger.Instance.Write("Level " + level + " is starting...", Logger.level.Info);
                            ProfileConstants.levelToPlay = level;
                            return(GameState.StartGameAtLevel);
                        }
                        else
                        {
                            Logger.Instance.Write("Level " + level + " was not yet unlocked", Logger.level.Info);
                            currentNumberInputDisplay.DisplayedString = "Level was not yet unlocked";
                            selectingLevel = false;
                            return(GameState.ChooseLevelState);
                        }
                    }
                    List <char> charList = KeyboardInputManager.getNumberInput();
                    foreach (char c in charList)
                    {
                        numberInput += c;
                    }
                    currentNumberInputDisplay.DisplayedString = numberInput;
                }
                else
                {
                    if (Mouse.IsButtonPressed(Mouse.Button.Left))                       //Wurde die LinkeMaustaste gedrückt?
                    {
                        switch (index)                                                  //Bin mit der Maus über den Index: SwitchCaseWeg
                        {                                                               //bearbeitet das aktuelle TextFeld
                        case 0:
                            selectingLevel = true;
                            return(GameState.ChooseLevelState);

                        //Levels
                        case 1: return(GameState.LoadLevelState);    //LevelsStarten

                        //Steuerung
                        case 2: return(GameState.LoadLevelState);

                        //MainMenu
                        case 3: return(GameState.LoadLevelState);
                        }
                    }
                    else
                    {
                        if (index != -1)
                        {
                            textlist[index].Color = Color.Blue;
                        }
                    }
                }
            }

            return(GameState.ChooseLevelState);
        }