Esempio n. 1
0
        public MainMenuState()
        {
            MusicManager.PlayMusic(AssetManager.MusicName.MainMenu);
            Console.WriteLine("MAINMENUSTATE");
            profiles = new ManageProfiles();
            profiles = profiles.loadManageProfiles();
            Initialisation();
            background                    = new Sprite(AssetManager.GetTexture(AssetManager.TextureName.MainMenuBackground));
            shinyEffectBarSprite          = new Sprite(AssetManager.GetTexture(AssetManager.TextureName.ShinyEffectBar));
            shinyEffectBarSprite.Position = new Vector2(0, -3.9F * shinyEffectBarSprite.TextureRect.Height);

            testSpriteForCord          = new AnimatedSprite(AssetManager.GetTexture(AssetManager.TextureName.KeyAnimated), 0.1F, 8);
            testSpriteForCord.Position = new Vector2f(20, 100);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        void Initialisation()
        {
            font = FontLoader.Instance.LoadFont("Assets/Fonts/pixelhole.ttf");

            screenButtons           = new RectangleShape();
            screenButtons.Texture   = AssetManager.GetTexture(AssetManager.TextureName.LevelButtonOptions);
            screenButtons.Size      = new Vector2f(screenButtons.Texture.Size.X, screenButtons.Texture.Size.Y);
            screenButtons.Rotation  = 90;
            screenButtons.FillColor = new Color(255, 255, 255, 200);
            screenButtons.Origin    = new Vector2f(0, screenButtons.TextureRect.Height);
            debugButtonRect         = new RectangleShape();
            mainMap          = new RectangleShape(new Vector2f(1280, 720));
            mainMap.Position = new Vector2f(0, 0);
            mainMap.Texture  = AssetManager.GetTexture(AssetManager.TextureName.MapBackground1);
            helpMap          = new RectangleShape(mainMap);
            helpMap.Position = new Vector2f(-1000, -1000);
            slideSpeed       = 10f;
            sliding          = false;

            lastScreen = new SuperText("<", font, 1);
            lastScreen.CharacterSize = 200;
            lastScreen.Position      = new Vector2f(275, 445);
            lastScreen.minFrequency  = 5;
            lastScreen.maxFrequency  = 10;
            nextScreen = new SuperText(">", font, 1);
            nextScreen.CharacterSize = 200;
            nextScreen.Position      = new Vector2f(865, 445);
            nextScreen.minFrequency  = 5;
            nextScreen.maxFrequency  = 10;

            worldName = new SuperText("1", font, 0.2f);
            worldName.CharacterSize = 145;
            worldName.Position      = new Vector2f(440, 500);
            worldNameFakePos        = new Vector2f(-1000, -1000);
            worldNameRealPos        = worldName.Position;

            // ProfileConstants.activeProfile;
            profiles = new ManageProfiles();
            profiles = profiles.loadManageProfiles();
            stars    = new ManageStars();
            stars    = stars.unsafelyLoadManageStars(profiles.getActiveProfileName());

            // currentlevel is positive -> player played a level in during this session -> should at at that level
            if (ProfileConstants.curLevel >= 0)
            {
                currentLevel = ProfileConstants.curLevel;
            }
            else
            {
                currentLevel = stars.EverythingUnlocked() ? stars.GetLastSelectedLevel() : stars.getIndexOfFirstUnsolvedLevel();
            }

            mainButtonList       = new List <LevelSelectButton>();
            mainButtonTargetList = new List <Vector2f>();
            helpButtonList       = new List <LevelSelectButton>();
            helpButtonTargetList = new List <Vector2f>();

            levelSelectList = new List <LevelSelectionScreen>();

            // this list is used to initialize the levelscreens
            List <List <Vector2f> > posList = new List <List <Vector2f> >()
            {
                new List <Vector2f>()
                {
                    new Vector2f(115, 380), new Vector2f(205, 385), new Vector2f(325, 355), new Vector2f(445, 305), new Vector2f(505, 375),
                    new Vector2f(675, 345), new Vector2f(785, 275), new Vector2f(865, 245), new Vector2f(965, 205), new Vector2f(1045, 225), new Vector2f(1105, 345), new Vector2f(1115, 515)
                },

                new List <Vector2f>()
                {
                    new Vector2f(225, 395), new Vector2f(435, 315), new Vector2f(535, 325), new Vector2f(555, 395), new Vector2f(715, 385), new Vector2f(735, 495),
                    new Vector2f(875, 435), new Vector2f(935, 245), new Vector2f(955, 175), new Vector2f(1055, 195), new Vector2f(1175, 215), new Vector2f(1235, 345)
                },

                new List <Vector2f>()
                {
                    new Vector2f(355, 455), new Vector2f(515, 425), new Vector2f(695, 295), new Vector2f(825, 285), new Vector2f(935, 245), new Vector2f(1035, 445),
                    new Vector2f(1155, 405),
                },                             //new Vector2f(1095, 535), new Vector2f(1145, 425) },

                new List <Vector2f>()
                {
                    new Vector2f(75, 425), new Vector2f(155, 545), new Vector2f(245, 455), new Vector2f(345, 355), new Vector2f(485, 265), new Vector2f(615, 245),
                    new Vector2f(685, 255), new Vector2f(715, 305), new Vector2f(775, 375), new Vector2f(835, 415), new Vector2f(995, 425), new Vector2f(1075, 465), new Vector2f(1155, 475), new Vector2f(1215, 405), new Vector2f(1240, 320)
                }
            };
            List <Texture> backgroundList = new List <Texture>()
            {
                AssetManager.GetTexture(AssetManager.TextureName.MapBackground1), AssetManager.GetTexture(AssetManager.TextureName.MapBackground2), AssetManager.GetTexture(AssetManager.TextureName.MapBackground3), AssetManager.GetTexture(AssetManager.TextureName.MapBackground4)
            };
            int curStartIndex = 0;

            for (int i = 0; i < posList.Count; i++)
            {
                levelSelectList.Add(new LevelSelectionScreen(backgroundList[i], posList[i], curStartIndex));
                curStartIndex += posList[i].Count;
            }

            mainButtonList = new List <LevelSelectButton>();
            helpButtonList = new List <LevelSelectButton>();

            leftButton  = new Button(new Vector2f(300, 600), new Vector2i(0, 1), AssetManager.GetTexture(AssetManager.TextureName.LevelButtonOptions), AssetManager.GetTexture(AssetManager.TextureName.LevelButtonOptionsGlow), 90);
            rightButton = new Button(new Vector2f(900, 600), new Vector2i(1, 1), AssetManager.GetTexture(AssetManager.TextureName.LevelButtonOptions), AssetManager.GetTexture(AssetManager.TextureName.LevelButtonOptionsGlow), 90);

            currentScreenPosition     = new Vector2i(GetPositionOnCurrentLevelScreen(), 0);
            worldName.DisplayedString = "World " + GetIndexOfCurrentLevelScreen();
            mainMap.Texture           = levelSelectList[GetIndexOfCurrentLevelScreen()].texture;
            SetButtonList(mainButtonList, stars);
            levelInfo = new LevelInfo(mainButtonList[GetPositionOnCurrentLevelScreen()], new Vector2f(25, 25), stars.GetScoreOfLevel(currentLevel));
            SetCurrentLevelInfo();
        }
Esempio n. 4
0
        void MainCampaign()
        {
            levelList.Add(new Level("Assets/MapFiles/1_Gelb/Gelb01.txt", 64, new Vector2i(2, 2), 1));
            levelList.Add(new Level("Assets/MapFiles/1_Gelb/Gelb02-EinfuehrungOrdner.txt", 64, new Vector2i(2, 3), 1));
            levelList.Add(new Level("Assets/MapFiles/1_Gelb/Gelb03.txt", 64, new Vector2i(4, 3), 1));
            levelList.Add(new Level("Assets/MapFiles/1_Gelb/Gelb04.txt", 64, new Vector2i(8, 1), 1));
            levelList.Add(new Level("Assets/MapFiles/1_Gelb/Gelb05-EinfuehrungSchalter.txt", 64, new Vector2i(6, 4), 1));
            levelList.Add(new Level("Assets/MapFiles/1_Gelb/Gelb06.txt", 64, new Vector2i(7, 3), 1));
            levelList.Add(new Level("Assets/MapFiles/1_Gelb/Gelb07.txt", 64, new Vector2i(10, 4), 1));
            levelList.Add(new Level("Assets/MapFiles/1_Gelb/Gelb08.txt", 64, new Vector2i(7, 2), 1));
            levelList.Add(new Level("Assets/MapFiles/1_Gelb/Gelb09.txt", 64, new Vector2i(3, 1), 1));
            levelList.Add(new Level("Assets/MapFiles/1_Gelb/Gelb10.txt", 64, new Vector2i(4, 3), 1));
            levelList.Add(new Level("Assets/MapFiles/1_Gelb/Gelb11.05.txt", 64, new Vector2i(6, 1), 1));
            levelList.Add(new Level("Assets/MapFiles/1_Gelb/Gelb11.txt", 64, new Vector2i(7, 7), 1));

            levelList.Add(new Level("Assets/MapFiles/2_Rot/Rot01-EinfuehrungRoterBot.txt", 64, new Vector2i(8, 3), 1));
            levelList.Add(new Level("Assets/MapFiles/2_Rot/Rot02.txt", 64, new Vector2i(1, 1), 1));
            levelList.Add(new Level("Assets/MapFiles/2_Rot/Rot03.txt", 64, new Vector2i(1, 4), 1));
            levelList.Add(new Level("Assets/MapFiles/2_Rot/Rot04.txt", 64, new Vector2i(7, 2), 1));
            levelList.Add(new Level("Assets/MapFiles/2_Rot/Rot05.txt", 64, new Vector2i(5, 7), 1));
            levelList.Add(new Level("Assets/MapFiles/2_Rot/Rot06.txt", 64, new Vector2i(5, 5), 1));

            levelList.Add(new Level("Assets/MapFiles/2_Rot/TRot01-EinfuehrungTeleporter.txt", 64, new Vector2i(4, 3), 1));
            levelList.Add(new Level("Assets/MapFiles/2_Rot/TRot02.txt", 64, new Vector2i(6, 2), 1));
            levelList.Add(new Level("Assets/MapFiles/2_Rot/TRot03.txt", 64, new Vector2i(1, 6), 1));
            levelList.Add(new Level("Assets/MapFiles/2_Rot/TRot04.txt", 64, new Vector2i(1, 5), 1));
            levelList.Add(new Level("Assets/MapFiles/2_Rot/TRot05.txt", 64, new Vector2i(7, 4), 1));
            levelList.Add(new Level("Assets/MapFiles/2_Rot/TRot06.txt", 64, new Vector2i(8, 1), 1));

            levelList.Add(new Level("Assets/MapFiles/3_Gruen/Gruen01.txt", 64, new Vector2i(8, 3), 1));
            levelList.Add(new Level("Assets/MapFiles/3_Gruen/Gruen02.txt", 64, new Vector2i(4, 3), 1));
            levelList.Add(new Level("Assets/MapFiles/3_Gruen/Gruen03.txt", 64, new Vector2i(6, 4), 1));
            levelList.Add(new Level("Assets/MapFiles/3_Gruen/Gruen05.txt", 64, new Vector2i(9, 9), 1));
            levelList.Add(new Level("Assets/MapFiles/3_Gruen/Gruen06.txt", 64, new Vector2i(8, 6), 1));
            levelList.Add(new Level("Assets/MapFiles/3_Gruen/Gruen07.txt", 64, new Vector2i(4, 10), 1));
            levelList.Add(new Level("Assets/MapFiles/3_Gruen/Gruen99Laby.txt", 64, new Vector2i(3, 3), 1));


            levelList.Add(new Level("Assets/MapFiles/4_Blau/Blau01.txt", 64, new Vector2i(5, 4), 1));
            levelList.Add(new Level("Assets/MapFiles/4_Blau/Blau02.txt", 64, new Vector2i(2, 5), 1));
            levelList.Add(new Level("Assets/MapFiles/4_Blau/Blau03.txt", 64, new Vector2i(5, 5), 1));
            levelList.Add(new Level("Assets/MapFiles/4_Blau/Blau04.txt", 64, new Vector2i(4, 1), 1));
            levelList.Add(new Level("Assets/MapFiles/4_Blau/Blau05.txt", 64, new Vector2i(5, 4), 1));
            levelList.Add(new Level("Assets/MapFiles/4_Blau/Blau06.txt", 64, new Vector2i(4, 5), 1));
            levelList.Add(new Level("Assets/MapFiles/4_Blau/Blau07.txt", 64, new Vector2i(5, 3), 1));
            levelList.Add(new Level("Assets/MapFiles/4_Blau/Blau071.txt", 64, new Vector2i(10, 7), 1));
            levelList.Add(new Level("Assets/MapFiles/4_Blau/Blau08.txt", 64, new Vector2i(11, 3), 1));
            levelList.Add(new Level("Assets/MapFiles/4_Blau/Blau09.txt", 64, new Vector2i(6, 4), 1));
            levelList.Add(new Level("Assets/MapFiles/4_Blau/Blau10.txt", 64, new Vector2i(2, 5), 1));
            levelList.Add(new Level("Assets/MapFiles/4_Blau/Blau11.txt", 64, new Vector2i(10, 3), 1));
            levelList.Add(new Level("Assets/MapFiles/4_Blau/Blau12.txt", 64, new Vector2i(10, 12), 1));
            levelList.Add(new Level("Assets/MapFiles/4_Blau/Blau13.txt", 64, new Vector2i(8, 10), 1));
            levelList.Add(new Level("Assets/MapFiles/4_Blau/thankyouforplaying.txt", 64, new Vector2i(2, 4), 1));


            nextGameState = GameState.InGame;

            // manageProfiles has to load all active profiles before it can be accessed
            manageProfiles = new ManageProfiles();
            manageProfiles = manageProfiles.loadManageProfiles();
            manageStars    = new ManageStars();
            manageStars    = manageStars.loadManageStars(manageProfiles.getActiveProfileName(), levelList.Count);
            curIndex       = manageStars.getIndexOfFirstUnsolvedLevel();
            SetTutorials();
        }