mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
add unlock on upgrade mechanic
This commit is contained in:
parent
93ac3f70be
commit
6dd3f2a439
@ -51,7 +51,7 @@ export class MetaRotaterBuilding extends MetaBuilding {
|
|||||||
getAvailableVariants(root) {
|
getAvailableVariants(root) {
|
||||||
let variants = [defaultBuildingVariant];
|
let variants = [defaultBuildingVariant];
|
||||||
if (root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_rotater_ccw)) {
|
if (root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_rotater_ccw)) {
|
||||||
variants.push(enumRotaterVariants.ccw, enumRotaterVariants.fl);
|
variants.push(enumRotaterVariants.ccw);
|
||||||
}
|
}
|
||||||
if (root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_rotater_fl)) {
|
if (root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_rotater_fl)) {
|
||||||
variants.push(enumRotaterVariants.fl);
|
variants.push(enumRotaterVariants.fl);
|
||||||
|
@ -7,6 +7,7 @@ import { enumItemProcessorTypes } from "./components/item_processor";
|
|||||||
import { GameRoot, enumLayer } from "./root";
|
import { GameRoot, enumLayer } from "./root";
|
||||||
import { enumSubShape, ShapeDefinition } from "./shape_definition";
|
import { enumSubShape, ShapeDefinition } from "./shape_definition";
|
||||||
import { enumHubGoalRewards, tutorialGoals } from "./tutorial_goals";
|
import { enumHubGoalRewards, tutorialGoals } from "./tutorial_goals";
|
||||||
|
import { HUDUnlockNotification } from "./hud/parts/unlock_notification";
|
||||||
import { UPGRADES, blueprintShape } from "./upgrades";
|
import { UPGRADES, blueprintShape } from "./upgrades";
|
||||||
|
|
||||||
export class HubGoals extends BasicSerializableObject {
|
export class HubGoals extends BasicSerializableObject {
|
||||||
@ -76,7 +77,7 @@ export class HubGoals extends BasicSerializableObject {
|
|||||||
this.level = 1;
|
this.level = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Which story rewards we already gained
|
* Which story and upgrade rewards we already gained
|
||||||
* @type {Object.<string, number>}
|
* @type {Object.<string, number>}
|
||||||
*/
|
*/
|
||||||
this.gainedRewards = {};
|
this.gainedRewards = {};
|
||||||
|
@ -20,6 +20,7 @@ export class HUDUnlockNotification extends BaseHUDPart {
|
|||||||
|
|
||||||
if (!(G_IS_DEV && globalConfig.debug.disableUnlockDialog)) {
|
if (!(G_IS_DEV && globalConfig.debug.disableUnlockDialog)) {
|
||||||
this.root.signals.storyGoalCompleted.add(this.showForLevel, this);
|
this.root.signals.storyGoalCompleted.add(this.showForLevel, this);
|
||||||
|
this.root.signals.upgradePurchased.add(this.showForUpgrade, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.buttonShowTimeout = null;
|
this.buttonShowTimeout = null;
|
||||||
@ -101,6 +102,81 @@ export class HUDUnlockNotification extends BaseHUDPart {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} upgradeId
|
||||||
|
*/
|
||||||
|
showForUpgrade(upgradeId) {
|
||||||
|
this.root.app.inputMgr.makeSureAttachedAndOnTop(this.inputReciever);
|
||||||
|
this.elemTitle.innerText = T.ingame.upgradeCompleteNotification.upgradeTitle;
|
||||||
|
|
||||||
|
// If it's not at the max level:
|
||||||
|
if(this.root.hubGoals.canUnlockUpgrade(upgradeId)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(!T.upgradeRewards[upgradeId]){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var reward;
|
||||||
|
for(let goalReward in enumHubGoalRewards){
|
||||||
|
if(T.upgradeRewards[upgradeId][goalReward]){
|
||||||
|
reward = goalReward;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!reward){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Functional for now -> Needs some rework; Only will register the unlock here if you actually click "upgrade" in the same session
|
||||||
|
this.root.hubGoals.gainedRewards[reward] = (this.root.hubGoals.gainedRewards[reward] || 0) + 1;
|
||||||
|
|
||||||
|
const rewardName = T.upgradeRewards[upgradeId][reward].title;
|
||||||
|
|
||||||
|
let html = `
|
||||||
|
<div class="rewardName">
|
||||||
|
${T.ingame.upgradeCompleteNotification.unlockText}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="rewardDesc">
|
||||||
|
${T.upgradeRewards[upgradeId][reward].desc}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
`;
|
||||||
|
|
||||||
|
html += "<div class='images'>";
|
||||||
|
const gained = enumHubGoalRewardsToContentUnlocked[reward];
|
||||||
|
if (gained) {
|
||||||
|
gained.forEach(([metaBuildingClass, variant]) => {
|
||||||
|
const metaBuilding = gMetaBuildingRegistry.findByClass(metaBuildingClass);
|
||||||
|
html += `<div class="buildingExplanation" data-icon="building_tutorials/${
|
||||||
|
metaBuilding.getId() + (variant === defaultBuildingVariant ? "" : "-" + variant)
|
||||||
|
}.png"></div>`;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
html += "</div>";
|
||||||
|
|
||||||
|
this.elemContents.innerHTML = html;
|
||||||
|
this.visible = true;
|
||||||
|
this.root.soundProxy.playUi(SOUNDS.levelComplete);
|
||||||
|
|
||||||
|
if (this.buttonShowTimeout) {
|
||||||
|
clearTimeout(this.buttonShowTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.element.querySelector("button.close").classList.remove("unlocked");
|
||||||
|
|
||||||
|
if (this.root.app.settings.getAllSettings().offerHints) {
|
||||||
|
this.buttonShowTimeout = setTimeout(
|
||||||
|
() => this.element.querySelector("button.close").classList.add("unlocked"),
|
||||||
|
G_IS_DEV ? 100 : 5000
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
this.element.querySelector("button.close").classList.add("unlocked");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
this.root.app.inputMgr.makeSureDetached(this.inputReciever);
|
this.root.app.inputMgr.makeSureDetached(this.inputReciever);
|
||||||
if (this.buttonShowTimeout) {
|
if (this.buttonShowTimeout) {
|
||||||
|
@ -338,6 +338,13 @@ ingame:
|
|||||||
unlockText: Unlocked <reward>!
|
unlockText: Unlocked <reward>!
|
||||||
buttonNextLevel: Next Level
|
buttonNextLevel: Next Level
|
||||||
|
|
||||||
|
# The notification when completing an upgrade
|
||||||
|
upgradeCompleteNotification:
|
||||||
|
upgradeTitle: Upgrade Unlocked
|
||||||
|
completed: Goal Completed
|
||||||
|
unlockText: Unlocked <reward>!
|
||||||
|
continue: Continue
|
||||||
|
|
||||||
# Notifications on the lower right
|
# Notifications on the lower right
|
||||||
notifications:
|
notifications:
|
||||||
newUpgrade: A new upgrade is available!
|
newUpgrade: A new upgrade is available!
|
||||||
@ -644,6 +651,13 @@ storyRewards:
|
|||||||
desc: >-
|
desc: >-
|
||||||
Congratulations! By the way, more content is planned for the standalone!
|
Congratulations! By the way, more content is planned for the standalone!
|
||||||
|
|
||||||
|
upgradeRewards:
|
||||||
|
# Rewards you get for completing upgrades
|
||||||
|
processors:
|
||||||
|
reward_rotater_fl:
|
||||||
|
title: 180 Degree Rotating
|
||||||
|
desc: You have unlocked a variant of the <strong>rotater</strong> - It allows you to rotate shapes 180 degrees!
|
||||||
|
|
||||||
settings:
|
settings:
|
||||||
title: Settings
|
title: Settings
|
||||||
categories:
|
categories:
|
||||||
|
Loading…
Reference in New Issue
Block a user