add weapon selection gui
This commit is contained in:
parent
8ea6c2d937
commit
02245ca5a9
6 changed files with 39 additions and 2369 deletions
|
@ -8,10 +8,29 @@ GUI.prototype.Weapons = class {
|
|||
}
|
||||
|
||||
update() {
|
||||
|
||||
let ship = game.world.playerShip;
|
||||
if (!ship) return;
|
||||
|
||||
this.element.innerHTML = '';
|
||||
ship.fixtures.forEach((fixture, i) => {
|
||||
if (!fixture.type) return;
|
||||
let div = document.createElement('div');
|
||||
div.classList.add('weapon');
|
||||
if (ship.activeFixture == i)
|
||||
div.classList.add('active');
|
||||
let img = `url(/img/turrets/${fixture.type}/normal.png)`;
|
||||
div.style.backgroundImage = img;
|
||||
this.element.appendChild(div);
|
||||
});
|
||||
}
|
||||
|
||||
switchWeapon(slot) {
|
||||
this.currentWeapon = 0;
|
||||
let el = this.element.querySelector('.weapon.active');
|
||||
if (el)
|
||||
el.classList.remove('active');
|
||||
let weapons = this.element.querySelectorAll('.weapon');
|
||||
if (weapons[slot])
|
||||
weapons[slot].classList.add('active');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue