Refactor
This commit is contained in:
parent
b774357807
commit
57d7009342
9 changed files with 204 additions and 251 deletions
|
|
@ -1,10 +1,10 @@
|
|||
import { PlayerCharacterBase } from '../../objects/types/player-character-base';
|
||||
import { CharacterBase } from '../../objects/types/character-base';
|
||||
import { serializable } from '../../serialization/serializable';
|
||||
import { Command } from '../command';
|
||||
|
||||
@serializable
|
||||
export class CreatePlayerCommand extends Command {
|
||||
public constructor(public readonly character: PlayerCharacterBase) {
|
||||
public constructor(public readonly character: CharacterBase) {
|
||||
super();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { CharacterTeam } from '../../objects/types/character-team';
|
||||
import { CharacterTeam } from '../../objects/types/character-base';
|
||||
import { serializable } from '../../serialization/serializable';
|
||||
import { Command } from '../command';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { vec2 } from 'gl-matrix';
|
||||
import { Id } from '../../communication/id';
|
||||
import { CharacterTeam } from '../../objects/types/character-team';
|
||||
import { CharacterTeam } from '../../objects/types/character-base';
|
||||
import { serializable } from '../../serialization/serializable';
|
||||
import { Command } from '../command';
|
||||
|
||||
|
|
|
|||
|
|
@ -9,10 +9,6 @@ export class Circle {
|
|||
return vec2.distance(this.center, target) - this.radius;
|
||||
}
|
||||
|
||||
public distanceBetween(target: Circle): number {
|
||||
return vec2.distance(target.center, this.center) - this.radius - target.radius;
|
||||
}
|
||||
|
||||
public toArray(): Array<any> {
|
||||
return [this.center, this.radius];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,8 +40,7 @@ export * from './serialization/serialize';
|
|||
export * from './serialization/serializes-to';
|
||||
export * from './serialization/serializable';
|
||||
export * from './serialization/override-deserialization';
|
||||
export * from './objects/types/character-team';
|
||||
export * from './objects/types/player-character-base';
|
||||
export * from './objects/types/character-base';
|
||||
export * from './objects/types/lamp-base';
|
||||
export * from './objects/types/planet-base';
|
||||
export * from './objects/types/projectile-base';
|
||||
|
|
|
|||
53
shared/src/objects/types/character-base.ts
Normal file
53
shared/src/objects/types/character-base.ts
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
import { Id } from '../../communication/id';
|
||||
import { Circle } from '../../helper/circle';
|
||||
import { serializable } from '../../serialization/serializable';
|
||||
import { GameObject } from '../game-object';
|
||||
|
||||
export enum CharacterTeam {
|
||||
decla = 'decla',
|
||||
neutral = 'neutral',
|
||||
red = 'red',
|
||||
}
|
||||
|
||||
@serializable
|
||||
export class CharacterBase extends GameObject {
|
||||
constructor(
|
||||
id: Id,
|
||||
public name: string,
|
||||
public killCount: number,
|
||||
public deathCount: number,
|
||||
public team: CharacterTeam,
|
||||
public health: number,
|
||||
public head?: Circle,
|
||||
public leftFoot?: Circle,
|
||||
public rightFoot?: Circle,
|
||||
) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
public onShoot(strength: number) {}
|
||||
|
||||
public setHealth(health: number) {
|
||||
this.health = health;
|
||||
}
|
||||
|
||||
public onDie() {}
|
||||
|
||||
public setKillCount(killCount: number) {
|
||||
this.killCount = killCount;
|
||||
}
|
||||
|
||||
public toArray(): Array<any> {
|
||||
return [
|
||||
this.id,
|
||||
this.name,
|
||||
this.killCount,
|
||||
this.deathCount,
|
||||
this.team,
|
||||
this.health,
|
||||
this.head,
|
||||
this.leftFoot,
|
||||
this.rightFoot,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
export enum CharacterTeam {
|
||||
decla = 'decla',
|
||||
neutral = 'neutral',
|
||||
red = 'red',
|
||||
}
|
||||
|
|
@ -2,8 +2,8 @@ import { vec2 } from 'gl-matrix';
|
|||
import { settings } from '../../settings';
|
||||
import { serializable } from '../../serialization/serializable';
|
||||
import { GameObject } from '../game-object';
|
||||
import { CharacterTeam } from './character-team';
|
||||
import { Id } from '../../communication/id';
|
||||
import { CharacterTeam } from './character-base';
|
||||
|
||||
@serializable
|
||||
export class ProjectileBase extends GameObject {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { rgb255 } from './helper/rgb255';
|
||||
import { CharacterTeam } from './objects/types/character-team';
|
||||
import { CharacterTeam } from './objects/types/character-base';
|
||||
|
||||
const declaColor = rgb255(64, 105, 165);
|
||||
const neutralColor = rgb255(82, 165, 64);
|
||||
|
|
@ -19,6 +19,7 @@ export const settings = {
|
|||
worldRadius: 10000,
|
||||
objectsOnCircleLength: 0.002,
|
||||
planetEdgeCount: 7,
|
||||
playerKillPoint: 10,
|
||||
takeControlTimeInSeconds: 4,
|
||||
loseControlTimeInSeconds: 24,
|
||||
planetPointGenerationInterval: 1.5,
|
||||
|
|
|
|||
Loading…
Reference in a new issue