add achievement for 25 points in time trial race
This commit is contained in:
parent
61cf744569
commit
192269c766
18
src/game.rs
18
src/game.rs
|
@ -24,6 +24,7 @@ pub const CHEAT_WARP_1: &str = "pizzeria";
|
|||
pub const CHEAT_WARP_2: &str = "busstopclippy2";
|
||||
pub const CHEAT_WARP_3: &str = "busstopclippy3";
|
||||
pub const RACE_TARGET_RADIUS: f64 = 5.0;
|
||||
pub const RACE_SCORE_ACHIEVEMENT: u64 = 25;
|
||||
|
||||
pub struct GamePlugin;
|
||||
impl Plugin for GamePlugin {
|
||||
|
@ -85,7 +86,7 @@ pub struct RaceState {
|
|||
pub started: bool,
|
||||
pub start_countdown: f64,
|
||||
pub timeout: f64,
|
||||
pub score: u64,
|
||||
pub score: f64,
|
||||
}
|
||||
#[derive(Component)]
|
||||
pub struct RaceTarget;
|
||||
|
@ -98,6 +99,7 @@ pub enum AchievementEvent {
|
|||
DrinkPizza,
|
||||
InJupitersShadow,
|
||||
FindEarth,
|
||||
RaceScore,
|
||||
}
|
||||
|
||||
#[derive(Event)]
|
||||
|
@ -612,6 +614,12 @@ fn handle_achievement_event(
|
|||
}
|
||||
tracker.find_earth = true;
|
||||
}
|
||||
AchievementEvent::RaceScore => {
|
||||
if !tracker.race_score {
|
||||
ew_game.send(GameEvent::Achievement(format!("Score {} Points In Time Trial", RACE_SCORE_ACHIEVEMENT)));
|
||||
}
|
||||
tracker.race_score = true;
|
||||
}
|
||||
AchievementEvent::RideVehicle(name) => {
|
||||
tracker.vehicles_ridden.insert(name.clone());
|
||||
let len = tracker.vehicles_ridden.len();
|
||||
|
@ -723,6 +731,7 @@ fn handle_race(
|
|||
mut settings: ResMut<Settings>,
|
||||
mut race: ResMut<RaceState>,
|
||||
mut ew_sfx: EventWriter<audio::PlaySfxEvent>,
|
||||
mut ew_achievement: EventWriter<game::AchievementEvent>,
|
||||
q_player: Query<(&Position, &LinearVelocity, &Transform), With<PlayerCamera>>,
|
||||
mut q_racetarget: Query<
|
||||
(Entity, &mut Position, &mut LinearVelocity, &mut Visibility),
|
||||
|
@ -759,18 +768,21 @@ fn handle_race(
|
|||
if !race.initialized {
|
||||
log.warning("Time Trial Race START!".to_string());
|
||||
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Honk));
|
||||
race.score = 0;
|
||||
race.score = 0.0;
|
||||
race.initialized = true;
|
||||
spawn_target = true;
|
||||
}
|
||||
|
||||
if player_pos.distance(target_pos.0) < RACE_TARGET_RADIUS {
|
||||
race.score += 1;
|
||||
race.score += 1.0;
|
||||
spawn_target = true;
|
||||
}
|
||||
|
||||
if spawn_target {
|
||||
race.timeout = time.elapsed_seconds_f64() + 5.0;
|
||||
if race.score >= RACE_SCORE_ACHIEVEMENT as f64 {
|
||||
ew_achievement.send(game::AchievementEvent::RaceScore);
|
||||
}
|
||||
let difficulty = 2.0 * race.score as f64;
|
||||
let mut delta = DVec3::new(0.0, 0.0, 100.0);
|
||||
delta = (player_trans.rotation * delta.as_vec3()).as_dvec3();
|
||||
|
|
14
src/var.rs
14
src/var.rs
|
@ -388,6 +388,7 @@ pub struct AchievementTracker {
|
|||
pub drink_a_pizza: bool,
|
||||
pub in_jupiters_shadow: bool,
|
||||
pub find_earth: bool,
|
||||
pub race_score: bool,
|
||||
|
||||
pub ride_every_vehicle: bool,
|
||||
pub vehicles_ridden: HashSet<String>,
|
||||
|
@ -407,6 +408,7 @@ impl AchievementTracker {
|
|||
self.talk_to_everyone,
|
||||
self.find_earth,
|
||||
self.in_jupiters_shadow,
|
||||
self.race_score,
|
||||
]
|
||||
}
|
||||
pub fn achieve_all(&mut self) {
|
||||
|
@ -416,6 +418,7 @@ impl AchievementTracker {
|
|||
self.talk_to_everyone = true;
|
||||
self.find_earth = true;
|
||||
self.in_jupiters_shadow = true;
|
||||
self.race_score = true;
|
||||
}
|
||||
pub fn to_textsections(&self) -> Vec<String> {
|
||||
fn collectible(current: usize, total: usize) -> String {
|
||||
|
@ -434,6 +437,10 @@ impl AchievementTracker {
|
|||
format!("Talk To Everyone{talk}\n"),
|
||||
"Find Earth\n".to_string(),
|
||||
"Enter Jupiter's Shadow\n".to_string(),
|
||||
format!(
|
||||
"Score {} Points In Time Trial\n",
|
||||
game::RACE_SCORE_ACHIEVEMENT
|
||||
),
|
||||
]
|
||||
}
|
||||
pub fn to_overview(&self) -> Vec<(bool, String)> {
|
||||
|
@ -444,6 +451,13 @@ impl AchievementTracker {
|
|||
(self.talk_to_everyone, "talk to everyone".into()),
|
||||
(self.find_earth, "find Earth".into()),
|
||||
(self.in_jupiters_shadow, "enter Jupiter's shadow".into()),
|
||||
(
|
||||
self.in_jupiters_shadow,
|
||||
format!(
|
||||
"score {} points in Time Trial",
|
||||
game::RACE_SCORE_ACHIEVEMENT
|
||||
),
|
||||
),
|
||||
]
|
||||
}
|
||||
pub fn to_summary(&self) -> String {
|
||||
|
|
Loading…
Reference in a new issue