Add player container

This commit is contained in:
schmelczerandras 2020-10-24 10:01:54 +02:00
commit b55e927a34
4 changed files with 159 additions and 133 deletions

View file

@ -8,7 +8,6 @@ import { CharacterTeam } from './character-team';
export class CharacterBase extends GameObject {
constructor(
id: Id,
public colorIndex: number,
public team: CharacterTeam,
public health: number,
public head?: Circle,
@ -19,7 +18,7 @@ export class CharacterBase extends GameObject {
}
public toArray(): Array<any> {
const { id, colorIndex, team, health, head, leftFoot, rightFoot } = this;
return [id, colorIndex, team, health, head, leftFoot, rightFoot];
const { id, team, health, head, leftFoot, rightFoot } = this;
return [id, team, health, head, leftFoot, rightFoot];
}
}

View file

@ -1,4 +1,5 @@
export enum CharacterTeam {
decla = 'decla',
neutral = 'neutral',
red = 'red',
}

View file

@ -11,14 +11,13 @@ export class PlayerCharacterBase extends CharacterBase {
public name: string,
public killCount: number,
public deathCount: number,
colorIndex: number,
team: CharacterTeam,
health: number,
head?: Circle,
leftFoot?: Circle,
rightFoot?: Circle,
) {
super(id, colorIndex, team, health, head, leftFoot, rightFoot);
super(id, team, health, head, leftFoot, rightFoot);
}
public toArray(): Array<any> {
@ -27,7 +26,6 @@ export class PlayerCharacterBase extends CharacterBase {
this.name,
this.killCount,
this.deathCount,
this.colorIndex,
this.team,
this.health,
this.head,

View file

@ -2,6 +2,7 @@ import { vec2 } from 'gl-matrix';
import { Id } from '../../transport/identity';
import { serializable } from '../../transport/serialization/serializable';
import { GameObject } from '../game-object';
import { CharacterTeam } from './character-team';
@serializable
export class ProjectileBase extends GameObject {
@ -9,13 +10,13 @@ export class ProjectileBase extends GameObject {
id: Id,
public center: vec2,
public radius: number,
public colorIndex: number,
public team: CharacterTeam,
public strength: number,
) {
super(id);
}
public toArray(): Array<any> {
return [this.id, this.center, this.radius, this.colorIndex, this.strength];
return [this.id, this.center, this.radius, this.team, this.strength];
}
}