StarGazerRoom.js 1.09 KB
Newer Older
Alexander Bazo committed
1
const colyseus = require("colyseus"),
2 3
    Logger = require("../utils/Logger.js");
    GazePoint = require("../game/GazePoint.js");
Alexander Bazo committed
4 5 6 7 8 9 10
    StarGazerState = require("../game/StarGazerState.js");

var deltaTime;

class StarGazerRoom extends colyseus.Room {

    onCreate(options) {
11
        Logger.log("Creating StarGazerRoom", "Game Room");
Alexander Bazo committed
12 13 14 15 16
        this.setSimulationInterval(this.update.bind(this));
        this.setState(new StarGazerState());
    }

    onJoin(client, options) {
17
        Logger.log(`Player ${client.sessionId} joined StarGazerRoom`, "Game Room");
Alexander Bazo committed
18 19 20
    }

    onMessage(client, message) {
21 22 23 24
        if(message.type === "gaze") {
            message.data.player = client.id;
            this.state.addGazePoint(GazePoint.fromClientData(message.data));
        }
Alexander Bazo committed
25 26 27
    }

    onLeave(client, consented) {
28
        Logger.log(`Player ${client.sessionId} left StarGazerRoom`, "Game Room");
Alexander Bazo committed
29 30 31
    }

    onDispose() {
32
        Logger.log("Disposing StarGazerRoom", "Game Room");
Alexander Bazo committed
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
    }

    startGame() {

    }

    update(deltaTime) {
        this.state.update(deltaTime);
    }



}


module.exports = StarGazerRoom;