1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-03-02 03:39:21 +00:00

Improve simplified belt, show hints everywheer

This commit is contained in:
tobspr
2020-09-19 12:21:32 +02:00
parent ed206363f2
commit 2075f4d011
18 changed files with 831 additions and 819 deletions

View File

@@ -1,6 +1,8 @@
/* typehints:start */
import { Application } from "../application";
/* typehints:end */
import { randomChoice } from "../core/utils";
import { T } from "../translations";
export class GameLoadingOverlay {
@@ -43,6 +45,7 @@ export class GameLoadingOverlay {
this.element.classList.add("gameLoadingOverlay");
this.parent.appendChild(this.element);
this.internalAddSpinnerAndText(this.element);
this.internalAddHint(this.element);
}
/**
@@ -55,4 +58,15 @@ export class GameLoadingOverlay {
inner.innerText = T.global.loading;
element.appendChild(inner);
}
/**
* Adds a random hint
* @param {HTMLElement} element
*/
internalAddHint(element) {
const hint = document.createElement("span");
hint.innerHTML = randomChoice(T.tips);
hint.classList.add("hint");
element.appendChild(hint);
}
}

22
src/js/game/hints.js Normal file
View File

@@ -0,0 +1,22 @@
import { randomChoice } from "../core/utils";
import { T } from "../translations";
const hintsShown = [];
/**
* Finds a new hint to show about the game which the user hasn't seen within this session
*/
export function getRandomHint() {
let maxTries = 100 * T.tips.length;
while (maxTries-- > 0) {
const hint = randomChoice(T.tips);
if (!hintsShown.includes(hint)) {
hintsShown.push(hint);
return hint;
}
}
// All tips shown so far
return randomChoice(T.tips);
}

View File

@@ -43,16 +43,6 @@ export class BeltSystem extends GameSystemWithFilter {
[enumDirection.right]: [],
};
/**
* Stores simplified sprites of a belt
* @type {Object<enumDirection, AtlasSprite>}
*/
this.potatoBeltSprites = {
[enumDirection.top]: Loader.getSprite("sprites/belt/potato_mode/forward.png"),
[enumDirection.right]: Loader.getSprite("sprites/belt/potato_mode/right.png"),
[enumDirection.left]: Loader.getSprite("sprites/belt/potato_mode/left.png"),
};
for (let i = 0; i < BELT_ANIM_COUNT; ++i) {
this.beltAnimations[enumDirection.top].push(
Loader.getSprite("sprites/belt/built/forward_" + i + ".png")
@@ -523,7 +513,7 @@ export class BeltSystem extends GameSystemWithFilter {
const entity = contents[i];
if (entity.components.Belt) {
const direction = entity.components.Belt.direction;
let sprite = this.potatoBeltSprites[direction];
let sprite = this.beltAnimations[direction][0];
if (entity.components.Belt.assignedPath === hoveredBeltPath) {
sprite = this.beltAnimations[direction][animationIndex % BELT_ANIM_COUNT];