Exemplo n.º 1
0
        private void UpdateProfilePercentage()
        {
            for (int i = 1; i <= 3; i++)
            {
                String percentageString = "";
                if (profiles.ProfileExists((MemoryMaze.profiles)i))
                {
                    stars            = stars.unsafelyLoadManageStars(profiles.getProfileName((MemoryMaze.profiles)i));
                    percentageString = stars.GetPercentage();
                }
                percentageString = percentageString.PadLeft(4, ' ');
                switch ((MemoryMaze.profiles)i)
                {
                case MemoryMaze.profiles.one:
                    profileOnePercentage.DisplayedString = percentageString;
                    break;

                case MemoryMaze.profiles.two:
                    profileTwoPercentage.DisplayedString = percentageString;
                    break;

                case MemoryMaze.profiles.three:
                    ProfileThreePercentage.DisplayedString = percentageString;
                    break;
                }
            }
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
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);
        }