Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 3 and 4 Player Mode #45

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ import Foundation
enum PlayersMode {
case singleplayer
case multiplayer
case threeplayer
case fourplayer
}
2 changes: 2 additions & 0 deletions TumblingTowersGame/TumblingTowersGame/Models/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ Pause Button: Pauses the game.
case gameModeSelection
case singleplayerGameplay
case multiplayerGameplay
case threeplayerGameplay
case fourplayerGameplay
case settings
case tutorial
case achievements
Expand Down
86 changes: 85 additions & 1 deletion TumblingTowersGame/TumblingTowersGame/Views/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,45 @@ struct ContentView: View {
} else if currGameScreen == .multiplayerGameplay, let gameMode = mainGameMgr.gameMode {
VStack {
GameplayLevelView(currGameScreen: $currGameScreen, gameEngineMgr: mainGameMgr.createGameEngineManager(height: deviceHeight / 2, width: deviceWidth), gameMode: gameMode)
.rotation3DEffect(.degrees(180), axis: (x: 0, y: 0, z: 1))
.rotation3DEffect(.degrees(180), axis: (x: 0, y: 0, z: 1))
GameplayLevelView(currGameScreen: $currGameScreen, gameEngineMgr: mainGameMgr.createGameEngineManager(height: deviceHeight / 2, width: deviceWidth), gameMode: gameMode)
}
} else if currGameScreen == .threeplayerGameplay, let gameMode = mainGameMgr.gameMode {
VStack {
HStack {
GameplayLevelView(currGameScreen: $currGameScreen, gameEngineMgr: mainGameMgr.createGameEngineManager(height: deviceHeight / 2, width: deviceWidth / 2), gameMode: gameMode)
.rotation3DEffect(.degrees(180), axis: (x: 0, y: 0, z: 1))
.frame(width: deviceWidth / 2, height: deviceHeight / 2, alignment: .trailing)

GameplayLevelView(currGameScreen: $currGameScreen, gameEngineMgr: mainGameMgr.createGameEngineManager(height: deviceHeight / 2, width: deviceWidth / 2), gameMode: gameMode)
.rotation3DEffect(.degrees(180), axis: (x: 0, y: 0, z: 1))
.frame(width: deviceWidth / 2, height: deviceHeight / 2, alignment: .trailing)
}

HStack {
GameplayLevelView(currGameScreen: $currGameScreen, gameEngineMgr: mainGameMgr.createGameEngineManager(height: deviceHeight / 2, width: deviceWidth), gameMode: gameMode)
}
}
} else if currGameScreen == .fourplayerGameplay, let gameMode = mainGameMgr.gameMode {
VStack {
HStack {
GameplayLevelView(currGameScreen: $currGameScreen, gameEngineMgr: mainGameMgr.createGameEngineManager(height: deviceHeight / 2, width: deviceWidth / 2), gameMode: gameMode)
.rotation3DEffect(.degrees(180), axis: (x: 0, y: 0, z: 1))
.frame(width: deviceWidth / 2, height: deviceHeight / 2, alignment: .trailing)

GameplayLevelView(currGameScreen: $currGameScreen, gameEngineMgr: mainGameMgr.createGameEngineManager(height: deviceHeight / 2, width: deviceWidth / 2), gameMode: gameMode)
.rotation3DEffect(.degrees(180), axis: (x: 0, y: 0, z: 1))
.frame(width: deviceWidth / 2, height: deviceHeight / 2, alignment: .trailing)
}

HStack {
GameplayLevelView(currGameScreen: $currGameScreen, gameEngineMgr: mainGameMgr.createGameEngineManager(height: deviceHeight / 2, width: deviceWidth / 2), gameMode: gameMode)
.frame(width: deviceWidth / 2, height: deviceHeight / 2, alignment: .trailing)

GameplayLevelView(currGameScreen: $currGameScreen, gameEngineMgr: mainGameMgr.createGameEngineManager(height: deviceHeight / 2, width: deviceWidth / 2), gameMode: gameMode)
.frame(width: deviceWidth / 2, height: deviceHeight / 2, alignment: .trailing)
}
}
} else if currGameScreen == .settings {
SettingsView(settingsMgr: SettingsManager(), currGameScreen: $currGameScreen, selectedInputType: mainGameMgr.inputSystem)
.environmentObject(mainGameMgr)
Expand Down Expand Up @@ -75,6 +111,54 @@ struct ContentView: View {
.environmentObject(gameEngineMgr2)
}
}
} else if mainGameMgr.playersMode == .threeplayer {
if mainGameMgr.gameEngineMgrs.count == 3,
let gameEngineMgr = mainGameMgr.gameEngineMgrs[0],
let gameEngineMgr2 = mainGameMgr.gameEngineMgrs[1],
let gameEngineMgr3 = mainGameMgr.gameEngineMgrs[2],
gameEngineMgr.gameEnded {
VStack {
HStack {
GameEndView(currGameScreen: $currGameScreen)
.environmentObject(gameEngineMgr)
.rotation3DEffect(.degrees(180), axis: (x: 0, y: 0, z: 1))
GameEndView(currGameScreen: $currGameScreen)
.environmentObject(gameEngineMgr2)
.rotation3DEffect(.degrees(180), axis: (x: 0, y: 0, z: 1))
}

HStack {
GameEndView(currGameScreen: $currGameScreen)
.environmentObject(gameEngineMgr3)
}
}
}
} else if mainGameMgr.playersMode == .fourplayer {
if mainGameMgr.gameEngineMgrs.count == 4,
let gameEngineMgr = mainGameMgr.gameEngineMgrs[0],
let gameEngineMgr2 = mainGameMgr.gameEngineMgrs[1],
let gameEngineMgr3 = mainGameMgr.gameEngineMgrs[2],
let gameEngineMgr4 = mainGameMgr.gameEngineMgrs[3],
gameEngineMgr.gameEnded {
VStack {
HStack {
GameEndView(currGameScreen: $currGameScreen)
.environmentObject(gameEngineMgr)
.rotation3DEffect(.degrees(180), axis: (x: 0, y: 0, z: 1))
GameEndView(currGameScreen: $currGameScreen)
.environmentObject(gameEngineMgr2)
.rotation3DEffect(.degrees(180), axis: (x: 0, y: 0, z: 1))
}

HStack {
GameEndView(currGameScreen: $currGameScreen)
.environmentObject(gameEngineMgr3)

GameEndView(currGameScreen: $currGameScreen)
.environmentObject(gameEngineMgr4)
}
}
}
}
}
)
Expand Down
4 changes: 2 additions & 2 deletions TumblingTowersGame/TumblingTowersGame/Views/GameEndView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ struct GameEndView: View {
VStack {
if gameEngineMgr.gameEnded {
Text(gameEngineMgr.gameEndMainMessage)
.font(.system(size: 70))
.font(.system(size: 45))
.fontWeight(.heavy)
Text(gameEngineMgr.gameEndSubMessage)
.font(.system(size: 30))
.font(.system(size: 25))
}
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,43 +24,23 @@ struct GameModeSelectView: View {

VStack {

if $mainGameMgr.playersMode.wrappedValue == .singleplayer {
if let playersMode = mainGameMgr.playersMode {
HStack {
drawGameModeOption(gameMode: .SURVIVAL, playerMode: .singleplayer,
drawGameModeOption(gameMode: .SURVIVAL, playerMode: playersMode,
name: Constants.GameModeTypes.SURVIVAL.rawValue.uppercased(),
fontSize: 30.0, red: 1, green: 0.341, blue: 0.341)

drawGameModeOption(gameMode: .SANDBOX, playerMode: .singleplayer,
drawGameModeOption(gameMode: .SANDBOX, playerMode: playersMode,
name: Constants.GameModeTypes.SANDBOX.rawValue.uppercased(),
fontSize: 30.0, red: 0.322, green: 0.443, blue: 1)
}

HStack {
drawGameModeOption(gameMode: .RACECLOCK, playerMode: .singleplayer,
drawGameModeOption(gameMode: .RACECLOCK, playerMode: playersMode,
name: Constants.GameModeTypes.RACECLOCK.rawValue.uppercased(),
fontSize: 30.0, red: 0.322, green: 1, blue: 0.322)

drawGameModeOption(gameMode: .TALLENOUGH, playerMode: .singleplayer,
name: Constants.GameModeTypes.TALLENOUGH.rawValue.uppercased(),
fontSize: 25.0, red: 1, green: 1, blue: 0.322)
}
} else if $mainGameMgr.playersMode.wrappedValue == .multiplayer {
HStack {
drawGameModeOption(gameMode: .SURVIVAL, playerMode: .multiplayer,
name: Constants.GameModeTypes.SURVIVAL.rawValue.uppercased(),
fontSize: 30.0, red: 1, green: 0.341, blue: 0.341)

drawGameModeOption(gameMode: .SANDBOX, playerMode: .multiplayer,
name: Constants.GameModeTypes.SANDBOX.rawValue.uppercased(),
fontSize: 30.0, red: 0.322, green: 0.443, blue: 1)
}

HStack {
drawGameModeOption(gameMode: .RACECLOCK, playerMode: .multiplayer,
name: Constants.GameModeTypes.RACECLOCK.rawValue.uppercased(),
fontSize: 30.0, red: 0.322, green: 1, blue: 0.322)

drawGameModeOption(gameMode: .TALLENOUGH, playerMode: .multiplayer,
drawGameModeOption(gameMode: .TALLENOUGH, playerMode: playersMode,
name: Constants.GameModeTypes.TALLENOUGH.rawValue.uppercased(),
fontSize: 25.0, red: 1, green: 1, blue: 0.322)
}
Expand Down Expand Up @@ -98,6 +78,10 @@ struct GameModeSelectView: View {
} else if playerMode == .multiplayer {
// do something
currGameScreen = .multiplayerGameplay
} else if playerMode == .threeplayer {
currGameScreen = .threeplayerGameplay
} else if playerMode == .fourplayer {
currGameScreen = .fourplayerGameplay
}
} label: {
Text(name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,21 @@ struct PlayersSelectView: View {
Text("How many players:")
.modifier(MenuButtonText(fontSize: 50))
Spacer().frame(height: 100)
HStack {
drawPlayersOption(playersMode: .singleplayer, name: "Singleplayer", fontSize: 30.0, red: 1, green: 0.341, blue: 0.341)

drawPlayersOption(playersMode: .multiplayer, name: "Multiplayer", fontSize: 30.0, red: 0.322, green: 0.443, blue: 1)

// MARK: Add back later
// drawGameModeOption(gameMode: .RACECLOCK, name: "RACE AGAINST CLOCK", fontSize: 30.0)
VStack {
HStack {
drawPlayersOption(playersMode: .singleplayer, name: "Singleplayer", fontSize: 30.0, red: 1, green: 0.341, blue: 0.341)

drawPlayersOption(playersMode: .multiplayer, name: "2 Players", fontSize: 30.0, red: 0.322, green: 0.443, blue: 1)

// MARK: Add back later
// drawGameModeOption(gameMode: .RACECLOCK, name: "RACE AGAINST CLOCK", fontSize: 30.0)
}

HStack {
drawPlayersOption(playersMode: .threeplayer, name: "3 Players", fontSize: 30.0, red: 0.322, green: 1, blue: 0.322)

drawPlayersOption(playersMode: .fourplayer, name: "4 Players", fontSize: 30.0, red: 1, green: 1, blue: 0.322)
}
}

NormalGoBackButtonView(currGameScreen: $currGameScreen)
Expand Down