Esempio n. 1
0
        private async void RightButtonClicked(object sender, EventArgs e)
        {
            if (!gameVars._displayKnown)
            {
                gameVars.IterationWordsLeft--;
                gameVars._currentIndex++;
                if (gameVars._currentIndex >= gameVars._currentDeck.Count) //finished iteration
                {
                    gameVars._currentDeck       = WordShuffler.ShuffleDeck(gameVars._incorrectWords);
                    gameVars._currentIndex      = 0;
                    gameVars.IterationWordsLeft = gameVars._currentDeck.Count;
                    gameVars._incorrectWords    = new List <Word>();
                }

                if (IsGameOver()) //check if game over
                {
                    await DisplayAlert("Finish", "Well Done!", "Back");

                    await Navigation.PopAsync();
                }
                else  //new iteration, game not over
                {
                    gameVars._displayKnown = true;
                    gameVars._currentWord  = gameVars._currentDeck[gameVars._currentIndex];
                    gameVars.DisplayText   = gameVars._currentWord.KnownWord;
                    if (gameVars._currentIndex == 0)
                    {
                        await DisplayAlert("", $"Starting new iteration with {gameVars._currentDeck.Count} words.", "OK");
                    }
                }

                FlipButtonsOpacity();
            }
        }
Esempio n. 2
0
        private void InitializeGameVariables(Group group)
        {
            gameVars = new GameVars();

            gameVars._group             = group;
            gameVars._words             = new List <Word>(VocabularySerializer.Deserialize(group.Words));
            gameVars._incorrectWords    = new List <Word>();
            gameVars._currentIndex      = 0;
            gameVars._currentDeck       = WordShuffler.ShuffleDeck(gameVars._words);
            gameVars.IterationWordsLeft = gameVars._currentDeck.Count;
            gameVars._displayKnown      = true;
            gameVars._currentWord       = gameVars._currentDeck[gameVars._currentIndex];
            gameVars.DisplayText        = gameVars._currentWord.KnownWord;

            Display.BindingContext   = this.gameVars as GameVars;
            WordsLeft.BindingContext = this.gameVars as GameVars;

            FlipButtonsOpacity();
        }
Esempio n. 3
0
        private async void WrongButtonClicked(object sender, EventArgs e)
        {
            if (!gameVars._displayKnown)
            {
                gameVars._incorrectWords.Add(gameVars._currentWord);
                gameVars.IterationWordsLeft--;
                gameVars._currentIndex++;
                if (gameVars._currentIndex >= gameVars._currentDeck.Count) //finished iteration
                {
                    gameVars._currentDeck       = WordShuffler.ShuffleDeck(gameVars._incorrectWords);
                    gameVars._currentIndex      = 0;
                    gameVars.IterationWordsLeft = gameVars._currentDeck.Count;
                    gameVars._incorrectWords    = new List <Word>();
                    await DisplayAlert("", $"Starting new iteration with {gameVars._currentDeck.Count} words.", "OK");
                }

                gameVars._displayKnown = true;
                gameVars._currentWord  = gameVars._currentDeck[gameVars._currentIndex];
                gameVars.DisplayText   = gameVars._currentWord.KnownWord;

                FlipButtonsOpacity();
            }
        }