feat(achievements): spawn confetti when all achievements are obtained
This commit is contained in:
@@ -51,12 +51,19 @@ export const useAchievementsStore = defineStore("achievements", () => {
|
|||||||
storage.value.advancement.languages.push(locale.value);
|
storage.value.advancement.languages.push(locale.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const confetti = useConfetti();
|
||||||
|
|
||||||
const unlock = (name: Achievement) => {
|
const unlock = (name: Achievement) => {
|
||||||
if (storage.value.unlocked.includes(name)) {
|
if (storage.value.unlocked.includes(name)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
storage.value.unlocked.push(name);
|
storage.value.unlocked.push(name);
|
||||||
|
|
||||||
|
if (storage.value.unlocked.length === ACHIEVEMENTS.length) {
|
||||||
|
confetti.spawn();
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -88,6 +88,12 @@ export const useAchievementsScreen = defineStore("achievementsScreen", {
|
|||||||
this.intro.itemOffsets[i] = -ACHIEVEMENTS_LINE_HEIGHT;
|
this.intro.itemOffsets[i] = -ACHIEVEMENTS_LINE_HEIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const achievements = useAchievementsStore();
|
||||||
|
if (achievements.allObtained) {
|
||||||
|
const confetti = useConfetti();
|
||||||
|
confetti.spawn();
|
||||||
|
}
|
||||||
|
|
||||||
const tl = gsap.timeline({
|
const tl = gsap.timeline({
|
||||||
onComplete: () => {
|
onComplete: () => {
|
||||||
this.isIntro = false;
|
this.isIntro = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user