Improve multiplayer

This commit is contained in:
schmelczerandras 2020-10-08 13:16:05 +02:00 committed by Schmelczer András
parent 220b20476f
commit 37954e2ef1
29 changed files with 321 additions and 267 deletions

View file

@ -10,6 +10,7 @@ import {
StepCommand,
UpdateObjectsCommand,
} from 'shared';
import { Game } from '../game';
import { Camera } from './camera';
import { CharacterView } from './character-view';
@ -21,7 +22,7 @@ export class GameObjectContainer extends CommandReceiver {
protected commandExecutors: CommandExecutors = {
[CreatePlayerCommand.type]: (c: CreatePlayerCommand) => {
this.player = c.character as CharacterView;
this.camera = new Camera();
this.camera = new Camera(this.game);
this.addObject(this.player);
this.addObject(this.camera);
},
@ -49,6 +50,10 @@ export class GameObjectContainer extends CommandReceiver {
},
};
constructor(private game: Game) {
super();
}
protected defaultCommandExecutor(c: Command) {
this.objects.forEach((o) => o.sendCommand(c));
}