Verified Commit b3a3b54a authored by Jørgen Syvertsen's avatar Jørgen Syvertsen
Browse files

Add HeroSelection between MainMenu and LobbyStates

parent a9834b09
......@@ -2,9 +2,10 @@ package se.battlegoo.battlegoose.gamestates
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import se.battlegoo.battlegoose.controllers.CreateLobbyController
import se.battlegoo.battlegoose.models.heroes.Hero
import se.battlegoo.battlegoose.views.CreateLobbyView
class CreateLobbyState : GameState() {
class CreateLobbyState(selectedHero: Hero) : LobbyState(selectedHero) {
private val createLobbyController: CreateLobbyController = CreateLobbyController(
createLobbyView = CreateLobbyView(
......
......@@ -10,7 +10,9 @@ import se.battlegoo.battlegoose.models.heroes.SergeantSwan
import se.battlegoo.battlegoose.views.HeroSelectionView
import se.battlegoo.battlegoose.views.HeroSelectionViewModel
class HeroSelectionState : GameState() {
class HeroSelectionState(
private val createLobbyState: (Hero<*>) -> LobbyState
): GameState() {
private val heroes: List<Hero> = listOf(SergeantSwan(), MajorMallard(), AdmiralAlbatross())
private val heroSelection = HeroSelection(heroes)
......@@ -28,11 +30,9 @@ class HeroSelectionState : GameState() {
private val controller = HeroSelectionController(
heroSelectionView,
heroSelection,
this::goBack
) { GameStateManager.replace(BattleState("", "", true)) } // TODO
private fun goBack() {
GameStateManager.goBack()
GameStateManager::goBack
) {
GameStateManager.replace(createLobbyState(heroSelection.selectedHero))
}
override fun update(dt: Float) {
......
......@@ -2,9 +2,10 @@ package se.battlegoo.battlegoose.gamestates
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import se.battlegoo.battlegoose.controllers.JoinLobbyController
import se.battlegoo.battlegoose.models.heroes.Hero
import se.battlegoo.battlegoose.views.JoinLobbyView
class JoinLobbyState : GameState() {
class JoinLobbyState(selectedHero: Hero) : LobbyState(selectedHero) {
private var joinLobbyController: JoinLobbyController = JoinLobbyController(
joinLobbyView = JoinLobbyView(stage),
......
package se.battlegoo.battlegoose.gamestates
import se.battlegoo.battlegoose.models.heroes.Hero
abstract class LobbyState(val selectedHero: Hero<*>) : GameState()
......@@ -11,8 +11,8 @@ class MainMenuState :
private var mainMenuView = MainMenuView(
stage,
onClickCreateLobby = { GameStateManager.push(CreateLobbyState()) },
onClickJoinLobby = { GameStateManager.push(JoinLobbyState()) },
onClickCreateLobby = { GameStateManager.push(HeroSelectionState { CreateLobbyState(it) }) },
onClickJoinLobby = { GameStateManager.push(HeroSelectionState { JoinLobbyState(it) }) },
// onClickJoinLobby = {
// Modal(
// "A longer title than the other",
......@@ -22,7 +22,7 @@ class MainMenuState :
// "This will move page",
// ModalType.Question(onYes = {GameStateManager.push(JoinLobbyState())} )).show()
// },
onClickQuickJoin = { GameStateManager.push(QuickJoinState()) },
onClickQuickJoin = { GameStateManager.push(HeroSelectionState { QuickJoinState(it) }) },
onClickLeaderboard = { GameStateManager.push(LeaderboardState()) },
onClickTutorial = { GameStateManager.push(TutorialState()) }
)
......
......@@ -2,9 +2,10 @@ package se.battlegoo.battlegoose.gamestates
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import se.battlegoo.battlegoose.controllers.QuickJoinController
import se.battlegoo.battlegoose.models.heroes.Hero
import se.battlegoo.battlegoose.views.QuickJoinView
class QuickJoinState : GameState() {
class QuickJoinState(selectedHero: Hero) : LobbyState(selectedHero) {
private val quickJoinController = QuickJoinController(
quickJoinView = QuickJoinView(this::goBack, stage),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment