mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
Fix sandbox controller
This commit is contained in:
parent
77440a68bc
commit
b0cc9539d7
@ -3,6 +3,7 @@ import { makeDiv } from "../../../core/utils";
|
|||||||
import { DynamicDomAttach } from "../dynamic_dom_attach";
|
import { DynamicDomAttach } from "../dynamic_dom_attach";
|
||||||
import { blueprintShape, UPGRADES } from "../../upgrades";
|
import { blueprintShape, UPGRADES } from "../../upgrades";
|
||||||
import { enumNotificationType } from "./notifications";
|
import { enumNotificationType } from "./notifications";
|
||||||
|
import { tutorialGoals } from "../../tutorial_goals";
|
||||||
|
|
||||||
export class HUDSandboxController extends BaseHUDPart {
|
export class HUDSandboxController extends BaseHUDPart {
|
||||||
createElements(parent) {
|
createElements(parent) {
|
||||||
@ -98,14 +99,26 @@ export class HUDSandboxController extends BaseHUDPart {
|
|||||||
}
|
}
|
||||||
|
|
||||||
modifyLevel(amount) {
|
modifyLevel(amount) {
|
||||||
this.root.hubGoals.level = Math.max(1, this.root.hubGoals.level + amount);
|
const hubGoals = this.root.hubGoals;
|
||||||
this.root.hubGoals.createNextGoal();
|
hubGoals.level = Math.max(1, hubGoals.level + amount);
|
||||||
|
hubGoals.createNextGoal();
|
||||||
|
|
||||||
// Clear all shapes of this level
|
// Clear all shapes of this level
|
||||||
this.root.hubGoals.storedShapes[this.root.hubGoals.currentGoal.definition.getHash()] = 0;
|
hubGoals.storedShapes[hubGoals.currentGoal.definition.getHash()] = 0;
|
||||||
|
|
||||||
|
this.root.hud.parts.pinnedShapes.rerenderFull();
|
||||||
|
|
||||||
|
// Compute gained rewards
|
||||||
|
hubGoals.gainedRewards = {};
|
||||||
|
for (let i = 0; i < hubGoals.level - 1; ++i) {
|
||||||
|
if (i < tutorialGoals.length) {
|
||||||
|
const reward = tutorialGoals[i].reward;
|
||||||
|
hubGoals.gainedRewards[reward] = (hubGoals.gainedRewards[reward] || 0) + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.root.hud.signals.notification.dispatch(
|
this.root.hud.signals.notification.dispatch(
|
||||||
"Changed level to " + this.root.hubGoals.level,
|
"Changed level to " + hubGoals.level,
|
||||||
enumNotificationType.upgrade
|
enumNotificationType.upgrade
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user