diff --git a/app/src/main/java/com/example/superslidegame/fragments/PopUpFragment.kt b/app/src/main/java/com/example/superslidegame/fragments/PopUpFragment.kt index 97f2da3..6cfe070 100644 --- a/app/src/main/java/com/example/superslidegame/fragments/PopUpFragment.kt +++ b/app/src/main/java/com/example/superslidegame/fragments/PopUpFragment.kt @@ -8,6 +8,7 @@ import android.view.ViewGroup import android.widget.Button import androidx.fragment.app.DialogFragment import com.example.superslidegame.databinding.FragmentPopUpBinding +import com.example.superslidegame.game.screen.GameScreen import com.example.superslidegame.game.screen.SelectLevel import com.example.superslidegame.log.screen.LogScreen @@ -33,6 +34,12 @@ class PopUpFragment : DialogFragment() { val nextLevelButton : Button = binding.nextLevelButtonWin val logButton : Button = binding.logButtonWin + if ((activity as GameScreen).isLastLevel()) { + nextLevelButton.visibility = View.GONE + } else { + nextLevelButton.visibility = View.VISIBLE + } + menuButton.setOnClickListener { activity?.finish() dismiss() diff --git a/app/src/main/java/com/example/superslidegame/game/screen/GameScreen.kt b/app/src/main/java/com/example/superslidegame/game/screen/GameScreen.kt index b28a7b1..d284889 100644 --- a/app/src/main/java/com/example/superslidegame/game/screen/GameScreen.kt +++ b/app/src/main/java/com/example/superslidegame/game/screen/GameScreen.kt @@ -118,6 +118,13 @@ class GameScreen : AppCompatActivity() { return gameState.level } + /** + * isLastLevel returns true if the game is in the last level. + */ + fun isLastLevel() : Boolean { + return gameState.level == GameLevel.MAX_LEVEL + } + /** * getPlayingDifficulty returns the difficulty of the game. */