Beispiel #1
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;
                }
            }
        }
Beispiel #2
0
        public void update(float deltaTime)
        {
            float speed = deltaTime;

            Vector2 inputMovement = new Vector2(0F, 0F);

            inputMovement.Y += KeyboardInputManager.IsPressed(Keyboard.Key.Down) ? speed : 0F;
            inputMovement.Y += KeyboardInputManager.IsPressed(Keyboard.Key.Up) ? -speed : 0F;

            inputMovement.X += KeyboardInputManager.IsPressed(Keyboard.Key.Left) ? -speed : 0F;
            inputMovement.X += KeyboardInputManager.IsPressed(Keyboard.Key.Right) ? speed : 0F;

            if (inputMovement.Y != 0F || inputMovement.X != 0F)
            {
                movement += inputMovement * speed / (float)Math.Sqrt(inputMovement.X * inputMovement.X + inputMovement.Y * inputMovement.Y);
            }

            movement *= (1F - deltaTime * 4F);    // friction

            position += movement;

            if (position.X < 0)
            {
                position -= movement;
                movement *= Vector2.Up;
            }
        }
Beispiel #3
0
        public GameState Update(float deltaTime)
        {
            if (KeyboardInputManager.IsPressed(Keyboard.Key.Return))
            {
                return(GameState.InGame);
            }

            return(GameState.MainMenu);
        }
Beispiel #4
0
 void DestroyBotForPoints(Bot it)
 {
     if (KeyboardInputManager.IsPressed(Keyboard.Key.R) && (controllid == 1) && it == botList.Find(b => b.id == 1))
     {
         scoreCounter += it.counter * (-1);
         it.isAlive    = false;
     }
     if (KeyboardInputManager.IsPressed(Keyboard.Key.R) && (controllid == 2) && it == botList.Find(b => b.id == 2))
     {
         scoreCounter += it.counter * (-1);
         it.isAlive    = false;
     }
     if (KeyboardInputManager.IsPressed(Keyboard.Key.R) && (controllid == 3) && it == botList.Find(b => b.id == 3))
     {
         scoreCounter += it.counter * (-1);
         it.isAlive    = false;
     }
 }
Beispiel #5
0
        void  CreateBot(Map map, Player player)                                                         //List<Bot> botsList, bool b_redbot, bool b_bluebot, bool b_greenbot)
        {
            if (KeyboardInputManager.IsPressed(Keyboard.Key.Num2) && (!iserstellt) && (!player.redbot)) //ToDo: Bedingungen zum erstelelen
            {
                if (player.redItemCounter > 0)
                {
                    redBot = new RedBot(mapPosition, map);
                    player.botList.Add(redBot);
                    player.controllid = 1;
                    counter           = 0;
                    player.redItemCounter--;
                    CreateBot();
                }
            }
            if (KeyboardInputManager.IsPressed(Keyboard.Key.Num2) && (!iserstellt) && (player.redbot))
            {
                if (player.redItemCounter > 0)
                {
                    player.scoreCounter -= player.botList.Find(b => b.id == 1).counter;
                    player.botList.Remove(player.botList.Find(b => b.id == 1));
                    redBot = new RedBot(mapPosition, map);
                    player.botList.Add(redBot);
                    player.controllid = 1;
                    counter           = 0;
                    player.redItemCounter--;
                    CreateBot();
                }
            }

            if (KeyboardInputManager.IsPressed(Keyboard.Key.Num4) && (!iserstellt) && (!player.bluebot)) //ToDo: Bedingungen zum erstelelen
            {
                if (player.blueItemCounter > 0)
                {
                    blueBot = new BlueBot(mapPosition, map);
                    player.botList.Add(blueBot);
                    player.controllid = 2;
                    counter           = 0;
                    player.blueItemCounter--;
                    CreateBot();
                }
            }
            if (KeyboardInputManager.IsPressed(Keyboard.Key.Num4) && (!iserstellt) && (player.bluebot))
            {
                if (player.blueItemCounter > 0)
                {
                    player.scoreCounter -= player.botList.Find(b => b.id == 2).counter;
                    player.botList.Remove(player.botList.Find(b => b.id == 2));

                    blueBot = new BlueBot(mapPosition, map);
                    player.botList.Add(blueBot);
                    player.controllid = 2;
                    counter           = 0;
                    player.blueItemCounter--;
                    CreateBot();
                }
            }
            if (KeyboardInputManager.IsPressed(Keyboard.Key.Num3) && (!iserstellt) && (!player.greenbot)) //ToDo: Bedingungen zum erstelelen
            {
                if (player.greenItemCounter > 0)
                {
                    greenBot = new GreenBot(mapPosition, map);
                    player.botList.Add(greenBot);
                    player.controllid = 3;
                    counter           = 0;
                    player.greenItemCounter--;
                    CreateBot();
                }
            }
            if (KeyboardInputManager.IsPressed(Keyboard.Key.Num3) && (!iserstellt) && (player.greenbot))
            {
                if (player.greenItemCounter > 0)
                {
                    player.scoreCounter -= player.botList.Find(b => b.id == 3).counter;
                    player.botList.Remove(player.botList.Find(b => b.id == 3));
                    greenBot = new GreenBot(mapPosition, map);
                    player.botList.Add(greenBot);
                    player.controllid = 3;
                    counter           = 0;
                    player.greenItemCounter--;
                    CreateBot();
                }
            }
        }
Beispiel #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);
        }
Beispiel #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);
        }