Refactor
This commit is contained in:
parent
1ce961d6c2
commit
99cdb62928
76 changed files with 340 additions and 433 deletions
|
|
@ -1,16 +1,11 @@
|
|||
import { vec2, vec3 } from 'gl-matrix';
|
||||
import { CircleLight, Renderer } from 'sdf-2d';
|
||||
import { CommandExecutors, Id, LampBase, UpdateProperty } from 'shared';
|
||||
import { RenderCommand } from '../commands/types/render';
|
||||
import { ViewObject } from './view-object';
|
||||
|
||||
export class LampView extends LampBase implements ViewObject {
|
||||
private light: CircleLight;
|
||||
|
||||
protected commandExecutors: CommandExecutors = {
|
||||
[RenderCommand.type]: (c: RenderCommand) => c.renderer.addDrawable(this.light),
|
||||
};
|
||||
|
||||
constructor(id: Id, center: vec2, color: vec3, lightness: number) {
|
||||
super(id, center, color, lightness);
|
||||
this.light = new CircleLight(center, color, lightness);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import { vec2 } from 'gl-matrix';
|
||||
import { Renderer } from 'sdf-2d';
|
||||
import { CommandExecutors, Id, Random, PlanetBase, UpdateProperty } from 'shared';
|
||||
import { RenderCommand } from '../commands/types/render';
|
||||
import { Id, Random, PlanetBase, UpdateProperty } from 'shared';
|
||||
import { PlanetShape } from '../shapes/planet-shape';
|
||||
import { ViewObject } from './view-object';
|
||||
|
||||
|
|
@ -17,10 +16,6 @@ export class PlanetView extends PlanetBase implements ViewObject {
|
|||
private shape: PlanetShape;
|
||||
private ownershipProgess: HTMLElement;
|
||||
|
||||
protected commandExecutors: CommandExecutors = {
|
||||
[RenderCommand.type]: (c: RenderCommand) => c.renderer.addDrawable(this.shape),
|
||||
};
|
||||
|
||||
constructor(id: Id, vertices: Array<vec2>, ownership: number) {
|
||||
super(id, vertices);
|
||||
this.shape = new PlanetShape(vertices, ownership);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ export class PlayerCharacterView extends PlayerCharacterBase implements ViewObje
|
|||
private nameElement: HTMLElement = document.createElement('div');
|
||||
private statsElement: HTMLElement = document.createElement('div');
|
||||
private healthElement: HTMLElement = document.createElement('div');
|
||||
private previousHealth;
|
||||
|
||||
public isMainCharacter = false;
|
||||
|
||||
|
|
@ -45,7 +44,6 @@ export class PlayerCharacterView extends PlayerCharacterBase implements ViewObje
|
|||
this.rightFootExtrapolator = new CircleExtrapolator(this.rightFoot!);
|
||||
this.headExtrapolator = new CircleExtrapolator(this.head!);
|
||||
|
||||
this.previousHealth = this.health;
|
||||
this.nameElement.className = 'player-tag ' + this.team;
|
||||
this.nameElement.innerText = this.name;
|
||||
this.nameElement.appendChild(this.healthElement);
|
||||
|
|
@ -77,17 +75,19 @@ export class PlayerCharacterView extends PlayerCharacterBase implements ViewObje
|
|||
Sounds.hit,
|
||||
(0.4 * 2 * (previousHealth - health)) / settings.playerMaxStrength,
|
||||
);
|
||||
|
||||
if (this.isMainCharacter) {
|
||||
VibrationHandler.vibrate(Math.min(200, (previousHealth - this.health) * 4));
|
||||
}
|
||||
}
|
||||
|
||||
public kill() {
|
||||
if (this.isMainCharacter) {
|
||||
VibrationHandler.vibrate(150);
|
||||
}
|
||||
}
|
||||
|
||||
public step(deltaTimeInSeconds: number): void {
|
||||
if (this.previousHealth > this.health) {
|
||||
if (this.isMainCharacter) {
|
||||
VibrationHandler.vibrate(Math.min(200, (this.previousHealth - this.health) * 4));
|
||||
}
|
||||
|
||||
this.previousHealth = this.health;
|
||||
}
|
||||
|
||||
this.head! = this.headExtrapolator.getValue(deltaTimeInSeconds);
|
||||
this.leftFoot! = this.leftFootExtrapolator.getValue(deltaTimeInSeconds);
|
||||
this.rightFoot! = this.rightFootExtrapolator.getValue(deltaTimeInSeconds);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue