Example #1
0
    public void PlayGame()
    {
        TxtHandler CurrentDataInTxtFile = new TxtHandler();

        SelectLevelMenu selector = new SelectLevelMenu();


        //Read text file to see the current level
        if (CurrentDataInTxtFile.getLevel() == 1)
        {
            selector.GoToLevelOne(true);
        }

        if (CurrentDataInTxtFile.getLevel() == 2)
        {
            selector.GoToLevelTwo(true);
        }

        if (CurrentDataInTxtFile.getLevel() == 3)
        {
            selector.GoToLevelThree(true);
        }

        if (CurrentDataInTxtFile.getLevel() == 4)
        {
            selector.GoToLevelFour(true);
        }

        if (CurrentDataInTxtFile.getLevel() == 5)
        {
            selector.GoToLevelFive(true);
        }

        SceneManager.LoadScene("Tap-That-Dot");
    }
Example #2
0
    void Update()
    {
        if (GameData.IsRunning)
        {
            if (_lastEnteredDot && GetDistanceFromLastDot() > LoseThreshold)
            {
                TxtHandler Reader = new TxtHandler();
                if (Reader.getIsMuted() == 0)
                {
                    //Triggers the sound

                    loseSound.Play();
                }

                DotMissedEvent.Raise();
            }



            if (_didTap)
            {
                GameData.IsRunning = true;
                if (_currentDot != null)
                {
                    Destroy(_currentDot);
                    GameData.DotsRemaining--;


                    // Plays with the pitch of the sound so it does not get repetitive
                    popSound.pitch = Random.Range(1, 3);


                    TxtHandler Reader = new TxtHandler();

                    if (Reader.getIsMuted() == 0)
                    {
                        //Triggers the sound
                        popSound.Play();
                    }



                    if (GameData.DotsRemaining <= 0)
                    {
                        int nextLevel = GameData.CurrentLevel + 1;

                        Reader.writeLevel(nextLevel);

                        OnWinEvent.Raise();

                        SelectLevelMenu selector = new SelectLevelMenu();
                        //Read text file to see the current level
                        if (Reader.getLevel() == 1)
                        {
                            selector.GoToLevelOne(false);
                        }

                        if (Reader.getLevel() == 2)
                        {
                            selector.GoToLevelTwo(false);
                        }

                        if (Reader.getLevel() == 3)
                        {
                            selector.GoToLevelThree(false);
                        }

                        if (Reader.getLevel() == 4)
                        {
                            selector.GoToLevelFour(false);
                        }

                        if (Reader.getLevel() == 5)
                        {
                            selector.GoToLevelFive(false);
                        }
                        if (Reader.getLevel() == 6)
                        {
                            SceneManager.LoadScene("VictoryScreen");
                        }

                        GameData.DotsRemaining = 0;
                        //GameData.CurrentLevel = GameData.CurrentLevel+1;
                    }
                    else
                    {
                        DotScoredEvent.Raise();
                    }
                }
                else
                {
                    DotMissedEvent.Raise();
                }
            }
        }
    }