|
|
|
@ -21,15 +21,21 @@ impl Plugin for TutorialPlugin {
|
|
|
|
Update,
|
|
|
|
Update,
|
|
|
|
(
|
|
|
|
(
|
|
|
|
// Run if we have a TutorialState *and* it is not TutorialState::None *and* we get a return keypress
|
|
|
|
// Run if we have a TutorialState *and* it is not TutorialState::None *and* we get a return keypress
|
|
|
|
transition
|
|
|
|
step.run_if(state_exists::<TutorialState>())
|
|
|
|
.run_if(state_exists::<TutorialState>())
|
|
|
|
.run_if(not(in_state(TutorialState::None)))
|
|
|
|
.run_if(not(in_state(TutorialState::None))),
|
|
|
|
.run_if(|keys: Res<Input<KeyCode>>| -> bool {
|
|
|
|
transition
|
|
|
|
keys.just_pressed(KeyCode::Return)
|
|
|
|
.run_if(state_exists::<TutorialState>())
|
|
|
|
}),
|
|
|
|
|
|
|
|
// Evaluate if a piece is selected
|
|
|
|
|
|
|
|
step.run_if(state_exists::<TutorialState>())
|
|
|
|
.run_if(not(in_state(TutorialState::None)))
|
|
|
|
.run_if(not(in_state(TutorialState::None)))
|
|
|
|
.run_if(any_component_added::<game::Selected>),
|
|
|
|
.run_if(any_component_added::<game::Selected>),
|
|
|
|
transition
|
|
|
|
// Evaluate if a piece is selected
|
|
|
|
.run_if(state_exists::<TutorialState>())
|
|
|
|
step.run_if(state_exists::<TutorialState>())
|
|
|
|
|
|
|
|
.run_if(not(in_state(TutorialState::None)))
|
|
|
|
|
|
|
|
.run_if(any_component_removed::<game::Selected>()),
|
|
|
|
|
|
|
|
// Evaluate if a piece's side changes
|
|
|
|
|
|
|
|
step.run_if(state_exists::<TutorialState>())
|
|
|
|
.run_if(not(in_state(TutorialState::None)))
|
|
|
|
.run_if(not(in_state(TutorialState::None)))
|
|
|
|
.run_if(any_component_changed::<game::Side>),
|
|
|
|
.run_if(any_component_changed::<game::Side>),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
@ -178,7 +184,7 @@ fn initialize_tutorial(
|
|
|
|
padding: UiRect::all(Val::Px(25.0)),
|
|
|
|
padding: UiRect::all(Val::Px(25.0)),
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
background_color: Color::BLACK.with_a(0.9).into(),
|
|
|
|
background_color: Color::BLACK.with_a(1.0).into(),
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
))
|
|
|
|
))
|
|
|
|
@ -209,20 +215,14 @@ fn initialize_tutorial(
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn transition(
|
|
|
|
fn step(
|
|
|
|
pieces: Query<&game::Piece, With<game::Selected>>,
|
|
|
|
pieces: Query<&game::Piece, Added<game::Selected>>,
|
|
|
|
transitions: Query<Entity, Changed<game::Side>>,
|
|
|
|
transitions: Query<Entity, Changed<game::Side>>,
|
|
|
|
curr_state: Res<State<TutorialState>>,
|
|
|
|
curr_state: Res<State<TutorialState>>,
|
|
|
|
mut next_state: ResMut<NextState<TutorialState>>,
|
|
|
|
mut next_state: ResMut<NextState<TutorialState>>,
|
|
|
|
keys: Res<Input<KeyCode>>,
|
|
|
|
|
|
|
|
mut seen: Local<HashSet<TutorialState>>,
|
|
|
|
mut seen: Local<HashSet<TutorialState>>,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
// TEMP: Early out, only handle Return keys
|
|
|
|
info!("Evalute tutorial state");
|
|
|
|
if !keys.just_pressed(KeyCode::Return) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
info!("Transitioning tutorial state");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Store the current state
|
|
|
|
// Store the current state
|
|
|
|
// Used to avoid doing a prevoius state again
|
|
|
|
// Used to avoid doing a prevoius state again
|
|
|
|
@ -245,6 +245,38 @@ fn transition(
|
|
|
|
| TutorialState::PieceJump
|
|
|
|
| TutorialState::PieceJump
|
|
|
|
| TutorialState::Empty
|
|
|
|
| TutorialState::Empty
|
|
|
|
| TutorialState::Ownership => {
|
|
|
|
| TutorialState::Ownership => {
|
|
|
|
|
|
|
|
// There are no pieces selected
|
|
|
|
|
|
|
|
if pieces.is_empty() {
|
|
|
|
|
|
|
|
if (*seen).contains(&TutorialState::PieceIntro)
|
|
|
|
|
|
|
|
&& (*seen).contains(&TutorialState::PieceQueen)
|
|
|
|
|
|
|
|
&& (*seen).contains(&TutorialState::PieceDrone)
|
|
|
|
|
|
|
|
&& (*seen).contains(&TutorialState::PiecePawn)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// And we have not touched on jumping yet
|
|
|
|
|
|
|
|
if !(*seen).contains(&TutorialState::PieceJump) {
|
|
|
|
|
|
|
|
TutorialState::PieceJump
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// A piece moves sides, so talk about ownership
|
|
|
|
|
|
|
|
else if !(*seen).contains(&TutorialState::Ownership)
|
|
|
|
|
|
|
|
&& transitions.iter().count() > 0
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
TutorialState::Ownership
|
|
|
|
|
|
|
|
// We have visited all relevant tutorial points, say goodbye
|
|
|
|
|
|
|
|
} else if (*seen).contains(&TutorialState::PieceJump)
|
|
|
|
|
|
|
|
&& (*seen).contains(&TutorialState::Ownership)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
TutorialState::Outro
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// We have not touched on jumping
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
TutorialState::PieceEnd
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Default, empty (tutorial doesn't always need to show something)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
TutorialState::Empty
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// One piece is selected
|
|
|
|
|
|
|
|
} else {
|
|
|
|
// When a queen is selected for the first time...
|
|
|
|
// When a queen is selected for the first time...
|
|
|
|
if pieces.iter().filter(|&p| *p == game::Piece::Queen).count() > 0
|
|
|
|
if pieces.iter().filter(|&p| *p == game::Piece::Queen).count() > 0
|
|
|
|
&& !(*seen).contains(&TutorialState::PieceQueen)
|
|
|
|
&& !(*seen).contains(&TutorialState::PieceQueen)
|
|
|
|
@ -260,35 +292,9 @@ fn transition(
|
|
|
|
&& !(*seen).contains(&TutorialState::PiecePawn)
|
|
|
|
&& !(*seen).contains(&TutorialState::PiecePawn)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TutorialState::PiecePawn
|
|
|
|
TutorialState::PiecePawn
|
|
|
|
// All pieces have been selected
|
|
|
|
|
|
|
|
} else if (*seen).contains(&TutorialState::PieceIntro)
|
|
|
|
|
|
|
|
&& (*seen).contains(&TutorialState::PieceQueen)
|
|
|
|
|
|
|
|
&& (*seen).contains(&TutorialState::PieceDrone)
|
|
|
|
|
|
|
|
&& (*seen).contains(&TutorialState::PiecePawn)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// And we have touched on jumping
|
|
|
|
|
|
|
|
if (*seen).contains(&TutorialState::PieceJump) {
|
|
|
|
|
|
|
|
TutorialState::PieceEnd
|
|
|
|
|
|
|
|
// We have not touched on jumping
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
TutorialState::PieceJump
|
|
|
|
panic!("This shouldn't be possible...!")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// A piece moves sides, so talk about ownership
|
|
|
|
|
|
|
|
} else if !(*seen).contains(&TutorialState::Ownership) && transitions.iter().count() > 0
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
TutorialState::Ownership
|
|
|
|
|
|
|
|
// We have visited all relevant tutorial points, say goodbye
|
|
|
|
|
|
|
|
} else if (*seen).contains(&TutorialState::PieceIntro)
|
|
|
|
|
|
|
|
&& (*seen).contains(&TutorialState::PieceQueen)
|
|
|
|
|
|
|
|
&& (*seen).contains(&TutorialState::PieceDrone)
|
|
|
|
|
|
|
|
&& (*seen).contains(&TutorialState::PiecePawn)
|
|
|
|
|
|
|
|
&& (*seen).contains(&TutorialState::PieceJump)
|
|
|
|
|
|
|
|
&& (*seen).contains(&TutorialState::Ownership)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
TutorialState::Outro
|
|
|
|
|
|
|
|
// Default, empty (tutorial doesn't always need to show something)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
TutorialState::Empty
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// After the outro, we exit the tutorial
|
|
|
|
// After the outro, we exit the tutorial
|
|
|
|
|