-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔀 Merge branch 'hugo/feature/Add-ColorQuest-gameplay'
- Loading branch information
Showing
7 changed files
with
226 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
Apps/LekaActivityUIExplorer/Sources/NewUI/Activities/ColorBingo/ColorBingoLevelOne.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Leka - iOS Monorepo | ||
// Copyright 2023 APF France handicap | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import GameEngineKit | ||
import SwiftUI | ||
|
||
private let choicesStep1 = [ | ||
ChoiceViewModel(item: "blue", type: .color, rightAnswer: true) | ||
] | ||
|
||
private let choicesStep2 = [ | ||
ChoiceViewModel(item: "green", type: .color, rightAnswer: true) | ||
] | ||
|
||
private let choicesStep3 = [ | ||
ChoiceViewModel(item: "pink", type: .color, rightAnswer: true) | ||
] | ||
|
||
private let choicesStep4 = [ | ||
ChoiceViewModel(item: "yellow", type: .color, rightAnswer: true) | ||
] | ||
|
||
private let choicesStep5 = [ | ||
ChoiceViewModel(item: "red", type: .color, rightAnswer: true) | ||
|
||
] | ||
|
||
private var steps: [StandardStepModel] = [ | ||
StandardStepModel(choices: choicesStep1, gameplay: .colorBingo, interface: .oneChoice), | ||
StandardStepModel(choices: choicesStep2, gameplay: .colorBingo, interface: .oneChoice), | ||
StandardStepModel(choices: choicesStep3, gameplay: .colorBingo, interface: .oneChoice), | ||
StandardStepModel(choices: choicesStep4, gameplay: .colorBingo, interface: .oneChoice), | ||
StandardStepModel(choices: choicesStep5, gameplay: .colorBingo, interface: .oneChoice), | ||
] | ||
|
||
struct ColorBingoLevelOne: View { | ||
private var stepManager = StepManager(steps: steps) | ||
|
||
var body: some View { | ||
StepView(stepManager: stepManager) | ||
} | ||
} | ||
|
||
struct ColorBingoLevelOne_Previews: PreviewProvider { | ||
static var previews: some View { | ||
ColorBingoLevelOne() | ||
.previewInterfaceOrientation(.landscapeLeft) | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
Apps/LekaActivityUIExplorer/Sources/NewUI/Activities/ColorBingo/ColorBingoLevelThree.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Leka - iOS Monorepo | ||
// Copyright 2023 APF France handicap | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import GameEngineKit | ||
import SwiftUI | ||
|
||
private let choicesStep1 = [ | ||
ChoiceViewModel(item: "red", type: .color), | ||
ChoiceViewModel(item: "blue", type: .color, rightAnswer: true), | ||
ChoiceViewModel(item: "yellow", type: .color), | ||
] | ||
|
||
private let choicesStep2 = [ | ||
ChoiceViewModel(item: "purple", type: .color), | ||
ChoiceViewModel(item: "green", type: .color), | ||
ChoiceViewModel(item: "blue", type: .color, rightAnswer: true), | ||
] | ||
|
||
private let choicesStep3 = [ | ||
ChoiceViewModel(item: "yellow", type: .color, rightAnswer: true), | ||
ChoiceViewModel(item: "blue", type: .color), | ||
ChoiceViewModel(item: "red", type: .color), | ||
] | ||
|
||
private let choicesStep4 = [ | ||
ChoiceViewModel(item: "green", type: .color), | ||
ChoiceViewModel(item: "pink", type: .color), | ||
ChoiceViewModel(item: "yellow", type: .color, rightAnswer: true), | ||
] | ||
|
||
private let choicesStep5 = [ | ||
ChoiceViewModel(item: "red", type: .color, rightAnswer: true), | ||
ChoiceViewModel(item: "blue", type: .color), | ||
ChoiceViewModel(item: "yellow", type: .color), | ||
] | ||
|
||
private var steps: [StandardStepModel] = [ | ||
StandardStepModel(choices: choicesStep1, gameplay: .colorBingo, interface: .threeChoicesInline), | ||
StandardStepModel(choices: choicesStep2, gameplay: .colorBingo, interface: .threeChoicesInline), | ||
StandardStepModel(choices: choicesStep3, gameplay: .colorBingo, interface: .threeChoicesInline), | ||
StandardStepModel(choices: choicesStep4, gameplay: .colorBingo, interface: .threeChoicesInline), | ||
StandardStepModel(choices: choicesStep5, gameplay: .colorBingo, interface: .threeChoicesInline), | ||
] | ||
|
||
struct ColorBingoLevelThree: View { | ||
private var stepManager = StepManager(steps: steps) | ||
|
||
var body: some View { | ||
StepView(stepManager: stepManager) | ||
} | ||
} | ||
|
||
struct ColorBingoLevelThree_Previews: PreviewProvider { | ||
static var previews: some View { | ||
ColorBingoLevelThree() | ||
.previewInterfaceOrientation(.landscapeLeft) | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
Apps/LekaActivityUIExplorer/Sources/NewUI/Activities/ColorBingo/ColorBingoLevelTwo.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Leka - iOS Monorepo | ||
// Copyright 2023 APF France handicap | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import GameEngineKit | ||
import SwiftUI | ||
|
||
private let choicesStep1 = [ | ||
ChoiceViewModel(item: "red", type: .color), | ||
ChoiceViewModel(item: "green", type: .color, rightAnswer: true), | ||
] | ||
|
||
private let choicesStep2 = [ | ||
ChoiceViewModel(item: "purple", type: .color), | ||
ChoiceViewModel(item: "blue", type: .color, rightAnswer: true), | ||
] | ||
|
||
private let choicesStep3 = [ | ||
ChoiceViewModel(item: "yellow", type: .color, rightAnswer: true), | ||
ChoiceViewModel(item: "red", type: .color), | ||
] | ||
|
||
private let choicesStep4 = [ | ||
ChoiceViewModel(item: "pink", type: .color), | ||
ChoiceViewModel(item: "yellow", type: .color, rightAnswer: true), | ||
] | ||
|
||
private let choicesStep5 = [ | ||
ChoiceViewModel(item: "red", type: .color, rightAnswer: true), | ||
ChoiceViewModel(item: "green", type: .color), | ||
] | ||
|
||
private var steps: [StandardStepModel] = [ | ||
StandardStepModel(choices: choicesStep1, gameplay: .colorBingo, interface: .twoChoices), | ||
StandardStepModel(choices: choicesStep2, gameplay: .colorBingo, interface: .twoChoices), | ||
StandardStepModel(choices: choicesStep3, gameplay: .colorBingo, interface: .twoChoices), | ||
StandardStepModel(choices: choicesStep4, gameplay: .colorBingo, interface: .twoChoices), | ||
StandardStepModel(choices: choicesStep5, gameplay: .colorBingo, interface: .twoChoices), | ||
] | ||
|
||
struct ColorBingoLevelTwo: View { | ||
private var stepManager = StepManager(steps: steps) | ||
|
||
var body: some View { | ||
StepView(stepManager: stepManager) | ||
} | ||
} | ||
|
||
struct ColorBingoLevelTwo_Previews: PreviewProvider { | ||
static var previews: some View { | ||
ColorBingoLevelTwo() | ||
.previewInterfaceOrientation(.landscapeLeft) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
Modules/GameEngineKit/Sources/Gameplay/Specific/ColorBingoGameplay.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Leka - iOS Monorepo | ||
// Copyright 2023 APF France handicap | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import Combine | ||
import Foundation | ||
|
||
public class ColorBingoGameplay: GameplayProtocol { | ||
public var choices = CurrentValueSubject<[ChoiceViewModel], Never>([]) | ||
public var state = CurrentValueSubject<GameplayState, Never>(.idle) | ||
|
||
public init(choices: [ChoiceViewModel]) { | ||
self.choices.send(choices) | ||
self.state.send(.playing) | ||
|
||
// TODO(@ladislas): Show the right answer color on Leka's belt | ||
let index = self.choices.value.firstIndex(where: { $0.rightAnswer })! | ||
let color = self.choices.value[index].item | ||
print("Leka is \(color)") | ||
} | ||
|
||
public func process(choice: ChoiceViewModel) { | ||
if choice.rightAnswer { | ||
if let index = choices.value.firstIndex(where: { $0.id == choice.id }) { | ||
self.choices.value[index].status = .playingRightAnimation | ||
|
||
// TO DO (@hugo) asyncAwait | ||
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { | ||
self.choices.value[index].status = .notSelected | ||
self.state.send(.finished) | ||
} | ||
// TODO(@ladislas): Run reinforcers and lottie animation | ||
} | ||
} else { | ||
if let index = choices.value.firstIndex(where: { $0.id == choice.id }) { | ||
self.choices.value[index].status = .playingWrongAnimation | ||
|
||
// TO DO (@hugo) asyncAwait | ||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.8) { | ||
self.choices.value[index].status = .notSelected | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters