cargo fmt

main
Elijah C. Voigt 2 years ago
parent 3acb1ad949
commit 0f9d9b27ea

@ -85,7 +85,7 @@ fn init_intro_text(
padding: UiRect::all(Val::Px(25.0)),
..default()
},
background_color: Color::BLACK.with_a(0.9).into(),
background_color: Color::BLACK.with_a(1.0).into(),
..default()
},
))
@ -96,7 +96,7 @@ fn init_intro_text(
value: c.to_string(),
style: TextStyle {
font_size: 16.0,
color: Color::WHITE.with_a(0.0),
color: Color::WHITE.with_a(0.2),
..default()
},
}))

@ -21,15 +21,21 @@ impl Plugin for TutorialPlugin {
Update,
(
// Run if we have a TutorialState *and* it is not TutorialState::None *and* we get a return keypress
transition
.run_if(state_exists::<TutorialState>())
.run_if(not(in_state(TutorialState::None))),
transition
.run_if(state_exists::<TutorialState>())
step.run_if(state_exists::<TutorialState>())
.run_if(not(in_state(TutorialState::None)))
.run_if(|keys: Res<Input<KeyCode>>| -> bool {
keys.just_pressed(KeyCode::Return)
}),
// Evaluate if a piece is selected
step.run_if(state_exists::<TutorialState>())
.run_if(not(in_state(TutorialState::None)))
.run_if(any_component_added::<game::Selected>),
transition
.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(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(any_component_changed::<game::Side>),
),
@ -178,7 +184,7 @@ fn initialize_tutorial(
padding: UiRect::all(Val::Px(25.0)),
..default()
},
background_color: Color::BLACK.with_a(0.9).into(),
background_color: Color::BLACK.with_a(1.0).into(),
..default()
},
))
@ -209,20 +215,14 @@ fn initialize_tutorial(
})
}
fn transition(
pieces: Query<&game::Piece, With<game::Selected>>,
fn step(
pieces: Query<&game::Piece, Added<game::Selected>>,
transitions: Query<Entity, Changed<game::Side>>,
curr_state: Res<State<TutorialState>>,
mut next_state: ResMut<NextState<TutorialState>>,
keys: Res<Input<KeyCode>>,
mut seen: Local<HashSet<TutorialState>>,
) {
// TEMP: Early out, only handle Return keys
if !keys.just_pressed(KeyCode::Return) {
return;
}
info!("Transitioning tutorial state");
info!("Evalute tutorial state");
// Store the current state
// Used to avoid doing a prevoius state again
@ -245,50 +245,56 @@ fn transition(
| TutorialState::PieceJump
| TutorialState::Empty
| TutorialState::Ownership => {
// When a queen is selected for the first time...
if pieces.iter().filter(|&p| *p == game::Piece::Queen).count() > 0
&& !(*seen).contains(&TutorialState::PieceQueen)
{
TutorialState::PieceQueen
// When a drone is selected for the first time...
} else if pieces.iter().filter(|&p| *p == game::Piece::Drone).count() > 0
&& !(*seen).contains(&TutorialState::PieceDrone)
{
TutorialState::PieceDrone
// When a pawn is selected for the first time...
} else if pieces.iter().filter(|&p| *p == game::Piece::Pawn).count() > 0
&& !(*seen).contains(&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
// 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::PieceJump
TutorialState::Empty
}
// 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)
// One piece is selected
} else {
TutorialState::Empty
// When a queen is selected for the first time...
if pieces.iter().filter(|&p| *p == game::Piece::Queen).count() > 0
&& !(*seen).contains(&TutorialState::PieceQueen)
{
TutorialState::PieceQueen
// When a drone is selected for the first time...
} else if pieces.iter().filter(|&p| *p == game::Piece::Drone).count() > 0
&& !(*seen).contains(&TutorialState::PieceDrone)
{
TutorialState::PieceDrone
// When a pawn is selected for the first time...
} else if pieces.iter().filter(|&p| *p == game::Piece::Pawn).count() > 0
&& !(*seen).contains(&TutorialState::PiecePawn)
{
TutorialState::PiecePawn
} else {
panic!("This shouldn't be possible...!")
}
}
}
// After the outro, we exit the tutorial

Loading…
Cancel
Save