add more visual feedback for inventory
This commit is contained in:
parent
5adab98902
commit
d3988447a6
@ -8,6 +8,7 @@ import TowerManager from './game/TowerManager';
|
||||
import { GameScene } from '../scenes/Game';
|
||||
import { AnimationManager } from './game/AnimationManager';
|
||||
import NotificationManager from './game/NotificationManager';
|
||||
import Gem from './game/Gem';
|
||||
|
||||
export class Engine {
|
||||
public static app: PIXI.Application;
|
||||
@ -25,6 +26,12 @@ export class Engine {
|
||||
public static GridRows: number = 17;
|
||||
public static MouseX: number = 0;
|
||||
public static MouseY: number = 0;
|
||||
|
||||
public static gemTest() {
|
||||
for (let i = 0; i < 48; i++) {
|
||||
this.GameScene.MissionStats.giveGem(new Gem(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default class GameMaster {
|
||||
|
@ -50,6 +50,11 @@ export default class MissionStats extends GameObject {
|
||||
}
|
||||
|
||||
public giveGem(gem: Gem) {
|
||||
if (this.inventory.length >= 48)
|
||||
return Engine.NotificationManager.Notify(
|
||||
"Can't hold more than 48 Gems. Extra Gem was thrown away.",
|
||||
'danger'
|
||||
);
|
||||
this.inventory.push(gem);
|
||||
Engine.GameScene.events.emit(StatsEvents.GemGivenEvent, gem);
|
||||
}
|
||||
|
@ -1,10 +1,15 @@
|
||||
import * as PIXI from 'pixi.js';
|
||||
import GuiObject from '../GuiObject';
|
||||
import GameAssets from '../Assets';
|
||||
import { Engine } from '../Bastion';
|
||||
import { StatsEvents } from '../Events';
|
||||
import Gem from '../game/Gem';
|
||||
import { VisualGemSlot } from './TowerPanel';
|
||||
|
||||
export default class GemTab extends GuiObject {
|
||||
private bounds: PIXI.Rectangle;
|
||||
private gemTabSprite: PIXI.NineSliceSprite;
|
||||
private vGems: VisualGemSlot[] = [];
|
||||
|
||||
constructor(bounds: PIXI.Rectangle) {
|
||||
super(false);
|
||||
@ -22,7 +27,29 @@ export default class GemTab extends GuiObject {
|
||||
this.gemTabSprite.y = 0;
|
||||
this.gemTabSprite.width = this.bounds.width;
|
||||
this.gemTabSprite.height = this.bounds.height;
|
||||
|
||||
this.container.addChild(this.gemTabSprite);
|
||||
|
||||
Engine.GameScene.events.on(StatsEvents.GemGivenEvent, () => {
|
||||
this.RebuildInventoryVisual();
|
||||
});
|
||||
}
|
||||
public RebuildInventoryVisual() {
|
||||
this.vGems.forEach((vGem) => vGem.destroy());
|
||||
Engine.GameScene.MissionStats.getInventory().forEach((gem, index) => {
|
||||
let vGem = new VisualGemSlot(0, this.container, gem);
|
||||
|
||||
let vGemYValue = 5;
|
||||
let vGemXValue = (index % 4) * 64 + 20;
|
||||
let vGemYIdx = index;
|
||||
while (true) {
|
||||
if (vGemYIdx <= 3) break;
|
||||
vGemYValue += 66;
|
||||
vGemYIdx -= 4;
|
||||
}
|
||||
|
||||
vGem.container.x = vGemXValue;
|
||||
vGem.container.y = vGemYValue;
|
||||
this.vGems.push(vGem);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user