Compare commits
No commits in common. "master" and "v0.0.2" have entirely different histories.
|
|
@ -3,9 +3,7 @@ chuck.js
|
||||||
|
|
||||||
Physical JavaScript Action Browser Multiplayer Game - it will be awesome!
|
Physical JavaScript Action Browser Multiplayer Game - it will be awesome!
|
||||||
|
|
||||||
<a href="http://chuck-game.tumblr.com/about" title="Play the chuck trailer" target="_blank">
|
[](http://chuck-game.tumblr.com/ "Screenshot of chuck.js - click to visit our development blog!")
|
||||||
<img src="https://cloud.githubusercontent.com/assets/692826/8396811/3369df82-1db6-11e5-939f-5ceeba64d802.png">
|
|
||||||
</a>
|
|
||||||
|
|
||||||
Follow the development at http://chuck-game.tumblr.com/
|
Follow the development at http://chuck-game.tumblr.com/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,74 +1,105 @@
|
||||||
define([
|
define([
|
||||||
'express',
|
|
||||||
'http',
|
'http',
|
||||||
'path',
|
'node-static',
|
||||||
'Server/Api',
|
'Server/Api',
|
||||||
'fs'
|
'fs'
|
||||||
],
|
],
|
||||||
|
|
||||||
function (express, http, path, Api, fs) {
|
function (http, nodeStatic, Api, fs) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function HttpServer (options, coordinator) {
|
function HttpServer (options, coordinator) {
|
||||||
options.port = options.port || 1234;
|
options.port = options.port || 1234;
|
||||||
|
options.caching = typeof options.caching != 'undefined' ? options.caching : 3600;
|
||||||
options.rootDirectory = options.rootDirectory || './';
|
options.rootDirectory = options.rootDirectory || './';
|
||||||
|
|
||||||
|
this.server = null;
|
||||||
this.api = new Api(coordinator);
|
this.api = new Api(coordinator);
|
||||||
this.app = express();
|
|
||||||
this.server = http.createServer(this.app);
|
|
||||||
this.init(options);
|
this.init(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpServer.prototype.init = function (options) {
|
HttpServer.prototype.init = function (options) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var app = this.app;
|
|
||||||
|
|
||||||
// Serve static files
|
//gzip true serves gzip file if there is one with .gz next to the original && if browser supports it
|
||||||
app.use('/static', express.static(path.join(options.rootDirectory, 'static')));
|
var fileServer = new nodeStatic.Server(options.rootDirectory, { cache: options.caching, gzip: true });
|
||||||
app.use('/app', express.static(path.join(options.rootDirectory, 'app')));
|
|
||||||
|
|
||||||
// Serve index.html at root
|
this.server = http.createServer(
|
||||||
app.get('/', function(req, res) {
|
function (req, res) {
|
||||||
res.sendFile(path.resolve(options.rootDirectory, 'static/html/index.html'));
|
|
||||||
|
var fullBody = '';
|
||||||
|
req.addListener('data', function(chunk) { // doesn't work on Jeenas computer without this
|
||||||
|
fullBody += chunk.toString();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Serve client.js and minified version
|
req.addListener('error', function(err) {
|
||||||
app.get('/client.js', function(req, res) {
|
console.log('');
|
||||||
if (process.env.NODE_ENV === 'production' && fs.existsSync(path.resolve(options.rootDirectory, 'build/client.min.js'))) {
|
});
|
||||||
res.sendFile(path.resolve(options.rootDirectory, 'build/client.min.js'));
|
|
||||||
|
|
||||||
|
req.addListener('end', function () {
|
||||||
|
|
||||||
|
switch(true) {
|
||||||
|
case req.url == '/':
|
||||||
|
fileServer.serveFile('./static/html/index.html', 200, {}, req, res);
|
||||||
|
console.checkpoint('HTTP Server serves index');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case req.url == '/client.js':
|
||||||
|
fs.exists('./build/client.min.js', function (exists) {
|
||||||
|
if (process.env.NODE_ENV && process.env.NODE_ENV == 'production' && exists) {
|
||||||
|
fileServer.serveFile('./build/client.min.js', 200, {}, req, res);
|
||||||
} else {
|
} else {
|
||||||
res.sendFile(path.resolve(options.rootDirectory, 'client.js'));
|
fileServer.serveFile('./client.js', 200, {}, req, res);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
app.get('/client.min.js', function(req, res) {
|
break;
|
||||||
res.sendFile(path.resolve(options.rootDirectory, 'build/client.min.js'));
|
|
||||||
});
|
|
||||||
|
|
||||||
// Serve require.js, screenfull.js, chart.js from node_modules
|
case req.url == '/client.min.js':
|
||||||
app.get('/require.js', function(req, res) {
|
fileServer.serveFile('./build/client.min.js', 200, {}, req, res);
|
||||||
res.sendFile(path.resolve(options.rootDirectory, 'node_modules/requirejs/require.js'));
|
break;
|
||||||
});
|
|
||||||
app.get('/screenfull.js', function(req, res) {
|
|
||||||
res.sendFile(path.resolve(options.rootDirectory, 'static/vendor/screenfull.js'));
|
|
||||||
});
|
|
||||||
app.get('/chart.js', function(req, res) {
|
|
||||||
// Chart.js v4 uses 'dist/chart.umd.js'
|
|
||||||
res.sendFile(path.resolve(options.rootDirectory, 'node_modules/chart.js/dist/chart.umd.js'));
|
|
||||||
});
|
|
||||||
|
|
||||||
// API endpoint
|
case req.url == '/require.js':
|
||||||
app.post('/api', express.text({type: '*/*'}), function(req, res) {
|
fileServer.serveFile('./node_modules/requirejs/require.js', 200, {}, req, res);
|
||||||
self.api.handleCall(req.body);
|
break;
|
||||||
|
|
||||||
|
case req.url == '/screenfull.js':
|
||||||
|
fileServer.serveFile('./node_modules/screenfull/dist/screenfull.js', 200, {}, req, res);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case req.url == '/chart.js':
|
||||||
|
fileServer.serveFile('./node_modules/chart.js/Chart.js', 200, {}, req, res);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case req.url == '/api':
|
||||||
|
self.api.handleCall(fullBody);
|
||||||
var status = self.api.isError ? 400 : 200;
|
var status = self.api.isError ? 400 : 200;
|
||||||
res.status(status).type(self.api.getContentType()).send(self.api.getOutput());
|
res.writeHead(status, {"Content-Type": self.api.getContentType()});
|
||||||
|
res.end(self.api.getOutput());
|
||||||
self.api.isError = false;
|
self.api.isError = false;
|
||||||
});
|
break;
|
||||||
|
|
||||||
// 404 handler
|
case new RegExp(/^\/app/).test(req.url):
|
||||||
app.use(function(req, res) {
|
fileServer.serve(req, res, function () {
|
||||||
res.status(404).send('<h1>404 not ... found</h1>');
|
self.handleFileError(res)
|
||||||
});
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case new RegExp(/^\/static/).test(req.url):
|
||||||
|
fileServer.serve(req, res, function () {
|
||||||
|
self.handleFileError(res)
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
self.handleFileError(res);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
this.server.once('error', function(err) {
|
this.server.once('error', function(err) {
|
||||||
if(err.code == 'EADDRINUSE') {
|
if(err.code == 'EADDRINUSE') {
|
||||||
|
|
@ -79,6 +110,7 @@ function (express, http, path, Api, fs) {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.server.listen(options.port);
|
this.server.listen(options.port);
|
||||||
|
|
||||||
console.checkpoint('start HTTP server');
|
console.checkpoint('start HTTP server');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -86,5 +118,10 @@ function (express, http, path, Api, fs) {
|
||||||
return this.server;
|
return this.server;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HttpServer.prototype.handleFileError = function (res) {
|
||||||
|
res.writeHead(404, {'Content-Type': 'text/html'});
|
||||||
|
res.end('<h1>404 not ... found</h1>');
|
||||||
|
}
|
||||||
|
|
||||||
return HttpServer;
|
return HttpServer;
|
||||||
});
|
});
|
||||||
|
|
@ -7,20 +7,32 @@ function (io) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function Socket (server, options, coordinator) {
|
function Socket (server, options, coordinator) {
|
||||||
|
options.logLevel = typeof options.logLevel != 'undefined'
|
||||||
|
? options.logLevel
|
||||||
|
: 0;
|
||||||
|
|
||||||
this.coordinator = coordinator;
|
this.coordinator = coordinator;
|
||||||
this.io = io(server, {
|
this.socket = io.listen(server);
|
||||||
// No more 'log level' or 'transports' in v4
|
|
||||||
// Add any v4-compatible options here if needed
|
|
||||||
});
|
|
||||||
this.init(options);
|
this.init(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
Socket.prototype.init = function (options) {
|
Socket.prototype.init = function (options) {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this.io.on('connection', function (socket) {
|
this.socket.configure('development', function () {
|
||||||
console.checkpoint('socket receiving connection');
|
this.set('log level', options.logLevel);
|
||||||
self.onConnection(socket);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.socket.configure('production', function () {
|
||||||
|
this.set('log level', options.logLevel);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.socket.on('connection', function (user) {
|
||||||
|
console.checkpoint('socket receiving connection');
|
||||||
|
self.onConnection(user);
|
||||||
|
});
|
||||||
|
|
||||||
console.checkpoint('start Socket Listener');
|
console.checkpoint('start Socket Listener');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,783 +0,0 @@
|
||||||
{
|
|
||||||
"allowSleep" : true,
|
|
||||||
"autoClearForces" : true,
|
|
||||||
"body" :
|
|
||||||
[
|
|
||||||
|
|
||||||
{
|
|
||||||
"angle" : 0,
|
|
||||||
"angularVelocity" : 0,
|
|
||||||
"awake" : true,
|
|
||||||
"fixture" :
|
|
||||||
[
|
|
||||||
|
|
||||||
{
|
|
||||||
"density" : 1,
|
|
||||||
"filter-groupIndex" : -55,
|
|
||||||
"friction" : 0.2,
|
|
||||||
"name" : "fixture3",
|
|
||||||
"polygon" :
|
|
||||||
{
|
|
||||||
"vertices" :
|
|
||||||
{
|
|
||||||
"x" :
|
|
||||||
[
|
|
||||||
0.04692989960312843,
|
|
||||||
0.04692989960312843,
|
|
||||||
-0.04693000018596649,
|
|
||||||
-0.04693000018596649
|
|
||||||
],
|
|
||||||
"y" :
|
|
||||||
[
|
|
||||||
-0.1895969957113266,
|
|
||||||
0.1895969957113266,
|
|
||||||
0.1895969957113266,
|
|
||||||
-0.1895969957113266
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"linearVelocity" : 0,
|
|
||||||
"massData-I" : 0.0004525936674326658,
|
|
||||||
"massData-center" :
|
|
||||||
{
|
|
||||||
"x" : -5.029141902923584e-08,
|
|
||||||
"y" : 0
|
|
||||||
},
|
|
||||||
"massData-mass" : 0.03559110686182976,
|
|
||||||
"name" : "upperLeftArm",
|
|
||||||
"position" :
|
|
||||||
{
|
|
||||||
"x" : -0.1165359988808632,
|
|
||||||
"y" : 0.9012569785118103
|
|
||||||
},
|
|
||||||
"type" : 2
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
"angle" : 0,
|
|
||||||
"angularVelocity" : 0,
|
|
||||||
"awake" : true,
|
|
||||||
"fixture" :
|
|
||||||
[
|
|
||||||
|
|
||||||
{
|
|
||||||
"density" : 1,
|
|
||||||
"filter-groupIndex" : -55,
|
|
||||||
"friction" : 0.2,
|
|
||||||
"name" : "fixture2",
|
|
||||||
"polygon" :
|
|
||||||
{
|
|
||||||
"vertices" :
|
|
||||||
{
|
|
||||||
"x" :
|
|
||||||
[
|
|
||||||
0.1366278976202011,
|
|
||||||
0.1366278976202011,
|
|
||||||
-0.1360991001129150,
|
|
||||||
-0.1360991001129150
|
|
||||||
],
|
|
||||||
"y" :
|
|
||||||
[
|
|
||||||
-0.3788780868053436,
|
|
||||||
0.3830279111862183,
|
|
||||||
0.3830279111862183,
|
|
||||||
-0.3788780868053436
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"linearVelocity" : 0,
|
|
||||||
"massData-I" : 0.01134084537625313,
|
|
||||||
"massData-center" :
|
|
||||||
{
|
|
||||||
"x" : 0.0002643987536430359,
|
|
||||||
"y" : 0.002074912190437317
|
|
||||||
},
|
|
||||||
"massData-mass" : 0.2077923566102982,
|
|
||||||
"name" : "chest",
|
|
||||||
"position" :
|
|
||||||
{
|
|
||||||
"x" : 0.0007875636219978333,
|
|
||||||
"y" : 0.7995355725288391
|
|
||||||
},
|
|
||||||
"type" : 2
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
"angle" : 0,
|
|
||||||
"angularVelocity" : 0,
|
|
||||||
"awake" : true,
|
|
||||||
"fixture" :
|
|
||||||
[
|
|
||||||
|
|
||||||
{
|
|
||||||
"circle" :
|
|
||||||
{
|
|
||||||
"center" :
|
|
||||||
{
|
|
||||||
"x" : -0.01561669446527958,
|
|
||||||
"y" : 0.004700659774243832
|
|
||||||
},
|
|
||||||
"radius" : 0.2268356680870056
|
|
||||||
},
|
|
||||||
"density" : 0.2204959988594055,
|
|
||||||
"filter-groupIndex" : -55,
|
|
||||||
"friction" : 0.2,
|
|
||||||
"name" : "fixture1"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"linearVelocity" : 0,
|
|
||||||
"massData-I" : 0.0009264730615541339,
|
|
||||||
"massData-center" :
|
|
||||||
{
|
|
||||||
"x" : -0.01561669446527958,
|
|
||||||
"y" : 0.004700659774243832
|
|
||||||
},
|
|
||||||
"massData-mass" : 0.03564291819930077,
|
|
||||||
"name" : "head",
|
|
||||||
"position" :
|
|
||||||
{
|
|
||||||
"x" : 0.02309736609458923,
|
|
||||||
"y" : 1.497289657592773
|
|
||||||
},
|
|
||||||
"type" : 2
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
"angle" : 0,
|
|
||||||
"angularVelocity" : 0,
|
|
||||||
"awake" : true,
|
|
||||||
"fixture" :
|
|
||||||
[
|
|
||||||
|
|
||||||
{
|
|
||||||
"density" : 1,
|
|
||||||
"filter-groupIndex" : -55,
|
|
||||||
"friction" : 0.2,
|
|
||||||
"name" : "fixture3",
|
|
||||||
"polygon" :
|
|
||||||
{
|
|
||||||
"vertices" :
|
|
||||||
{
|
|
||||||
"x" :
|
|
||||||
[
|
|
||||||
0.04693000018596649,
|
|
||||||
0.04693000018596649,
|
|
||||||
-0.04693005979061127,
|
|
||||||
-0.04693005979061127
|
|
||||||
],
|
|
||||||
"y" :
|
|
||||||
[
|
|
||||||
-0.1159216761589050,
|
|
||||||
0.1159217953681946,
|
|
||||||
0.1159217953681946,
|
|
||||||
-0.1159216761589050
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"linearVelocity" : 0,
|
|
||||||
"massData-I" : 0.0001134485355578363,
|
|
||||||
"massData-center" :
|
|
||||||
{
|
|
||||||
"x" : -2.980232238769531e-08,
|
|
||||||
"y" : 5.960464477539062e-08
|
|
||||||
},
|
|
||||||
"massData-mass" : 0.02176084183156490,
|
|
||||||
"name" : "lowerRightArm",
|
|
||||||
"position" :
|
|
||||||
{
|
|
||||||
"x" : 0.1183081120252609,
|
|
||||||
"y" : 0.6842151284217834
|
|
||||||
},
|
|
||||||
"type" : 2
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
"angle" : 0,
|
|
||||||
"angularVelocity" : 0,
|
|
||||||
"awake" : true,
|
|
||||||
"fixture" :
|
|
||||||
[
|
|
||||||
|
|
||||||
{
|
|
||||||
"density" : 1,
|
|
||||||
"filter-groupIndex" : -55,
|
|
||||||
"friction" : 0.2,
|
|
||||||
"name" : "fixture3",
|
|
||||||
"polygon" :
|
|
||||||
{
|
|
||||||
"vertices" :
|
|
||||||
{
|
|
||||||
"x" :
|
|
||||||
[
|
|
||||||
0.07039500027894974,
|
|
||||||
0.07039500027894974,
|
|
||||||
-0.07039500027894974,
|
|
||||||
-0.07039500027894974
|
|
||||||
],
|
|
||||||
"y" :
|
|
||||||
[
|
|
||||||
-0.09294360131025314,
|
|
||||||
0.1277720034122467,
|
|
||||||
0.1277720034122467,
|
|
||||||
-0.09294360131025314
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"linearVelocity" : 0,
|
|
||||||
"massData-I" : 0.0001869037223514169,
|
|
||||||
"massData-center" :
|
|
||||||
{
|
|
||||||
"x" : 0,
|
|
||||||
"y" : 0.01741420105099678
|
|
||||||
},
|
|
||||||
"massData-mass" : 0.03107454814016819,
|
|
||||||
"name" : "lowerLeftLeg",
|
|
||||||
"position" :
|
|
||||||
{
|
|
||||||
"x" : -0.03829947486519814,
|
|
||||||
"y" : 0.09799569845199585
|
|
||||||
},
|
|
||||||
"type" : 2
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
"angle" : 0,
|
|
||||||
"angularVelocity" : 0,
|
|
||||||
"awake" : true,
|
|
||||||
"fixture" :
|
|
||||||
[
|
|
||||||
|
|
||||||
{
|
|
||||||
"density" : 1,
|
|
||||||
"filter-groupIndex" : -55,
|
|
||||||
"friction" : 0.2,
|
|
||||||
"name" : "fixture3",
|
|
||||||
"polygon" :
|
|
||||||
{
|
|
||||||
"vertices" :
|
|
||||||
{
|
|
||||||
"x" :
|
|
||||||
[
|
|
||||||
0.04693000763654709,
|
|
||||||
0.04693000763654709,
|
|
||||||
-0.04692991077899933,
|
|
||||||
-0.04692991077899933
|
|
||||||
],
|
|
||||||
"y" :
|
|
||||||
[
|
|
||||||
-0.1159216761589050,
|
|
||||||
0.1159217953681946,
|
|
||||||
0.1159217953681946,
|
|
||||||
-0.1159216761589050
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"linearVelocity" : 0,
|
|
||||||
"massData-I" : 0.0001134483172791079,
|
|
||||||
"massData-center" :
|
|
||||||
{
|
|
||||||
"x" : 4.842877032729120e-08,
|
|
||||||
"y" : 5.960464477539062e-08
|
|
||||||
},
|
|
||||||
"massData-mass" : 0.02176081016659737,
|
|
||||||
"name" : "lowerLeftArm",
|
|
||||||
"position" :
|
|
||||||
{
|
|
||||||
"x" : -0.1165381968021393,
|
|
||||||
"y" : 0.6842151284217834
|
|
||||||
},
|
|
||||||
"type" : 2
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
"angle" : 0,
|
|
||||||
"angularVelocity" : 0,
|
|
||||||
"awake" : true,
|
|
||||||
"fixture" :
|
|
||||||
[
|
|
||||||
|
|
||||||
{
|
|
||||||
"density" : 1,
|
|
||||||
"filter-groupIndex" : -55,
|
|
||||||
"friction" : 0.2,
|
|
||||||
"name" : "fixture3",
|
|
||||||
"polygon" :
|
|
||||||
{
|
|
||||||
"vertices" :
|
|
||||||
{
|
|
||||||
"x" :
|
|
||||||
[
|
|
||||||
0.04693000018596649,
|
|
||||||
0.04693000018596649,
|
|
||||||
-0.04693010076880455,
|
|
||||||
-0.04693010076880455
|
|
||||||
],
|
|
||||||
"y" :
|
|
||||||
[
|
|
||||||
-0.1895969957113266,
|
|
||||||
0.1895969957113266,
|
|
||||||
0.1895969957113266,
|
|
||||||
-0.1895969957113266
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"linearVelocity" : 0,
|
|
||||||
"massData-I" : 0.0004525947733782232,
|
|
||||||
"massData-center" :
|
|
||||||
{
|
|
||||||
"x" : -5.029141902923584e-08,
|
|
||||||
"y" : 0
|
|
||||||
},
|
|
||||||
"massData-mass" : 0.03559118881821632,
|
|
||||||
"name" : "upperRightArm",
|
|
||||||
"position" :
|
|
||||||
{
|
|
||||||
"x" : 0.1183080002665520,
|
|
||||||
"y" : 0.9012569785118103
|
|
||||||
},
|
|
||||||
"type" : 2
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
"angle" : 0,
|
|
||||||
"angularVelocity" : 0,
|
|
||||||
"awake" : true,
|
|
||||||
"fixture" :
|
|
||||||
[
|
|
||||||
|
|
||||||
{
|
|
||||||
"density" : 1,
|
|
||||||
"filter-groupIndex" : -55,
|
|
||||||
"friction" : 0.2,
|
|
||||||
"name" : "fixture3",
|
|
||||||
"polygon" :
|
|
||||||
{
|
|
||||||
"vertices" :
|
|
||||||
{
|
|
||||||
"x" :
|
|
||||||
[
|
|
||||||
0.07039496302604675,
|
|
||||||
0.07039496302604675,
|
|
||||||
-0.07039486616849899,
|
|
||||||
-0.07039486616849899
|
|
||||||
],
|
|
||||||
"y" :
|
|
||||||
[
|
|
||||||
-0.1890522241592407,
|
|
||||||
0.1890524625778198,
|
|
||||||
0.1890524625778198,
|
|
||||||
-0.1890522241592407
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"linearVelocity" : 0,
|
|
||||||
"massData-I" : 0.0007221315754577518,
|
|
||||||
"massData-center" :
|
|
||||||
{
|
|
||||||
"x" : 4.842877388000488e-08,
|
|
||||||
"y" : 1.192092895507812e-07
|
|
||||||
},
|
|
||||||
"massData-mass" : 0.05323329567909241,
|
|
||||||
"name" : "upperRightLeg",
|
|
||||||
"position" :
|
|
||||||
{
|
|
||||||
"x" : 0.03859551250934601,
|
|
||||||
"y" : 0.3325110077857971
|
|
||||||
},
|
|
||||||
"type" : 2
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
"angle" : 0,
|
|
||||||
"angularVelocity" : 0,
|
|
||||||
"awake" : true,
|
|
||||||
"fixture" :
|
|
||||||
[
|
|
||||||
|
|
||||||
{
|
|
||||||
"density" : 1,
|
|
||||||
"filter-groupIndex" : -55,
|
|
||||||
"friction" : 0.2,
|
|
||||||
"name" : "fixture3",
|
|
||||||
"polygon" :
|
|
||||||
{
|
|
||||||
"vertices" :
|
|
||||||
{
|
|
||||||
"x" :
|
|
||||||
[
|
|
||||||
0.07039505988359451,
|
|
||||||
0.07039505988359451,
|
|
||||||
-0.07039495557546616,
|
|
||||||
-0.07039495557546616
|
|
||||||
],
|
|
||||||
"y" :
|
|
||||||
[
|
|
||||||
-0.1890522241592407,
|
|
||||||
0.1890524625778198,
|
|
||||||
0.1890524625778198,
|
|
||||||
-0.1890522241592407
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"linearVelocity" : 0,
|
|
||||||
"massData-I" : 0.000722132739610970,
|
|
||||||
"massData-center" :
|
|
||||||
{
|
|
||||||
"x" : 5.215406417846680e-08,
|
|
||||||
"y" : 1.192092824453539e-07
|
|
||||||
},
|
|
||||||
"massData-mass" : 0.05323336645960808,
|
|
||||||
"name" : "upperLeftLeg",
|
|
||||||
"position" :
|
|
||||||
{
|
|
||||||
"x" : -0.03829947486519814,
|
|
||||||
"y" : 0.3325110077857971
|
|
||||||
},
|
|
||||||
"type" : 2
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
"angle" : 0,
|
|
||||||
"angularVelocity" : 0,
|
|
||||||
"awake" : true,
|
|
||||||
"fixture" :
|
|
||||||
[
|
|
||||||
|
|
||||||
{
|
|
||||||
"density" : 1,
|
|
||||||
"filter-groupIndex" : -55,
|
|
||||||
"friction" : 0.2,
|
|
||||||
"name" : "fixture3",
|
|
||||||
"polygon" :
|
|
||||||
{
|
|
||||||
"vertices" :
|
|
||||||
{
|
|
||||||
"x" :
|
|
||||||
[
|
|
||||||
0.07039500027894974,
|
|
||||||
0.07039500027894974,
|
|
||||||
-0.07039490342140198,
|
|
||||||
-0.07039490342140198
|
|
||||||
],
|
|
||||||
"y" :
|
|
||||||
[
|
|
||||||
-0.09294389933347702,
|
|
||||||
0.1276109963655472,
|
|
||||||
0.1276109963655472,
|
|
||||||
-0.09294389933347702
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"linearVelocity" : 0,
|
|
||||||
"massData-I" : 0.0001864968799054623,
|
|
||||||
"massData-center" :
|
|
||||||
{
|
|
||||||
"x" : 4.842877032729120e-08,
|
|
||||||
"y" : 0.01733354665338993
|
|
||||||
},
|
|
||||||
"massData-mass" : 0.03105190023779869,
|
|
||||||
"name" : "lowerRightLeg",
|
|
||||||
"position" :
|
|
||||||
{
|
|
||||||
"x" : 0.03859551250934601,
|
|
||||||
"y" : 0.09799569845199585
|
|
||||||
},
|
|
||||||
"type" : 2
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"collisionbitplanes" :
|
|
||||||
{
|
|
||||||
"names" :
|
|
||||||
[
|
|
||||||
"bitplane1",
|
|
||||||
"bitplane2",
|
|
||||||
"bitplane3",
|
|
||||||
"bitplane4",
|
|
||||||
"bitplane5",
|
|
||||||
"bitplane6",
|
|
||||||
"bitplane7",
|
|
||||||
"bitplane8",
|
|
||||||
"bitplane9",
|
|
||||||
"bitplane10",
|
|
||||||
"bitplane11",
|
|
||||||
"bitplane12",
|
|
||||||
"bitplane13",
|
|
||||||
"bitplane14",
|
|
||||||
"bitplane15",
|
|
||||||
"bitplane16",
|
|
||||||
"bitplane17",
|
|
||||||
"bitplane18",
|
|
||||||
"bitplane19",
|
|
||||||
"bitplane20",
|
|
||||||
"bitplane21",
|
|
||||||
"bitplane22",
|
|
||||||
"bitplane23",
|
|
||||||
"bitplane24",
|
|
||||||
"bitplane25",
|
|
||||||
"bitplane26",
|
|
||||||
"bitplane27",
|
|
||||||
"bitplane28",
|
|
||||||
"bitplane29",
|
|
||||||
"bitplane30",
|
|
||||||
"bitplane31",
|
|
||||||
"bitplane32"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"continuousPhysics" : true,
|
|
||||||
"gravity" :
|
|
||||||
{
|
|
||||||
"x" : 0,
|
|
||||||
"y" : -10
|
|
||||||
},
|
|
||||||
"joint" :
|
|
||||||
[
|
|
||||||
|
|
||||||
{
|
|
||||||
"anchorA" :
|
|
||||||
{
|
|
||||||
"x" : 0.0003538504242897034,
|
|
||||||
"y" : 0.07107692956924438
|
|
||||||
},
|
|
||||||
"anchorB" :
|
|
||||||
{
|
|
||||||
"x" : 0.0003536641597747803,
|
|
||||||
"y" : -0.1459649801254272
|
|
||||||
},
|
|
||||||
"bodyA" : 3,
|
|
||||||
"bodyB" : 6,
|
|
||||||
"enableLimit" : true,
|
|
||||||
"enableMotor" : false,
|
|
||||||
"jointSpeed" : 0,
|
|
||||||
"lowerLimit" : 0.01745329238474369,
|
|
||||||
"maxMotorTorque" : 1,
|
|
||||||
"motorSpeed" : 0,
|
|
||||||
"name" : "joint1",
|
|
||||||
"refAngle" : 0,
|
|
||||||
"type" : "revolute",
|
|
||||||
"upperLimit" : 1.919862151145935
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
"anchorA" :
|
|
||||||
{
|
|
||||||
"x" : -0.0007802955806255341,
|
|
||||||
"y" : -0.1484909951686859
|
|
||||||
},
|
|
||||||
"anchorB" :
|
|
||||||
{
|
|
||||||
"x" : -0.0007801018655300140,
|
|
||||||
"y" : 0.08614099025726318
|
|
||||||
},
|
|
||||||
"bodyA" : 8,
|
|
||||||
"bodyB" : 4,
|
|
||||||
"enableLimit" : true,
|
|
||||||
"enableMotor" : false,
|
|
||||||
"jointSpeed" : 0,
|
|
||||||
"lowerLimit" : 0.01745329238474369,
|
|
||||||
"maxMotorTorque" : 1,
|
|
||||||
"motorSpeed" : 0,
|
|
||||||
"name" : "joint7",
|
|
||||||
"refAngle" : 0,
|
|
||||||
"type" : "revolute",
|
|
||||||
"upperLimit" : 2.443460941314697
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
"anchorA" :
|
|
||||||
{
|
|
||||||
"x" : -0.004979588091373444,
|
|
||||||
"y" : -0.1506859958171844
|
|
||||||
},
|
|
||||||
"anchorB" :
|
|
||||||
{
|
|
||||||
"x" : -0.005973689258098602,
|
|
||||||
"y" : 0.08482310175895691
|
|
||||||
},
|
|
||||||
"bodyA" : 7,
|
|
||||||
"bodyB" : 9,
|
|
||||||
"enableLimit" : true,
|
|
||||||
"enableMotor" : false,
|
|
||||||
"jointSpeed" : 0,
|
|
||||||
"lowerLimit" : 0.01745329238474369,
|
|
||||||
"maxMotorTorque" : 1,
|
|
||||||
"motorSpeed" : 0,
|
|
||||||
"name" : "joint8",
|
|
||||||
"refAngle" : 0,
|
|
||||||
"type" : "revolute",
|
|
||||||
"upperLimit" : 2.443460941314697
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
"anchorA" :
|
|
||||||
{
|
|
||||||
"x" : -0.06799955666065216,
|
|
||||||
"y" : -0.3021813035011292
|
|
||||||
},
|
|
||||||
"anchorB" :
|
|
||||||
{
|
|
||||||
"x" : -0.02891255542635918,
|
|
||||||
"y" : 0.1648437976837158
|
|
||||||
},
|
|
||||||
"bodyA" : 1,
|
|
||||||
"bodyB" : 8,
|
|
||||||
"enableLimit" : true,
|
|
||||||
"enableMotor" : false,
|
|
||||||
"jointSpeed" : 0,
|
|
||||||
"lowerLimit" : -0.7853981852531433,
|
|
||||||
"maxMotorTorque" : 1,
|
|
||||||
"motorSpeed" : 0,
|
|
||||||
"name" : "joint6",
|
|
||||||
"refAngle" : 0,
|
|
||||||
"type" : "revolute",
|
|
||||||
"upperLimit" : 1.570796370506287
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
"anchorA" :
|
|
||||||
{
|
|
||||||
"x" : 0.06260262429714203,
|
|
||||||
"y" : -0.3029872477054596
|
|
||||||
},
|
|
||||||
"anchorB" :
|
|
||||||
{
|
|
||||||
"x" : 0.02294230461120605,
|
|
||||||
"y" : 0.1640380322933197
|
|
||||||
},
|
|
||||||
"bodyA" : 1,
|
|
||||||
"bodyB" : 7,
|
|
||||||
"enableLimit" : true,
|
|
||||||
"enableMotor" : false,
|
|
||||||
"jointSpeed" : 0,
|
|
||||||
"lowerLimit" : -0.7853981852531433,
|
|
||||||
"maxMotorTorque" : 1,
|
|
||||||
"motorSpeed" : 0,
|
|
||||||
"name" : "joint5",
|
|
||||||
"refAngle" : 0,
|
|
||||||
"type" : "revolute",
|
|
||||||
"upperLimit" : 1.570796370506287
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
"anchorA" :
|
|
||||||
{
|
|
||||||
"x" : 0.1179294362664223,
|
|
||||||
"y" : 0.2464744448661804
|
|
||||||
},
|
|
||||||
"anchorB" :
|
|
||||||
{
|
|
||||||
"x" : 0.0004089996218681335,
|
|
||||||
"y" : 0.1447530388832092
|
|
||||||
},
|
|
||||||
"bodyA" : 1,
|
|
||||||
"bodyB" : 6,
|
|
||||||
"enableLimit" : false,
|
|
||||||
"enableMotor" : false,
|
|
||||||
"jointSpeed" : 0,
|
|
||||||
"lowerLimit" : -2.268928050994873,
|
|
||||||
"maxMotorTorque" : 1,
|
|
||||||
"motorSpeed" : 0,
|
|
||||||
"name" : "joint2",
|
|
||||||
"refAngle" : 0,
|
|
||||||
"type" : "revolute",
|
|
||||||
"upperLimit" : 3.141592741012573
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
"anchorA" :
|
|
||||||
{
|
|
||||||
"x" : -0.1188285648822784,
|
|
||||||
"y" : 0.2521644234657288
|
|
||||||
},
|
|
||||||
"anchorB" :
|
|
||||||
{
|
|
||||||
"x" : -0.001505002379417419,
|
|
||||||
"y" : 0.1504430174827576
|
|
||||||
},
|
|
||||||
"bodyA" : 1,
|
|
||||||
"bodyB" : 0,
|
|
||||||
"enableLimit" : false,
|
|
||||||
"enableMotor" : false,
|
|
||||||
"jointSpeed" : 0,
|
|
||||||
"lowerLimit" : -2.268928050994873,
|
|
||||||
"maxMotorTorque" : 1,
|
|
||||||
"motorSpeed" : 0,
|
|
||||||
"name" : "joint3",
|
|
||||||
"refAngle" : 0,
|
|
||||||
"type" : "revolute",
|
|
||||||
"upperLimit" : 3.141592741012573
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
"anchorA" :
|
|
||||||
{
|
|
||||||
"x" : 0.0008554458618164062,
|
|
||||||
"y" : -0.1461489796638489
|
|
||||||
},
|
|
||||||
"anchorB" :
|
|
||||||
{
|
|
||||||
"x" : 0.0008557140827178955,
|
|
||||||
"y" : 0.07089227437973022
|
|
||||||
},
|
|
||||||
"bodyA" : 0,
|
|
||||||
"bodyB" : 5,
|
|
||||||
"enableLimit" : true,
|
|
||||||
"enableMotor" : false,
|
|
||||||
"jointSpeed" : 0,
|
|
||||||
"lowerLimit" : -1.919862151145935,
|
|
||||||
"maxMotorTorque" : 1,
|
|
||||||
"motorSpeed" : 0,
|
|
||||||
"name" : "joint4",
|
|
||||||
"refAngle" : 0,
|
|
||||||
"type" : "revolute",
|
|
||||||
"upperLimit" : 0.01745329238474369
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
"anchorA" :
|
|
||||||
{
|
|
||||||
"x" : 0.02210754156112671,
|
|
||||||
"y" : 0.4607425332069397
|
|
||||||
},
|
|
||||||
"anchorB" :
|
|
||||||
{
|
|
||||||
"x" : -0.02544101513922215,
|
|
||||||
"y" : -0.2591779232025146
|
|
||||||
},
|
|
||||||
"bodyA" : 1,
|
|
||||||
"bodyB" : 2,
|
|
||||||
"enableLimit" : true,
|
|
||||||
"enableMotor" : false,
|
|
||||||
"jointSpeed" : 0,
|
|
||||||
"lowerLimit" : -0.6981316804885864,
|
|
||||||
"maxMotorTorque" : 0,
|
|
||||||
"motorSpeed" : 0,
|
|
||||||
"name" : "joint9",
|
|
||||||
"refAngle" : 0,
|
|
||||||
"type" : "revolute",
|
|
||||||
"upperLimit" : 1.221730470657349
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"positionIterations" : 3,
|
|
||||||
"stepsPerSecond" : 60.0,
|
|
||||||
"subStepping" : false,
|
|
||||||
"velocityIterations" : 8,
|
|
||||||
"warmStarting" : true
|
|
||||||
}
|
|
||||||
|
|
@ -3,11 +3,11 @@
|
||||||
"Lib/Utilities/NotificationCenter",
|
"Lib/Utilities/NotificationCenter",
|
||||||
"Game/Channel/User",
|
"Game/Channel/User",
|
||||||
"Lib/Utilities/Protocol/Helper",
|
"Lib/Utilities/Protocol/Helper",
|
||||||
"Lib/Utilities/OptionsHelper",
|
"Lib/Utilities/Options",
|
||||||
"Game/Config/Settings"
|
"Game/Config/Settings"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (GameController, nc, User, ProtocolHelper, optionsHelper, Settings) {
|
function (GameController, Nc, User, ProtocolHelper, Options, Settings) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -21,19 +21,19 @@
|
||||||
this.levelListIndex = -1;
|
this.levelListIndex = -1;
|
||||||
this.gameController = null;
|
this.gameController = null;
|
||||||
|
|
||||||
this.options = options = optionsHelper.merge(options, {
|
this.options = options = Options.merge(options, {
|
||||||
levelUids: Settings.CHANNEL_DEFAULT_LEVELS
|
levelUids: Settings.CHANNEL_DEFAULT_LEVELS
|
||||||
});
|
});
|
||||||
|
|
||||||
// Notification Center
|
// Notification Center
|
||||||
nc.on(nc.ns.channel.events.round.end, this.onEndRound, this);
|
Nc.on(Nc.ns.channel.events.round.end, this.onEndRound, this);
|
||||||
nc.on(nc.ns.channel.events.controlCommand.channel, function (message) {
|
Nc.on(Nc.ns.channel.events.controlCommand.channel, function (message) {
|
||||||
ProtocolHelper.applyCommand(message.data, self);
|
ProtocolHelper.applyCommand(message.data, self);
|
||||||
});
|
});
|
||||||
nc.on(nc.ns.channel.to.client.gameCommand.broadcast, this.broadcastGameCommand, this);
|
Nc.on(Nc.ns.channel.to.client.gameCommand.broadcast, this.broadcastGameCommand, this);
|
||||||
nc.on(nc.ns.channel.to.client.controlCommand.broadcast, this.broadcastControlCommand, this);
|
Nc.on(Nc.ns.channel.to.client.controlCommand.broadcast, this.broadcastControlCommand, this);
|
||||||
//nc.on(nc.ns.channel.to.client.gameCommand.broadcastExcept, this.broadcastGameCommandExcept, this);
|
//Nc.on(Nc.ns.channel.to.client.gameCommand.broadcastExcept, this.broadcastGameCommandExcept, this);
|
||||||
//nc.on(nc.ns.channel.to.client.controlCommand.broadcastExcept, this.broadcastControlCommandExcept, this);
|
//Nc.on(Nc.ns.channel.to.client.controlCommand.broadcastExcept, this.broadcastControlCommandExcept, this);
|
||||||
|
|
||||||
this.beginRound();
|
this.beginRound();
|
||||||
|
|
||||||
|
|
@ -82,7 +82,6 @@
|
||||||
|
|
||||||
Channel.prototype.onEndRound = function() {
|
Channel.prototype.onEndRound = function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.gameController.endRound();
|
|
||||||
this.broadcastControlCommand("endRound", true);
|
this.broadcastControlCommand("endRound", true);
|
||||||
|
|
||||||
console.checkpoint("End Round (" + this.name + ") - Begin Round in " + Settings.CHANNEL_END_ROUND_TIME + " seconds");
|
console.checkpoint("End Round (" + this.name + ") - Begin Round in " + Settings.CHANNEL_END_ROUND_TIME + " seconds");
|
||||||
|
|
@ -103,10 +102,10 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
if(!this.gameController.level || !this.gameController.level.isLoaded) {
|
if(!this.gameController.level || !this.gameController.level.isLoaded) {
|
||||||
var token = nc.on(nc.ns.core.game.events.level.loaded, function() {
|
var token = Nc.on(Nc.ns.core.game.events.level.loaded, function() {
|
||||||
self.sendJoinSuccess(options);
|
self.sendJoinSuccess(options);
|
||||||
self.users[options.id].sendControlCommand("beginRound", clientGameControllerOptions);
|
self.users[options.id].sendControlCommand("beginRound", clientGameControllerOptions);
|
||||||
nc.off(token);
|
Nc.off(token);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.sendJoinSuccess(options);
|
this.sendJoinSuccess(options);
|
||||||
|
|
@ -135,16 +134,16 @@
|
||||||
levelUid: levelUid
|
levelUid: levelUid
|
||||||
};
|
};
|
||||||
|
|
||||||
//nc.trigger("user/" + user.id + "/joinSuccess", options);
|
//Nc.trigger("user/" + user.id + "/joinSuccess", options);
|
||||||
user.sendControlCommand("joinSuccess", options);
|
user.sendControlCommand("joinSuccess", options);
|
||||||
nc.trigger(nc.ns.channel.events.user.joined, user);
|
Nc.trigger(Nc.ns.channel.events.user.joined, user);
|
||||||
|
|
||||||
this.broadcastControlCommandExcept("userJoined", user.options, user);
|
this.broadcastControlCommandExcept("userJoined", user.options, user);
|
||||||
};
|
};
|
||||||
|
|
||||||
Channel.prototype.onReleaseUser = function (userId) {
|
Channel.prototype.onReleaseUser = function (userId) {
|
||||||
var self = this;
|
var self = this;
|
||||||
nc.trigger(nc.ns.channel.events.user.left, userId);
|
Nc.trigger(Nc.ns.channel.events.user.left, userId);
|
||||||
delete this.users[userId];
|
delete this.users[userId];
|
||||||
|
|
||||||
this.broadcastControlCommand("userLeft", userId);
|
this.broadcastControlCommand("userLeft", userId);
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ define([
|
||||||
"Game/Config/Settings"
|
"Game/Config/Settings"
|
||||||
],
|
],
|
||||||
|
|
||||||
function(Parent, nc, Parser, Settings) {
|
function(Parent, Nc, Parser, Settings) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -35,9 +35,9 @@ function(Parent, nc, Parser, Settings) {
|
||||||
};
|
};
|
||||||
|
|
||||||
PlayerController.prototype.handActionRequest = function(options) {
|
PlayerController.prototype.handActionRequest = function(options) {
|
||||||
options.x = parseFloat(options.x) || 0.0;
|
options.x = parseFloat(options.x) || 0;
|
||||||
options.y = parseFloat(options.y) || 0.0;
|
options.y = parseFloat(options.y) || 0;
|
||||||
options.av = parseFloat(options.av) || 0.0;
|
options.av = parseFloat(options.av) || 0;
|
||||||
if (options) this.player.handActionRequest(options);
|
if (options) this.player.handActionRequest(options);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -45,7 +45,7 @@ function(Parent, nc, Parser, Settings) {
|
||||||
this.player.suicide();
|
this.player.suicide();
|
||||||
};
|
};
|
||||||
|
|
||||||
PlayerController.prototype.mePositionStateOverride = function(update) {
|
PlayerController.prototype.mePositionStateUpdate = function(update) {
|
||||||
|
|
||||||
if(!this.player.isSpawned()) {
|
if(!this.player.isSpawned()) {
|
||||||
// if someone still falls but is dead on the server already
|
// if someone still falls but is dead on the server already
|
||||||
|
|
@ -57,7 +57,7 @@ function(Parent, nc, Parser, Settings) {
|
||||||
y: Math.abs(update.p.y - this.player.doll.body.GetPosition().y)
|
y: Math.abs(update.p.y - this.player.doll.body.GetPosition().y)
|
||||||
};
|
};
|
||||||
|
|
||||||
if(difference.x < Settings.PUNKBUSTER_DIFFERENCE_METERS &&
|
if(true || difference.x < Settings.PUNKBUSTER_DIFFERENCE_METERS &&
|
||||||
difference.y < Settings.PUNKBUSTER_DIFFERENCE_METERS) {
|
difference.y < Settings.PUNKBUSTER_DIFFERENCE_METERS) {
|
||||||
this.player.doll.updatePositionState(update);
|
this.player.doll.updatePositionState(update);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -71,7 +71,7 @@ function(Parent, nc, Parser, Settings) {
|
||||||
lv: body.GetLinearVelocity()
|
lv: body.GetLinearVelocity()
|
||||||
};
|
};
|
||||||
|
|
||||||
nc.trigger(nc.ns.channel.to.client.user.gameCommand.send + this.player.id, "positionStateReset", options);
|
Nc.trigger(Nc.ns.channel.to.client.user.gameCommand.send + this.player.id, "positionStateReset", options);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,17 @@ define([
|
||||||
"Game/Core/GameController",
|
"Game/Core/GameController",
|
||||||
"Game/Channel/Physics/Engine",
|
"Game/Channel/Physics/Engine",
|
||||||
"Game/Config/Settings",
|
"Game/Config/Settings",
|
||||||
|
"Game/Channel/Control/PlayerController",
|
||||||
"Lib/Utilities/RequestAnimFrame",
|
"Lib/Utilities/RequestAnimFrame",
|
||||||
"Lib/Utilities/NotificationCenter",
|
"Lib/Utilities/NotificationCenter",
|
||||||
"Lib/Vendor/Box2D",
|
"Lib/Vendor/Box2D",
|
||||||
"Game/Channel/Player",
|
"Game/Channel/Player",
|
||||||
"Game/Channel/GameObjects/GameObject",
|
"Game/Channel/GameObjects/GameObject",
|
||||||
"Game/Channel/GameObjects/Doll",
|
"Game/Channel/GameObjects/Doll",
|
||||||
"Game/Channel/GameObjects/Items/RubeDoll"
|
"Game/Channel/GameObjects/Items/RagDoll"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, PhysicsEngine, Settings, requestAnimFrame, nc, Box2D, Player, GameObject, Doll, RubeDoll) {
|
function (Parent, PhysicsEngine, Settings, PlayerController, requestAnimFrame, Nc, Box2D, Player, GameObject, Doll, RagDoll) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -20,22 +21,22 @@ function (Parent, PhysicsEngine, Settings, requestAnimFrame, nc, Box2D, Player,
|
||||||
this.animationTimeout = null;
|
this.animationTimeout = null;
|
||||||
this.worldUpdateTimeout = null;
|
this.worldUpdateTimeout = null;
|
||||||
this.spawnTimeouts = [];
|
this.spawnTimeouts = [];
|
||||||
this.roundHasEnded = false;
|
|
||||||
|
|
||||||
Parent.call(this, options);
|
Parent.call(this, options);
|
||||||
|
|
||||||
this.ncTokens = this.ncTokens.concat([
|
this.ncTokens = this.ncTokens.concat([
|
||||||
nc.on(nc.ns.channel.events.user.joined, this.onUserJoined, this),
|
Nc.on(Nc.ns.channel.events.user.joined, this.onUserJoined, this),
|
||||||
nc.on(nc.ns.channel.events.user.left, this.onUserLeft, this),
|
Nc.on(Nc.ns.channel.events.user.left, this.onUserLeft, this),
|
||||||
nc.on(nc.ns.channel.events.user.level.reset, this.onResetLevel, this),
|
Nc.on(Nc.ns.channel.events.user.level.reset, this.onResetLevel, this),
|
||||||
nc.on(nc.ns.channel.events.user.client.ready, this.onClientReady, this),
|
Nc.on(Nc.ns.channel.events.user.client.ready, this.onClientReady, this),
|
||||||
nc.on(nc.ns.core.game.events.level.loaded, this.onLevelLoaded, this),
|
Nc.on(Nc.ns.core.game.events.level.loaded, this.onLevelLoaded, this),
|
||||||
nc.on(nc.ns.channel.events.game.player.killed, this.onPlayerKilled, this),
|
Nc.on(Nc.ns.channel.events.game.player.killed, this.onPlayerKilled, this),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
console.checkpoint('starting game controller for channel (' + options.channelName + ')');
|
console.checkpoint('starting game controller for channel (' + options.channelName + ')');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GameController.prototype = Object.create(Parent.prototype);
|
GameController.prototype = Object.create(Parent.prototype);
|
||||||
|
|
||||||
GameController.prototype.update = function () {
|
GameController.prototype.update = function () {
|
||||||
|
|
@ -58,28 +59,15 @@ function (Parent, PhysicsEngine, Settings, requestAnimFrame, nc, Box2D, Player,
|
||||||
this.createPlayer(user);
|
this.createPlayer(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
GameController.prototype.onUserLeft = function (userId) {
|
|
||||||
var player = this.players[userId];
|
|
||||||
this.clearItemsOfPlayerFingerPrints(player);
|
|
||||||
Parent.prototype.onUserLeft.call(this, userId);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameController.prototype.clearItemsOfPlayerFingerPrints = function(player) {
|
|
||||||
nc.trigger(nc.ns.channel.events.game.player.clearFingerPrints, player);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameController.prototype.createPlayer = function(user) {
|
GameController.prototype.createPlayer = function(user) {
|
||||||
|
var player = Parent.prototype.createPlayer.call(this, user);
|
||||||
var revealedGameController = {
|
player.setPlayerController(new PlayerController(player))
|
||||||
isInBetweenRounds: this.isInBetweenRounds.bind(this)
|
|
||||||
};
|
|
||||||
var player = Parent.prototype.createPlayer.call(this, user, revealedGameController);
|
|
||||||
user.setPlayer(player);
|
user.setPlayer(player);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameController.prototype.onPlayerKilled = function(player, killedByPlayer) {
|
GameController.prototype.onPlayerKilled = function(player, killedByPlayer) {
|
||||||
if(killedByPlayer.stats.score >= this.options.scoreLimit) {
|
if(killedByPlayer.stats.score >= this.options.scoreLimit) {
|
||||||
nc.trigger(nc.ns.channel.events.round.end);
|
Nc.trigger(Nc.ns.channel.events.round.end);
|
||||||
} else {
|
} else {
|
||||||
this.spawnPlayer(player, Settings.RESPAWN_TIME);
|
this.spawnPlayer(player, Settings.RESPAWN_TIME);
|
||||||
}
|
}
|
||||||
|
|
@ -95,6 +83,8 @@ function (Parent, PhysicsEngine, Settings, requestAnimFrame, nc, Box2D, Player,
|
||||||
|
|
||||||
var spawnTimeout = setTimeout(function() {
|
var spawnTimeout = setTimeout(function() {
|
||||||
player.spawn(spawnPoint.x, spawnPoint.y);
|
player.spawn(spawnPoint.x, spawnPoint.y);
|
||||||
|
// put it into
|
||||||
|
self.gameObjects.animated.push(player);
|
||||||
|
|
||||||
var options = {
|
var options = {
|
||||||
id: player.id,
|
id: player.id,
|
||||||
|
|
@ -102,7 +92,7 @@ function (Parent, PhysicsEngine, Settings, requestAnimFrame, nc, Box2D, Player,
|
||||||
y: spawnPoint.y
|
y: spawnPoint.y
|
||||||
};
|
};
|
||||||
|
|
||||||
nc.trigger(nc.ns.channel.to.client.gameCommand.broadcast, "spawnPlayer", options);
|
Nc.trigger(Nc.ns.channel.to.client.gameCommand.broadcast, "spawnPlayer", options);
|
||||||
|
|
||||||
var i = self.spawnTimeouts.indexOf(spawnTimeout);
|
var i = self.spawnTimeouts.indexOf(spawnTimeout);
|
||||||
self.spawnTimeouts.splice(i, 1);
|
self.spawnTimeouts.splice(i, 1);
|
||||||
|
|
@ -117,7 +107,7 @@ function (Parent, PhysicsEngine, Settings, requestAnimFrame, nc, Box2D, Player,
|
||||||
var update = this.getWorldUpdateObject(false);
|
var update = this.getWorldUpdateObject(false);
|
||||||
|
|
||||||
if(Object.getOwnPropertyNames(update).length > 0) {
|
if(Object.getOwnPropertyNames(update).length > 0) {
|
||||||
nc.trigger(nc.ns.channel.to.client.gameCommand.broadcast, "worldUpdate", update);
|
Nc.trigger(Nc.ns.channel.to.client.gameCommand.broadcast, "worldUpdate", update);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.worldUpdateTimeout = setTimeout(this.updateWorld.bind(this), Settings.NETWORK_UPDATE_INTERVAL);
|
this.worldUpdateTimeout = setTimeout(this.updateWorld.bind(this), Settings.NETWORK_UPDATE_INTERVAL);
|
||||||
|
|
@ -128,7 +118,6 @@ function (Parent, PhysicsEngine, Settings, requestAnimFrame, nc, Box2D, Player,
|
||||||
|
|
||||||
var update = {};
|
var update = {};
|
||||||
|
|
||||||
/*
|
|
||||||
var body = this.physicsEngine.world.GetBodyList();
|
var body = this.physicsEngine.world.GetBodyList();
|
||||||
do {
|
do {
|
||||||
if((getSleeping || body.IsAwake()) && body.GetType() === Box2D.Dynamics.b2Body.b2_dynamicBody) {
|
if((getSleeping || body.IsAwake()) && body.GetType() === Box2D.Dynamics.b2Body.b2_dynamicBody) {
|
||||||
|
|
@ -136,33 +125,22 @@ function (Parent, PhysicsEngine, Settings, requestAnimFrame, nc, Box2D, Player,
|
||||||
|
|
||||||
if (userData instanceof GameObject) {
|
if (userData instanceof GameObject) {
|
||||||
var gameObject = userData;
|
var gameObject = userData;
|
||||||
var updateData = gameObject.getUpdateData();
|
|
||||||
|
|
||||||
if (updateData) {
|
update[gameObject.uid] = {
|
||||||
update[gameObject.uid] = updateData;
|
p: body.GetPosition(),
|
||||||
|
a: body.GetAngle(),
|
||||||
|
lv: body.GetLinearVelocity(),
|
||||||
|
av: body.GetAngularVelocity()
|
||||||
|
};
|
||||||
|
|
||||||
|
if(gameObject instanceof Doll) {
|
||||||
|
update[gameObject.uid].as = gameObject.getActionState();
|
||||||
|
update[gameObject.uid].laxy = gameObject.lookAtXY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (body = body.GetNext());
|
} while (body = body.GetNext());
|
||||||
*/
|
|
||||||
|
|
||||||
for (var uid in this.worldUpdateObjects) {
|
|
||||||
|
|
||||||
var gameObject = this.worldUpdateObjects[uid];
|
|
||||||
|
|
||||||
if (!(gameObject instanceof GameObject)) {
|
|
||||||
console.warn('Cant find object ' + uid + ' in worldUpdateObjects pool (channel side), here is the object:');
|
|
||||||
console.log(gameObject);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
var updateData = gameObject.getUpdateData(getSleeping);
|
|
||||||
|
|
||||||
if (updateData) {
|
|
||||||
update[gameObject.uid] = updateData;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return update;
|
return update;
|
||||||
};
|
};
|
||||||
|
|
@ -190,36 +168,23 @@ function (Parent, PhysicsEngine, Settings, requestAnimFrame, nc, Box2D, Player,
|
||||||
return spawnedPlayers;
|
return spawnedPlayers;
|
||||||
};
|
};
|
||||||
|
|
||||||
GameController.prototype._getRuntimeItems = function() {
|
GameController.prototype.getRuntimeItems = function() {
|
||||||
|
var objects = [];
|
||||||
|
|
||||||
var runtimeItems = [];
|
for (var i = 0; i < this.gameObjects.animated.length; i++) {
|
||||||
for (var uid in this.worldUpdateObjects) {
|
if(this.gameObjects.animated[i] instanceof RagDoll) {
|
||||||
if(this.worldUpdateObjects[uid] instanceof RubeDoll) {
|
var object = this.gameObjects.animated[i];
|
||||||
var object = this.worldUpdateObjects[uid];
|
|
||||||
runtimeItems.push(object);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return runtimeItems;
|
|
||||||
};
|
|
||||||
|
|
||||||
GameController.prototype.gatherRuntimeItemsForWorldUpdate = function() {
|
|
||||||
var infos = [];
|
|
||||||
var runtimeItems = this._getRuntimeItems();
|
|
||||||
|
|
||||||
// On the other side this is using the level.createItem mechanism to
|
|
||||||
// create the RubeDoll from its ItemSettings
|
|
||||||
for (var i = 0; i < runtimeItems.length; i++) {
|
|
||||||
var object = runtimeItems[i];
|
|
||||||
var options = object.options;
|
var options = object.options;
|
||||||
options.x = object.getPosition().x;
|
options.x = object.getPosition().x;
|
||||||
options.y = object.getPosition().y;
|
options.y = object.getPosition().y;
|
||||||
infos.push({
|
objects.push({
|
||||||
uid: object.uid,
|
uid: object.uid,
|
||||||
options: object.options
|
options: object.options
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return infos;
|
return objects;
|
||||||
};
|
};
|
||||||
|
|
||||||
GameController.prototype.onClientReady = function(userId) {
|
GameController.prototype.onClientReady = function(userId) {
|
||||||
|
|
@ -228,34 +193,22 @@ function (Parent, PhysicsEngine, Settings, requestAnimFrame, nc, Box2D, Player,
|
||||||
var options = {
|
var options = {
|
||||||
spawnedPlayers: this.getSpawnedPlayersAndTheirPositions(),
|
spawnedPlayers: this.getSpawnedPlayersAndTheirPositions(),
|
||||||
worldUpdate: this.getWorldUpdateObject(true),
|
worldUpdate: this.getWorldUpdateObject(true),
|
||||||
runtimeItems: this.gatherRuntimeItemsForWorldUpdate(),
|
runtimeItems: this.getRuntimeItems(),
|
||||||
userId: userId
|
userId: userId
|
||||||
};
|
};
|
||||||
|
|
||||||
nc.trigger(nc.ns.channel.to.client.user.gameCommand.send + userId, "clientReadyResponse", options);
|
Nc.trigger(Nc.ns.channel.to.client.user.gameCommand.send + userId, "clientReadyResponse", options);
|
||||||
|
|
||||||
this.spawnPlayer(player, 0);
|
this.spawnPlayer(player, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameController.prototype.endRound = function() {
|
|
||||||
this.roundHasEnded = true;
|
|
||||||
|
|
||||||
for(var id in this.players) {
|
|
||||||
this.players[id].setInBetweenRounds(true);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
GameController.prototype.isInBetweenRounds = function() {
|
|
||||||
return this.roundHasEnded;
|
|
||||||
};
|
|
||||||
|
|
||||||
// FIXME: remove this method
|
// FIXME: remove this method
|
||||||
GameController.prototype.onResetLevel = function(userId) {
|
GameController.prototype.onResetLevel = function(userId) {
|
||||||
|
|
||||||
console.log('OH NO!!! ON RESET LEVEL IS CALLED AND RESPAWNES PLAYERS');
|
console.log('OH NO!!! ON RESET LEVEL IS CALLED AND RESPAWNES PLAYERS');
|
||||||
|
|
||||||
Parent.prototype.onResetLevel.call(this);
|
Parent.prototype.onResetLevel.call(this);
|
||||||
nc.trigger(nc.ns.channel.to.client.gameCommand.broadcast, "resetLevel", true);
|
Nc.trigger(Nc.ns.channel.to.client.gameCommand.broadcast, "resetLevel", true);
|
||||||
for (var key in this.players) {
|
for (var key in this.players) {
|
||||||
this.spawnPlayer(this.players[key]);
|
this.spawnPlayer(this.players[key]);
|
||||||
}
|
}
|
||||||
|
|
@ -269,11 +222,6 @@ function (Parent, PhysicsEngine, Settings, requestAnimFrame, nc, Box2D, Player,
|
||||||
clearTimeout(this.spawnTimeouts[i]);
|
clearTimeout(this.spawnTimeouts[i]);
|
||||||
};
|
};
|
||||||
|
|
||||||
var runtimeItems = this._getRuntimeItems();
|
|
||||||
for (var i = 0; i < runtimeItems.length; i++) {
|
|
||||||
runtimeItems[i].destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
Parent.prototype.destroy.call(this);
|
Parent.prototype.destroy.call(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ define([
|
||||||
"Lib/Utilities/Assert"
|
"Lib/Utilities/Assert"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, Item, Box2D, nc, Assert) {
|
function (Parent, Item, Box2D, Nc, Assert) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -54,7 +54,6 @@ function (Parent, Item, Box2D, nc, Assert) {
|
||||||
var b2Math = Box2D.Common.Math.b2Math;
|
var b2Math = Box2D.Common.Math.b2Math;
|
||||||
var absItemVelocity = b2Math.AbsV(itemVelocity);
|
var absItemVelocity = b2Math.AbsV(itemVelocity);
|
||||||
var min = 1;
|
var min = 1;
|
||||||
var damage = 0;
|
|
||||||
|
|
||||||
if(absItemVelocity.x > min || absItemVelocity.y > min) {
|
if(absItemVelocity.x > min || absItemVelocity.y > min) {
|
||||||
if(item.lastMoved && item.lastMoved.player != this.player) {
|
if(item.lastMoved && item.lastMoved.player != this.player) {
|
||||||
|
|
@ -73,24 +72,21 @@ function (Parent, Item, Box2D, nc, Assert) {
|
||||||
// + 0.5 and / 2: offsetting for lower velocity impact
|
// + 0.5 and / 2: offsetting for lower velocity impact
|
||||||
// * 300: tested imperically by throwing piano from deadly height
|
// * 300: tested imperically by throwing piano from deadly height
|
||||||
// * 80: tested imperically by throwing knife fast
|
// * 80: tested imperically by throwing knife fast
|
||||||
damage = (velocityDamage + 0.5) * (weightDamage * 300 + dangerDamage * 80) / 2;
|
var damage = (velocityDamage + 0.5) * (weightDamage * 300 + dangerDamage * 80) / 2;
|
||||||
|
|
||||||
var lastMovedPlayer = item.lastMoved.player;
|
var lastMovedPlayer = item.lastMoved.player;
|
||||||
var callback = function() {
|
var callback = function() {
|
||||||
self.player.addDamage(damage, lastMovedPlayer, item);
|
self.player.addDamage(damage, lastMovedPlayer, item);
|
||||||
};
|
};
|
||||||
|
|
||||||
nc.trigger(nc.ns.channel.engine.worldQueue.add, callback);
|
Nc.trigger(Nc.ns.channel.engine.worldQueue.add, callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// only set lastMovedBy if player wasn't hurt by collision
|
|
||||||
if (damage === 0) {
|
|
||||||
item.setLastMovedBy(this.player);
|
item.setLastMovedBy(this.player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Doll.prototype.updatePositionState = function(update) {
|
Doll.prototype.updatePositionState = function(update) {
|
||||||
|
|
@ -103,18 +99,6 @@ function (Parent, Item, Box2D, nc, Assert) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Doll.prototype.getUpdateData = function(getSleeping) {
|
|
||||||
|
|
||||||
var updateData = Parent.prototype.getUpdateData.call(this, getSleeping);
|
|
||||||
|
|
||||||
if(updateData) {
|
|
||||||
updateData.as = this.getActionState();
|
|
||||||
updateData.laxy = this.lookAtXY;
|
|
||||||
}
|
|
||||||
|
|
||||||
return updateData;
|
|
||||||
};
|
|
||||||
|
|
||||||
return Doll;
|
return Doll;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -1,39 +1,9 @@
|
||||||
define([
|
define([
|
||||||
"Game/Core/GameObjects/GameObject",
|
"Game/Core/GameObjects/GameObject"
|
||||||
"Lib/Vendor/Box2D"
|
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, Box2D) {
|
function(Parent) {
|
||||||
|
|
||||||
"use strict";
|
return Parent;
|
||||||
|
|
||||||
function GameObject(physicsEngine, uid) {
|
|
||||||
Parent.call(this, physicsEngine, uid);
|
|
||||||
}
|
|
||||||
|
|
||||||
GameObject.prototype = Object.create(Parent.prototype);
|
|
||||||
|
|
||||||
GameObject.prototype.getUpdateData = function(getSleeping) {
|
|
||||||
|
|
||||||
if (!this.body) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.body.GetType() === Box2D.Dynamics.b2Body.b2_staticBody) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!getSleeping && !this.body.IsAwake()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
p: this.body.GetPosition(),
|
|
||||||
a: this.body.GetAngle(),
|
|
||||||
lv: this.body.GetLinearVelocity(),
|
|
||||||
av: this.body.GetAngularVelocity()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return GameObject;
|
|
||||||
});
|
});
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
define([
|
define([
|
||||||
"Game/Core/GameObjects/Item",
|
"Game/Core/GameObjects/Item"
|
||||||
"Lib/Utilities/NotificationCenter",
|
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, nc) {
|
function (Parent) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -11,17 +10,10 @@ function (Parent, nc) {
|
||||||
Parent.call(this, physicsEngine, uid, options);
|
Parent.call(this, physicsEngine, uid, options);
|
||||||
this.heldByPlayers = [];
|
this.heldByPlayers = [];
|
||||||
this.lastMoved = null;
|
this.lastMoved = null;
|
||||||
|
|
||||||
this.ncTokens = (this.ncTokens || []).concat([
|
|
||||||
nc.on(nc.ns.channel.events.game.player.clearFingerPrints, this.clearOfPlayerFingerPrints, this)
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Item.prototype = Object.create(Parent.prototype);
|
Item.prototype = Object.create(Parent.prototype);
|
||||||
|
|
||||||
Item.prototype.getLastMovedBy = function() {
|
|
||||||
return this.lastMoved;
|
|
||||||
}
|
|
||||||
|
|
||||||
Item.prototype.setLastMovedBy = function(player) {
|
Item.prototype.setLastMovedBy = function(player) {
|
||||||
|
|
||||||
|
|
@ -64,13 +56,6 @@ function (Parent, nc) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Item.prototype.clearOfPlayerFingerPrints = function(player) {
|
|
||||||
if (this.getLastMovedBy() && this.getLastMovedBy().player === player) {
|
|
||||||
console.checkpoint('Removing fingerprints from ' + this.options.image);
|
|
||||||
this.setLastMovedBy(null);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Item.prototype.onCollisionChange = function(isColliding, fixture) {
|
Item.prototype.onCollisionChange = function(isColliding, fixture) {
|
||||||
|
|
||||||
if(isColliding) {
|
if(isColliding) {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ define([
|
||||||
"Lib/Utilities/NotificationCenter"
|
"Lib/Utilities/NotificationCenter"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, Settings, nc) {
|
function (Parent, Settings, Nc) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -35,7 +35,7 @@ function (Parent, Settings, nc) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.scheduledForDestruction = true;
|
this.scheduledForDestruction = true;
|
||||||
this.destructionTimeout = setTimeout(function() {
|
this.destructionTimeout = setTimeout(function() {
|
||||||
nc.trigger(nc.ns.channel.to.client.gameCommand.broadcast, 'removeGameObject', {
|
Nc.trigger(Nc.ns.channel.to.client.gameCommand.broadcast, 'removeGameObject', {
|
||||||
type: 'animated',
|
type: 'animated',
|
||||||
uid: self.uid
|
uid: self.uid
|
||||||
});
|
});
|
||||||
|
|
|
||||||
11
app/Game/Channel/GameObjects/Items/Rube.js
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
define([
|
||||||
|
"Game/Core/GameObjects/Items/Rube"
|
||||||
|
],
|
||||||
|
|
||||||
|
function (Parent) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
return Parent;
|
||||||
|
|
||||||
|
});
|
||||||
|
|
@ -1,79 +0,0 @@
|
||||||
define([
|
|
||||||
"Game/Core/GameObjects/Items/RubeDoll",
|
|
||||||
"Game/Config/Settings",
|
|
||||||
"Lib/Utilities/NotificationCenter"
|
|
||||||
],
|
|
||||||
|
|
||||||
function (Parent, Settings, nc) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function RubeDoll(physicsEngine, uid, options) {
|
|
||||||
this.scheduledForDestruction = false;
|
|
||||||
this.destructionTimeout = null;
|
|
||||||
|
|
||||||
Parent.call(this, physicsEngine, uid, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
RubeDoll.prototype = Object.create(Parent.prototype);
|
|
||||||
|
|
||||||
RubeDoll.prototype.beingGrabbed = function(player) {
|
|
||||||
Parent.prototype.beingGrabbed.call(this, player);
|
|
||||||
if(this.scheduledForDestruction) {
|
|
||||||
clearTimeout(this.destructionTimeout);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
RubeDoll.prototype.beingReleased = function(player) {
|
|
||||||
Parent.prototype.beingReleased.call(this, player);
|
|
||||||
if(this.scheduledForDestruction) {
|
|
||||||
this.delayedDestroy();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
RubeDoll.prototype.delayedDestroy = function() {
|
|
||||||
var self = this;
|
|
||||||
this.scheduledForDestruction = true;
|
|
||||||
this.destructionTimeout = setTimeout(function() {
|
|
||||||
nc.trigger(nc.ns.channel.to.client.gameCommand.broadcast, 'removeGameObject', {
|
|
||||||
type: 'animated',
|
|
||||||
uid: self.uid
|
|
||||||
});
|
|
||||||
self.destroy();
|
|
||||||
}, Settings.RAGDOLL_DESTRUCTION_TIME * 1000);
|
|
||||||
};
|
|
||||||
|
|
||||||
RubeDoll.prototype.getUpdateData = function(getSleeping) {
|
|
||||||
var updateData = Parent.prototype.getUpdateData.call(this, getSleeping);
|
|
||||||
|
|
||||||
// if parent is asleep it sends null, to do no update
|
|
||||||
if(!updateData) {
|
|
||||||
return updateData;
|
|
||||||
}
|
|
||||||
|
|
||||||
// adding limb update data
|
|
||||||
var limbUpdateData = {};
|
|
||||||
|
|
||||||
for(var name in this.limbs) {
|
|
||||||
limbUpdateData[name] = {
|
|
||||||
p: this.limbs[name].GetPosition(),
|
|
||||||
a: this.limbs[name].GetAngle(),
|
|
||||||
lv: this.limbs[name].GetLinearVelocity(),
|
|
||||||
av: this.limbs[name].GetAngularVelocity()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
updateData['limbs'] = limbUpdateData;
|
|
||||||
|
|
||||||
return updateData;
|
|
||||||
}
|
|
||||||
|
|
||||||
RubeDoll.prototype.destroy = function() {
|
|
||||||
if(this.scheduledForDestruction) {
|
|
||||||
clearTimeout(this.destructionTimeout);
|
|
||||||
}
|
|
||||||
Parent.prototype.destroy.call(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
return RubeDoll;
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
@ -8,8 +8,8 @@ function (Parent, Settings, FileSystem) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function Level (uid, engine) {
|
function Level (uid, engine, gameObjects) {
|
||||||
Parent.call(this, uid, engine);
|
Parent.call(this, uid, engine, gameObjects);
|
||||||
}
|
}
|
||||||
|
|
||||||
Level.prototype = Object.create(Parent.prototype);
|
Level.prototype = Object.create(Parent.prototype);
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ define([
|
||||||
"fs"
|
"fs"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (nc, Channel, Settings, fs) {
|
function (Nc, Channel, Settings, fs) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -14,7 +14,7 @@ function (nc, Channel, Settings, fs) {
|
||||||
this.process = process;
|
this.process = process;
|
||||||
this.recordingFileName = null;
|
this.recordingFileName = null;
|
||||||
|
|
||||||
nc.on(nc.ns.channel.to.server.controlCommand.send, this.send, this);
|
Nc.on(Nc.ns.channel.to.server.controlCommand.send, this.send, this);
|
||||||
|
|
||||||
process.on("message", this.onProcessMessage.bind(this));
|
process.on("message", this.onProcessMessage.bind(this));
|
||||||
}
|
}
|
||||||
|
|
@ -82,10 +82,10 @@ function (nc, Channel, Settings, fs) {
|
||||||
PipeToServer.prototype.onMessage = function (message) {
|
PipeToServer.prototype.onMessage = function (message) {
|
||||||
switch(message.recipient) {
|
switch(message.recipient) {
|
||||||
case "channel":
|
case "channel":
|
||||||
nc.trigger(nc.ns.channel.events.controlCommand.channel, message);
|
Nc.trigger(Nc.ns.channel.events.controlCommand.channel, message);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
nc.trigger(nc.ns.channel.events.controlCommand.user + message.recipient, message);
|
Nc.trigger(Nc.ns.channel.events.controlCommand.user + message.recipient, message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,14 @@
|
||||||
define([
|
define([
|
||||||
"Game/Core/Player",
|
"Game/Core/Player",
|
||||||
"Lib/Utilities/NotificationCenter",
|
"Lib/Utilities/NotificationCenter"
|
||||||
"Game/Channel/Control/PlayerController"
|
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, nc, PlayerController) {
|
function (Parent, Nc) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function Player(id, physicsEngine, user, revealedGameController) {
|
function Player(id, physicsEngine, user) {
|
||||||
Parent.call(this, id, physicsEngine, user, revealedGameController);
|
Parent.call(this, id, physicsEngine, user);
|
||||||
|
|
||||||
this.playerController = new PlayerController(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Player.prototype = Object.create(Parent.prototype);
|
Player.prototype = Object.create(Parent.prototype);
|
||||||
|
|
@ -44,7 +41,7 @@ function (Parent, nc, PlayerController) {
|
||||||
this.throw(options, item);
|
this.throw(options, item);
|
||||||
|
|
||||||
options.action = "throw";
|
options.action = "throw";
|
||||||
nc.trigger(nc.ns.channel.to.client.gameCommand.broadcast, "handActionResponse", options);
|
Nc.trigger(Nc.ns.channel.to.client.gameCommand.broadcast, "handActionResponse", options);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// grab
|
// grab
|
||||||
|
|
@ -52,7 +49,7 @@ function (Parent, nc, PlayerController) {
|
||||||
this.grab(item);
|
this.grab(item);
|
||||||
|
|
||||||
options.action = "grab";
|
options.action = "grab";
|
||||||
nc.trigger(nc.ns.channel.to.client.gameCommand.broadcast, "handActionResponse", options);
|
Nc.trigger(Nc.ns.channel.to.client.gameCommand.broadcast, "handActionResponse", options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -64,12 +61,6 @@ function (Parent, nc, PlayerController) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Player.prototype.addDamage = function(damage, enemy, byItem) {
|
Player.prototype.addDamage = function(damage, enemy, byItem) {
|
||||||
|
|
||||||
// Prevent stats change (kills) after round has ended
|
|
||||||
if (this.revealedGameController.isInBetweenRounds()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.stats.health -= damage;
|
this.stats.health -= damage;
|
||||||
|
|
||||||
if(this.stats.health < 0) this.stats.health = 0;
|
if(this.stats.health < 0) this.stats.health = 0;
|
||||||
|
|
@ -93,14 +84,14 @@ function (Parent, nc, PlayerController) {
|
||||||
var ragDollId = this.stats.deaths;
|
var ragDollId = this.stats.deaths;
|
||||||
Parent.prototype.kill.call(this, killedByPlayer, ragDollId);
|
Parent.prototype.kill.call(this, killedByPlayer, ragDollId);
|
||||||
|
|
||||||
nc.trigger(nc.ns.channel.to.client.gameCommand.broadcast, "playerKill", {
|
Nc.trigger(Nc.ns.channel.to.client.gameCommand.broadcast, "playerKill", {
|
||||||
playerId: this.id,
|
playerId: this.id,
|
||||||
killedByPlayerId: killedByPlayer.id,
|
killedByPlayerId: killedByPlayer.id,
|
||||||
ragDollId: ragDollId,
|
ragDollId: ragDollId,
|
||||||
item: byItem ? byItem.options.name : "Suicide"
|
item: byItem ? byItem.options.name : "Suicide"
|
||||||
});
|
});
|
||||||
|
|
||||||
nc.trigger(nc.ns.channel.events.game.player.killed, this, killedByPlayer); // sends endround
|
Nc.trigger(Nc.ns.channel.events.game.player.killed, this, killedByPlayer); // sends endround
|
||||||
|
|
||||||
if(this.ragDoll) {
|
if(this.ragDoll) {
|
||||||
this.ragDoll.delayedDestroy();
|
this.ragDoll.delayedDestroy();
|
||||||
|
|
@ -112,19 +103,20 @@ function (Parent, nc, PlayerController) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Player.prototype.broadcastStats = function(enemy) {
|
Player.prototype.broadcastStats = function(enemy) {
|
||||||
nc.trigger(nc.ns.channel.to.client.gameCommand.broadcast, "updateStats", {
|
Nc.trigger(Nc.ns.channel.to.client.gameCommand.broadcast, "updateStats", {
|
||||||
playerId: this.id,
|
playerId: this.id,
|
||||||
stats: this.stats
|
stats: this.stats
|
||||||
});
|
});
|
||||||
|
|
||||||
if(enemy && enemy != this) {
|
if(enemy && enemy != this) {
|
||||||
nc.trigger(nc.ns.channel.to.client.gameCommand.broadcast, "updateStats", {
|
Nc.trigger(Nc.ns.channel.to.client.gameCommand.broadcast, "updateStats", {
|
||||||
playerId: enemy.id,
|
playerId: enemy.id,
|
||||||
stats: enemy.stats
|
stats: enemy.stats
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
return Player;
|
return Player;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -5,7 +5,7 @@ define([
|
||||||
"Lib/Utilities/Protocol/Parser",
|
"Lib/Utilities/Protocol/Parser",
|
||||||
],
|
],
|
||||||
|
|
||||||
function(Parent, nc, ProtocolHelper, ProtocolParser) {
|
function(Parent, Nc, ProtocolHelper, ProtocolParser) {
|
||||||
|
|
||||||
function User(id, options) {
|
function User(id, options) {
|
||||||
Parent.call(this, id, options);
|
Parent.call(this, id, options);
|
||||||
|
|
@ -14,15 +14,15 @@ function(Parent, nc, ProtocolHelper, ProtocolParser) {
|
||||||
this.isReady = false;
|
this.isReady = false;
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
nc.on(nc.ns.channel.to.client.user.controlCommand.joinSuccess + this.id, function(options) {
|
Nc.on(Nc.ns.channel.to.client.user.controlCommand.joinSuccess + this.id, function(options) {
|
||||||
self.sendControlCommand("joinSuccess", options);
|
self.sendControlCommand("joinSuccess", options);
|
||||||
});
|
});
|
||||||
|
|
||||||
nc.on(nc.ns.channel.events.controlCommand.user + this.id, function(message) {
|
Nc.on(Nc.ns.channel.events.controlCommand.user + this.id, function(message) {
|
||||||
ProtocolHelper.applyCommand(message.data, self);
|
ProtocolHelper.applyCommand(message.data, self);
|
||||||
});
|
});
|
||||||
|
|
||||||
nc.on(nc.ns.channel.to.client.user.gameCommand.send + this.id, function(command, options) {
|
Nc.on(Nc.ns.channel.to.client.user.gameCommand.send + this.id, function(command, options) {
|
||||||
self.sendGameCommand(command, options);
|
self.sendGameCommand(command, options);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -44,10 +44,10 @@ function(Parent, nc, ProtocolHelper, ProtocolParser) {
|
||||||
} // FIXME: move this to Protocol helper as a function
|
} // FIXME: move this to Protocol helper as a function
|
||||||
|
|
||||||
if(command.hasOwnProperty("resetLevel")) {
|
if(command.hasOwnProperty("resetLevel")) {
|
||||||
nc.trigger(nc.ns.channel.events.user.level.reset, this.id);
|
Nc.trigger(Nc.ns.channel.events.user.level.reset, this.id);
|
||||||
} else if(command.hasOwnProperty("clientReady")) {
|
} else if(command.hasOwnProperty("clientReady")) {
|
||||||
this.isReady = true;
|
this.isReady = true;
|
||||||
nc.trigger(nc.ns.channel.events.user.client.ready, this.id);
|
Nc.trigger(Nc.ns.channel.events.user.client.ready, this.id);
|
||||||
} else {
|
} else {
|
||||||
this.player.playerController.applyCommand(command);
|
this.player.playerController.applyCommand(command);
|
||||||
}
|
}
|
||||||
|
|
@ -61,17 +61,7 @@ function(Parent, nc, ProtocolHelper, ProtocolParser) {
|
||||||
var recipient = this.id;
|
var recipient = this.id;
|
||||||
var data = ProtocolHelper.encodeCommand(command, options);
|
var data = ProtocolHelper.encodeCommand(command, options);
|
||||||
|
|
||||||
/**
|
Nc.trigger(Nc.ns.channel.to.server.controlCommand.send, recipient, data);
|
||||||
* Listen for beginRound control command
|
|
||||||
* to set client to be unready again
|
|
||||||
* so it can load its new level without getting
|
|
||||||
* any gameCommands like worldUpdate
|
|
||||||
*/
|
|
||||||
if(command == "beginRound") {
|
|
||||||
this.isReady = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
nc.trigger(nc.ns.channel.to.server.controlCommand.send, recipient, data);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
User.prototype.sendGameCommand = function(command, options) {
|
User.prototype.sendGameCommand = function(command, options) {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ define([
|
||||||
"Lib/Utilities/NotificationCenter"
|
"Lib/Utilities/NotificationCenter"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (nc) {
|
function (Nc) {
|
||||||
|
|
||||||
function Input(playerController) {
|
function Input(playerController) {
|
||||||
this.playerController = playerController;
|
this.playerController = playerController;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ define([
|
||||||
"Game/Client/Control/Swiper"
|
"Game/Client/Control/Swiper"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, KeyboardInput, domController, Settings, Swiper) {
|
function (Parent, KeyboardInput, DomController, Settings, Swiper) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -122,7 +122,7 @@ function (Parent, KeyboardInput, domController, Settings, Swiper) {
|
||||||
};
|
};
|
||||||
|
|
||||||
KeyboardAndMouse.prototype.mouseInit = function() {
|
KeyboardAndMouse.prototype.mouseInit = function() {
|
||||||
var canvas = domController.getCanvas();
|
var canvas = DomController.getCanvas();
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
canvas.onmousedown = function(e) {
|
canvas.onmousedown = function(e) {
|
||||||
|
|
@ -216,7 +216,6 @@ function (Parent, KeyboardInput, domController, Settings, Swiper) {
|
||||||
|
|
||||||
KeyboardAndMouse.prototype.activateModifier = function() {
|
KeyboardAndMouse.prototype.activateModifier = function() {
|
||||||
this.modifier = true;
|
this.modifier = true;
|
||||||
this.playerController.activateModifier();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
KeyboardAndMouse.prototype.deactivateModifier = function() {
|
KeyboardAndMouse.prototype.deactivateModifier = function() {
|
||||||
|
|
@ -224,7 +223,6 @@ function (Parent, KeyboardInput, domController, Settings, Swiper) {
|
||||||
this.x = this.lastLookDirection * Settings.VIEWPORT_LOOK_AHEAD;
|
this.x = this.lastLookDirection * Settings.VIEWPORT_LOOK_AHEAD;
|
||||||
this.y = 0;
|
this.y = 0;
|
||||||
this.onXyChange(this.x, this.y);
|
this.onXyChange(this.x, this.y);
|
||||||
this.playerController.deactivateModifier();
|
|
||||||
};
|
};
|
||||||
return KeyboardAndMouse;
|
return KeyboardAndMouse;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ define([
|
||||||
"Game/Client/PointerLockManager"
|
"Game/Client/PointerLockManager"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, nc, KeyboardAndMouse, Gamepad, pointerLockManager) {
|
function (Parent, Nc, KeyboardAndMouse, Gamepad, PointerLockManager) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -27,96 +27,74 @@ function (Parent, nc, KeyboardAndMouse, Gamepad, pointerLockManager) {
|
||||||
};
|
};
|
||||||
|
|
||||||
PlayerController.prototype.moveLeft = function () {
|
PlayerController.prototype.moveLeft = function () {
|
||||||
if (!this.isPlayerInputAllowed()) return;
|
if (!PointerLockManager.isLocked()) return;
|
||||||
Parent.prototype.moveLeft.call(this);
|
Parent.prototype.moveLeft.call(this);
|
||||||
nc.trigger(nc.ns.client.to.server.gameCommand.send, 'moveLeft');
|
Nc.trigger(Nc.ns.client.to.server.gameCommand.send, 'moveLeft');
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerController.prototype.moveRight = function () {
|
PlayerController.prototype.moveRight = function () {
|
||||||
if (!this.isPlayerInputAllowed()) return;
|
if (!PointerLockManager.isLocked()) return;
|
||||||
Parent.prototype.moveRight.call(this);
|
Parent.prototype.moveRight.call(this);
|
||||||
nc.trigger(nc.ns.client.to.server.gameCommand.send, 'moveRight');
|
Nc.trigger(Nc.ns.client.to.server.gameCommand.send, 'moveRight');
|
||||||
}
|
}
|
||||||
|
|
||||||
// always allow to stop, to prevent endless running
|
|
||||||
PlayerController.prototype.stop = function () {
|
PlayerController.prototype.stop = function () {
|
||||||
Parent.prototype.stop.call(this);
|
Parent.prototype.stop.call(this);
|
||||||
nc.trigger(nc.ns.client.to.server.gameCommand.send, 'stop');
|
Nc.trigger(Nc.ns.client.to.server.gameCommand.send, 'stop');
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerController.prototype.jump = function () {
|
PlayerController.prototype.jump = function () {
|
||||||
if (!this.isPlayerInputAllowed()) return;
|
if (!PointerLockManager.isLocked()) return;
|
||||||
Parent.prototype.jump.call(this);
|
Parent.prototype.jump.call(this);
|
||||||
nc.trigger(nc.ns.client.to.server.gameCommand.send, 'jump');
|
Nc.trigger(Nc.ns.client.to.server.gameCommand.send, 'jump');
|
||||||
}
|
}
|
||||||
|
|
||||||
// always allow to stop.
|
|
||||||
PlayerController.prototype.jumpStop = function () {
|
PlayerController.prototype.jumpStop = function () {
|
||||||
|
if (!PointerLockManager.isLocked()) return;
|
||||||
Parent.prototype.jumpStop.call(this);
|
Parent.prototype.jumpStop.call(this);
|
||||||
nc.trigger(nc.ns.client.to.server.gameCommand.send, 'jumpStop');
|
Nc.trigger(Nc.ns.client.to.server.gameCommand.send, 'jumpStop');
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerController.prototype.setXY = function(x, y) {
|
PlayerController.prototype.setXY = function(x, y) {
|
||||||
if (!this.isPlayerInputAllowed()) return;
|
if (!PointerLockManager.isLocked()) return;
|
||||||
var options = {x:x, y:y};
|
var options = {x:x, y:y};
|
||||||
Parent.prototype.lookAt.call(this, options);
|
Parent.prototype.lookAt.call(this, options);
|
||||||
nc.trigger(nc.ns.client.to.server.gameCommand.send, 'lookAt', options);
|
Nc.trigger(Nc.ns.client.to.server.gameCommand.send, 'lookAt', options);
|
||||||
};
|
};
|
||||||
|
|
||||||
PlayerController.prototype.suicide = function() {
|
PlayerController.prototype.suicide = function() {
|
||||||
if (!this.isPlayerInputAllowed()) return;
|
if (!PointerLockManager.isLocked()) return;
|
||||||
nc.trigger(nc.ns.client.to.server.gameCommand.send, "suicide");
|
Nc.trigger(Nc.ns.client.to.server.gameCommand.send, "suicide");
|
||||||
};
|
};
|
||||||
|
|
||||||
PlayerController.prototype.handActionRequest = function(options) {
|
PlayerController.prototype.handActionRequest = function(options) {
|
||||||
if (!this.isPlayerInputAllowed()) return;
|
if (!PointerLockManager.isLocked()) return;
|
||||||
nc.trigger(nc.ns.client.to.server.gameCommand.send, "handActionRequest", options);
|
Nc.trigger(Nc.ns.client.to.server.gameCommand.send, "handActionRequest", options);
|
||||||
};
|
};
|
||||||
|
|
||||||
PlayerController.prototype.showInfo = function() {
|
PlayerController.prototype.showInfo = function() {
|
||||||
if (!this.isPlayerInputAllowed()) return;
|
if (!PointerLockManager.isLocked()) return;
|
||||||
nc.trigger(nc.ns.client.game.gameStats.toggle, true);
|
Nc.trigger(Nc.ns.client.game.gameStats.toggle, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
PlayerController.prototype.hideInfo = function() {
|
PlayerController.prototype.hideInfo = function() {
|
||||||
if (!this.isPlayerInputAllowed()) return;
|
if (!PointerLockManager.isLocked()) return;
|
||||||
nc.trigger(nc.ns.client.game.gameStats.toggle, false);
|
Nc.trigger(Nc.ns.client.game.gameStats.toggle, false);
|
||||||
};
|
};
|
||||||
|
|
||||||
PlayerController.prototype.zoomIn = function() {
|
PlayerController.prototype.zoomIn = function() {
|
||||||
if (!this.isPlayerInputAllowed()) return;
|
if (!PointerLockManager.isLocked()) return;
|
||||||
nc.trigger(nc.ns.client.game.zoomIn, true);
|
Nc.trigger(Nc.ns.client.game.zoomIn, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
PlayerController.prototype.zoomOut = function() {
|
PlayerController.prototype.zoomOut = function() {
|
||||||
if (!this.isPlayerInputAllowed()) return;
|
if (!PointerLockManager.isLocked()) return;
|
||||||
nc.trigger(nc.ns.client.game.zoomOut, false);
|
Nc.trigger(Nc.ns.client.game.zoomOut, false);
|
||||||
};
|
};
|
||||||
|
|
||||||
PlayerController.prototype.zoomReset = function() {
|
PlayerController.prototype.zoomReset = function() {
|
||||||
if (!this.isPlayerInputAllowed()) return;
|
if (!PointerLockManager.isLocked()) return;
|
||||||
nc.trigger(nc.ns.client.game.zoomReset, false);
|
Nc.trigger(Nc.ns.client.game.zoomReset, false);
|
||||||
};
|
|
||||||
|
|
||||||
PlayerController.prototype.activateModifier = function() {
|
|
||||||
if (!this.isPlayerInputAllowed()) return;
|
|
||||||
Parent.prototype.activateModifier.call(this);
|
|
||||||
nc.trigger(nc.ns.client.to.server.gameCommand.send, "activateModifier");
|
|
||||||
};
|
|
||||||
|
|
||||||
PlayerController.prototype.deactivateModifier = function() {
|
|
||||||
if (!this.isPlayerInputAllowed()) return;
|
|
||||||
Parent.prototype.deactivateModifier.call(this);
|
|
||||||
nc.trigger(nc.ns.client.to.server.gameCommand.send, "deactivateModifier");
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Client overwrite - allow player input if PointerLock is locked to canvas
|
|
||||||
* and is not in between games
|
|
||||||
*/
|
|
||||||
PlayerController.prototype.isPlayerInputAllowed = function() {
|
|
||||||
return pointerLockManager.isLocked()
|
|
||||||
&& Parent.prototype.isPlayerInputAllowed.call(this);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ define([
|
||||||
"Lib/Utilities/NotificationCenter",
|
"Lib/Utilities/NotificationCenter",
|
||||||
],
|
],
|
||||||
|
|
||||||
function (nc) {
|
function (Nc) {
|
||||||
|
|
||||||
var MAX_LENGTH = 200;
|
var MAX_LENGTH = 200;
|
||||||
var MIN_LENGTH = 5;
|
var MIN_LENGTH = 5;
|
||||||
|
|
@ -42,7 +42,7 @@ function (nc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var i = points.length - 1;
|
var i = points.length - 1;
|
||||||
nc.trigger(nc.ns.client.view.swiper.swipe, points[i].x, points[i].y);
|
Nc.trigger(Nc.ns.client.view.swiper.swipe, points[i].x, points[i].y);
|
||||||
}
|
}
|
||||||
|
|
||||||
Swiper.prototype.updateLengthSum = function(currentLength) {
|
Swiper.prototype.updateLengthSum = function(currentLength) {
|
||||||
|
|
@ -135,7 +135,7 @@ function (nc) {
|
||||||
var sumx = 0;
|
var sumx = 0;
|
||||||
var sumy = 0;
|
var sumy = 0;
|
||||||
|
|
||||||
nc.trigger(nc.ns.client.view.swiper.end);
|
Nc.trigger(Nc.ns.client.view.swiper.end);
|
||||||
|
|
||||||
for(var i=0, count = this.points.length; i < count; i++) {
|
for(var i=0, count = this.points.length; i < count; i++) {
|
||||||
var p = this.points[i];
|
var p = this.points[i];
|
||||||
|
|
@ -166,7 +166,7 @@ function (nc) {
|
||||||
|
|
||||||
Swiper.prototype.destroy = function() {
|
Swiper.prototype.destroy = function() {
|
||||||
for (var i = 0; i < this.ncTokens.length; i++) {
|
for (var i = 0; i < this.ncTokens.length; i++) {
|
||||||
nc.off(this.ncTokens[i]);
|
Nc.off(this.ncTokens[i]);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ define([
|
||||||
"Lib/Utilities/Exception"
|
"Lib/Utilities/Exception"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, nc, requestAnimFrame, Settings, GameObject, Doll, domController, ProtocolHelper, Me, AudioPlayer, pointerLockManager, Assert, Exception) {
|
function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, Nc, requestAnimFrame, Settings, GameObject, Doll, DomController, ProtocolHelper, Me, AudioPlayer, PointerLockManager, Assert, Exception) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -33,7 +33,7 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, nc, reque
|
||||||
Parent.call(this, options);
|
Parent.call(this, options);
|
||||||
|
|
||||||
this.ncTokens = this.ncTokens.concat([
|
this.ncTokens = this.ncTokens.concat([
|
||||||
nc.on(nc.ns.client.game.gameStats.toggle, this.toggleGameStats, this)
|
Nc.on(Nc.ns.client.game.gameStats.toggle, this.toggleGameStats, this)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -52,34 +52,43 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, nc, reque
|
||||||
|
|
||||||
if(this.me) {
|
if(this.me) {
|
||||||
this.me.update();
|
this.me.update();
|
||||||
this.mePositionStateOverride();
|
this.mePositionStateUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
nc.trigger(nc.ns.client.game.events.render);
|
for (var i = 0; i < this.gameObjects.animated.length; i++) {
|
||||||
|
this.gameObjects.animated[i].render();
|
||||||
|
}
|
||||||
|
|
||||||
this.view.render();
|
this.view.render();
|
||||||
domController.fpsStep();
|
DomController.fpsStep();
|
||||||
};
|
};
|
||||||
|
|
||||||
GameController.prototype.mePositionStateOverride = function() {
|
GameController.prototype.mePositionStateUpdate = function() {
|
||||||
if(this.me.isPositionStateOverrideNeeded()) {
|
if(this.me.isPositionStateUpdateNeeded()) {
|
||||||
nc.trigger(
|
Nc.trigger(Nc.ns.client.to.server.gameCommand.send, "mePositionStateUpdate", this.me.getPositionStateUpdate());
|
||||||
nc.ns.client.to.server.gameCommand.send,
|
|
||||||
"mePositionStateOverride",
|
|
||||||
this.me.getPositionStateOverride()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
GameController.prototype.onClientReadyResponse = function(options) {
|
GameController.prototype.onClientReadyResponse = function(options) {
|
||||||
var i;
|
var i;
|
||||||
|
|
||||||
|
if (options.worldUpdate) {
|
||||||
|
this.onWorldUpdate(options.worldUpdate);
|
||||||
|
}
|
||||||
|
|
||||||
if (options.runtimeItems) {
|
if (options.runtimeItems) {
|
||||||
for (i = 0; i < options.runtimeItems.length; i++) {
|
for (i = 0; i < options.runtimeItems.length; i++) {
|
||||||
|
|
||||||
var itemDef = options.runtimeItems[i];
|
var itemDef = options.runtimeItems[i];
|
||||||
|
|
||||||
if(!this.getItemByUid(itemDef.uid)) {
|
var alreadyExists = false;
|
||||||
|
for (var j = 0; j < this.gameObjects.animated.length; j++) {
|
||||||
|
if(this.gameObjects.animated[j].uid == itemDef.uid) {
|
||||||
|
alreadyExists = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!alreadyExists) {
|
||||||
// When creating from synchronization we need to bring it into level format (px)
|
// When creating from synchronization we need to bring it into level format (px)
|
||||||
itemDef.options.x *= Settings.RATIO;
|
itemDef.options.x *= Settings.RATIO;
|
||||||
itemDef.options.y *= Settings.RATIO;
|
itemDef.options.y *= Settings.RATIO;
|
||||||
|
|
@ -99,21 +108,10 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, nc, reque
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.worldUpdate) { // needs to stay after onSpawnPlayer otherwise others doll will not be there
|
|
||||||
this.onWorldUpdate(options.worldUpdate);
|
|
||||||
}
|
|
||||||
|
|
||||||
//this.audioPlayer = new AudioPlayer(Settings.AUDIO_PATH + "city.mp3");
|
//this.audioPlayer = new AudioPlayer(Settings.AUDIO_PATH + "city.mp3");
|
||||||
//this.audioPlayer.play();
|
//this.audioPlayer.play();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
TODO :
|
|
||||||
- remove this
|
|
||||||
- overwrite setUpdateData inside client / Me with an empty function
|
|
||||||
|
|
||||||
GameController.prototype.onWorldUpdateGameObject = function(body, gameObject, update) {
|
GameController.prototype.onWorldUpdateGameObject = function(body, gameObject, update) {
|
||||||
if(gameObject === this.me.doll) {
|
if(gameObject === this.me.doll) {
|
||||||
this.me.setLastServerPositionState(update);
|
this.me.setLastServerPositionState(update);
|
||||||
|
|
@ -124,22 +122,6 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, nc, reque
|
||||||
|
|
||||||
Parent.prototype.onWorldUpdateGameObject.call(this, body, gameObject, update);
|
Parent.prototype.onWorldUpdateGameObject.call(this, body, gameObject, update);
|
||||||
};
|
};
|
||||||
*/
|
|
||||||
|
|
||||||
GameController.prototype.onRemoveGameObject = function(options) {
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
GameController.prototype.updateGameObject = function (gameObject, gameObjectUpdate) {
|
|
||||||
if(gameObject === this.me.doll) {
|
|
||||||
this.me.setLastServerPositionState(gameObjectUpdate);
|
|
||||||
if(!this.me.acceptPositionStateUpdateFromServer()) {
|
|
||||||
return; // this is to ignore own doll updates from world update
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Parent.prototype.updateGameObject.call(this, gameObject, gameObjectUpdate);
|
|
||||||
}
|
|
||||||
|
|
||||||
GameController.prototype.createMe = function(user) {
|
GameController.prototype.createMe = function(user) {
|
||||||
this.me = new Me(user.id, this.physicsEngine, user);
|
this.me = new Me(user.id, this.physicsEngine, user);
|
||||||
|
|
@ -147,6 +129,7 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, nc, reque
|
||||||
};
|
};
|
||||||
|
|
||||||
GameController.prototype.setMe = function() {
|
GameController.prototype.setMe = function() {
|
||||||
|
this.me.setPlayerController(new PlayerController(this.me));
|
||||||
this.view.setMe(this.me);
|
this.view.setMe(this.me);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -178,7 +161,15 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, nc, reque
|
||||||
|
|
||||||
GameController.prototype.onHandActionResponse = function(options) {
|
GameController.prototype.onHandActionResponse = function(options) {
|
||||||
var player = this.players[options.playerId];
|
var player = this.players[options.playerId];
|
||||||
var item = this.getItemByUid(options.itemUid);
|
|
||||||
|
var item = null;
|
||||||
|
for (var i = 0; i < this.gameObjects.animated.length; i++) {
|
||||||
|
var currentItem = this.gameObjects.animated[i];
|
||||||
|
if(currentItem.uid == options.itemUid) {
|
||||||
|
item = currentItem;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(item) {
|
if(item) {
|
||||||
if(options.action == "throw") {
|
if(options.action == "throw") {
|
||||||
|
|
@ -214,7 +205,7 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, nc, reque
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
nc.trigger(nc.ns.client.view.gameStats.update, sortedPlayers);
|
Nc.trigger(Nc.ns.client.view.gameStats.update, sortedPlayers);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameController.prototype.onPlayerKill = function(options) {
|
GameController.prototype.onPlayerKill = function(options) {
|
||||||
|
|
@ -222,7 +213,7 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, nc, reque
|
||||||
var killedByPlayer = this.players[options.killedByPlayerId];
|
var killedByPlayer = this.players[options.killedByPlayerId];
|
||||||
player.kill(killedByPlayer, options.ragDollId);
|
player.kill(killedByPlayer, options.ragDollId);
|
||||||
|
|
||||||
nc.trigger(nc.ns.client.view.gameStats.kill, {
|
Nc.trigger(Nc.ns.client.view.gameStats.kill, {
|
||||||
victim: {
|
victim: {
|
||||||
name: player.user.options.nickname,
|
name: player.user.options.nickname,
|
||||||
isMe: player === this.me
|
isMe: player === this.me
|
||||||
|
|
@ -239,25 +230,32 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, nc, reque
|
||||||
this.me.resetPositionState(options);
|
this.me.resetPositionState(options);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GameController.prototype.onRemoveGameObject = function(options) {
|
||||||
|
var object = null;
|
||||||
|
for (var i = 0; i < this.gameObjects[options.type].length; i++) {
|
||||||
|
if(this.gameObjects[options.type][i].uid == options.uid) {
|
||||||
|
object = this.gameObjects[options.type][i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(object) {
|
||||||
|
//this.onGameObjectRemove(options.type, object);
|
||||||
|
object.destroy();
|
||||||
|
} else {
|
||||||
|
console.warn("GameObject for removal can not be found locally. " + options.uid);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
GameController.prototype.loadLevel = function (path) {
|
GameController.prototype.loadLevel = function (path) {
|
||||||
Parent.prototype.loadLevel.call(this, path);
|
Parent.prototype.loadLevel.call(this, path);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameController.prototype.onLevelLoaded = function () {
|
GameController.prototype.onLevelLoaded = function () {
|
||||||
pointerLockManager.update(null, {start:true});
|
PointerLockManager.update(null, {start:true});
|
||||||
};
|
};
|
||||||
|
|
||||||
GameController.prototype.toggleGameStats = function(show) {
|
GameController.prototype.toggleGameStats = function(show) {
|
||||||
nc.trigger(nc.ns.client.view.gameStats.toggle, show);
|
Nc.trigger(Nc.ns.client.view.gameStats.toggle, show);
|
||||||
};
|
|
||||||
|
|
||||||
GameController.prototype.beginRound = function() {
|
|
||||||
this.me.setInBetweenRounds(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameController.prototype.endRound = function() {
|
|
||||||
this.me.setInBetweenRounds(true);
|
|
||||||
this.toggleGameStats(true);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GameController.prototype.destroy = function() {
|
GameController.prototype.destroy = function() {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ define([
|
||||||
"Game/Client/View/Abstract/Layer",
|
"Game/Client/View/Abstract/Layer",
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, Settings, nc, Exception, ColorConverter, Layer) {
|
function (Parent, Settings, Nc, Exception, ColorConverter, Layer) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -50,14 +50,14 @@ function (Parent, Settings, nc, Exception, ColorConverter, Layer) {
|
||||||
if(!state) throw new Exception("action state is undefined");
|
if(!state) throw new Exception("action state is undefined");
|
||||||
|
|
||||||
if(this.animatedMeshes[this.actionState]) {
|
if(this.animatedMeshes[this.actionState]) {
|
||||||
nc.trigger(
|
Nc.trigger(
|
||||||
nc.ns.client.view.mesh.update,
|
Nc.ns.client.view.mesh.update,
|
||||||
this.layerId,
|
this.layerId,
|
||||||
this.animatedMeshesContainer.withArms[this.actionState],
|
this.animatedMeshesContainer.withArms[this.actionState],
|
||||||
{ visible: false }
|
{ visible: false }
|
||||||
);
|
);
|
||||||
nc.trigger(
|
Nc.trigger(
|
||||||
nc.ns.client.view.mesh.update,
|
Nc.ns.client.view.mesh.update,
|
||||||
this.layerId,
|
this.layerId,
|
||||||
this.animatedMeshesContainer.withoutArms[this.actionState],
|
this.animatedMeshesContainer.withoutArms[this.actionState],
|
||||||
{ visible: false }
|
{ visible: false }
|
||||||
|
|
@ -66,8 +66,8 @@ function (Parent, Settings, nc, Exception, ColorConverter, Layer) {
|
||||||
|
|
||||||
Parent.prototype.setActionState.call(this, state);
|
Parent.prototype.setActionState.call(this, state);
|
||||||
|
|
||||||
nc.trigger(
|
Nc.trigger(
|
||||||
nc.ns.client.view.mesh.update,
|
Nc.ns.client.view.mesh.update,
|
||||||
this.layerId,
|
this.layerId,
|
||||||
this.animatedMeshes[this.actionState],
|
this.animatedMeshes[this.actionState],
|
||||||
{
|
{
|
||||||
|
|
@ -82,7 +82,7 @@ function (Parent, Settings, nc, Exception, ColorConverter, Layer) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
var setShirtColor = function (mesh) {
|
var setShirtColor = function (mesh) {
|
||||||
nc.trigger(nc.ns.client.view.mesh.addFilter, self.layerId, mesh, 'colorRangeReplace', {
|
Nc.trigger(Nc.ns.client.view.mesh.addFilter, self.layerId, mesh, 'colorRangeReplace', {
|
||||||
minColor: 0x3b4a31,
|
minColor: 0x3b4a31,
|
||||||
maxColor: 0x657f54,
|
maxColor: 0x657f54,
|
||||||
newColor: self.primaryColor,
|
newColor: self.primaryColor,
|
||||||
|
|
@ -131,12 +131,12 @@ function (Parent, Settings, nc, Exception, ColorConverter, Layer) {
|
||||||
|
|
||||||
var callback = function(mesh) {
|
var callback = function(mesh) {
|
||||||
self.animatedMeshesContainer[arm][key] = mesh;
|
self.animatedMeshesContainer[arm][key] = mesh;
|
||||||
nc.trigger(nc.ns.client.view.mesh.add, self.layerId, mesh);
|
Nc.trigger(Nc.ns.client.view.mesh.add, self.layerId, mesh);
|
||||||
|
|
||||||
setShirtColor(mesh);
|
setShirtColor(mesh);
|
||||||
};
|
};
|
||||||
|
|
||||||
nc.trigger(nc.ns.client.view.animatedMesh.create, this.layerId, texturePaths, callback, {
|
Nc.trigger(Nc.ns.client.view.animatedMesh.create, this.layerId, texturePaths, callback, {
|
||||||
visible: false,
|
visible: false,
|
||||||
pivot: {
|
pivot: {
|
||||||
x: 0,
|
x: 0,
|
||||||
|
|
@ -159,9 +159,9 @@ function (Parent, Settings, nc, Exception, ColorConverter, Layer) {
|
||||||
var texturePath = Settings.GRAPHICS_PATH + "Characters/Chuck/head.png";
|
var texturePath = Settings.GRAPHICS_PATH + "Characters/Chuck/head.png";
|
||||||
var callback = function (mesh) {
|
var callback = function (mesh) {
|
||||||
self.headMesh = mesh;
|
self.headMesh = mesh;
|
||||||
nc.trigger(nc.ns.client.view.mesh.add, self.layerId, mesh);
|
Nc.trigger(Nc.ns.client.view.mesh.add, self.layerId, mesh);
|
||||||
}
|
}
|
||||||
nc.trigger(nc.ns.client.view.mesh.create, this.layerId, texturePath, callback, {
|
Nc.trigger(Nc.ns.client.view.mesh.create, this.layerId, texturePath, callback, {
|
||||||
pivot: {
|
pivot: {
|
||||||
x: 5,
|
x: 5,
|
||||||
y: 12
|
y: 12
|
||||||
|
|
@ -179,10 +179,10 @@ function (Parent, Settings, nc, Exception, ColorConverter, Layer) {
|
||||||
texturePath = Settings.GRAPHICS_PATH + "Characters/Chuck/holdingArm.png";
|
texturePath = Settings.GRAPHICS_PATH + "Characters/Chuck/holdingArm.png";
|
||||||
var callback = function (mesh) {
|
var callback = function (mesh) {
|
||||||
self.holdingArmMesh = mesh;
|
self.holdingArmMesh = mesh;
|
||||||
nc.trigger(nc.ns.client.view.mesh.add, self.layerId, mesh);
|
Nc.trigger(Nc.ns.client.view.mesh.add, self.layerId, mesh);
|
||||||
setShirtColor(mesh);
|
setShirtColor(mesh);
|
||||||
}
|
}
|
||||||
nc.trigger(nc.ns.client.view.mesh.create, this.layerId, texturePath, callback, {
|
Nc.trigger(Nc.ns.client.view.mesh.create, this.layerId, texturePath, callback, {
|
||||||
visible: false,
|
visible: false,
|
||||||
pivot: {
|
pivot: {
|
||||||
//x: 35/2 * 4,
|
//x: 35/2 * 4,
|
||||||
|
|
@ -206,7 +206,7 @@ function (Parent, Settings, nc, Exception, ColorConverter, Layer) {
|
||||||
|
|
||||||
if(oldLookDirection != this.lookDirection) {
|
if(oldLookDirection != this.lookDirection) {
|
||||||
for(var key in this.animatedMeshes) {
|
for(var key in this.animatedMeshes) {
|
||||||
nc.trigger(nc.ns.client.view.mesh.update,
|
Nc.trigger(Nc.ns.client.view.mesh.update,
|
||||||
this.layerId,
|
this.layerId,
|
||||||
this.animatedMeshes[key],
|
this.animatedMeshes[key],
|
||||||
{
|
{
|
||||||
|
|
@ -215,7 +215,7 @@ function (Parent, Settings, nc, Exception, ColorConverter, Layer) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
nc.trigger(nc.ns.client.view.mesh.update,
|
Nc.trigger(Nc.ns.client.view.mesh.update,
|
||||||
this.layerId,
|
this.layerId,
|
||||||
this.holdingArmMesh,
|
this.holdingArmMesh,
|
||||||
{
|
{
|
||||||
|
|
@ -226,7 +226,7 @@ function (Parent, Settings, nc, Exception, ColorConverter, Layer) {
|
||||||
|
|
||||||
var angle = Math.atan2(this.lookAtXY.x, this.lookAtXY.y) / 2 - 0.7855 * this.lookDirection; // 0.7855 = 45°
|
var angle = Math.atan2(this.lookAtXY.x, this.lookAtXY.y) / 2 - 0.7855 * this.lookDirection; // 0.7855 = 45°
|
||||||
|
|
||||||
nc.trigger(nc.ns.client.view.mesh.update,
|
Nc.trigger(Nc.ns.client.view.mesh.update,
|
||||||
this.layerId,
|
this.layerId,
|
||||||
this.headMesh,
|
this.headMesh,
|
||||||
{
|
{
|
||||||
|
|
@ -240,22 +240,22 @@ function (Parent, Settings, nc, Exception, ColorConverter, Layer) {
|
||||||
Parent.prototype.grab.call(this, item);
|
Parent.prototype.grab.call(this, item);
|
||||||
this.animatedMeshes = this.animatedMeshesContainer.withoutArms;
|
this.animatedMeshes = this.animatedMeshesContainer.withoutArms;
|
||||||
this.setActionState(this.actionState, true);
|
this.setActionState(this.actionState, true);
|
||||||
nc.trigger(nc.ns.client.view.mesh.update, this.layerId, this.holdingArmMesh, { visible: true });
|
Nc.trigger(Nc.ns.client.view.mesh.update, this.layerId, this.holdingArmMesh, { visible: true });
|
||||||
};
|
};
|
||||||
|
|
||||||
Doll.prototype.throw = function(item, options) {
|
Doll.prototype.throw = function(item, options) {
|
||||||
Parent.prototype.throw.call(this, item, options);
|
Parent.prototype.throw.call(this, item, options);
|
||||||
this.animatedMeshes = this.animatedMeshesContainer.withArms;
|
this.animatedMeshes = this.animatedMeshesContainer.withArms;
|
||||||
this.setActionState(this.actionState, true);
|
this.setActionState(this.actionState, true);
|
||||||
nc.trigger(nc.ns.client.view.mesh.update, this.layerId, this.holdingArmMesh, { visible: false });
|
Nc.trigger(Nc.ns.client.view.mesh.update, this.layerId, this.holdingArmMesh, { visible: false });
|
||||||
};
|
};
|
||||||
|
|
||||||
Doll.prototype.destroy = function () {
|
Doll.prototype.destroy = function () {
|
||||||
for (var key in this.animatedMeshes) {
|
for (var key in this.animatedMeshes) {
|
||||||
nc.trigger(nc.ns.client.view.mesh.remove, this.layerId, this.animatedMeshes[key]);
|
Nc.trigger(Nc.ns.client.view.mesh.remove, this.layerId, this.animatedMeshes[key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
nc.trigger(nc.ns.client.view.mesh.remove, this.layerId, this.headMesh);
|
Nc.trigger(Nc.ns.client.view.mesh.remove, this.layerId, this.headMesh);
|
||||||
|
|
||||||
Parent.prototype.destroy.call(this);
|
Parent.prototype.destroy.call(this);
|
||||||
}
|
}
|
||||||
|
|
@ -272,7 +272,7 @@ function (Parent, Settings, nc, Exception, ColorConverter, Layer) {
|
||||||
|
|
||||||
var factor = stepLength / 30;
|
var factor = stepLength / 30;
|
||||||
|
|
||||||
nc.trigger(nc.ns.client.view.mesh.update,
|
Nc.trigger(Nc.ns.client.view.mesh.update,
|
||||||
this.layerId,
|
this.layerId,
|
||||||
this.animatedMeshes[this.actionState],
|
this.animatedMeshes[this.actionState],
|
||||||
{
|
{
|
||||||
|
|
@ -283,7 +283,7 @@ function (Parent, Settings, nc, Exception, ColorConverter, Layer) {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
nc.trigger(nc.ns.client.view.mesh.update,
|
Nc.trigger(Nc.ns.client.view.mesh.update,
|
||||||
this.layerId,
|
this.layerId,
|
||||||
this.headMesh,
|
this.headMesh,
|
||||||
{
|
{
|
||||||
|
|
@ -292,7 +292,7 @@ function (Parent, Settings, nc, Exception, ColorConverter, Layer) {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
nc.trigger(nc.ns.client.view.mesh.update,
|
Nc.trigger(Nc.ns.client.view.mesh.update,
|
||||||
this.layerId,
|
this.layerId,
|
||||||
this.holdingArmMesh,
|
this.holdingArmMesh,
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ define([
|
||||||
"Lib/Utilities/NotificationCenter"
|
"Lib/Utilities/NotificationCenter"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, Exception, nc) {
|
function (Parent, Exception, Nc) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,17 +5,13 @@ define([
|
||||||
"Game/Client/View/Abstract/Layer"
|
"Game/Client/View/Abstract/Layer"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, Settings, nc, Layer) {
|
function (Parent, Settings, Nc, Layer) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function Item(physicsEngine, uid, options) {
|
function Item(physicsEngine, uid, options) {
|
||||||
this.layerId = Layer.ID.ITEM;
|
this.layerId = Layer.ID.ITEM;
|
||||||
Parent.call(this, physicsEngine, uid, options);
|
Parent.call(this, physicsEngine, uid, options);
|
||||||
|
|
||||||
this.ncTokens = this.ncTokens.concat([
|
|
||||||
nc.on(nc.ns.client.game.events.render, this.render, this)
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Item.prototype = Object.create(Parent.prototype);
|
Item.prototype = Object.create(Parent.prototype);
|
||||||
|
|
@ -30,10 +26,10 @@ function (Parent, Settings, nc, Layer) {
|
||||||
|
|
||||||
var callback = function(mesh) {
|
var callback = function(mesh) {
|
||||||
self.mesh = mesh;
|
self.mesh = mesh;
|
||||||
nc.trigger(nc.ns.client.view.mesh.add, self.layerId, mesh);
|
Nc.trigger(Nc.ns.client.view.mesh.add, self.layerId, mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
nc.trigger(nc.ns.client.view.mesh.create,
|
Nc.trigger(Nc.ns.client.view.mesh.create,
|
||||||
this.layerId,
|
this.layerId,
|
||||||
texturePath,
|
texturePath,
|
||||||
callback,
|
callback,
|
||||||
|
|
@ -49,13 +45,13 @@ function (Parent, Settings, nc, Layer) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Item.prototype.destroy = function() {
|
Item.prototype.destroy = function() {
|
||||||
nc.trigger(nc.ns.client.view.mesh.remove, this.layerId, this.mesh);
|
Nc.trigger(Nc.ns.client.view.mesh.remove, this.layerId, this.mesh);
|
||||||
Parent.prototype.destroy.call(this);
|
Parent.prototype.destroy.call(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
Item.prototype.render = function() {
|
Item.prototype.render = function() {
|
||||||
|
|
||||||
nc.trigger(nc.ns.client.view.mesh.update,
|
Nc.trigger(Nc.ns.client.view.mesh.update,
|
||||||
this.layerId,
|
this.layerId,
|
||||||
this.mesh,
|
this.mesh,
|
||||||
{
|
{
|
||||||
|
|
@ -72,7 +68,7 @@ function (Parent, Settings, nc, Layer) {
|
||||||
Parent.prototype.flip.call(this, direction);
|
Parent.prototype.flip.call(this, direction);
|
||||||
|
|
||||||
if(oldFlipDirection != direction) {
|
if(oldFlipDirection != direction) {
|
||||||
nc.trigger(nc.ns.client.view.mesh.update,
|
Nc.trigger(Nc.ns.client.view.mesh.update,
|
||||||
this.layerId,
|
this.layerId,
|
||||||
this.mesh,
|
this.mesh,
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ define([
|
||||||
"Game/Client/View/Abstract/Layer"
|
"Game/Client/View/Abstract/Layer"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, CoreItem, Settings, nc, Layer) {
|
function (Parent, CoreItem, Settings, Nc, Layer) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -40,10 +40,10 @@ function (Parent, CoreItem, Settings, nc, Layer) {
|
||||||
self.limbMeshes[name] = mesh;
|
self.limbMeshes[name] = mesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
nc.trigger(nc.ns.client.view.mesh.add, self.layerId, mesh);
|
Nc.trigger(Nc.ns.client.view.mesh.add, self.layerId, mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
nc.trigger(nc.ns.client.view.mesh.create,
|
Nc.trigger(Nc.ns.client.view.mesh.create,
|
||||||
this.layerId,
|
this.layerId,
|
||||||
texturePath + name + ".png",
|
texturePath + name + ".png",
|
||||||
callback,
|
callback,
|
||||||
|
|
@ -64,7 +64,7 @@ function (Parent, CoreItem, Settings, nc, Layer) {
|
||||||
if(this.limbs) {
|
if(this.limbs) {
|
||||||
for(var name in this.limbMeshes) {
|
for(var name in this.limbMeshes) {
|
||||||
if(this.limbs[name]) {
|
if(this.limbs[name]) {
|
||||||
nc.trigger(nc.ns.client.view.mesh.update,
|
Nc.trigger(Nc.ns.client.view.mesh.update,
|
||||||
this.layerId,
|
this.layerId,
|
||||||
this.limbMeshes[name],
|
this.limbMeshes[name],
|
||||||
{
|
{
|
||||||
|
|
@ -85,7 +85,7 @@ function (Parent, CoreItem, Settings, nc, Layer) {
|
||||||
CoreItem.prototype.flip.call(this, direction);
|
CoreItem.prototype.flip.call(this, direction);
|
||||||
|
|
||||||
if(oldFlipDirection != direction) {
|
if(oldFlipDirection != direction) {
|
||||||
nc.trigger(nc.ns.client.view.mesh.update,
|
Nc.trigger(Nc.ns.client.view.mesh.update,
|
||||||
this.layerId,
|
this.layerId,
|
||||||
this.mesh,
|
this.mesh,
|
||||||
{
|
{
|
||||||
|
|
@ -94,7 +94,7 @@ function (Parent, CoreItem, Settings, nc, Layer) {
|
||||||
);
|
);
|
||||||
|
|
||||||
for (var name in this.limbMeshes) {
|
for (var name in this.limbMeshes) {
|
||||||
nc.trigger(nc.ns.client.view.mesh.update,
|
Nc.trigger(Nc.ns.client.view.mesh.update,
|
||||||
this.layerId,
|
this.layerId,
|
||||||
this.limbMeshes[name],
|
this.limbMeshes[name],
|
||||||
{
|
{
|
||||||
|
|
@ -108,7 +108,7 @@ function (Parent, CoreItem, Settings, nc, Layer) {
|
||||||
RagDoll.prototype.destroy = function() {
|
RagDoll.prototype.destroy = function() {
|
||||||
|
|
||||||
for (var name in this.limbMeshes) {
|
for (var name in this.limbMeshes) {
|
||||||
nc.trigger(nc.ns.client.view.mesh.remove, this.layerId, this.limbMeshes[name]);
|
Nc.trigger(Nc.ns.client.view.mesh.remove, this.layerId, this.limbMeshes[name]);
|
||||||
};
|
};
|
||||||
|
|
||||||
Parent.prototype.destroy.call(this);
|
Parent.prototype.destroy.call(this);
|
||||||
|
|
|
||||||
28
app/Game/Client/GameObjects/Items/Rube.js
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
define([
|
||||||
|
"Game/Core/GameObjects/Items/Rube"
|
||||||
|
],
|
||||||
|
|
||||||
|
function (Parent) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
function Rube(physicsEngine, uid, options) {
|
||||||
|
Parent.call(this, physicsEngine, uid, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
Rube.prototype = Object.create(Parent.prototype);
|
||||||
|
|
||||||
|
Rube.prototype.createMesh = function() {
|
||||||
|
};
|
||||||
|
|
||||||
|
Rube.prototype.destroy = function() {
|
||||||
|
};
|
||||||
|
|
||||||
|
Rube.prototype.render = function() {
|
||||||
|
}
|
||||||
|
|
||||||
|
Rube.prototype.flip = function(direction) {
|
||||||
|
};
|
||||||
|
|
||||||
|
return Rube;
|
||||||
|
});
|
||||||
|
|
@ -1,254 +0,0 @@
|
||||||
define([
|
|
||||||
"Game/Core/GameObjects/Items/RubeDoll",
|
|
||||||
"Game/Client/View/Abstract/Layer",
|
|
||||||
"Game/Config/Settings",
|
|
||||||
"Lib/Utilities/NotificationCenter",
|
|
||||||
],
|
|
||||||
|
|
||||||
function (Parent, Layer, Settings, nc) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function RubeDoll(physicsEngine, uid, options) {
|
|
||||||
|
|
||||||
this.primaryColor = options.primaryColor;
|
|
||||||
|
|
||||||
var limbOptions = {};
|
|
||||||
|
|
||||||
limbOptions.chest = {
|
|
||||||
width: 6,
|
|
||||||
height: 18,
|
|
||||||
x: 0,
|
|
||||||
y: 0
|
|
||||||
};
|
|
||||||
|
|
||||||
limbOptions.head = {
|
|
||||||
width: 10,
|
|
||||||
height: 12,
|
|
||||||
x: 0,
|
|
||||||
y: - limbOptions.chest.height / 2 - 7
|
|
||||||
};
|
|
||||||
|
|
||||||
limbOptions.upperLeftLeg = {
|
|
||||||
width: 5,
|
|
||||||
height: 8,
|
|
||||||
x: -2,
|
|
||||||
y: limbOptions.chest.height / 2
|
|
||||||
};
|
|
||||||
|
|
||||||
limbOptions.upperRightLeg = {
|
|
||||||
width: 5,
|
|
||||||
height: 8,
|
|
||||||
x: 2,
|
|
||||||
y: limbOptions.chest.height / 2
|
|
||||||
};
|
|
||||||
|
|
||||||
limbOptions.lowerLeftLeg = {
|
|
||||||
width: 5,
|
|
||||||
height: 4,
|
|
||||||
x: -2,
|
|
||||||
y: limbOptions.chest.height / 2 + limbOptions.upperLeftLeg.height
|
|
||||||
};
|
|
||||||
|
|
||||||
limbOptions.lowerRightLeg = {
|
|
||||||
width: 5,
|
|
||||||
height: 4,
|
|
||||||
x: 2,
|
|
||||||
y: limbOptions.chest.height / 2 + limbOptions.upperRightLeg.height
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
limbOptions.upperLeftArm = {
|
|
||||||
width: 4,
|
|
||||||
height: 8,
|
|
||||||
x: -2,
|
|
||||||
y: -limbOptions.chest.height / 2
|
|
||||||
};
|
|
||||||
|
|
||||||
limbOptions.upperRightArm = {
|
|
||||||
width: 4,
|
|
||||||
height: 8,
|
|
||||||
x: 2,
|
|
||||||
y: -limbOptions.chest.height / 2
|
|
||||||
};
|
|
||||||
|
|
||||||
limbOptions.lowerLeftArm = {
|
|
||||||
width: 4,
|
|
||||||
height: 5,
|
|
||||||
x: -2,
|
|
||||||
y: -limbOptions.chest.height / 2 + limbOptions.upperLeftArm.height
|
|
||||||
};
|
|
||||||
|
|
||||||
limbOptions.lowerRightArm = {
|
|
||||||
width: 4,
|
|
||||||
height: 5,
|
|
||||||
x: 2,
|
|
||||||
y: -limbOptions.chest.height / 2 + limbOptions.upperRightArm.height
|
|
||||||
};
|
|
||||||
|
|
||||||
this.limbOptions = limbOptions;
|
|
||||||
|
|
||||||
this.layerId = Layer.ID.SPAWN;
|
|
||||||
this.limbMeshes = {};
|
|
||||||
this.baseMeshName = "chest";
|
|
||||||
this.characterName = "Chuck";
|
|
||||||
this.lastFlipDirection = -options.direction || 1;
|
|
||||||
|
|
||||||
Parent.call(this, physicsEngine, uid, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
RubeDoll.prototype = Object.create(Parent.prototype);
|
|
||||||
|
|
||||||
RubeDoll.prototype.createMesh = function() {
|
|
||||||
|
|
||||||
this.createLimbMesh("lowerRightLeg");
|
|
||||||
this.createLimbMesh("upperRightLeg");
|
|
||||||
this.createLimbMesh("lowerRightArm");
|
|
||||||
this.createLimbMesh("upperRightArm");
|
|
||||||
|
|
||||||
this.createLimbMesh("chest");
|
|
||||||
this.createLimbMesh("head");
|
|
||||||
|
|
||||||
this.createLimbMesh("lowerLeftLeg");
|
|
||||||
this.createLimbMesh("upperLeftLeg");
|
|
||||||
this.createLimbMesh("lowerLeftArm");
|
|
||||||
this.createLimbMesh("upperLeftArm");
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
RubeDoll.prototype.createLimbMesh = function(name) {
|
|
||||||
var self = this;
|
|
||||||
var texturePath = Settings.GRAPHICS_PATH
|
|
||||||
+ Settings.GRAPHICS_SUBPATH_CHARACTERS + ""
|
|
||||||
+ this.characterName + '/';
|
|
||||||
|
|
||||||
|
|
||||||
var callback = function(mesh) {
|
|
||||||
if(name == self.baseMeshName) {
|
|
||||||
self.mesh = mesh;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.limbMeshes[name] = mesh;
|
|
||||||
|
|
||||||
nc.trigger(nc.ns.client.view.mesh.add, self.layerId, mesh);
|
|
||||||
|
|
||||||
// setting shirt color
|
|
||||||
nc.trigger(nc.ns.client.view.mesh.addFilter, self.layerId, mesh, "colorRangeReplace", {
|
|
||||||
minColor: 0x3b4a31,
|
|
||||||
maxColor: 0x6d855d,
|
|
||||||
newColor: self.primaryColor,
|
|
||||||
brightnessOffset: 0.56
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
nc.trigger(nc.ns.client.view.mesh.create,
|
|
||||||
this.layerId,
|
|
||||||
texturePath + name + ".png",
|
|
||||||
callback,
|
|
||||||
{
|
|
||||||
width: this.limbOptions[name].width,
|
|
||||||
height: this.limbOptions[name].height,
|
|
||||||
pivot: {
|
|
||||||
x: this.limbOptions[name].width / 2,
|
|
||||||
y: this.limbOptions[name].height / 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
RubeDoll.prototype.destroy = function() {
|
|
||||||
|
|
||||||
for (var name in this.limbMeshes) {
|
|
||||||
nc.trigger(nc.ns.client.view.mesh.remove, this.layerId, this.limbMeshes[name]);
|
|
||||||
};
|
|
||||||
|
|
||||||
Parent.prototype.destroy.call(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
RubeDoll.prototype.render = function() {
|
|
||||||
//Parent.prototype.render.call(this);
|
|
||||||
|
|
||||||
nc.trigger(nc.ns.client.view.mesh.update,
|
|
||||||
this.layerId,
|
|
||||||
this.mesh,
|
|
||||||
{
|
|
||||||
x: this.body.GetPosition().x * Settings.RATIO,
|
|
||||||
y: this.body.GetPosition().y * Settings.RATIO,
|
|
||||||
rotation: this.body.GetAngle()
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
if(this.limbs) {
|
|
||||||
for(var name in this.limbMeshes) {
|
|
||||||
if(this.limbs[name]) {
|
|
||||||
nc.trigger(nc.ns.client.view.mesh.update,
|
|
||||||
this.layerId,
|
|
||||||
this.limbMeshes[name],
|
|
||||||
{
|
|
||||||
x: this.limbs[name].GetPosition().x * Settings.RATIO,
|
|
||||||
y: this.limbs[name].GetPosition().y * Settings.RATIO,
|
|
||||||
rotation: this.limbs[name].GetAngle()
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
RubeDoll.prototype.flip = function(direction) {
|
|
||||||
|
|
||||||
Parent.prototype.flip.call(this, direction);
|
|
||||||
|
|
||||||
// flipping depth of right body side arm/leg images with left
|
|
||||||
if (this.lastFlipDirection != direction) { // FIXME : this is a bit broken.
|
|
||||||
|
|
||||||
this.lastFlipDirection = direction;
|
|
||||||
|
|
||||||
nc.trigger(nc.ns.client.view.mesh.swapMeshIndexes,
|
|
||||||
this.layerId,
|
|
||||||
this.limbMeshes["lowerRightLeg"],
|
|
||||||
this.limbMeshes["lowerLeftLeg"]
|
|
||||||
);
|
|
||||||
nc.trigger(nc.ns.client.view.mesh.swapMeshIndexes,
|
|
||||||
this.layerId,
|
|
||||||
this.limbMeshes["upperRightLeg"],
|
|
||||||
this.limbMeshes["upperLeftLeg"]
|
|
||||||
);
|
|
||||||
nc.trigger(nc.ns.client.view.mesh.swapMeshIndexes,
|
|
||||||
this.layerId,
|
|
||||||
this.limbMeshes["lowerRightArm"],
|
|
||||||
this.limbMeshes["lowerLeftArm"]
|
|
||||||
);
|
|
||||||
nc.trigger(nc.ns.client.view.mesh.swapMeshIndexes,
|
|
||||||
this.layerId,
|
|
||||||
this.limbMeshes["upperRightArm"],
|
|
||||||
this.limbMeshes["upperLeftArm"]
|
|
||||||
);
|
|
||||||
|
|
||||||
// swap short images
|
|
||||||
nc.trigger(nc.ns.client.view.mesh.swapMeshes,
|
|
||||||
this.layerId,
|
|
||||||
this.limbMeshes["upperRightLeg"],
|
|
||||||
this.limbMeshes["upperLeftLeg"]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// x flipping has to happen after (see swapMeshes)
|
|
||||||
if(this.limbs) {
|
|
||||||
for(var name in this.limbMeshes) {
|
|
||||||
if(this.limbs[name]) {
|
|
||||||
nc.trigger(nc.ns.client.view.mesh.update,
|
|
||||||
this.layerId,
|
|
||||||
this.limbMeshes[name],
|
|
||||||
{
|
|
||||||
xScale: direction,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return RubeDoll;
|
|
||||||
});
|
|
||||||
|
|
@ -5,7 +5,7 @@ define([
|
||||||
"Game/Client/View/Abstract/Layer"
|
"Game/Client/View/Abstract/Layer"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, Settings, nc, Layer) {
|
function (Parent, Settings, Nc, Layer) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -31,10 +31,10 @@ function (Parent, Settings, nc, Layer) {
|
||||||
|
|
||||||
var callback = function(mesh) {
|
var callback = function(mesh) {
|
||||||
self.mesh = mesh;
|
self.mesh = mesh;
|
||||||
nc.trigger(nc.ns.client.view.mesh.add, self.layerId, mesh);
|
Nc.trigger(Nc.ns.client.view.mesh.add, self.layerId, mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
nc.trigger(nc.ns.client.view.mesh.create,
|
Nc.trigger(Nc.ns.client.view.mesh.create,
|
||||||
this.layerId,
|
this.layerId,
|
||||||
texturePath,
|
texturePath,
|
||||||
callback,
|
callback,
|
||||||
|
|
@ -50,13 +50,13 @@ function (Parent, Settings, nc, Layer) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Tile.prototype.destroy = function() {
|
Tile.prototype.destroy = function() {
|
||||||
nc.trigger(nc.ns.client.view.mesh.remove, this.layerId, this.mesh);
|
Nc.trigger(Nc.ns.client.view.mesh.remove, this.layerId, this.mesh);
|
||||||
Parent.prototype.destroy.call(this);
|
Parent.prototype.destroy.call(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
Tile.prototype.render = function() {
|
Tile.prototype.render = function() {
|
||||||
|
|
||||||
nc.trigger(nc.ns.client.view.mesh.update,
|
Nc.trigger(Nc.ns.client.view.mesh.update,
|
||||||
this.layerId,
|
this.layerId,
|
||||||
this.mesh,
|
this.mesh,
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ define([
|
||||||
"Game/Client/View/Abstract/Layer"
|
"Game/Client/View/Abstract/Layer"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, Settings, nc, PIXI, AbstractLayer) {
|
function (Parent, Settings, Nc, PIXI, AbstractLayer) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -46,7 +46,7 @@ function (Parent, Settings, nc, PIXI, AbstractLayer) {
|
||||||
loader.onComplete = function() { callback(levelData); };
|
loader.onComplete = function() { callback(levelData); };
|
||||||
loader.onProgress = function() {
|
loader.onProgress = function() {
|
||||||
var progress = parseInt(100 / numPaths * ++count, 10) + 1;
|
var progress = parseInt(100 / numPaths * ++count, 10) + 1;
|
||||||
nc.trigger(nc.ns.client.view.preloadBar.update, progress);
|
Nc.trigger(Nc.ns.client.view.preloadBar.update, progress);
|
||||||
}
|
}
|
||||||
loader.load();
|
loader.load();
|
||||||
};
|
};
|
||||||
|
|
@ -116,8 +116,8 @@ function (Parent, Settings, nc, PIXI, AbstractLayer) {
|
||||||
if (options.properties && options.properties.parallaxSpeed) {
|
if (options.properties && options.properties.parallaxSpeed) {
|
||||||
parallaxSpeed = parseFloat(options.properties.parallaxSpeed);
|
parallaxSpeed = parseFloat(options.properties.parallaxSpeed);
|
||||||
}
|
}
|
||||||
nc.trigger(
|
Nc.trigger(
|
||||||
nc.ns.client.view.layer.createAndInsert,
|
Nc.ns.client.view.layer.createAndInsert,
|
||||||
options.layerId,
|
options.layerId,
|
||||||
{
|
{
|
||||||
parallaxSpeed: parallaxSpeed,
|
parallaxSpeed: parallaxSpeed,
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,13 @@ define([
|
||||||
"Lib/Utilities/NotificationCenter",
|
"Lib/Utilities/NotificationCenter",
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, Settings, nc) {
|
function (Parent, Settings, Nc) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function TiledLevel(uid, engine) {
|
function TiledLevel(uid, engine, gameObjects) {
|
||||||
this.layerId = "background";
|
this.layerId = "background";
|
||||||
Parent.call(this, uid, engine);
|
Parent.call(this, uid, engine, gameObjects);
|
||||||
}
|
}
|
||||||
|
|
||||||
TiledLevel.prototype = Object.create(Parent.prototype);
|
TiledLevel.prototype = Object.create(Parent.prototype);
|
||||||
|
|
@ -22,7 +22,7 @@ function (Parent, Settings, nc) {
|
||||||
height: tilesLayerData.height * Settings.TILE_SIZE
|
height: tilesLayerData.height * Settings.TILE_SIZE
|
||||||
};
|
};
|
||||||
|
|
||||||
nc.trigger(nc.ns.client.view.layer.levelSizeUpdate, this.levelSize);
|
Nc.trigger(Nc.ns.client.view.layer.levelSizeUpdate, this.levelSize);
|
||||||
|
|
||||||
Parent.prototype.setup.call(this, levelData);
|
Parent.prototype.setup.call(this, levelData);
|
||||||
};
|
};
|
||||||
|
|
@ -78,8 +78,8 @@ function (Parent, Settings, nc) {
|
||||||
var texturePath = Settings.MAPS_PATH + options.image;
|
var texturePath = Settings.MAPS_PATH + options.image;
|
||||||
|
|
||||||
var callback = function(mesh) {
|
var callback = function(mesh) {
|
||||||
nc.trigger(nc.ns.client.view.mesh.add, options.layerId, mesh);
|
Nc.trigger(Nc.ns.client.view.mesh.add, options.layerId, mesh);
|
||||||
nc.trigger(nc.ns.client.view.mesh.update, options.layerId, mesh, {
|
Nc.trigger(Nc.ns.client.view.mesh.update, options.layerId, mesh, {
|
||||||
x: 0,//self.levelData.width * Settings.TILE_SIZE / 2,
|
x: 0,//self.levelData.width * Settings.TILE_SIZE / 2,
|
||||||
y: 0,//self.levelData.height * Settings.TILE_SIZE / 2,
|
y: 0,//self.levelData.height * Settings.TILE_SIZE / 2,
|
||||||
pivot: {
|
pivot: {
|
||||||
|
|
@ -91,7 +91,7 @@ function (Parent, Settings, nc) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
nc.trigger(nc.ns.client.view.mesh.create,
|
Nc.trigger(Nc.ns.client.view.mesh.create,
|
||||||
options.layerId,
|
options.layerId,
|
||||||
texturePath,
|
texturePath,
|
||||||
callback,
|
callback,
|
||||||
|
|
@ -123,10 +123,10 @@ function (Parent, Settings, nc) {
|
||||||
var tileType = parts[parts.length - 1].split(".")[0].split("")
|
var tileType = parts[parts.length - 1].split(".")[0].split("")
|
||||||
|
|
||||||
var callback = function(mesh) {
|
var callback = function(mesh) {
|
||||||
nc.trigger(nc.ns.client.view.mesh.add, options.layerId, mesh);
|
Nc.trigger(Nc.ns.client.view.mesh.add, options.layerId, mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
nc.trigger(nc.ns.client.view.mesh.create,
|
Nc.trigger(Nc.ns.client.view.mesh.create,
|
||||||
options.layerId,
|
options.layerId,
|
||||||
Settings.MAPS_PATH + imagePath,
|
Settings.MAPS_PATH + imagePath,
|
||||||
callback,
|
callback,
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,10 @@ define([
|
||||||
"Game/Client/Player",
|
"Game/Client/Player",
|
||||||
"Game/Config/Settings",
|
"Game/Config/Settings",
|
||||||
"Lib/Utilities/NotificationCenter",
|
"Lib/Utilities/NotificationCenter",
|
||||||
"Lib/Utilities/Assert",
|
"Lib/Utilities/Assert"
|
||||||
"Game/Client/Control/PlayerController",
|
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, Settings, nc, Assert, PlayerController) {
|
function (Parent, Settings, Nc, Assert) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -28,7 +27,6 @@ function (Parent, Settings, nc, Assert, PlayerController) {
|
||||||
|
|
||||||
this.arrowMesh = null;
|
this.arrowMesh = null;
|
||||||
this.createAndAddArrow();
|
this.createAndAddArrow();
|
||||||
this.playerController = new PlayerController(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Me.prototype = Object.create(Parent.prototype);
|
Me.prototype = Object.create(Parent.prototype);
|
||||||
|
|
@ -53,8 +51,7 @@ function (Parent, Settings, nc, Assert, PlayerController) {
|
||||||
this.lastServerPositionState = update;
|
this.lastServerPositionState = update;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Checks if client should send out its position to server
|
Me.prototype.isPositionStateUpdateNeeded = function() {
|
||||||
Me.prototype.isPositionStateOverrideNeeded = function() {
|
|
||||||
|
|
||||||
if(!this.doll) {
|
if(!this.doll) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -76,7 +73,7 @@ function (Parent, Settings, nc, Assert, PlayerController) {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
Me.prototype.getPositionStateOverride = function() {
|
Me.prototype.getPositionStateUpdate = function() {
|
||||||
return {
|
return {
|
||||||
p: this.doll.body.GetPosition().Copy(),
|
p: this.doll.body.GetPosition().Copy(),
|
||||||
lv: this.doll.body.GetLinearVelocity().Copy()
|
lv: this.doll.body.GetLinearVelocity().Copy()
|
||||||
|
|
@ -108,7 +105,7 @@ function (Parent, Settings, nc, Assert, PlayerController) {
|
||||||
var callback = function(arrowMesh) {
|
var callback = function(arrowMesh) {
|
||||||
self.arrowMesh = arrowMesh;
|
self.arrowMesh = arrowMesh;
|
||||||
};
|
};
|
||||||
nc.trigger(nc.ns.client.view.playerArrow.createAndAdd, callback, options);
|
Nc.trigger(Nc.ns.client.view.playerArrow.createAndAdd, callback, options);
|
||||||
};
|
};
|
||||||
|
|
||||||
Me.prototype.render = function() {
|
Me.prototype.render = function() {
|
||||||
|
|
@ -120,7 +117,7 @@ function (Parent, Settings, nc, Assert, PlayerController) {
|
||||||
x: position.x * Settings.RATIO,
|
x: position.x * Settings.RATIO,
|
||||||
y: position.y * Settings.RATIO,
|
y: position.y * Settings.RATIO,
|
||||||
};
|
};
|
||||||
nc.trigger(nc.ns.client.view.playerArrow.update, this.arrowMesh, options);
|
Nc.trigger(Nc.ns.client.view.playerArrow.update, this.arrowMesh, options);
|
||||||
};
|
};
|
||||||
|
|
||||||
return Me;
|
return Me;
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ define([
|
||||||
"Game/Client/View/DomController"
|
"Game/Client/View/DomController"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (ProtocolHelper, GameController, User, nc, Settings, domController) {
|
function (ProtocolHelper, GameController, User, Nc, Settings, DomController) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -25,32 +25,20 @@ function (ProtocolHelper, GameController, User, nc, Settings, domController) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.socketLink.on('message', function (message) {
|
this.socketLink.on('message', function (message) {
|
||||||
var m = JSON.parse(message)
|
var m = JSON.parse(message)
|
||||||
|
|
||||||
if(Settings.NETWORK_LOG_INCOMING) {
|
if(Settings.NETWORK_LOG_INCOMING) {
|
||||||
var shouldBeFiltered = false;
|
|
||||||
var keyword;
|
|
||||||
|
|
||||||
for (var i = 0; i < Settings.NETWORK_LOG_FILTER.length; i++) {
|
if (message.indexOf('worldUpdate') == -1 && message.indexOf('pong') == -1) {
|
||||||
keyword = Settings.NETWORK_LOG_FILTER[i];
|
|
||||||
if(message.search(keyword) != -1) {
|
|
||||||
shouldBeFiltered = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if(!shouldBeFiltered) {
|
|
||||||
console.log('INCOMING', message);
|
console.log('INCOMING', message);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ProtocolHelper.applyCommand(message, self);
|
ProtocolHelper.applyCommand(message, self);
|
||||||
});
|
});
|
||||||
|
|
||||||
nc.on(nc.ns.client.to.server.gameCommand.send, this.sendGameCommand, this);
|
Nc.on(Nc.ns.client.to.server.gameCommand.send, this.sendGameCommand, this);
|
||||||
nc.on(nc.ns.core.game.events.level.loaded, this.onLevelLoaded, this);
|
Nc.on(Nc.ns.core.game.events.level.loaded, this.onLevelLoaded, this);
|
||||||
|
|
||||||
domController.setNick(nickname);
|
DomController.setNick(nickname);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Socket callbacks
|
// Socket callbacks
|
||||||
|
|
@ -63,7 +51,7 @@ function (ProtocolHelper, GameController, User, nc, Settings, domController) {
|
||||||
nickname: this.nickname
|
nickname: this.nickname
|
||||||
}
|
}
|
||||||
this.sendCommand('join', options);
|
this.sendCommand('join', options);
|
||||||
domController.setConnected(true);
|
DomController.setConnected(true);
|
||||||
} else {
|
} else {
|
||||||
alert("Error: no channel name");
|
alert("Error: no channel name");
|
||||||
window.location.href = "/";
|
window.location.href = "/";
|
||||||
|
|
@ -74,7 +62,7 @@ function (ProtocolHelper, GameController, User, nc, Settings, domController) {
|
||||||
//if(this.gameController) this.gameController.destruct();
|
//if(this.gameController) this.gameController.destruct();
|
||||||
//this.gameController = null;
|
//this.gameController = null;
|
||||||
console.log('disconnected. game destroyed. no auto-reconnect');
|
console.log('disconnected. game destroyed. no auto-reconnect');
|
||||||
domController.setConnected(false);
|
DomController.setConnected(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Networker.prototype.onJoinSuccess = function (options) {
|
Networker.prototype.onJoinSuccess = function (options) {
|
||||||
|
|
@ -129,6 +117,8 @@ function (ProtocolHelper, GameController, User, nc, Settings, domController) {
|
||||||
this.socketLink.send(message);
|
this.socketLink.send(message);
|
||||||
|
|
||||||
if(Settings.NETWORK_LOG_OUTGOING) {
|
if(Settings.NETWORK_LOG_OUTGOING) {
|
||||||
|
if(Settings.NETWORK_LOG_FILTER.length > 0) {
|
||||||
|
|
||||||
var shouldBeFiltered = false;
|
var shouldBeFiltered = false;
|
||||||
var keyword;
|
var keyword;
|
||||||
|
|
||||||
|
|
@ -143,6 +133,9 @@ function (ProtocolHelper, GameController, User, nc, Settings, domController) {
|
||||||
if(!shouldBeFiltered) {
|
if(!shouldBeFiltered) {
|
||||||
console.log('OUTGOING', message);
|
console.log('OUTGOING', message);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
console.log('OUTGOING', message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -183,7 +176,7 @@ function (ProtocolHelper, GameController, User, nc, Settings, domController) {
|
||||||
|
|
||||||
Networker.prototype.onPong = function(timestamp) {
|
Networker.prototype.onPong = function(timestamp) {
|
||||||
var ping = (Date.now() - parseInt(timestamp, 10));
|
var ping = (Date.now() - parseInt(timestamp, 10));
|
||||||
domController.setPing(ping);
|
DomController.setPing(ping);
|
||||||
setTimeout(this.ping.bind(this), 1000);
|
setTimeout(this.ping.bind(this), 1000);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -191,6 +184,7 @@ function (ProtocolHelper, GameController, User, nc, Settings, domController) {
|
||||||
|
|
||||||
if(this.gameController) {
|
if(this.gameController) {
|
||||||
this.gameController.destroy();
|
this.gameController.destroy();
|
||||||
|
delete this.gameController;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.gameController = new GameController(options);
|
this.gameController = new GameController(options);
|
||||||
|
|
@ -202,12 +196,10 @@ function (ProtocolHelper, GameController, User, nc, Settings, domController) {
|
||||||
this.gameController.createPlayer(this.users[userId]);
|
this.gameController.createPlayer(this.users[userId]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.gameController.beginRound();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Networker.prototype.onEndRound = function() {
|
Networker.prototype.onEndRound = function() {
|
||||||
this.gameController.endRound();
|
this.gameController.toggleGameStats(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
return Networker;
|
return Networker;
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ define([
|
||||||
"Game/Client/View/Pixi/Layers/Debug"
|
"Game/Client/View/Pixi/Layers/Debug"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, Settings, domController, Box2D, nc, DebugDraw, debugLayer) {
|
function (Parent, Settings, DomController, Box2D, Nc, DebugDraw, debugLayer) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -17,7 +17,7 @@ function (Parent, Settings, domController, Box2D, nc, DebugDraw, debugLayer) {
|
||||||
|
|
||||||
this.debugMode = false;
|
this.debugMode = false;
|
||||||
|
|
||||||
nc.on(nc.ns.client.view.debugMode.toggle, this.onToggleDebugMode, this);
|
Nc.on(Nc.ns.client.view.debugMode.toggle, this.onToggleDebugMode, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Engine.prototype = Object.create(Parent.prototype);
|
Engine.prototype = Object.create(Parent.prototype);
|
||||||
|
|
|
||||||
|
|
@ -4,21 +4,17 @@ define([
|
||||||
"Game/Config/Settings"
|
"Game/Config/Settings"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, nc, Settings) {
|
function (Parent, Nc, Settings) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function Player(id, physicsEngine, user, isMe) {
|
function Player(id, physicsEngine, user) {
|
||||||
Parent.call(this, id, physicsEngine, user);
|
Parent.call(this, id, physicsEngine, user);
|
||||||
|
|
||||||
this.healthBarView = null;
|
this.healthBarView = null;
|
||||||
this.healthBarViewVisibleTimeout = null;
|
this.healthBarViewVisibleTimeout = null;
|
||||||
this.healthBarViewVisible = false;
|
this.healthBarViewVisible = false;
|
||||||
this.initHealthBar();
|
this.initHealthBar();
|
||||||
|
|
||||||
this.ncTokens = (this.ncTokens || []).concat([
|
|
||||||
nc.on(nc.ns.client.game.events.render, this.render, this)
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Player.prototype = Object.create(Parent.prototype);
|
Player.prototype = Object.create(Parent.prototype);
|
||||||
|
|
@ -47,7 +43,7 @@ function (Parent, nc, Settings) {
|
||||||
var callback = function(healthBarView) {
|
var callback = function(healthBarView) {
|
||||||
self.healthBarView = healthBarView;
|
self.healthBarView = healthBarView;
|
||||||
}
|
}
|
||||||
nc.trigger(nc.ns.client.view.healthBar.createAndAdd, callback, options);
|
Nc.trigger(Nc.ns.client.view.healthBar.createAndAdd, callback, options);
|
||||||
};
|
};
|
||||||
|
|
||||||
Player.prototype.onHealthChange = function() {
|
Player.prototype.onHealthChange = function() {
|
||||||
|
|
@ -75,18 +71,22 @@ function (Parent, nc, Settings) {
|
||||||
healthFactor: this.stats.health / 100,
|
healthFactor: this.stats.health / 100,
|
||||||
visible: this.healthBarViewVisible
|
visible: this.healthBarViewVisible
|
||||||
};
|
};
|
||||||
nc.trigger(nc.ns.client.view.healthBar.update, this.healthBarView, options);
|
Nc.trigger(Nc.ns.client.view.healthBar.update, this.healthBarView, options);
|
||||||
|
|
||||||
this.healthBarViewVisibleTimeout = setTimeout(function() {
|
this.healthBarViewVisibleTimeout = setTimeout(function() {
|
||||||
self.healthBarViewVisible = false;
|
self.healthBarViewVisible = false;
|
||||||
nc.trigger(nc.ns.client.view.healthBar.update, self.healthBarView, {visible: self.healthBarViewVisible});
|
Nc.trigger(Nc.ns.client.view.healthBar.update, self.healthBarView, {visible: self.healthBarViewVisible});
|
||||||
}, Settings.HEALTH_DISPLAY_TIME * 1000);
|
}, Settings.HEALTH_DISPLAY_TIME * 1000);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
nc.trigger(nc.ns.client.view.healthBar.update, this.healthBarView, {visible: this.healthBarViewVisible});
|
Nc.trigger(Nc.ns.client.view.healthBar.update, this.healthBarView, {visible: this.healthBarViewVisible});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Player.prototype.getNickname = function() {
|
||||||
|
return this.user.options.nickname;
|
||||||
|
};
|
||||||
|
|
||||||
Player.prototype.render = function() {
|
Player.prototype.render = function() {
|
||||||
|
|
||||||
if(this.doll) {
|
if(this.doll) {
|
||||||
|
|
@ -100,7 +100,7 @@ function (Parent, nc, Settings) {
|
||||||
x: position.x * Settings.RATIO,
|
x: position.x * Settings.RATIO,
|
||||||
y: position.y * Settings.RATIO,
|
y: position.y * Settings.RATIO,
|
||||||
}
|
}
|
||||||
nc.trigger(nc.ns.client.view.healthBar.update, this.healthBarView, options);
|
Nc.trigger(Nc.ns.client.view.healthBar.update, this.healthBarView, options);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -110,8 +110,7 @@ function (Parent, nc, Settings) {
|
||||||
|
|
||||||
Player.prototype.destroy = function() {
|
Player.prototype.destroy = function() {
|
||||||
clearTimeout(this.healthBarViewVisibleTimeout);
|
clearTimeout(this.healthBarViewVisibleTimeout);
|
||||||
nc.trigger(nc.ns.client.view.healthBar.remove, this.healthBarView);
|
Nc.trigger(Nc.ns.client.view.healthBar.remove, this.healthBarView);
|
||||||
nc.off(this.ncTokens);
|
|
||||||
Parent.prototype.destroy.call(this);
|
Parent.prototype.destroy.call(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,12 @@ define([
|
||||||
"Lib/Utilities/NotificationCenter"
|
"Lib/Utilities/NotificationCenter"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (qs, nc) {
|
function (Qs, Nc) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function PointerLockManager() {
|
function PointerLockManager() {
|
||||||
this.canvas = qs.$("#canvas");
|
this.canvas = Qs.$("#canvas");
|
||||||
|
|
||||||
this.listeners = [];
|
this.listeners = [];
|
||||||
|
|
||||||
|
|
@ -21,7 +21,7 @@ function (qs, nc) {
|
||||||
document.addEventListener('webkitpointerlockchange', this.update.bind(this), false);
|
document.addEventListener('webkitpointerlockchange', this.update.bind(this), false);
|
||||||
|
|
||||||
this.ncTokens = [
|
this.ncTokens = [
|
||||||
nc.on(nc.ns.client.pointerLock.request, this.request, this)
|
Nc.on(Nc.ns.client.pointerLock.request, this.request, this)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -40,7 +40,7 @@ function (qs, nc) {
|
||||||
// called by the browser event and others
|
// called by the browser event and others
|
||||||
PointerLockManager.prototype.update = function(e, options) {
|
PointerLockManager.prototype.update = function(e, options) {
|
||||||
options = options ? options : {};
|
options = options ? options : {};
|
||||||
nc.trigger(nc.ns.client.pointerLock.change, this.isLocked(), options);
|
Nc.trigger(Nc.ns.client.pointerLock.change, this.isLocked(), options);
|
||||||
};
|
};
|
||||||
|
|
||||||
PointerLockManager.prototype.isLocked = function() {
|
PointerLockManager.prototype.isLocked = function() {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ define([
|
||||||
"Lib/Utilities/NotificationCenter"
|
"Lib/Utilities/NotificationCenter"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Abstract, nc) {
|
function (Abstract, Nc) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -59,7 +59,7 @@ function (Abstract, nc) {
|
||||||
|
|
||||||
Layer.prototype.destroy = function() {
|
Layer.prototype.destroy = function() {
|
||||||
for (var i = 0; i < this.ncTokens.length; i++) {
|
for (var i = 0; i < this.ncTokens.length; i++) {
|
||||||
nc.off(this.ncTokens[i]);
|
Nc.off(this.ncTokens[i]);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ define([
|
||||||
"Lib/Utilities/NotificationCenter"
|
"Lib/Utilities/NotificationCenter"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Abstract, domController, Settings, Exception, nc) {
|
function (Abstract, DomController, Settings, Exception, Nc) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -16,14 +16,14 @@ function (Abstract, domController, Settings, Exception, nc) {
|
||||||
this.debugMode = false;
|
this.debugMode = false;
|
||||||
|
|
||||||
this.ncTokens = [
|
this.ncTokens = [
|
||||||
nc.on(nc.ns.client.view.display.change, this.onDisplaySizeChange, this),
|
Nc.on(Nc.ns.client.view.display.change, this.onDisplaySizeChange, this),
|
||||||
nc.on(nc.ns.client.view.debugMode.toggle, this.onToggleDebugMode, this),
|
Nc.on(Nc.ns.client.view.debugMode.toggle, this.onToggleDebugMode, this),
|
||||||
|
|
||||||
nc.on(nc.ns.client.game.zoomIn, this.onZoomIn, this),
|
Nc.on(Nc.ns.client.game.zoomIn, this.onZoomIn, this),
|
||||||
nc.on(nc.ns.client.game.zoomOut, this.onZoomOut, this),
|
Nc.on(Nc.ns.client.game.zoomOut, this.onZoomOut, this),
|
||||||
nc.on(nc.ns.client.game.zoomReset, this.onZoomReset, this),
|
Nc.on(Nc.ns.client.game.zoomReset, this.onZoomReset, this),
|
||||||
|
|
||||||
nc.on(nc.ns.client.view.preloadBar.update, this.onUpdateLoader, this),
|
Nc.on(Nc.ns.client.view.preloadBar.update, this.onUpdateLoader, this),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -47,7 +47,7 @@ function (Abstract, domController, Settings, Exception, nc) {
|
||||||
|
|
||||||
AbstractView.prototype.initCanvas = function (canvas) {
|
AbstractView.prototype.initCanvas = function (canvas) {
|
||||||
this.canvas = canvas;
|
this.canvas = canvas;
|
||||||
domController.initCanvas(canvas);
|
DomController.initCanvas(canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractView.prototype.setMe = function(player) {
|
AbstractView.prototype.setMe = function(player) {
|
||||||
|
|
@ -98,7 +98,7 @@ function (Abstract, domController, Settings, Exception, nc) {
|
||||||
|
|
||||||
AbstractView.prototype.destroy = function() {
|
AbstractView.prototype.destroy = function() {
|
||||||
for (var i = 0; i < this.ncTokens.length; i++) {
|
for (var i = 0; i < this.ncTokens.length; i++) {
|
||||||
nc.off(this.ncTokens[i]);
|
Nc.off(this.ncTokens[i]);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ define([
|
||||||
"Game/Client/PointerLockManager"
|
"Game/Client/PointerLockManager"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Settings, nc, Screenfull, Graph, pointerLockManager) {
|
function (Settings, Nc, Screenfull, Graph, PointerLockManager) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -15,19 +15,18 @@ function (Settings, nc, Screenfull, Graph, pointerLockManager) {
|
||||||
this.stats = null;
|
this.stats = null;
|
||||||
this.ping = null;
|
this.ping = null;
|
||||||
this.nickContainer = null;
|
this.nickContainer = null;
|
||||||
this.fpsContainer = null;
|
this.fpsContainer = "";
|
||||||
this.devToolsContainer = null;
|
this.devToolsContainer = null;
|
||||||
this.frames = 0;
|
|
||||||
|
|
||||||
this.canvas = document.getElementById("canvas");
|
|
||||||
|
|
||||||
this.initDevTools();
|
this.initDevTools();
|
||||||
}
|
}
|
||||||
|
|
||||||
DomController.prototype.initDevTools = function() {
|
DomController.prototype.initDevTools = function() {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
var li, button, label;
|
var li, button, label;
|
||||||
|
|
||||||
|
this.canvas = document.getElementById("canvas");
|
||||||
this.devToolsContainer = document.getElementById("menuBar");
|
this.devToolsContainer = document.getElementById("menuBar");
|
||||||
|
|
||||||
// create back to menu button
|
// create back to menu button
|
||||||
|
|
@ -49,16 +48,6 @@ function (Settings, nc, Screenfull, Graph, pointerLockManager) {
|
||||||
this.devToolsContainer.appendChild(li);
|
this.devToolsContainer.appendChild(li);
|
||||||
this.nickContainer = label;
|
this.nickContainer = label;
|
||||||
|
|
||||||
|
|
||||||
// create fps label with updater
|
|
||||||
li = document.createElement("li");
|
|
||||||
label = document.createElement("label");
|
|
||||||
label.id = "label-fps";
|
|
||||||
li.appendChild(label);
|
|
||||||
this.devToolsContainer.appendChild(li);
|
|
||||||
this.fpsContainer = label;
|
|
||||||
|
|
||||||
/*
|
|
||||||
// create new fps meter
|
// create new fps meter
|
||||||
li = document.createElement("li");
|
li = document.createElement("li");
|
||||||
var fpsCanvas = document.createElement("canvas");
|
var fpsCanvas = document.createElement("canvas");
|
||||||
|
|
@ -70,6 +59,14 @@ function (Settings, nc, Screenfull, Graph, pointerLockManager) {
|
||||||
|
|
||||||
this.fpsGraph = new Graph(fpsCanvas.getContext("2d"), true);
|
this.fpsGraph = new Graph(fpsCanvas.getContext("2d"), true);
|
||||||
|
|
||||||
|
// create fps label with updater
|
||||||
|
li = document.createElement("li");
|
||||||
|
label = document.createElement("label");
|
||||||
|
label.id = "label-fps";
|
||||||
|
li.appendChild(label);
|
||||||
|
this.devToolsContainer.appendChild(li);
|
||||||
|
this.fpsContainer = label;
|
||||||
|
|
||||||
this.fpsGraph.onUpdate(function(value){
|
this.fpsGraph.onUpdate(function(value){
|
||||||
self.fpsContainer.innerHTML = "FPS:" + value;
|
self.fpsContainer.innerHTML = "FPS:" + value;
|
||||||
|
|
||||||
|
|
@ -102,12 +99,6 @@ function (Settings, nc, Screenfull, Graph, pointerLockManager) {
|
||||||
scaleStepWidth: 0,
|
scaleStepWidth: 0,
|
||||||
scaleSteps: 0
|
scaleSteps: 0
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
|
|
||||||
setInterval(function() {
|
|
||||||
self.fpsContainer.innerHTML = "FPS:" + self.frames;
|
|
||||||
self.frames = 0;
|
|
||||||
}, 1000);
|
|
||||||
|
|
||||||
// create Ping: container
|
// create Ping: container
|
||||||
li = document.createElement("li");
|
li = document.createElement("li");
|
||||||
|
|
@ -122,7 +113,7 @@ function (Settings, nc, Screenfull, Graph, pointerLockManager) {
|
||||||
var checkbox = document.createElement("input");
|
var checkbox = document.createElement("input");
|
||||||
checkbox.type = "checkbox";
|
checkbox.type = "checkbox";
|
||||||
checkbox.onclick = function(e) {
|
checkbox.onclick = function(e) {
|
||||||
nc.trigger(nc.ns.client.view.debugMode.toggle, e.target.checked);
|
Nc.trigger(Nc.ns.client.view.debugMode.toggle, e.target.checked);
|
||||||
};
|
};
|
||||||
label.appendChild(checkbox);
|
label.appendChild(checkbox);
|
||||||
label.appendChild(document.createTextNode("Debug"));
|
label.appendChild(document.createTextNode("Debug"));
|
||||||
|
|
@ -137,7 +128,7 @@ function (Settings, nc, Screenfull, Graph, pointerLockManager) {
|
||||||
button.innerHTML = "Fullscreen";
|
button.innerHTML = "Fullscreen";
|
||||||
button.onclick = function() {
|
button.onclick = function() {
|
||||||
if(Screenfull.enabled) {
|
if(Screenfull.enabled) {
|
||||||
pointerLockManager.request();
|
PointerLockManager.request();
|
||||||
Screenfull.request(self.canvas);
|
Screenfull.request(self.canvas);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -147,7 +138,7 @@ function (Settings, nc, Screenfull, Graph, pointerLockManager) {
|
||||||
|
|
||||||
// FIXME : isn't this a weird place for this?
|
// FIXME : isn't this a weird place for this?
|
||||||
window.onresize = function() {
|
window.onresize = function() {
|
||||||
nc.trigger(nc.ns.client.view.display.change);
|
Nc.trigger(Nc.ns.client.view.display.change);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -156,13 +147,12 @@ function (Settings, nc, Screenfull, Graph, pointerLockManager) {
|
||||||
};
|
};
|
||||||
|
|
||||||
DomController.prototype.fpsStep = function() {
|
DomController.prototype.fpsStep = function() {
|
||||||
this.frames++;
|
this.fpsGraph.step();
|
||||||
// this.fpsGraph.step();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
DomController.prototype.setPing = function(ping) {
|
DomController.prototype.setPing = function(ping) {
|
||||||
this.ping.innerHTML = "Ping:" + ping;
|
this.ping.innerHTML = "Ping:" + ping;
|
||||||
// this.pingGraph.addValue(ping);
|
this.pingGraph.addValue(ping);
|
||||||
};
|
};
|
||||||
|
|
||||||
DomController.prototype.getCanvasContainer = function () {
|
DomController.prototype.getCanvasContainer = function () {
|
||||||
|
|
@ -180,7 +170,7 @@ function (Settings, nc, Screenfull, Graph, pointerLockManager) {
|
||||||
};
|
};
|
||||||
|
|
||||||
DomController.prototype.initCanvas = function (canvas) {
|
DomController.prototype.initCanvas = function (canvas) {
|
||||||
nc.trigger(nc.ns.client.view.display.change, Screenfull.isFullscreen);
|
Nc.trigger(Nc.ns.client.view.display.change, Screenfull.isFullscreen);
|
||||||
};
|
};
|
||||||
|
|
||||||
DomController.prototype.setConnected = function(connected) {
|
DomController.prototype.setConnected = function(connected) {
|
||||||
|
|
@ -190,14 +180,13 @@ function (Settings, nc, Screenfull, Graph, pointerLockManager) {
|
||||||
document.body.style.backgroundColor = '#aaaaaa';
|
document.body.style.backgroundColor = '#aaaaaa';
|
||||||
this.ping.innerHTML = "Disconnected. ".replace(/ /g, ' ');
|
this.ping.innerHTML = "Disconnected. ".replace(/ /g, ' ');
|
||||||
this.ping.style.color = "#ff0000";
|
this.ping.style.color = "#ff0000";
|
||||||
/*
|
|
||||||
self = this;
|
self = this;
|
||||||
setTimeout(function(){self.ping.innerHTML = "Reload Page...".replace(/ /g, ' ');}, 3000);
|
setTimeout(function(){self.ping.innerHTML = "Reload Page...".replace(/ /g, ' ');}, 3000);
|
||||||
setTimeout(function(){self.ping.innerHTML = "Reload in 3...".replace(/ /g, ' ');}, 6000);
|
setTimeout(function(){self.ping.innerHTML = "Reload in 3...".replace(/ /g, ' ');}, 6000);
|
||||||
setTimeout(function(){self.ping.innerHTML = "Reload in 2...".replace(/ /g, ' ');}, 7000);
|
setTimeout(function(){self.ping.innerHTML = "Reload in 2...".replace(/ /g, ' ');}, 7000);
|
||||||
setTimeout(function(){self.ping.innerHTML = "Reload in 1...".replace(/ /g, ' ');}, 8000);
|
setTimeout(function(){self.ping.innerHTML = "Reload in 1...".replace(/ /g, ' ');}, 8000);
|
||||||
setTimeout(function(){self.ping.innerHTML = "Reload now. ".replace(/ /g, ' '); location.reload(); }, 9000);
|
setTimeout(function(){self.ping.innerHTML = "Reload now. ".replace(/ /g, ' '); location.reload(); }, 9000);
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ define([
|
||||||
"Game/Client/View/Pixi/Layer"
|
"Game/Client/View/Pixi/Layer"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (nc, Exception, Layer) {
|
function (Nc, Exception, Layer) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -13,16 +13,14 @@ function (nc, Exception, Layer) {
|
||||||
this.container = container;
|
this.container = container;
|
||||||
|
|
||||||
this.ncTokens = [
|
this.ncTokens = [
|
||||||
nc.on(nc.ns.client.view.layer.createAndInsert, this.createAndInsert, this),
|
Nc.on(Nc.ns.client.view.layer.createAndInsert, this.createAndInsert, this),
|
||||||
nc.on(nc.ns.client.view.mesh.create, this.createMesh, this),
|
Nc.on(Nc.ns.client.view.mesh.create, this.createMesh, this),
|
||||||
nc.on(nc.ns.client.view.animatedMesh.create, this.createAnimatedMesh, this),
|
Nc.on(Nc.ns.client.view.animatedMesh.create, this.createAnimatedMesh, this),
|
||||||
nc.on(nc.ns.client.view.mesh.add, this.addMesh, this),
|
Nc.on(Nc.ns.client.view.mesh.add, this.addMesh, this),
|
||||||
nc.on(nc.ns.client.view.mesh.remove, this.removeMesh, this),
|
Nc.on(Nc.ns.client.view.mesh.remove, this.removeMesh, this),
|
||||||
nc.on(nc.ns.client.view.mesh.update, this.updateMesh, this),
|
Nc.on(Nc.ns.client.view.mesh.update, this.updateMesh, this),
|
||||||
nc.on(nc.ns.client.view.mesh.addFilter, this.addFilter, this),
|
Nc.on(Nc.ns.client.view.mesh.addFilter, this.addFilter, this),
|
||||||
nc.on(nc.ns.client.view.mesh.removeFilter, this.removeFilter, this),
|
Nc.on(Nc.ns.client.view.mesh.removeFilter, this.removeFilter, this)
|
||||||
nc.on(nc.ns.client.view.mesh.swapMeshIndexes, this.swapMeshIndexes, this),
|
|
||||||
nc.on(nc.ns.client.view.mesh.swapMeshes, this.swapMeshes, this)
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -159,19 +157,9 @@ function (nc, Exception, Layer) {
|
||||||
this.delegate.apply(this, arguments);
|
this.delegate.apply(this, arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
LayerManager.prototype.swapMeshIndexes = function() {
|
|
||||||
Array.prototype.splice.call(arguments, 0, 0, 'swapMeshIndexes')
|
|
||||||
this.delegate.apply(this, arguments);
|
|
||||||
};
|
|
||||||
|
|
||||||
LayerManager.prototype.swapMeshes = function() {
|
|
||||||
Array.prototype.splice.call(arguments, 0, 0, 'swapMeshes')
|
|
||||||
this.delegate.apply(this, arguments);
|
|
||||||
};
|
|
||||||
|
|
||||||
LayerManager.prototype.destroy = function() {
|
LayerManager.prototype.destroy = function() {
|
||||||
for (var i = 0; i < this.ncTokens.length; i++) {
|
for (var i = 0; i < this.ncTokens.length; i++) {
|
||||||
nc.off(this.ncTokens[i]);
|
Nc.off(this.ncTokens[i]);
|
||||||
};
|
};
|
||||||
for (var i = this.layers.length - 1; i >= 0; i--) {
|
for (var i = this.layers.length - 1; i >= 0; i--) {
|
||||||
var layer = this.layers[i];
|
var layer = this.layers[i];
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ define([
|
||||||
"Lib/Vendor/Screenfull"
|
"Lib/Vendor/Screenfull"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Settings, nc, Stats, Screenfull) {
|
function (Settings, Nc, Stats, Screenfull) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,11 @@ define([
|
||||||
"Lib/Utilities/ColorConverter"
|
"Lib/Utilities/ColorConverter"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (PIXI, nc, Settings, ColorConverter) {
|
function (PIXI, Nc, Settings, ColorConverter) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function GameStats(view) {
|
function GameStats(gameContainer) {
|
||||||
|
|
||||||
this.style = {
|
this.style = {
|
||||||
borderWidth: 3,
|
borderWidth: 3,
|
||||||
|
|
@ -27,7 +27,7 @@ function (PIXI, nc, Settings, ColorConverter) {
|
||||||
fontSize: 12
|
fontSize: 12
|
||||||
};
|
};
|
||||||
|
|
||||||
this.view = view;
|
this.gameContainer = gameContainer;
|
||||||
|
|
||||||
this.container = new PIXI.DisplayObjectContainer();
|
this.container = new PIXI.DisplayObjectContainer();
|
||||||
|
|
||||||
|
|
@ -63,8 +63,8 @@ function (PIXI, nc, Settings, ColorConverter) {
|
||||||
this.sortedPlayers = [];
|
this.sortedPlayers = [];
|
||||||
|
|
||||||
this.ncTokens = [
|
this.ncTokens = [
|
||||||
nc.on(nc.ns.client.view.gameStats.toggle, this.toggle, this),
|
Nc.on(Nc.ns.client.view.gameStats.toggle, this.toggle, this),
|
||||||
nc.on(nc.ns.client.view.gameStats.update, this.update, this)
|
Nc.on(Nc.ns.client.view.gameStats.update, this.update, this)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -77,12 +77,11 @@ function (PIXI, nc, Settings, ColorConverter) {
|
||||||
this.redraw();
|
this.redraw();
|
||||||
// show stats with filters
|
// show stats with filters
|
||||||
this.container.visible = true;
|
this.container.visible = true;
|
||||||
|
this.gameContainer.filters = this.filters;
|
||||||
this.view.addFilters(this.filters);
|
|
||||||
this.filters.forEach(function(filter) { filter.dirty = true; });
|
this.filters.forEach(function(filter) { filter.dirty = true; });
|
||||||
} else {
|
} else {
|
||||||
this.container.visible = false;
|
this.container.visible = false;
|
||||||
this.view.removeFilters(this.filters);
|
this.gameContainer.filters = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -197,7 +196,7 @@ function (PIXI, nc, Settings, ColorConverter) {
|
||||||
|
|
||||||
GameStats.prototype.destroy = function() {
|
GameStats.prototype.destroy = function() {
|
||||||
for (var i = 0; i < this.ncTokens.length; i++) {
|
for (var i = 0; i < this.ncTokens.length; i++) {
|
||||||
nc.off(this.ncTokens[i]);
|
Nc.off(this.ncTokens[i]);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ define([
|
||||||
"Lib/Utilities/NotificationCenter"
|
"Lib/Utilities/NotificationCenter"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, PIXI, ColorRangeReplaceFilter, Settings, ColorConverter, nc) {
|
function (Parent, PIXI, ColorRangeReplaceFilter, Settings, ColorConverter, Nc) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -23,7 +23,7 @@ function (Parent, PIXI, ColorRangeReplaceFilter, Settings, ColorConverter, nc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.ncTokens = this.ncTokens.concat([
|
this.ncTokens = this.ncTokens.concat([
|
||||||
nc.on(nc.ns.client.view.layer.levelSizeUpdate, this.onLevelSizeUpdate, this)
|
Nc.on(Nc.ns.client.view.layer.levelSizeUpdate, this.onLevelSizeUpdate, this)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (Settings.SHOW_LAYER_INFO) {
|
if (Settings.SHOW_LAYER_INFO) {
|
||||||
|
|
@ -95,30 +95,6 @@ function (Parent, PIXI, ColorRangeReplaceFilter, Settings, ColorConverter, nc) {
|
||||||
this.container.removeChild(mesh);
|
this.container.removeChild(mesh);
|
||||||
};
|
};
|
||||||
|
|
||||||
Layer.prototype.swapMeshIndexes = function(meshA, meshB) {
|
|
||||||
var indexA = this.container.getChildIndex(meshA);
|
|
||||||
var indexB = this.container.getChildIndex(meshB);
|
|
||||||
|
|
||||||
this.container.setChildIndex(meshA, indexB);
|
|
||||||
this.container.setChildIndex(meshB, indexA);
|
|
||||||
};
|
|
||||||
|
|
||||||
Layer.prototype.swapMeshes = function(meshA, meshB) {
|
|
||||||
var textureA = meshA.texture;
|
|
||||||
var textureB = meshB.texture;
|
|
||||||
|
|
||||||
meshA.setTexture(textureB);
|
|
||||||
meshA.onTextureUpdate();
|
|
||||||
meshA.scale.x = 1;
|
|
||||||
meshA.scale.y = 1;
|
|
||||||
|
|
||||||
meshB.setTexture(textureA);
|
|
||||||
meshB.onTextureUpdate();
|
|
||||||
meshB.scale.x = 1;
|
|
||||||
meshB.scale.y = 1;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
Layer.prototype.createMesh = function (texturePath, callback, options) {
|
Layer.prototype.createMesh = function (texturePath, callback, options) {
|
||||||
|
|
||||||
var texture = (options && options.fromFrame)
|
var texture = (options && options.fromFrame)
|
||||||
|
|
@ -174,11 +150,6 @@ function (Parent, PIXI, ColorRangeReplaceFilter, Settings, ColorConverter, nc) {
|
||||||
|
|
||||||
Layer.prototype.addFilter = function(mesh, filterName, options) {
|
Layer.prototype.addFilter = function(mesh, filterName, options) {
|
||||||
|
|
||||||
// use game container if mesh null
|
|
||||||
if(mesh === null) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.getAvailableMeshFilters().hasOwnProperty(filterName)) {
|
if (!this.getAvailableMeshFilters().hasOwnProperty(filterName)) {
|
||||||
throw new Exception('Filter ' + filterName + ' is not available');
|
throw new Exception('Filter ' + filterName + ' is not available');
|
||||||
}
|
}
|
||||||
|
|
@ -233,8 +204,6 @@ function (Parent, PIXI, ColorRangeReplaceFilter, Settings, ColorConverter, nc) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME this should throw an error i think since "options" is not defined here
|
|
||||||
// maybe we never actually call this method?
|
|
||||||
var MeshFilter = this.getAvailableMeshFilters()[options.filter];
|
var MeshFilter = this.getAvailableMeshFilters()[options.filter];
|
||||||
|
|
||||||
filters = filters.filter(function(filter){
|
filters = filters.filter(function(filter){
|
||||||
|
|
|
||||||
|
|
@ -16,5 +16,12 @@ function (Parent, PIXI) {
|
||||||
|
|
||||||
Debug.prototype = Object.create(Parent.prototype);
|
Debug.prototype = Object.create(Parent.prototype);
|
||||||
|
|
||||||
|
Debug.prototype.render = function(centerPosition, zoom) {
|
||||||
|
Parent.prototype.render.call(this, centerPosition, zoom);
|
||||||
|
|
||||||
|
this.container.x -= 300 * zoom;
|
||||||
|
this.container.y -= 200 * zoom;
|
||||||
|
};
|
||||||
|
|
||||||
return new Debug();
|
return new Debug();
|
||||||
});
|
});
|
||||||
|
|
@ -5,7 +5,7 @@ define([
|
||||||
"Game/Config/Settings"
|
"Game/Config/Settings"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, PIXI, nc, Settings) {
|
function (Parent, PIXI, Nc, Settings) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -13,12 +13,12 @@ function (Parent, PIXI, nc, Settings) {
|
||||||
Parent.call(this, "ghost", {parallaxSpeed: 0});
|
Parent.call(this, "ghost", {parallaxSpeed: 0});
|
||||||
|
|
||||||
this.ncTokens = this.ncTokens.concat([
|
this.ncTokens = this.ncTokens.concat([
|
||||||
nc.on(nc.ns.client.view.layer.levelSizeUpdate, this.onLevelSizeUpdate, this),
|
Nc.on(Nc.ns.client.view.layer.levelSizeUpdate, this.onLevelSizeUpdate, this),
|
||||||
nc.on(nc.ns.client.view.playerArrow.createAndAdd, this.onCreateAndAddPlayerArrow, this),
|
Nc.on(Nc.ns.client.view.playerArrow.createAndAdd, this.onCreateAndAddPlayerArrow, this),
|
||||||
nc.on(nc.ns.client.view.playerArrow.update, this.onUpdatePlayerArrow, this),
|
Nc.on(Nc.ns.client.view.playerArrow.update, this.onUpdatePlayerArrow, this),
|
||||||
nc.on(nc.ns.client.view.healthBar.createAndAdd, this.onCreateAndAddHealthBar, this),
|
Nc.on(Nc.ns.client.view.healthBar.createAndAdd, this.onCreateAndAddHealthBar, this),
|
||||||
nc.on(nc.ns.client.view.healthBar.update, this.onUpdateHealthBar, this),
|
Nc.on(Nc.ns.client.view.healthBar.update, this.onUpdateHealthBar, this),
|
||||||
nc.on(nc.ns.client.view.healthBar.remove, this.onRemoveHealthBar, this),
|
Nc.on(Nc.ns.client.view.healthBar.remove, this.onRemoveHealthBar, this),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -36,10 +36,10 @@ function (Parent, PIXI, nc, Settings) {
|
||||||
arrow.visible = false;
|
arrow.visible = false;
|
||||||
this.container.addChild(arrow);
|
this.container.addChild(arrow);
|
||||||
|
|
||||||
var width = 10,
|
var width = 12,
|
||||||
height = 10;
|
height = 12;
|
||||||
|
|
||||||
arrow.beginFill(0xffffff, 0.4);
|
arrow.beginFill(0xffffff, 0.1);
|
||||||
arrow.lineStyle(0, 0x000000);
|
arrow.lineStyle(0, 0x000000);
|
||||||
arrow.moveTo(0, 0);
|
arrow.moveTo(0, 0);
|
||||||
arrow.lineTo(width, 0);
|
arrow.lineTo(width, 0);
|
||||||
|
|
@ -56,7 +56,7 @@ function (Parent, PIXI, nc, Settings) {
|
||||||
Ghost.prototype.onUpdatePlayerArrow = function(arrow, options) {
|
Ghost.prototype.onUpdatePlayerArrow = function(arrow, options) {
|
||||||
|
|
||||||
var offsetX = 0,
|
var offsetX = 0,
|
||||||
offsetY = -55,
|
offsetY = -60,
|
||||||
x = offsetX + options.x,
|
x = offsetX + options.x,
|
||||||
y = offsetY + options.y;
|
y = offsetY + options.y;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ define([
|
||||||
"Game/Config/Settings"
|
"Game/Config/Settings"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, PIXI, nc, Settings) {
|
function (Parent, PIXI, Nc, Settings) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -13,7 +13,7 @@ function (Parent, PIXI, nc, Settings) {
|
||||||
Parent.call(this, "messages", {parallaxSpeed:-1});
|
Parent.call(this, "messages", {parallaxSpeed:-1});
|
||||||
|
|
||||||
this.ncTokens = this.ncTokens.concat([
|
this.ncTokens = this.ncTokens.concat([
|
||||||
nc.on(nc.ns.client.view.gameStats.kill, this.onKill, this)
|
Nc.on(Nc.ns.client.view.gameStats.kill, this.onKill, this)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
this.mainTextOptions = {
|
this.mainTextOptions = {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ define([
|
||||||
"Game/Config/Settings"
|
"Game/Config/Settings"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, PIXI, nc, Settings) {
|
function (Parent, PIXI, Nc, Settings) {
|
||||||
|
|
||||||
function Swiper() {
|
function Swiper() {
|
||||||
Parent.call(this, "swiper", {parallaxSpeed:0});
|
Parent.call(this, "swiper", {parallaxSpeed:0});
|
||||||
|
|
@ -13,8 +13,8 @@ function (Parent, PIXI, nc, Settings) {
|
||||||
this.static = true;
|
this.static = true;
|
||||||
|
|
||||||
this.ncTokens = this.ncTokens.concat([
|
this.ncTokens = this.ncTokens.concat([
|
||||||
nc.on(nc.ns.client.view.swiper.swipe, this.swipe, this),
|
Nc.on(Nc.ns.client.view.swiper.swipe, this.swipe, this),
|
||||||
nc.on(nc.ns.client.view.swiper.end, this.end, this)
|
Nc.on(Nc.ns.client.view.swiper.end, this.end, this)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
this.sprite = new PIXI.Graphics();
|
this.sprite = new PIXI.Graphics();
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ define([
|
||||||
"Game/Client/View/Pixi/Layers/Messages"
|
"Game/Client/View/Pixi/Layers/Messages"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, domController, PIXI, Settings, nc, Exception, GameStats, LayerManager, Ghost, Swiper, pointerLockManager, Debug, Messages) {
|
function (Parent, DomController, PIXI, Settings, Nc, Exception, GameStats, LayerManager, Ghost, Swiper, PointerLockManager, Debug, Messages) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -35,8 +35,8 @@ function (Parent, domController, PIXI, Settings, nc, Exception, GameStats, Layer
|
||||||
this.init();
|
this.init();
|
||||||
|
|
||||||
this.ncTokens = this.ncTokens.concat([
|
this.ncTokens = this.ncTokens.concat([
|
||||||
nc.on(nc.ns.client.pointerLock.change, this.onPointerLockChange, this),
|
Nc.on(Nc.ns.client.pointerLock.change, this.onPointerLockChange, this),
|
||||||
nc.on(nc.ns.core.game.events.level.loaded, this.showDefaultLayers, this)
|
Nc.on(Nc.ns.core.game.events.level.loaded, this.showDefaultLayers, this)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
PIXI.scaleModes.DEFAULT = PIXI.scaleModes.NEAREST;
|
PIXI.scaleModes.DEFAULT = PIXI.scaleModes.NEAREST;
|
||||||
|
|
@ -47,7 +47,7 @@ function (Parent, domController, PIXI, Settings, nc, Exception, GameStats, Layer
|
||||||
PixiView.prototype.init = function () {
|
PixiView.prototype.init = function () {
|
||||||
|
|
||||||
var rendererOptions = {
|
var rendererOptions = {
|
||||||
view: domController.getCanvas(),
|
view: DomController.getCanvas(),
|
||||||
antialiasing: false,
|
antialiasing: false,
|
||||||
transparent: false,
|
transparent: false,
|
||||||
resolution: 1
|
resolution: 1
|
||||||
|
|
@ -82,7 +82,7 @@ function (Parent, domController, PIXI, Settings, nc, Exception, GameStats, Layer
|
||||||
this.initPointerLockView();
|
this.initPointerLockView();
|
||||||
|
|
||||||
// Tab Overlay (not using layer manager, cause of filters)
|
// Tab Overlay (not using layer manager, cause of filters)
|
||||||
this.gameStats = new GameStats(this);
|
this.gameStats = new GameStats(this.container);
|
||||||
this.stage.addChild(this.gameStats.getInfoContainer());
|
this.stage.addChild(this.gameStats.getInfoContainer());
|
||||||
|
|
||||||
this.ghostLayer = new Ghost();
|
this.ghostLayer = new Ghost();
|
||||||
|
|
@ -121,7 +121,6 @@ function (Parent, domController, PIXI, Settings, nc, Exception, GameStats, Layer
|
||||||
}
|
}
|
||||||
|
|
||||||
PixiView.prototype.initPointerLockView = function() {
|
PixiView.prototype.initPointerLockView = function() {
|
||||||
if (!Settings.ENABLE_POINTER_LOCK_FILTER) return;
|
|
||||||
|
|
||||||
var blurFilter = new PIXI.BlurFilter();
|
var blurFilter = new PIXI.BlurFilter();
|
||||||
blurFilter.blurX = 42 * this.currentZoom;
|
blurFilter.blurX = 42 * this.currentZoom;
|
||||||
|
|
@ -140,11 +139,8 @@ function (Parent, domController, PIXI, Settings, nc, Exception, GameStats, Layer
|
||||||
};
|
};
|
||||||
|
|
||||||
PixiView.prototype.onPointerLockChange = function(isLocked, options) {
|
PixiView.prototype.onPointerLockChange = function(isLocked, options) {
|
||||||
if (!Settings.ENABLE_POINTER_LOCK_FILTER) return;
|
|
||||||
|
|
||||||
if(isLocked) {
|
if(isLocked) {
|
||||||
this.removeFilters(this.pointerLockFilters);
|
this.container.filters = null;
|
||||||
|
|
||||||
this.clickToEnable.visible = false;
|
this.clickToEnable.visible = false;
|
||||||
this.onZoomReset();
|
this.onZoomReset();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -160,7 +156,7 @@ function (Parent, domController, PIXI, Settings, nc, Exception, GameStats, Layer
|
||||||
strokeThickness: 6 * this.currentZoom
|
strokeThickness: 6 * this.currentZoom
|
||||||
});
|
});
|
||||||
|
|
||||||
this.addFilters(this.pointerLockFilters);
|
this.container.filters = this.pointerLockFilters;
|
||||||
this.pointerLockFilters.forEach(function(filter) { filter.dirty = true; });
|
this.pointerLockFilters.forEach(function(filter) { filter.dirty = true; });
|
||||||
|
|
||||||
this.clickToEnable.position = new PIXI.Point(Settings.STAGE_WIDTH / 2 - this.clickToEnable.width / 2, Settings.STAGE_HEIGHT / 2 - this.clickToEnable.height / 2)
|
this.clickToEnable.position = new PIXI.Point(Settings.STAGE_WIDTH / 2 - this.clickToEnable.width / 2, Settings.STAGE_HEIGHT / 2 - this.clickToEnable.height / 2)
|
||||||
|
|
@ -171,46 +167,6 @@ function (Parent, domController, PIXI, Settings, nc, Exception, GameStats, Layer
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
PixiView.prototype.removeFilters = function(filters) {
|
|
||||||
|
|
||||||
if(this.container && this.container.filters && this.container.filters.length) {
|
|
||||||
for (var i = this.container.filters.length - 1; i >= 0; i--) {
|
|
||||||
|
|
||||||
for (var j = filters.length - 1; j >= 0; j--) {
|
|
||||||
if (filters[j] === this.container.filters[i]) {
|
|
||||||
this.container.filters.splice(i, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// weird bug, filters.length cant be 0, must be set to null
|
|
||||||
if(this.container.filters.length < 1) {
|
|
||||||
this.container.filters = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
PixiView.prototype.addFilters = function(filters) {
|
|
||||||
if (filters.length < 1) return;
|
|
||||||
if (!this.container) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.container.filters) {
|
|
||||||
/*
|
|
||||||
* slice does a copy, which is important here -
|
|
||||||
* otherwise this.pointerLockFilters will be manipulated too on remove.
|
|
||||||
*/
|
|
||||||
this.container.filters = filters.slice();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var i = 0; i < filters.length; i++) {
|
|
||||||
this.container.filters.push(filters[i]);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
PixiView.prototype.calculateCenterPosition = function() {
|
PixiView.prototype.calculateCenterPosition = function() {
|
||||||
var target = this.me.getHeadPosition();
|
var target = this.me.getHeadPosition();
|
||||||
|
|
||||||
|
|
@ -231,7 +187,7 @@ function (Parent, domController, PIXI, Settings, nc, Exception, GameStats, Layer
|
||||||
this.renderer.resize(window.innerWidth, window.innerHeight);
|
this.renderer.resize(window.innerWidth, window.innerHeight);
|
||||||
this.currentZoom = window.innerWidth / 600;
|
this.currentZoom = window.innerWidth / 600;
|
||||||
|
|
||||||
pointerLockManager.update(null, {}); // only to reposition clickToEnable text
|
PointerLockManager.update(null, {}); // only to reposition clickToEnable text
|
||||||
};
|
};
|
||||||
|
|
||||||
PixiView.prototype.initLoader = function() {
|
PixiView.prototype.initLoader = function() {
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
define([
|
define([
|
||||||
"Game/Client/View/Abstract/View",
|
"Game/Client/View/Abstract/View",
|
||||||
|
"Game/Client/View/DomController",
|
||||||
"Lib/Vendor/Three",
|
"Lib/Vendor/Three",
|
||||||
"Game/Config/Settings"
|
"Game/Config/Settings"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, Three, Settings) {
|
function (Parent, DomController, Three, Settings) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ define([
|
||||||
"Lib/Utilities/NotificationCenter"
|
"Lib/Utilities/NotificationCenter"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Settings, Exception, AbstractView, PixiView, nc) {
|
function (Settings, Exception, AbstractView, PixiView, Nc) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -411,17 +411,19 @@ function () {
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
"RubeDoll":
|
|
||||||
|
|
||||||
|
"Rube":
|
||||||
{
|
{
|
||||||
"category": "kitchen",
|
"category": "kitchen",
|
||||||
"image": "banana.gif",
|
"image": "banana.gif",
|
||||||
|
|
||||||
"weight": "3",
|
// "type": "rube",
|
||||||
"width": "15",
|
"weight": "1",
|
||||||
|
"width": "5",
|
||||||
"height": "9",
|
"height": "9",
|
||||||
|
|
||||||
"type": "rubedoll",
|
"grabAngle": "0.5",
|
||||||
"grabAngle": "0.001", // seems to be a bug, that 0 does not work!
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@ function () {
|
||||||
BOX2D_WORLD_AABB_SIZE: 3000,
|
BOX2D_WORLD_AABB_SIZE: 3000,
|
||||||
BOX2D_ALLOW_SLEEP: true,
|
BOX2D_ALLOW_SLEEP: true,
|
||||||
BOX2D_GRAVITY: 26,
|
BOX2D_GRAVITY: 26,
|
||||||
BOX2D_VELOCITY_ITERATIONS: 20,
|
BOX2D_VELOCITY_ITERATIONS: 5,
|
||||||
BOX2D_POSITION_ITERATIONS: 10, // 200/100 created problems (awful teleporting when repositioning joints)
|
BOX2D_POSITION_ITERATIONS: 5,
|
||||||
BOX2D_TIME_STEP: 1 / 60,
|
BOX2D_TIME_STEP: 1 / 60,
|
||||||
|
|
||||||
// PATHS
|
// PATHS
|
||||||
|
|
@ -39,7 +39,6 @@ function () {
|
||||||
VIEW_CONTROLLER: 0 ? "Three" : "Pixi",
|
VIEW_CONTROLLER: 0 ? "Three" : "Pixi",
|
||||||
ARROW_GLIDE: 30, // % of the way per frame
|
ARROW_GLIDE: 30, // % of the way per frame
|
||||||
SHOW_LAYER_INFO: false,
|
SHOW_LAYER_INFO: false,
|
||||||
ENABLE_POINTER_LOCK_FILTER: true,
|
|
||||||
|
|
||||||
// GAME PLAY
|
// GAME PLAY
|
||||||
WALK_SPEED: 4,
|
WALK_SPEED: 4,
|
||||||
|
|
@ -88,10 +87,10 @@ function () {
|
||||||
CHANNEL_MAX_USERS: 20,
|
CHANNEL_MAX_USERS: 20,
|
||||||
CHANNEL_DESTRUCTION_TIME: 0.5 * 60,
|
CHANNEL_DESTRUCTION_TIME: 0.5 * 60,
|
||||||
CHANNEL_END_ROUND_TIME: 20, //10,
|
CHANNEL_END_ROUND_TIME: 20, //10,
|
||||||
CHANNEL_DEFAULT_MAX_USERS: 10,
|
CHANNEL_DEFAULT_MAX_USERS: 40,
|
||||||
CHANNEL_DEFAULT_SCORE_LIMIT: 5,
|
CHANNEL_DEFAULT_SCORE_LIMIT: 10,
|
||||||
CHANNEL_DEFAULT_LEVELS: ["debug"],
|
CHANNEL_DEFAULT_LEVELS: ["debug"],
|
||||||
CHANNEL_RECORD_SESSION: false,
|
CHANNEL_RECORD_SESSION: true,
|
||||||
|
|
||||||
// ME STATE
|
// ME STATE
|
||||||
ME_STATE_MAX_DIFFERENCE_METERS: 1,
|
ME_STATE_MAX_DIFFERENCE_METERS: 1,
|
||||||
|
|
|
||||||
|
|
@ -4,18 +4,20 @@ define([
|
||||||
function () {
|
function () {
|
||||||
|
|
||||||
function PlayerController (player) {
|
function PlayerController (player) {
|
||||||
|
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
|
||||||
|
this._shift;
|
||||||
|
this._isJumping;
|
||||||
this._walkingDirectionStatus = 0;
|
this._walkingDirectionStatus = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerController.prototype.moveLeft = function () {
|
PlayerController.prototype.moveLeft = function () {
|
||||||
if(!this.isPlayerInputAllowed()) return;
|
|
||||||
this.player.move(-1);
|
this.player.move(-1);
|
||||||
this._walkingDirectionStatus = -1;
|
this._walkingDirectionStatus = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerController.prototype.moveRight = function () {
|
PlayerController.prototype.moveRight = function () {
|
||||||
if(!this.isPlayerInputAllowed()) return;
|
|
||||||
this.player.move(1);
|
this.player.move(1);
|
||||||
this._walkingDirectionStatus = 1;
|
this._walkingDirectionStatus = 1;
|
||||||
}
|
}
|
||||||
|
|
@ -26,7 +28,7 @@ function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerController.prototype.jump = function () {
|
PlayerController.prototype.jump = function () {
|
||||||
if(!this.isPlayerInputAllowed()) return;
|
this._isJumping = true;
|
||||||
this.player.jump();
|
this.player.jump();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -35,31 +37,15 @@ function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerController.prototype.lookAt = function (options) {
|
PlayerController.prototype.lookAt = function (options) {
|
||||||
if(!this.isPlayerInputAllowed()) return;
|
|
||||||
if(options) this.player.lookAt(options.x, options.y);
|
if(options) this.player.lookAt(options.x, options.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerController.prototype.activateModifier = function() {
|
|
||||||
if (!this.isPlayerInputAllowed()) return;
|
|
||||||
this.player.activateModifier();
|
|
||||||
};
|
|
||||||
|
|
||||||
PlayerController.prototype.deactivateModifier = function() {
|
|
||||||
if (!this.isPlayerInputAllowed()) return;
|
|
||||||
this.player.deactivateModifier();
|
|
||||||
};
|
|
||||||
|
|
||||||
PlayerController.prototype.update = function () {
|
PlayerController.prototype.update = function () {
|
||||||
if(this._walkingDirectionStatus != 0) {
|
if(this._walkingDirectionStatus != 0) {
|
||||||
this.player.move(this._walkingDirectionStatus);
|
this.player.move(this._walkingDirectionStatus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default behaviour - may be needed later?
|
|
||||||
PlayerController.prototype.isPlayerInputAllowed = function() {
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
PlayerController.prototype.destroy = function() {
|
PlayerController.prototype.destroy = function() {
|
||||||
// extend if necessary
|
// extend if necessary
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,10 @@ define([
|
||||||
"Lib/Utilities/NotificationCenter",
|
"Lib/Utilities/NotificationCenter",
|
||||||
"Game/" + GLOBALS.context + "/GameObjects/Doll",
|
"Game/" + GLOBALS.context + "/GameObjects/Doll",
|
||||||
"Game/" + GLOBALS.context + "/GameObjects/GameObject",
|
"Game/" + GLOBALS.context + "/GameObjects/GameObject",
|
||||||
"Game/" + GLOBALS.context + "/GameObjects/Item",
|
"Lib/Utilities/Assert"
|
||||||
"Lib/Utilities/Assert",
|
|
||||||
],
|
],
|
||||||
|
|
||||||
function (PhysicsEngine, TiledLevel, Player, nc, Doll, GameObject, Item, Assert) {
|
function (PhysicsEngine, TiledLevel, Player, Nc, Doll, GameObject, Assert) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -18,14 +17,15 @@ function (PhysicsEngine, TiledLevel, Player, nc, Doll, GameObject, Item, Assert)
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.players = {};
|
this.players = {};
|
||||||
this.level = null;
|
this.level = null;
|
||||||
this.worldUpdateObjects = {};
|
this.gameObjects = null;
|
||||||
|
this.resetGameObjects();
|
||||||
|
|
||||||
this.physicsEngine = new PhysicsEngine();
|
this.physicsEngine = new PhysicsEngine();
|
||||||
this.physicsEngine.setCollisionDetector();
|
this.physicsEngine.setCollisionDetector();
|
||||||
|
|
||||||
this.ncTokens = [
|
this.ncTokens = [
|
||||||
nc.on(nc.ns.core.game.worldUpdateObjects.add, this.onWorldUpdateObjectAdd, this),
|
Nc.on(Nc.ns.core.game.gameObject.add, this.onGameObjectAdd, this),
|
||||||
nc.on(nc.ns.core.game.worldUpdateObjects.remove, this.onWorldUpdateObjectRemove, this)
|
Nc.on(Nc.ns.core.game.gameObject.remove, this.onGameObjectRemove, this)
|
||||||
];
|
];
|
||||||
|
|
||||||
this.loadLevel(options.levelUid);
|
this.loadLevel(options.levelUid);
|
||||||
|
|
@ -37,61 +37,89 @@ function (PhysicsEngine, TiledLevel, Player, nc, Doll, GameObject, Item, Assert)
|
||||||
// extend for both sides if necessary
|
// extend for both sides if necessary
|
||||||
};
|
};
|
||||||
|
|
||||||
GameController.prototype.onWorldUpdateObjectAdd = function(object) {
|
GameController.prototype.resetGameObjects = function() {
|
||||||
this.worldUpdateObjects[object.uid] = object;
|
this.gameObjects = {
|
||||||
|
fixed: [],
|
||||||
|
animated: []
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
GameController.prototype.onWorldUpdateObjectRemove = function(object) {
|
GameController.prototype.onGameObjectAdd = function(type, object) {
|
||||||
delete this.worldUpdateObjects[object.uid];
|
this.gameObjects[type].push(object);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameController.prototype.onGameObjectRemove = function(type, object) {
|
||||||
|
var i = this.gameObjects[type].indexOf(object);
|
||||||
|
if(i>=0) this.gameObjects[type].splice(i, 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameController.prototype.getPhysicsEngine = function () {
|
GameController.prototype.getPhysicsEngine = function () {
|
||||||
return this.physicsEngine;
|
return this.physicsEngine;
|
||||||
};
|
};
|
||||||
|
|
||||||
GameController.prototype.getItemByUid = function(uid) {
|
|
||||||
// FIXME : maybe divide this into a dedicated item pool?
|
|
||||||
return this.worldUpdateObjects[uid];
|
|
||||||
};
|
|
||||||
|
|
||||||
GameController.prototype.loadLevel = function (levelUid) {
|
GameController.prototype.loadLevel = function (levelUid) {
|
||||||
|
|
||||||
if (this.level) {
|
if (this.level) {
|
||||||
this.level.destroy();
|
this.level.destroy();
|
||||||
this.worldUpdateObjects = {};
|
this.resetGameObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.level = new TiledLevel(levelUid, this.physicsEngine);
|
this.level = new TiledLevel(levelUid, this.physicsEngine, this.gameObjects);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* This is now in core, because the recorder/player
|
|
||||||
* uses the world update mechanism on the channel side
|
|
||||||
*/
|
|
||||||
GameController.prototype.onWorldUpdate = function (updateData) {
|
GameController.prototype.onWorldUpdate = function (updateData) {
|
||||||
|
|
||||||
for (var uid in updateData) {
|
var body = this.physicsEngine.world.GetBodyList();
|
||||||
|
do {
|
||||||
var gameObject = this.worldUpdateObjects[uid];
|
var userData = body.GetUserData();
|
||||||
|
if (userData instanceof GameObject) {
|
||||||
if (!(gameObject instanceof GameObject)) {
|
var gameObject = userData;
|
||||||
console.warn('Can\'t find object ' + uid + ' in worldUpdateObjects pool:', Object.keys(this.worldUpdateObjects));
|
if(updateData[gameObject.uid]) {
|
||||||
continue;
|
var update = updateData[gameObject.uid];
|
||||||
|
this.onWorldUpdateGameObject(body, gameObject, update);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updateGameObject(gameObject, updateData[uid]);
|
} while (body = body.GetNext());
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GameController.prototype.onWorldUpdateGameObject = function(body, gameObject, update) {
|
||||||
GameController.prototype.updateGameObject = function(gameObject, gameObjectUpdate) {
|
if (gameObject instanceof Doll) {
|
||||||
gameObject.setUpdateData(gameObjectUpdate);
|
/*
|
||||||
|
if(gameObject === this.me.doll) {
|
||||||
|
this.me.setLastServerPositionState(update);
|
||||||
|
if(!this.me.acceptPositionStateUpdateFromServer()) {
|
||||||
|
return; // this is to ignore own doll updates from world update
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
gameObject.setActionState(update.as);
|
||||||
|
gameObject.lookAt(update.laxy.x, update.laxy.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.number(update.p.x, update.p.y);
|
||||||
|
Assert.number(update.a);
|
||||||
|
Assert.number(update.lv.x, update.lv.y);
|
||||||
|
Assert.number(update.av);
|
||||||
|
|
||||||
|
body.SetAwake(true);
|
||||||
|
body.SetPosition(update.p);
|
||||||
|
body.SetAngle(update.a);
|
||||||
|
body.SetLinearVelocity(update.lv);
|
||||||
|
body.SetAngularVelocity(update.av);
|
||||||
|
};
|
||||||
|
|
||||||
GameController.prototype.onResetLevel = function() {
|
GameController.prototype.onResetLevel = function() {
|
||||||
this.loadLevel(this.level.uid);
|
this.loadLevel(this.level.uid);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
GameController.prototype.userJoined = function (user) {
|
||||||
|
this.players[user.id] = this.createPlayer(user);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
GameController.prototype.onUserLeft = function (userId) {
|
GameController.prototype.onUserLeft = function (userId) {
|
||||||
var player = this.players[userId];
|
var player = this.players[userId];
|
||||||
if(!player) {
|
if(!player) {
|
||||||
|
|
@ -103,31 +131,48 @@ function (PhysicsEngine, TiledLevel, Player, nc, Doll, GameObject, Item, Assert)
|
||||||
delete this.players[userId];
|
delete this.players[userId];
|
||||||
};
|
};
|
||||||
|
|
||||||
GameController.prototype.createPlayer = function(user, revealedGameController) {
|
GameController.prototype.createPlayer = function(user) {
|
||||||
var player = new Player(user.id, this.physicsEngine, user, revealedGameController);
|
var player = new Player(user.id, this.physicsEngine, user);
|
||||||
this.players[user.id] = player;
|
this.players[user.id] = player;
|
||||||
return player;
|
return player;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
GameController.prototype.destroy = function () {
|
GameController.prototype.destroy = function () {
|
||||||
|
var i = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
for(var player in this.players) {
|
for(var player in this.players) {
|
||||||
this.players[player].destroy();
|
// this.players[player].destroy();
|
||||||
|
|
||||||
|
// FIXME:
|
||||||
|
// commented out for now, because players are in gameObjects array.
|
||||||
|
// try using a real gameobject for the health bar
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
for (i = 0; i < this.ncTokens.length; i++) {
|
||||||
|
Nc.off(this.ncTokens[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME ns.client in core?
|
/*
|
||||||
nc.trigger(nc.ns.client.game.events.destroy);
|
* Contents of gameObject: Players, Items, Tiles, RagDolls
|
||||||
|
* No Dolls.
|
||||||
|
*/
|
||||||
|
|
||||||
// Testing after destroy if worldUpdateObjects is empty
|
for (var key in this.gameObjects) {
|
||||||
// events.game.destroy -> gameobjects.destroy() -> nc.trigger(worldUpdateObjects.remove)
|
for (i = 0; i < this.gameObjects[key].length; i++) {
|
||||||
if(Object.keys(this.worldUpdateObjects).length > 0) {
|
var gameObject = this.gameObjects[key][i];
|
||||||
console.warn('Not all worldUpdateObjects have been removed... ', Object.keys(this.worldUpdateObjects));
|
|
||||||
|
gameObject.destroy();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.gameObjects = {
|
||||||
|
fixed: [],
|
||||||
|
animated: []
|
||||||
|
};
|
||||||
|
|
||||||
this.physicsEngine.destroy();
|
this.physicsEngine.destroy();
|
||||||
this.worldUpdateObjects = null;
|
|
||||||
|
|
||||||
nc.off(this.ncTokens);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return GameController;
|
return GameController;
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ define([
|
||||||
"Lib/Utilities/Assert"
|
"Lib/Utilities/Assert"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, Exception, Box2D, Settings, CollisionDetector, Item, nc, Assert) {
|
function (Parent, Exception, Box2D, Settings, CollisionDetector, Item, Nc, Assert) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -40,12 +40,11 @@ function (Parent, Exception, Box2D, Settings, CollisionDetector, Item, nc, Asser
|
||||||
this.holdingJoint = null;
|
this.holdingJoint = null;
|
||||||
this.holdingItem = null;
|
this.holdingItem = null;
|
||||||
|
|
||||||
this.ragDoll = {head: null, body: null}; // FIXME: wtf is this? can we remove it?
|
this.ragDoll = {head: null, body: null};
|
||||||
|
|
||||||
this.createFixtures();
|
this.createFixtures();
|
||||||
this.body.SetActive(false);
|
this.body.SetActive(false);
|
||||||
|
|
||||||
nc.trigger(nc.ns.core.game.worldUpdateObjects.add, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Doll.prototype = Object.create(Parent.prototype);
|
Doll.prototype = Object.create(Parent.prototype);
|
||||||
|
|
@ -228,14 +227,14 @@ function (Parent, Exception, Box2D, Settings, CollisionDetector, Item, nc, Asser
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Doll.prototype.move = function (direction, modifierActivated) {
|
Doll.prototype.move = function (direction) {
|
||||||
|
|
||||||
this.moveDirection = direction;
|
this.moveDirection = direction;
|
||||||
var speed;
|
var speed;
|
||||||
var isHoldingHeavyItem = this.holdingItem && this.holdingItem.options.weight > Settings.MAX_RUNNING_WEIGHT;
|
var isHoldingHeavyItem = this.holdingItem && this.holdingItem.options.weight > Settings.MAX_RUNNING_WEIGHT;
|
||||||
|
|
||||||
switch(true) {
|
switch(true) {
|
||||||
case direction == this.lookDirection && this.isStanding() && !isHoldingHeavyItem && !modifierActivated:
|
case direction == this.lookDirection && this.isStanding() && !isHoldingHeavyItem:
|
||||||
speed = Settings.RUN_SPEED;
|
speed = Settings.RUN_SPEED;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -264,7 +263,7 @@ function (Parent, Exception, Box2D, Settings, CollisionDetector, Item, nc, Asser
|
||||||
if(this.isStanding()) {
|
if(this.isStanding()) {
|
||||||
if(this.moveDirection == this.lookDirection) {
|
if(this.moveDirection == this.lookDirection) {
|
||||||
|
|
||||||
if(isHoldingHeavyItem || modifierActivated) {
|
if(isHoldingHeavyItem) {
|
||||||
this.setActionState("walk");
|
this.setActionState("walk");
|
||||||
} else {
|
} else {
|
||||||
this.setActionState("run");
|
this.setActionState("run");
|
||||||
|
|
@ -472,16 +471,7 @@ function (Parent, Exception, Box2D, Settings, CollisionDetector, Item, nc, Asser
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Doll.prototype.setUpdateData = function(update) {
|
|
||||||
|
|
||||||
Parent.prototype.setUpdateData.call(this, update);
|
|
||||||
|
|
||||||
this.setActionState(update.as);
|
|
||||||
this.lookAt(update.laxy.x, update.laxy.y);
|
|
||||||
};
|
|
||||||
|
|
||||||
Doll.prototype.destroy = function() {
|
Doll.prototype.destroy = function() {
|
||||||
nc.trigger(nc.ns.core.game.worldUpdateObjects.remove, this);
|
|
||||||
Parent.prototype.destroy.call(this);
|
Parent.prototype.destroy.call(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,9 @@
|
||||||
define([
|
define([
|
||||||
"Lib/Vendor/Box2D",
|
"Lib/Vendor/Box2D",
|
||||||
"Lib/Utilities/Exception",
|
"Lib/Utilities/Exception"
|
||||||
"Lib/Utilities/Assert",
|
|
||||||
"Lib/Utilities/NotificationCenter"
|
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Box2D, Exception, Assert, nc) {
|
function (Box2D, Exception) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -14,11 +12,7 @@ function (Box2D, Exception, Assert, nc) {
|
||||||
|
|
||||||
var def = this.getBodyDef();
|
var def = this.getBodyDef();
|
||||||
def.userData = this;
|
def.userData = this;
|
||||||
this.body = physicsEngine.createBody(def);
|
this.body = physicsEngine.getWorld().CreateBody(def);
|
||||||
|
|
||||||
this.ncTokens = (this.ncTokens || []).concat([
|
|
||||||
nc.on(nc.ns.client.game.events.destroy, this.destroy, this)
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GameObject.prototype.getBodyDef = function() {
|
GameObject.prototype.getBodyDef = function() {
|
||||||
|
|
@ -26,14 +20,11 @@ function (Box2D, Exception, Assert, nc) {
|
||||||
};
|
};
|
||||||
|
|
||||||
GameObject.prototype.destroy = function() {
|
GameObject.prototype.destroy = function() {
|
||||||
|
|
||||||
if(this.body instanceof Box2D.Dynamics.b2Body) {
|
if(this.body instanceof Box2D.Dynamics.b2Body) {
|
||||||
this.body.GetWorld().DestroyBody(this.body);
|
this.body.GetWorld().DestroyBody(this.body);
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("can not destroy body");
|
throw new Exception("can not destroy body");
|
||||||
}
|
}
|
||||||
|
|
||||||
nc.off(this.ncTokens);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GameObject.prototype.getBody = function() {
|
GameObject.prototype.getBody = function() {
|
||||||
|
|
@ -44,20 +35,6 @@ function (Box2D, Exception, Assert, nc) {
|
||||||
return this.body.GetPosition().Copy();
|
return this.body.GetPosition().Copy();
|
||||||
};
|
};
|
||||||
|
|
||||||
GameObject.prototype.setUpdateData = function(update) {
|
|
||||||
|
|
||||||
Assert.number(update.p.x, update.p.y);
|
|
||||||
Assert.number(update.a);
|
|
||||||
Assert.number(update.lv.x, update.lv.y);
|
|
||||||
Assert.number(update.av);
|
|
||||||
|
|
||||||
this.body.SetAwake(true);
|
|
||||||
this.body.SetPosition(update.p);
|
|
||||||
this.body.SetAngle(update.a);
|
|
||||||
this.body.SetLinearVelocity(update.lv);
|
|
||||||
this.body.SetAngularVelocity(update.av);
|
|
||||||
};
|
|
||||||
|
|
||||||
return GameObject;
|
return GameObject;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
define([
|
define([
|
||||||
"Game/" + GLOBALS.context + "/GameObjects/GameObject",
|
"Game/" + GLOBALS.context + "/GameObjects/GameObject",
|
||||||
"Lib/Vendor/Box2D",
|
"Lib/Vendor/Box2D",
|
||||||
"Lib/Utilities/OptionsHelper",
|
"Lib/Utilities/Options",
|
||||||
"Game/Config/Settings",
|
"Game/Config/Settings",
|
||||||
"Lib/Utilities/Exception",
|
"Lib/Utilities/Exception",
|
||||||
"Lib/Utilities/NotificationCenter",
|
"Lib/Utilities/NotificationCenter",
|
||||||
"Lib/Utilities/Assert"
|
"Lib/Utilities/Assert"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, Box2D, optionsHelper, Settings, Exception, nc, Assert) {
|
function (Parent, Box2D, Options, Settings, Exception, Nc, Assert) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -26,7 +26,7 @@ function (Parent, Box2D, optionsHelper, Settings, Exception, nc, Assert) {
|
||||||
y: parseFloat(options.y)
|
y: parseFloat(options.y)
|
||||||
};
|
};
|
||||||
|
|
||||||
this.options = optionsHelper.merge(floatOptions, options);
|
this.options = Options.merge(floatOptions, options);
|
||||||
|
|
||||||
if(!this.options.category) {
|
if(!this.options.category) {
|
||||||
// FIXME add more validation
|
// FIXME add more validation
|
||||||
|
|
@ -41,7 +41,7 @@ function (Parent, Box2D, optionsHelper, Settings, Exception, nc, Assert) {
|
||||||
this.body.SetBullet(true);
|
this.body.SetBullet(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
nc.trigger(nc.ns.core.game.worldUpdateObjects.add, this);
|
Nc.trigger(Nc.ns.core.game.gameObject.add, "animated", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Item.prototype = Object.create(Parent.prototype);
|
Item.prototype = Object.create(Parent.prototype);
|
||||||
|
|
@ -128,8 +128,8 @@ function (Parent, Box2D, optionsHelper, Settings, Exception, nc, Assert) {
|
||||||
handPosition.y
|
handPosition.y
|
||||||
);
|
);
|
||||||
this.body.SetPosition(position);
|
this.body.SetPosition(position);
|
||||||
this.body.SetAngle((this.options.grabAngle || 0.0) * direction);
|
|
||||||
this.flip(direction);
|
this.flip(direction);
|
||||||
|
this.body.SetAngle((this.options.grabAngle || 0) * direction);
|
||||||
};
|
};
|
||||||
|
|
||||||
Item.prototype.getGrabPoint = function() {
|
Item.prototype.getGrabPoint = function() {
|
||||||
|
|
@ -158,7 +158,7 @@ function (Parent, Box2D, optionsHelper, Settings, Exception, nc, Assert) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Item.prototype.destroy = function() {
|
Item.prototype.destroy = function() {
|
||||||
nc.trigger(nc.ns.core.game.worldUpdateObjects.remove, this);
|
Nc.trigger(Nc.ns.core.game.gameObject.remove, "animated", this);
|
||||||
Parent.prototype.destroy.call(this);
|
Parent.prototype.destroy.call(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,11 @@ define([
|
||||||
"Game/Config/Settings",
|
"Game/Config/Settings",
|
||||||
"Lib/Utilities/NotificationCenter",
|
"Lib/Utilities/NotificationCenter",
|
||||||
"Lib/Utilities/Assert",
|
"Lib/Utilities/Assert",
|
||||||
"Lib/Utilities/OptionsHelper",
|
"Lib/Utilities/Options",
|
||||||
"Game/Config/ItemSettings",
|
"Game/Config/ItemSettings",
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, Box2D, Settings, nc, Assert, optionsHelper, ItemSettings) {
|
function (Parent, Box2D, Settings, Nc, Assert, Options, ItemSettings) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -96,8 +96,8 @@ function (Parent, Box2D, Settings, nc, Assert, optionsHelper, ItemSettings) {
|
||||||
|
|
||||||
|
|
||||||
// FIXME
|
// FIXME
|
||||||
var ragdollOptions = optionsHelper.merge(ItemSettings.RagDoll, ItemSettings.Default);
|
var ragdollOptions = Options.merge(ItemSettings.RagDoll, ItemSettings.Default);
|
||||||
options = optionsHelper.merge(options, ragdollOptions);
|
options = Options.merge(options, ragdollOptions);
|
||||||
Parent.call(this, physicsEngine, uid, options);
|
Parent.call(this, physicsEngine, uid, options);
|
||||||
//this.createSensor();
|
//this.createSensor();
|
||||||
|
|
||||||
|
|
@ -352,7 +352,7 @@ function (Parent, Box2D, Settings, nc, Assert, optionsHelper, ItemSettings) {
|
||||||
chestPosition.y + this.options.limbs.head.y / Settings.RATIO
|
chestPosition.y + this.options.limbs.head.y / Settings.RATIO
|
||||||
);
|
);
|
||||||
this.limbs.head.SetPosition(position);
|
this.limbs.head.SetPosition(position);
|
||||||
this.limbs.head.SetAngle((this.options.grabAngle || 0.0) * direction);
|
this.limbs.head.SetAngle((this.options.grabAngle || 0) * direction);
|
||||||
};
|
};
|
||||||
|
|
||||||
RagDoll.prototype.throw = function(options, carrierVelocity) {
|
RagDoll.prototype.throw = function(options, carrierVelocity) {
|
||||||
|
|
@ -378,6 +378,7 @@ function (Parent, Box2D, Settings, nc, Assert, optionsHelper, ItemSettings) {
|
||||||
|
|
||||||
RagDoll.prototype.destroy = function() {
|
RagDoll.prototype.destroy = function() {
|
||||||
|
|
||||||
|
Nc.trigger(Nc.ns.core.game.gameObject.remove, "animated", this);
|
||||||
var world = this.body.GetWorld();
|
var world = this.body.GetWorld();
|
||||||
|
|
||||||
for (var name in this.limbs) {
|
for (var name in this.limbs) {
|
||||||
|
|
|
||||||
1412
app/Game/Core/GameObjects/Items/Rube.js
Normal file
|
|
@ -1,223 +0,0 @@
|
||||||
define([
|
|
||||||
"Game/" + GLOBALS.context + "/GameObjects/Item",
|
|
||||||
"Lib/Vendor/RubeLoader",
|
|
||||||
"Lib/Vendor/Box2D",
|
|
||||||
"Game/Config/Settings",
|
|
||||||
"Lib/Utilities/Assert",
|
|
||||||
"Lib/Utilities/NotificationCenter",
|
|
||||||
"Lib/Utilities/Matrix",
|
|
||||||
"json!Game/Asset/RubeDoll.json" // using requirejs json loader plugin
|
|
||||||
],
|
|
||||||
|
|
||||||
function (Parent, RubeLoader, Box2D, Settings, Assert, nc, Matrix, RubeDollJson) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function RubeDoll(physicsEngine, uid, options) {
|
|
||||||
Assert.number(options.x, options.y);
|
|
||||||
|
|
||||||
this.rubeLoader = null;
|
|
||||||
this.body = null;
|
|
||||||
this.limbs = {};
|
|
||||||
this.joints = null;
|
|
||||||
this.limits = [];
|
|
||||||
|
|
||||||
var chest = null;
|
|
||||||
this.rubeLoader = new RubeLoader(RubeDollJson, physicsEngine.getWorldForRubeLoader());
|
|
||||||
|
|
||||||
this.loadRubeDollFromScene(options);
|
|
||||||
|
|
||||||
Parent.call(this, physicsEngine, uid, options);
|
|
||||||
physicsEngine.destroyBody(this.body);
|
|
||||||
this.body = this.limbs.chest;
|
|
||||||
delete this.limbs.chest;
|
|
||||||
|
|
||||||
this.body.SetUserData(this);
|
|
||||||
|
|
||||||
this.flip(options.direction || 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
RubeDoll.prototype = Object.create(Parent.prototype);
|
|
||||||
|
|
||||||
RubeDoll.prototype.loadRubeDollFromScene = function(options) {
|
|
||||||
var scene = this.rubeLoader.getScene();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (var i in scene.bodies) {
|
|
||||||
var body = scene.bodies[i];
|
|
||||||
var position = body.GetPosition().Copy();
|
|
||||||
position.Add(new Box2D.Common.Math.b2Vec2(
|
|
||||||
options.x / Settings.RATIO,
|
|
||||||
options.y / Settings.RATIO
|
|
||||||
));
|
|
||||||
body.SetPosition(position);
|
|
||||||
this.limbs[body.name] = body;
|
|
||||||
|
|
||||||
// code snipped possibly needed for filtering between doll and rubedoll while holding
|
|
||||||
//var filterData = new Box2D.Dynamics.b2FilterData();
|
|
||||||
//filterData.groupIndex = -66;
|
|
||||||
//if(body.name != "head" && body.name != "chest") {
|
|
||||||
// for (var fixture = body.GetFixtureList(); fixture; fixture = fixture.GetNext()) {
|
|
||||||
// fixture.SetFilterData(filterData);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.joints = scene.joints;
|
|
||||||
|
|
||||||
var count = 0;
|
|
||||||
for (var i in this.joints) {
|
|
||||||
this.limits[i] = {
|
|
||||||
lower: this.joints[i].GetLowerLimit(),
|
|
||||||
upper: this.joints[i].GetUpperLimit(),
|
|
||||||
};
|
|
||||||
/*
|
|
||||||
this.joints[i].EnableLimit(false);
|
|
||||||
|
|
||||||
if(count < 4 && this.joints[i] instanceof Box2D.Dynamics.Joints.b2RevoluteJoint) {
|
|
||||||
console.log(i);
|
|
||||||
} else {
|
|
||||||
body.GetWorld().DestroyJoint(this.joints[i]);
|
|
||||||
}
|
|
||||||
count++;
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
RubeDoll.prototype.getFixtureDef = function() {
|
|
||||||
var fixtureDef = new Box2D.Dynamics.b2FixtureDef();
|
|
||||||
fixtureDef.shape = new Box2D.Collision.Shapes.b2CircleShape();
|
|
||||||
return fixtureDef;
|
|
||||||
};
|
|
||||||
|
|
||||||
RubeDoll.prototype.flip = function(direction) {
|
|
||||||
var oldFlipDirection = this.flipDirection;
|
|
||||||
|
|
||||||
Parent.prototype.flip.call(this, direction);
|
|
||||||
|
|
||||||
if(oldFlipDirection != direction) {
|
|
||||||
|
|
||||||
for (var i in this.joints) {
|
|
||||||
var joint = this.joints[i];
|
|
||||||
var limits = this.limits[i];
|
|
||||||
|
|
||||||
if (joint instanceof Box2D.Dynamics.Joints.b2RevoluteJoint) {
|
|
||||||
|
|
||||||
if (direction > 0) {
|
|
||||||
joint.SetLimits(limits.lower, limits.upper);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
var a1 = limits.lower * -1;
|
|
||||||
var a2 = limits.upper * -1;
|
|
||||||
|
|
||||||
if (a2 > a1) {
|
|
||||||
joint.SetLimits(a1, a2);
|
|
||||||
} else {
|
|
||||||
joint.SetLimits(a2, a1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// joint.SetAngle(joint.GetAngle() * -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
RubeDoll.prototype.reposition = function(handPosition, direction) {
|
|
||||||
var oldPosition = this.getPosition();
|
|
||||||
var oldAngle = this.body.GetAngle();
|
|
||||||
var oldDirection = this.flipDirection;
|
|
||||||
|
|
||||||
// calls flip() at the end of Parent reposition()
|
|
||||||
Parent.prototype.reposition.call(this, handPosition, direction);
|
|
||||||
|
|
||||||
var differenceAngle = oldAngle - this.body.GetAngle();
|
|
||||||
|
|
||||||
//this.body.SetLinearVelocity(new Box2D.Common.Math.b2Vec2(0, 0));
|
|
||||||
|
|
||||||
var offset = Box2D.Common.Math.b2Math.SubtractVV(this.getPosition(), oldPosition);
|
|
||||||
var grabAngle = (this.options.grabAngle || 0.001);
|
|
||||||
|
|
||||||
for(var key in this.limbs) {
|
|
||||||
var limb = this.limbs[key];
|
|
||||||
|
|
||||||
// Setting position offset first (floor to hand)
|
|
||||||
var position = limb.GetPosition().Copy();
|
|
||||||
position.Add(offset);
|
|
||||||
limb.SetPosition(position);
|
|
||||||
|
|
||||||
// grabing local point to "rotate" around (x, y position transform only)
|
|
||||||
var localPoint = this.body.GetLocalPoint(limb.GetPosition().Copy());
|
|
||||||
|
|
||||||
// create rotation matrix from chest rotation difference
|
|
||||||
var mat = Box2D.Common.Math.b2Mat22.FromAngle(differenceAngle);
|
|
||||||
|
|
||||||
// matrix multiplication with local limb position
|
|
||||||
position = Box2D.Common.Math.b2Math.MulTMV(mat, localPoint);
|
|
||||||
|
|
||||||
// translating back to global position
|
|
||||||
var globalPoint = this.body.GetWorldPoint(position);
|
|
||||||
limb.SetPosition(globalPoint);
|
|
||||||
|
|
||||||
// relative limb rotating by chest rotation difference
|
|
||||||
var d = (oldDirection == direction) ? -1 : 1;
|
|
||||||
limb.SetAngle((limb.GetAngle() - differenceAngle) * d);
|
|
||||||
|
|
||||||
//limb.SetType(Box2D.Dynamics.b2Body.b2_staticBody);
|
|
||||||
//limb.SetLinearVelocity(new Box2D.Common.Math.b2Vec2(0, 0));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
RubeDoll.prototype.setVelocities = function(options) {
|
|
||||||
Assert.number(options.linearVelocity.x, options.linearVelocity.y);
|
|
||||||
Assert.number(options.angularVelocity);
|
|
||||||
|
|
||||||
this.body.SetLinearVelocity(options.linearVelocity);
|
|
||||||
this.body.SetAngularVelocity(options.angularVelocity);
|
|
||||||
for(var name in this.limbs) {
|
|
||||||
this.limbs[name].SetLinearVelocity(options.linearVelocity);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
RubeDoll.prototype.getPosition = function() {
|
|
||||||
return this.body.GetPosition().Copy();
|
|
||||||
};
|
|
||||||
|
|
||||||
RubeDoll.prototype.getHeadPosition = function() {
|
|
||||||
return this.limbs.head.GetPosition().Copy();
|
|
||||||
};
|
|
||||||
|
|
||||||
RubeDoll.prototype.setUpdateData = function(update) {
|
|
||||||
|
|
||||||
Parent.prototype.setUpdateData.call(this, update);
|
|
||||||
|
|
||||||
/*
|
|
||||||
for(var name in update.limbs) {
|
|
||||||
Assert.number(update.limbs[name].p.x, update.limbs[name].p.y);
|
|
||||||
Assert.number(update.limbs[name].a);
|
|
||||||
Assert.number(update.limbs[name].lv.x, update.limbs[name].lv.y);
|
|
||||||
Assert.number(update.limbs[name].av);
|
|
||||||
|
|
||||||
this.limbs[name].SetAwake(true);
|
|
||||||
this.limbs[name].SetPosition(update.limbs[name].p);
|
|
||||||
this.limbs[name].SetAngle(update.limbs[name].a);
|
|
||||||
this.limbs[name].SetLinearVelocity(update.limbs[name].lv);
|
|
||||||
this.limbs[name].SetAngularVelocity(update.limbs[name].av);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
RubeDoll.prototype.destroy = function() {
|
|
||||||
|
|
||||||
var world = this.body.GetWorld();
|
|
||||||
|
|
||||||
for (var name in this.limbs) {
|
|
||||||
world.DestroyBody(this.limbs[name]);
|
|
||||||
}
|
|
||||||
|
|
||||||
Parent.prototype.destroy.call(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
return RubeDoll;
|
|
||||||
});
|
|
||||||
|
|
@ -5,96 +5,6 @@ define([
|
||||||
"Lib/Utilities/Assert"
|
"Lib/Utilities/Assert"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, Box2D, Settings, Assert) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function Skateboard(physicsEngine, uid, options) {
|
|
||||||
|
|
||||||
Parent.call(this, physicsEngine, uid, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
Skateboard.prototype = Object.create(Parent.prototype);
|
|
||||||
|
|
||||||
Skateboard.prototype.createFixture = function () {
|
|
||||||
Assert.number(this.options.width, this.options.height);
|
|
||||||
Assert.number(this.options.weight);
|
|
||||||
|
|
||||||
var deckShape = new Box2D.Collision.Shapes.b2PolygonShape();
|
|
||||||
var w = this.options.width / Settings.RATIO;
|
|
||||||
var h = 2 / Settings.RATIO;
|
|
||||||
deckShape.SetAsOrientedBox(w / 2, h / 2, new Box2D.Common.Math.b2Vec2(0, -(4.5 / Settings.RATIO)));
|
|
||||||
|
|
||||||
var fixtureDef = new Box2D.Dynamics.b2FixtureDef();
|
|
||||||
fixtureDef.shape = deckShape;
|
|
||||||
|
|
||||||
var offset = 4,
|
|
||||||
factor = 80;
|
|
||||||
var density = ((this.options.weight + offset) / this.options.width / this.options.height) * factor;
|
|
||||||
fixtureDef.density = density;
|
|
||||||
fixtureDef.friction = Settings.ITEM_FRICTION;
|
|
||||||
fixtureDef.restitution = 0.2;
|
|
||||||
fixtureDef.isSensor = false;
|
|
||||||
|
|
||||||
this.body.CreateFixture(fixtureDef);
|
|
||||||
|
|
||||||
|
|
||||||
this.addWheel(
|
|
||||||
-8,
|
|
||||||
-2.5
|
|
||||||
);
|
|
||||||
|
|
||||||
this.addWheel(
|
|
||||||
7,
|
|
||||||
-2.5
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
Skateboard.prototype.addWheel = function(x, y) {
|
|
||||||
Assert.number(x, y);
|
|
||||||
|
|
||||||
var bodyDef = new Box2D.Dynamics.b2BodyDef();
|
|
||||||
bodyDef.type = Box2D.Dynamics.b2Body.b2_dynamicBody;
|
|
||||||
bodyDef.position.x = x / Settings.RATIO;
|
|
||||||
bodyDef.position.y = y / Settings.RATIO;
|
|
||||||
bodyDef.angle = 0;
|
|
||||||
|
|
||||||
var wheelShape = new Box2D.Collision.Shapes.b2CircleShape();
|
|
||||||
wheelShape.SetRadius(2.5 / Settings.RATIO);
|
|
||||||
wheelShape.SetLocalPosition(new Box2D.Common.Math.b2Vec2(x / Settings.RATIO, y / Settings.RATIO));
|
|
||||||
|
|
||||||
|
|
||||||
var fixtureDef = new Box2D.Dynamics.b2FixtureDef();
|
|
||||||
var offset = 4,
|
|
||||||
factor = 80;
|
|
||||||
var density = ((0.1 + offset) / 3 / 3) * factor;
|
|
||||||
fixtureDef.density = density;
|
|
||||||
fixtureDef.shape = wheelShape;
|
|
||||||
fixtureDef.restitution = 0.2;
|
|
||||||
fixtureDef.isSensor = false;
|
|
||||||
fixtureDef.friction = 0.0005;
|
|
||||||
|
|
||||||
this.body.CreateFixture(fixtureDef);
|
|
||||||
};
|
|
||||||
|
|
||||||
Skateboard.prototype.flip = function(direction) {
|
|
||||||
this.flipDirection = direction;
|
|
||||||
};
|
|
||||||
|
|
||||||
return Skateboard;
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
define([
|
|
||||||
"Game/" + GLOBALS.context + "/GameObjects/Item",
|
|
||||||
"Lib/Vendor/Box2D",
|
|
||||||
"Game/Config/Settings",
|
|
||||||
"Lib/Utilities/Assert"
|
|
||||||
],
|
|
||||||
|
|
||||||
function (Parent, Box2D, Settings, Assert) {
|
function (Parent, Box2D, Settings, Assert) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
@ -207,4 +117,3 @@ function (Parent, Box2D, Settings, Assert) {
|
||||||
return Skateboard;
|
return Skateboard;
|
||||||
|
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
|
|
@ -7,7 +7,7 @@ define([
|
||||||
"Lib/Utilities/Assert"
|
"Lib/Utilities/Assert"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, Box2D, Settings, Exception, nc, Assert) {
|
function (Parent, Box2D, Settings, Exception, Nc, Assert) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -15,6 +15,8 @@ function (Parent, Box2D, Settings, Exception, nc, Assert) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
Parent.call(this, physicsEngine, uid);
|
Parent.call(this, physicsEngine, uid);
|
||||||
this.createPhysicTile(this.options);
|
this.createPhysicTile(this.options);
|
||||||
|
|
||||||
|
Nc.trigger(Nc.ns.core.game.gameObject.add, "fixed", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Tile.prototype = Object.create(Parent.prototype);
|
Tile.prototype = Object.create(Parent.prototype);
|
||||||
|
|
@ -118,6 +120,10 @@ function (Parent, Box2D, Settings, Exception, nc, Assert) {
|
||||||
return vs.push(new Box2D.Common.Math.b2Vec2(this.mkArg(m1), this.mkArg(m2)));
|
return vs.push(new Box2D.Common.Math.b2Vec2(this.mkArg(m1), this.mkArg(m2)));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Tile.prototype.destroy = function() {
|
||||||
|
Nc.trigger(Nc.ns.core.game.gameObject.remove, "fixed", this);
|
||||||
|
};
|
||||||
|
|
||||||
return Tile;
|
return Tile;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -8,9 +8,9 @@ define([
|
||||||
"Game/" + GLOBALS.context + "/GameObjects/Item",
|
"Game/" + GLOBALS.context + "/GameObjects/Item",
|
||||||
"Game/" + GLOBALS.context + "/GameObjects/Items/Skateboard",
|
"Game/" + GLOBALS.context + "/GameObjects/Items/Skateboard",
|
||||||
"Game/" + GLOBALS.context + "/GameObjects/Items/RagDoll",
|
"Game/" + GLOBALS.context + "/GameObjects/Items/RagDoll",
|
||||||
"Game/" + GLOBALS.context + "/GameObjects/Items/RubeDoll"
|
"Game/" + GLOBALS.context + "/GameObjects/Items/Rube"
|
||||||
|
|
||||||
], function (Settings, Box2D, nc, Abstract, CollisionDetector, Tile, Item, Skateboard, RagDoll, RubeDoll) {
|
], function (Settings, Box2D, Nc, Abstract, CollisionDetector, Tile, Item, Skateboard, RagDoll, Rube) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -25,7 +25,6 @@ define([
|
||||||
|
|
||||||
Level.prototype.load = function (uid) {
|
Level.prototype.load = function (uid) {
|
||||||
var self = this;
|
var self = this;
|
||||||
// FIXME: check if theres a security hazard here (user injected path)
|
|
||||||
var path = Settings.MAPS_PATH + uid + ".json";
|
var path = Settings.MAPS_PATH + uid + ".json";
|
||||||
this.loadLevelDataFromPath(path, function (levelData) {
|
this.loadLevelDataFromPath(path, function (levelData) {
|
||||||
self.setup(levelData);
|
self.setup(levelData);
|
||||||
|
|
@ -34,7 +33,7 @@ define([
|
||||||
|
|
||||||
Level.prototype.setup = function(levelData) { // jshint unused:false
|
Level.prototype.setup = function(levelData) { // jshint unused:false
|
||||||
this.isLoaded = true;
|
this.isLoaded = true;
|
||||||
nc.trigger(nc.ns.core.game.events.level.loaded);
|
Nc.trigger(Nc.ns.core.game.events.level.loaded);
|
||||||
};
|
};
|
||||||
|
|
||||||
Level.prototype.createItems = function(options) {
|
Level.prototype.createItems = function(options) {
|
||||||
|
|
@ -47,12 +46,12 @@ define([
|
||||||
Level.prototype.createItem = function(uid, options) {
|
Level.prototype.createItem = function(uid, options) {
|
||||||
|
|
||||||
switch(options.type) {
|
switch(options.type) {
|
||||||
case "skateboard":
|
//case "skateboard":
|
||||||
return new Skateboard(this.engine, uid, options);
|
// return new Skateboard(this.engine, uid, options);
|
||||||
case "ragdoll":
|
case "ragdoll":
|
||||||
return new RagDoll(this.engine, uid, options);
|
return new RagDoll(this.engine, uid, options);
|
||||||
case "rubedoll":
|
case "rube":
|
||||||
return new RubeDoll(this.engine, uid, options);
|
return new Rube(this.engine, uid, options);
|
||||||
default:
|
default:
|
||||||
return new Item(this.engine, uid, options);
|
return new Item(this.engine, uid, options);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ define([
|
||||||
"Game/Config/Settings",
|
"Game/Config/Settings",
|
||||||
"Game/Config/ItemSettings",
|
"Game/Config/ItemSettings",
|
||||||
"Lib/Vendor/Box2D",
|
"Lib/Vendor/Box2D",
|
||||||
"Lib/Utilities/OptionsHelper",
|
"Lib/Utilities/Options",
|
||||||
"Lib/Utilities/Exception",
|
"Lib/Utilities/Exception",
|
||||||
"Lib/Utilities/NotificationCenter",
|
"Lib/Utilities/NotificationCenter",
|
||||||
"Lib/Utilities/Assert",
|
"Lib/Utilities/Assert",
|
||||||
|
|
@ -13,7 +13,7 @@ define([
|
||||||
"Game/" + GLOBALS.context + "/GameObjects/Item",
|
"Game/" + GLOBALS.context + "/GameObjects/Item",
|
||||||
"Game/" + GLOBALS.context + "/GameObjects/Items/Skateboard",
|
"Game/" + GLOBALS.context + "/GameObjects/Items/Skateboard",
|
||||||
|
|
||||||
], function (Parent, Settings, ItemSettings, Box2D, optionsHelper, Exception, nc, Assert, AbstractLayer, CollisionDetector, Tile, Item, Skateboard) {
|
], function (Parent, Settings, ItemSettings, Box2D, Options, Exception, Nc, Assert, AbstractLayer, CollisionDetector, Tile, Item, Skateboard) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -187,7 +187,7 @@ define([
|
||||||
throw new Exception("Item name (" + name + ") cannot be found in item list");
|
throw new Exception("Item name (" + name + ") cannot be found in item list");
|
||||||
}
|
}
|
||||||
|
|
||||||
return optionsHelper.merge(ItemSettings[name], ItemSettings.Default);
|
return Options.merge(ItemSettings[name], ItemSettings.Default);
|
||||||
};
|
};
|
||||||
|
|
||||||
TiledLevel.prototype.getTileImagePath = function(gid) {
|
TiledLevel.prototype.getTileImagePath = function(gid) {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ define([
|
||||||
"Lib/Utilities/NotificationCenter"
|
"Lib/Utilities/NotificationCenter"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Settings, Box2D, CollisionDetector, nc) {
|
function (Settings, Box2D, CollisionDetector, Nc) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -15,30 +15,33 @@ function (Settings, Box2D, CollisionDetector, nc) {
|
||||||
Settings.BOX2D_ALLOW_SLEEP
|
Settings.BOX2D_ALLOW_SLEEP
|
||||||
);
|
);
|
||||||
this.world.SetWarmStarting(true);
|
this.world.SetWarmStarting(true);
|
||||||
|
this.ground = null;
|
||||||
this.lastStep = Date.now();
|
this.lastStep = Date.now();
|
||||||
this.worldQueue = [];
|
this.worldQueue = [];
|
||||||
|
|
||||||
this.ncTokens = [
|
this.ncTokens = [
|
||||||
nc.on(nc.ns.channel.engine.worldQueue.add, this.addToWorldQueue, this)
|
Nc.on(Nc.ns.channel.engine.worldQueue.add, this.addToWorldQueue, this)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Engine.prototype.getWorld = function () {
|
||||||
|
return this.world;
|
||||||
|
}
|
||||||
|
|
||||||
|
Engine.prototype.getGround = function () {
|
||||||
|
return this.ground;
|
||||||
|
}
|
||||||
|
|
||||||
Engine.prototype.setCollisionDetector = function () {
|
Engine.prototype.setCollisionDetector = function () {
|
||||||
|
|
||||||
var detector = new CollisionDetector();
|
var detector = new CollisionDetector();
|
||||||
this.world.SetContactListener(detector.getListener());
|
this.world.SetContactListener(detector.getListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
Engine.prototype.getWorldForRubeLoader = function() {
|
|
||||||
return this.world;
|
|
||||||
};
|
|
||||||
|
|
||||||
Engine.prototype.createBody = function (bodyDef) {
|
Engine.prototype.createBody = function (bodyDef) {
|
||||||
return this.world.CreateBody(bodyDef);
|
var body = this.world.CreateBody(bodyDef);
|
||||||
}
|
if(!this.ground) this.ground = body;
|
||||||
|
return body;
|
||||||
Engine.prototype.destroyBody = function (body) {
|
|
||||||
return this.world.DestroyBody(body);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Engine.prototype.addToWorldQueue = function(callback) {
|
Engine.prototype.addToWorldQueue = function(callback) {
|
||||||
|
|
@ -62,8 +65,8 @@ function (Settings, Box2D, CollisionDetector, nc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Engine.prototype.destroy = function() {
|
Engine.prototype.destroy = function() {
|
||||||
nc.offAll(this.ncTokens);
|
|
||||||
delete this.world;
|
delete this.world;
|
||||||
|
Nc.offAll(this.ncTokens);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,17 @@
|
||||||
define([
|
define([
|
||||||
"Game/" + GLOBALS.context + "/GameObjects/Doll",
|
"Game/" + GLOBALS.context + "/GameObjects/Doll",
|
||||||
"Game/" + GLOBALS.context + "/Control/PlayerController",
|
|
||||||
"Game/Config/Settings",
|
"Game/Config/Settings",
|
||||||
"Lib/Utilities/NotificationCenter",
|
"Lib/Utilities/NotificationCenter",
|
||||||
"Lib/Utilities/Exception",
|
"Lib/Utilities/Exception",
|
||||||
"Lib/Utilities/ColorConverter",
|
|
||||||
"Game/" + GLOBALS.context + "/GameObjects/SpectatorDoll",
|
"Game/" + GLOBALS.context + "/GameObjects/SpectatorDoll",
|
||||||
"Game/" + GLOBALS.context + "/GameObjects/Items/RubeDoll"
|
"Game/" + GLOBALS.context + "/GameObjects/Items/RagDoll"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Doll, PlayerController, Settings, nc, Exception, ColorConverter, SpectatorDoll, RubeDoll) {
|
function (Doll, Settings, Nc, Exception, SpectatorDoll, RagDoll) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function Player (id, physicsEngine, user, revealedGameController) {
|
function Player (id, physicsEngine, user) {
|
||||||
this.stats = {
|
this.stats = {
|
||||||
health: 100,
|
health: 100,
|
||||||
deaths: 0,
|
deaths: 0,
|
||||||
|
|
@ -22,20 +20,15 @@ function (Doll, PlayerController, Settings, nc, Exception, ColorConverter, Spect
|
||||||
|
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.physicsEngine = physicsEngine;
|
this.physicsEngine = physicsEngine;
|
||||||
this.playerController = null; // pre-initialise with null, because client/players don't get one
|
this.playerController = null;
|
||||||
this.doll;
|
this.doll;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.spawned = false;
|
this.spawned = false;
|
||||||
this.holdingItem = null;
|
this.holdingItem = null;
|
||||||
this.inBetweenRounds = true;
|
|
||||||
this.spectatorDoll = new SpectatorDoll(this.physicsEngine, "spectatorDoll-" + this.id, this);
|
this.spectatorDoll = new SpectatorDoll(this.physicsEngine, "spectatorDoll-" + this.id, this);
|
||||||
this.revealedGameController = revealedGameController;
|
|
||||||
this.modifierActivated = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player.prototype.getNickname = function() {
|
Nc.trigger(Nc.ns.core.game.gameObject.add, 'animated', this);
|
||||||
return this.user.options.nickname;
|
}
|
||||||
};
|
|
||||||
|
|
||||||
Player.prototype.getActiveDoll = function() {
|
Player.prototype.getActiveDoll = function() {
|
||||||
if(this.spawned) {
|
if(this.spawned) {
|
||||||
|
|
@ -67,7 +60,7 @@ function (Doll, PlayerController, Settings, nc, Exception, ColorConverter, Spect
|
||||||
|
|
||||||
Player.prototype.move = function (direction) {
|
Player.prototype.move = function (direction) {
|
||||||
if(!this.spawned) return false;
|
if(!this.spawned) return false;
|
||||||
this.doll.move(direction, this.modifierActivated);
|
this.doll.move(direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
Player.prototype.stop = function () {
|
Player.prototype.stop = function () {
|
||||||
|
|
@ -91,16 +84,6 @@ function (Doll, PlayerController, Settings, nc, Exception, ColorConverter, Spect
|
||||||
this.doll.lookAt(x, y);
|
this.doll.lookAt(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
Player.prototype.activateModifier = function () {
|
|
||||||
if(!this.spawned) return false;
|
|
||||||
this.modifierActivated = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player.prototype.deactivateModifier = function () {
|
|
||||||
if(!this.spawned) return false;
|
|
||||||
this.modifierActivated = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player.prototype.grab = function(item) {
|
Player.prototype.grab = function(item) {
|
||||||
if(!this.spawned) return false;
|
if(!this.spawned) return false;
|
||||||
this.doll.grab(item);
|
this.doll.grab(item);
|
||||||
|
|
@ -129,10 +112,6 @@ function (Doll, PlayerController, Settings, nc, Exception, ColorConverter, Spect
|
||||||
}
|
}
|
||||||
|
|
||||||
// prepare for creating the ragdoll
|
// prepare for creating the ragdoll
|
||||||
|
|
||||||
var converter = new ColorConverter();
|
|
||||||
var primaryColor = converter.getColorByName(this.getNickname());
|
|
||||||
|
|
||||||
var options = {
|
var options = {
|
||||||
x: this.getPosition().x * Settings.RATIO,
|
x: this.getPosition().x * Settings.RATIO,
|
||||||
y: this.getPosition().y * Settings.RATIO,
|
y: this.getPosition().y * Settings.RATIO,
|
||||||
|
|
@ -141,23 +120,21 @@ function (Doll, PlayerController, Settings, nc, Exception, ColorConverter, Spect
|
||||||
image: "chest.png",
|
image: "chest.png",
|
||||||
name: "RagDoll",
|
name: "RagDoll",
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
type: "rubedoll",
|
type: "ragdoll",
|
||||||
weight: 3,
|
weight: 3,
|
||||||
width: 5,
|
width: 5,
|
||||||
height: 12,
|
height: 12
|
||||||
primaryColor: primaryColor,
|
|
||||||
direction: this.doll.lookDirection
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var rubeDoll = new RubeDoll(this.physicsEngine, "rubeDoll-" + this.id + "-" + ragDollId, options);
|
var ragDoll = new RagDoll(this.physicsEngine, "ragDoll-" + this.id + "-" + ragDollId, options);
|
||||||
rubeDoll.setVelocities(this.doll.getVelocities());
|
ragDoll.setVelocities(this.doll.getVelocities());
|
||||||
|
|
||||||
this.spawned = false;
|
this.spawned = false;
|
||||||
|
|
||||||
this.doll.destroy();
|
this.doll.destroy();
|
||||||
this.doll = null;
|
this.doll = null;
|
||||||
|
|
||||||
this.ragDoll = rubeDoll;
|
this.ragDoll = ragDoll;
|
||||||
};
|
};
|
||||||
|
|
||||||
Player.prototype.update = function () {
|
Player.prototype.update = function () {
|
||||||
|
|
@ -173,7 +150,7 @@ function (Doll, PlayerController, Settings, nc, Exception, ColorConverter, Spect
|
||||||
|
|
||||||
Player.prototype.destroy = function () {
|
Player.prototype.destroy = function () {
|
||||||
|
|
||||||
// FIXME add destroy nc hook
|
Nc.trigger(Nc.ns.core.game.gameObject.remove, 'animated', this);
|
||||||
|
|
||||||
if(this.holdingItem) {
|
if(this.holdingItem) {
|
||||||
var options = {
|
var options = {
|
||||||
|
|
@ -186,8 +163,6 @@ function (Doll, PlayerController, Settings, nc, Exception, ColorConverter, Spect
|
||||||
|
|
||||||
this.spectatorDoll.destroy();
|
this.spectatorDoll.destroy();
|
||||||
|
|
||||||
// doll destoys itself at the end cause its a gameobject
|
|
||||||
// but on userLeft, the player has to destroy it.
|
|
||||||
if(this.doll) {
|
if(this.doll) {
|
||||||
this.doll.destroy();
|
this.doll.destroy();
|
||||||
}
|
}
|
||||||
|
|
@ -197,13 +172,9 @@ function (Doll, PlayerController, Settings, nc, Exception, ColorConverter, Spect
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Player.prototype.setInBetweenRounds = function(inBetweenRounds) {
|
Player.prototype.setPlayerController = function(playerController) {
|
||||||
this.inBetweenRounds = inBetweenRounds;
|
this.playerController = playerController;
|
||||||
};
|
}
|
||||||
|
|
||||||
Player.prototype.isInBetweenRounds = function() {
|
|
||||||
return this.inBetweenRounds;
|
|
||||||
};
|
|
||||||
|
|
||||||
return Player;
|
return Player;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,334 +0,0 @@
|
||||||
define([
|
|
||||||
],
|
|
||||||
|
|
||||||
/*
|
|
||||||
Stolen from Pixi V2
|
|
||||||
*/
|
|
||||||
|
|
||||||
function () {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Point object represents a location in a two-dimensional coordinate system, where x represents the horizontal axis and y represents the vertical axis.
|
|
||||||
*
|
|
||||||
* @class Point
|
|
||||||
* @constructor
|
|
||||||
* @param x {Number} position of the point on the x axis
|
|
||||||
* @param y {Number} position of the point on the y axis
|
|
||||||
*/
|
|
||||||
var Point = function(x, y)
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @property x
|
|
||||||
* @type Number
|
|
||||||
* @default 0
|
|
||||||
*/
|
|
||||||
this.x = x || 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @property y
|
|
||||||
* @type Number
|
|
||||||
* @default 0
|
|
||||||
*/
|
|
||||||
this.y = y || 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a clone of this point
|
|
||||||
*
|
|
||||||
* @method clone
|
|
||||||
* @return {Point} a copy of the point
|
|
||||||
*/
|
|
||||||
Point.prototype.clone = function()
|
|
||||||
{
|
|
||||||
return new Point(this.x, this.y);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the point to a new x and y position.
|
|
||||||
* If y is omitted, both x and y will be set to x.
|
|
||||||
*
|
|
||||||
* @method set
|
|
||||||
* @param [x=0] {Number} position of the point on the x axis
|
|
||||||
* @param [y=0] {Number} position of the point on the y axis
|
|
||||||
*/
|
|
||||||
Point.prototype.set = function(x, y)
|
|
||||||
{
|
|
||||||
this.x = x || 0;
|
|
||||||
this.y = y || ( (y !== 0) ? this.x : 0 ) ;
|
|
||||||
};
|
|
||||||
|
|
||||||
// constructor
|
|
||||||
Point.prototype.constructor = Point;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Matrix class is now an object, which makes it a lot faster,
|
|
||||||
* here is a representation of it :
|
|
||||||
* | a | b | tx|
|
|
||||||
* | c | d | ty|
|
|
||||||
* | 0 | 0 | 1 |
|
|
||||||
*
|
|
||||||
* @class Matrix
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
var Matrix = function()
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @property a
|
|
||||||
* @type Number
|
|
||||||
* @default 1
|
|
||||||
*/
|
|
||||||
this.a = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @property b
|
|
||||||
* @type Number
|
|
||||||
* @default 0
|
|
||||||
*/
|
|
||||||
this.b = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @property c
|
|
||||||
* @type Number
|
|
||||||
* @default 0
|
|
||||||
*/
|
|
||||||
this.c = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @property d
|
|
||||||
* @type Number
|
|
||||||
* @default 1
|
|
||||||
*/
|
|
||||||
this.d = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @property tx
|
|
||||||
* @type Number
|
|
||||||
* @default 0
|
|
||||||
*/
|
|
||||||
this.tx = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @property ty
|
|
||||||
* @type Number
|
|
||||||
* @default 0
|
|
||||||
*/
|
|
||||||
this.ty = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a Matrix object based on the given array. The Element to Matrix mapping order is as follows:
|
|
||||||
*
|
|
||||||
* a = array[0]
|
|
||||||
* b = array[1]
|
|
||||||
* c = array[3]
|
|
||||||
* d = array[4]
|
|
||||||
* tx = array[2]
|
|
||||||
* ty = array[5]
|
|
||||||
*
|
|
||||||
* @method fromArray
|
|
||||||
* @param array {Array} The array that the matrix will be populated from.
|
|
||||||
*/
|
|
||||||
Matrix.prototype.fromArray = function(array)
|
|
||||||
{
|
|
||||||
this.a = array[0];
|
|
||||||
this.b = array[1];
|
|
||||||
this.c = array[3];
|
|
||||||
this.d = array[4];
|
|
||||||
this.tx = array[2];
|
|
||||||
this.ty = array[5];
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an array from the current Matrix object.
|
|
||||||
*
|
|
||||||
* @method toArray
|
|
||||||
* @param transpose {Boolean} Whether we need to transpose the matrix or not
|
|
||||||
* @return {Array} the newly created array which contains the matrix
|
|
||||||
*/
|
|
||||||
Matrix.prototype.toArray = function(transpose)
|
|
||||||
{
|
|
||||||
if(!this.array) this.array = new Float32Array(9);
|
|
||||||
var array = this.array;
|
|
||||||
|
|
||||||
if(transpose)
|
|
||||||
{
|
|
||||||
array[0] = this.a;
|
|
||||||
array[1] = this.b;
|
|
||||||
array[2] = 0;
|
|
||||||
array[3] = this.c;
|
|
||||||
array[4] = this.d;
|
|
||||||
array[5] = 0;
|
|
||||||
array[6] = this.tx;
|
|
||||||
array[7] = this.ty;
|
|
||||||
array[8] = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
array[0] = this.a;
|
|
||||||
array[1] = this.c;
|
|
||||||
array[2] = this.tx;
|
|
||||||
array[3] = this.b;
|
|
||||||
array[4] = this.d;
|
|
||||||
array[5] = this.ty;
|
|
||||||
array[6] = 0;
|
|
||||||
array[7] = 0;
|
|
||||||
array[8] = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return array;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a new position with the current transformation applied.
|
|
||||||
* Can be used to go from a child's coordinate space to the world coordinate space. (e.g. rendering)
|
|
||||||
*
|
|
||||||
* @method apply
|
|
||||||
* @param pos {Point} The origin
|
|
||||||
* @param [newPos] {Point} The point that the new position is assigned to (allowed to be same as input)
|
|
||||||
* @return {Point} The new point, transformed through this matrix
|
|
||||||
*/
|
|
||||||
Matrix.prototype.apply = function(pos, newPos)
|
|
||||||
{
|
|
||||||
newPos = newPos || new Point();
|
|
||||||
|
|
||||||
newPos.x = this.a * pos.x + this.c * pos.y + this.tx;
|
|
||||||
newPos.y = this.b * pos.x + this.d * pos.y + this.ty;
|
|
||||||
|
|
||||||
return newPos;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a new position with the inverse of the current transformation applied.
|
|
||||||
* Can be used to go from the world coordinate space to a child's coordinate space. (e.g. input)
|
|
||||||
*
|
|
||||||
* @method applyInverse
|
|
||||||
* @param pos {Point} The origin
|
|
||||||
* @param [newPos] {Point} The point that the new position is assigned to (allowed to be same as input)
|
|
||||||
* @return {Point} The new point, inverse-transformed through this matrix
|
|
||||||
*/
|
|
||||||
Matrix.prototype.applyInverse = function(pos, newPos)
|
|
||||||
{
|
|
||||||
newPos = newPos || new Point();
|
|
||||||
|
|
||||||
var id = 1 / (this.a * this.d + this.c * -this.b);
|
|
||||||
|
|
||||||
newPos.x = this.d * id * pos.x + -this.c * id * pos.y + (this.ty * this.c - this.tx * this.d) * id;
|
|
||||||
newPos.y = this.a * id * pos.y + -this.b * id * pos.x + (-this.ty * this.a + this.tx * this.b) * id;
|
|
||||||
|
|
||||||
return newPos;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Translates the matrix on the x and y.
|
|
||||||
*
|
|
||||||
* @method translate
|
|
||||||
* @param {Number} x
|
|
||||||
* @param {Number} y
|
|
||||||
* @return {Matrix} This matrix. Good for chaining method calls.
|
|
||||||
**/
|
|
||||||
Matrix.prototype.translate = function(x, y)
|
|
||||||
{
|
|
||||||
this.tx += x;
|
|
||||||
this.ty += y;
|
|
||||||
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Applies a scale transformation to the matrix.
|
|
||||||
*
|
|
||||||
* @method scale
|
|
||||||
* @param {Number} x The amount to scale horizontally
|
|
||||||
* @param {Number} y The amount to scale vertically
|
|
||||||
* @return {Matrix} This matrix. Good for chaining method calls.
|
|
||||||
**/
|
|
||||||
Matrix.prototype.scale = function(x, y)
|
|
||||||
{
|
|
||||||
this.a *= x;
|
|
||||||
this.d *= y;
|
|
||||||
this.c *= x;
|
|
||||||
this.b *= y;
|
|
||||||
this.tx *= x;
|
|
||||||
this.ty *= y;
|
|
||||||
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Applies a rotation transformation to the matrix.
|
|
||||||
* @method rotate
|
|
||||||
* @param {Number} angle The angle in radians.
|
|
||||||
* @return {Matrix} This matrix. Good for chaining method calls.
|
|
||||||
**/
|
|
||||||
Matrix.prototype.rotate = function(angle)
|
|
||||||
{
|
|
||||||
var cos = Math.cos( angle );
|
|
||||||
var sin = Math.sin( angle );
|
|
||||||
|
|
||||||
var a1 = this.a;
|
|
||||||
var c1 = this.c;
|
|
||||||
var tx1 = this.tx;
|
|
||||||
|
|
||||||
this.a = a1 * cos-this.b * sin;
|
|
||||||
this.b = a1 * sin+this.b * cos;
|
|
||||||
this.c = c1 * cos-this.d * sin;
|
|
||||||
this.d = c1 * sin+this.d * cos;
|
|
||||||
this.tx = tx1 * cos - this.ty * sin;
|
|
||||||
this.ty = tx1 * sin + this.ty * cos;
|
|
||||||
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Appends the given Matrix to this Matrix.
|
|
||||||
*
|
|
||||||
* @method append
|
|
||||||
* @param {Matrix} matrix
|
|
||||||
* @return {Matrix} This matrix. Good for chaining method calls.
|
|
||||||
*/
|
|
||||||
Matrix.prototype.append = function(matrix)
|
|
||||||
{
|
|
||||||
var a1 = this.a;
|
|
||||||
var b1 = this.b;
|
|
||||||
var c1 = this.c;
|
|
||||||
var d1 = this.d;
|
|
||||||
|
|
||||||
this.a = matrix.a * a1 + matrix.b * c1;
|
|
||||||
this.b = matrix.a * b1 + matrix.b * d1;
|
|
||||||
this.c = matrix.c * a1 + matrix.d * c1;
|
|
||||||
this.d = matrix.c * b1 + matrix.d * d1;
|
|
||||||
|
|
||||||
this.tx = matrix.tx * a1 + matrix.ty * c1 + this.tx;
|
|
||||||
this.ty = matrix.tx * b1 + matrix.ty * d1 + this.ty;
|
|
||||||
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resets this Matix to an identity (default) matrix.
|
|
||||||
*
|
|
||||||
* @method identity
|
|
||||||
* @return {Matrix} This matrix. Good for chaining method calls.
|
|
||||||
*/
|
|
||||||
Matrix.prototype.identity = function()
|
|
||||||
{
|
|
||||||
this.a = 1;
|
|
||||||
this.b = 0;
|
|
||||||
this.c = 0;
|
|
||||||
this.d = 1;
|
|
||||||
this.tx = 0;
|
|
||||||
this.ty = 0;
|
|
||||||
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
return Matrix;
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
@ -7,7 +7,7 @@ function (Exception) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function populate(obj, path) {
|
function populate(obj, path) {
|
||||||
path = path || "nc.ns";
|
path = path || "Nc.ns";
|
||||||
for(var key in obj) {
|
for(var key in obj) {
|
||||||
if(!obj.hasOwnProperty(key)) continue;
|
if(!obj.hasOwnProperty(key)) continue;
|
||||||
if(obj[key] === null) {
|
if(obj[key] === null) {
|
||||||
|
|
@ -23,6 +23,7 @@ function (Exception) {
|
||||||
this.topics = {};
|
this.topics = {};
|
||||||
this.subUid = -1;
|
this.subUid = -1;
|
||||||
|
|
||||||
|
var i = 0;
|
||||||
this.ns = {
|
this.ns = {
|
||||||
client: {
|
client: {
|
||||||
pointerLock: {
|
pointerLock: {
|
||||||
|
|
@ -40,9 +41,7 @@ function (Exception) {
|
||||||
remove: null,
|
remove: null,
|
||||||
update: null,
|
update: null,
|
||||||
addFilter: null,
|
addFilter: null,
|
||||||
removeFilter: null,
|
removeFilter: null
|
||||||
swapMeshIndexes: null,
|
|
||||||
swapMeshes: null
|
|
||||||
},
|
},
|
||||||
animatedMesh: {
|
animatedMesh: {
|
||||||
create: null
|
create: null
|
||||||
|
|
@ -84,10 +83,6 @@ function (Exception) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
game: {
|
game: {
|
||||||
events: {
|
|
||||||
render: null,
|
|
||||||
destroy: null
|
|
||||||
},
|
|
||||||
gameStats: {
|
gameStats: {
|
||||||
toggle: null
|
toggle: null
|
||||||
},
|
},
|
||||||
|
|
@ -105,9 +100,9 @@ function (Exception) {
|
||||||
},
|
},
|
||||||
core: {
|
core: {
|
||||||
game: {
|
game: {
|
||||||
worldUpdateObjects: {
|
gameObject: {
|
||||||
add: null,
|
add: null,
|
||||||
remove: null,
|
remove: null
|
||||||
},
|
},
|
||||||
events: {
|
events: {
|
||||||
level: {
|
level: {
|
||||||
|
|
@ -137,10 +132,8 @@ function (Exception) {
|
||||||
},
|
},
|
||||||
game: {
|
game: {
|
||||||
player: {
|
player: {
|
||||||
killed: null,
|
killed: null
|
||||||
clearFingerPrints: null
|
}
|
||||||
},
|
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
engine: {
|
engine: {
|
||||||
|
|
@ -194,20 +187,17 @@ function (Exception) {
|
||||||
};
|
};
|
||||||
|
|
||||||
populate(this.ns);
|
populate(this.ns);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NotificationCenter.prototype.validate = function(topic) {
|
NotificationCenter.prototype.validate = function(topic) {
|
||||||
if (topic === undefined) {
|
|
||||||
throw new Exception("Topic not registered in nc. See stack trace.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof topic === 'object') {
|
if (typeof topic === 'object') {
|
||||||
throw new Exception("Topic bad format " + JSON.stringify(topic));
|
throw new Exception("Topic bad format " + JSON.stringify(topic));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (topic.indexOf("nc.ns") !== 0) {
|
if (topic.indexOf("Nc.ns") !== 0) {
|
||||||
throw new Exception("Topic bad format, does not begin with nc.ns. : " + topic);
|
throw new Exception("Topic bad format, does not begin with Nc.ns. : " + topic);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -249,24 +239,18 @@ function (Exception) {
|
||||||
|
|
||||||
NotificationCenter.prototype.off = function (token) {
|
NotificationCenter.prototype.off = function (token) {
|
||||||
|
|
||||||
if(token && token.constructor === Array) {
|
|
||||||
this.offAll(token);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(var m in this.topics) {
|
for(var m in this.topics) {
|
||||||
if (this.topics[m]) {
|
if (this.topics[m]) {
|
||||||
for(var i = 0, j = this.topics[m].length; i < j; i++) {
|
for(var i = 0, j = this.topics[m].length; i < j; i++) {
|
||||||
if (this.topics[m][i].token === token) {
|
if (this.topics[m][i].token === token) {
|
||||||
this.topics[m].splice(i, 1);
|
this.topics[m].splice(i, 1);
|
||||||
return;
|
return token;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// should be treated as a private function - use nc.off(Array);
|
|
||||||
NotificationCenter.prototype.offAll = function (tokens) {
|
NotificationCenter.prototype.offAll = function (tokens) {
|
||||||
for (var i = 0; i < tokens.length; i++) {
|
for (var i = 0; i < tokens.length; i++) {
|
||||||
this.off(tokens[i]);
|
this.off(tokens[i]);
|
||||||
|
|
|
||||||
|
|
@ -6,19 +6,18 @@ function (Exception) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function OptionsHelper() {
|
function Options() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME we could actually use Object.assign() for merging here
|
Options.prototype.merge = function(options, preset) {
|
||||||
OptionsHelper.prototype.merge = function(options, preset) {
|
|
||||||
|
|
||||||
if(!preset && !options) {
|
if(!preset && !options) {
|
||||||
throw new Exception("OptionsHelper requires objects");
|
throw new Exception("Options requires objects");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(preset.constructor !== Object && options.constructor !== Object) {
|
if(preset.constructor !== Object && options.constructor !== Object) {
|
||||||
throw new Exception("OptionsHelper requires objects");
|
throw new Exception("Options requires objects");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!preset || preset.constructor !== Object) {
|
if(!preset || preset.constructor !== Object) {
|
||||||
|
|
@ -44,7 +43,7 @@ function (Exception) {
|
||||||
if(options[key].constructor !== Object) {
|
if(options[key].constructor !== Object) {
|
||||||
preset[key] = options[key];
|
preset[key] = options[key];
|
||||||
} else {
|
} else {
|
||||||
preset[key] = OptionsHelper.prototype.merge.call(this, options[key], preset[key]);
|
preset[key] = Options.prototype.merge.call(this, options[key], preset[key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -52,6 +51,6 @@ function (Exception) {
|
||||||
return preset;
|
return preset;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new OptionsHelper();
|
return new Options();
|
||||||
|
|
||||||
});
|
});
|
||||||
4
app/Lib/Vendor/Box2D.js
vendored
|
|
@ -6006,10 +6006,6 @@ Box2D.postDefs = [];
|
||||||
xf = b.m_xf;
|
xf = b.m_xf;
|
||||||
for (f = b.GetFixtureList();
|
for (f = b.GetFixtureList();
|
||||||
f; f = f.m_next) {
|
f; f = f.m_next) {
|
||||||
// Disable drawing sensors by removing false ||
|
|
||||||
if (false || f.IsSensor()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
s = f.GetShape();
|
s = f.GetShape();
|
||||||
if (b.IsActive() == false) {
|
if (b.IsActive() == false) {
|
||||||
color.Set(0.5, 0.5, 0.3);
|
color.Set(0.5, 0.5, 0.3);
|
||||||
|
|
|
||||||
72
app/Lib/Vendor/RequireJs/Plugin/Json.js
vendored
|
|
@ -1,72 +0,0 @@
|
||||||
/** @license
|
|
||||||
* RequireJS plugin for loading JSON files
|
|
||||||
* - depends on Text plugin and it was HEAVILY "inspired" by it as well.
|
|
||||||
* Author: Miller Medeiros
|
|
||||||
* Version: 0.4.0 (2014/04/10)
|
|
||||||
* Released under the MIT license
|
|
||||||
*/
|
|
||||||
define(['text'], function(text){
|
|
||||||
|
|
||||||
var CACHE_BUST_QUERY_PARAM = 'bust',
|
|
||||||
CACHE_BUST_FLAG = '!bust',
|
|
||||||
jsonParse = (typeof JSON !== 'undefined' && typeof JSON.parse === 'function')? JSON.parse : function(val){
|
|
||||||
return eval('('+ val +')'); //quick and dirty
|
|
||||||
},
|
|
||||||
buildMap = {};
|
|
||||||
|
|
||||||
function cacheBust(url){
|
|
||||||
url = url.replace(CACHE_BUST_FLAG, '');
|
|
||||||
url += (url.indexOf('?') < 0)? '?' : '&';
|
|
||||||
return url + CACHE_BUST_QUERY_PARAM +'='+ Math.round(2147483647 * Math.random());
|
|
||||||
}
|
|
||||||
|
|
||||||
//API
|
|
||||||
return {
|
|
||||||
|
|
||||||
load : function(name, req, onLoad, config) {
|
|
||||||
if (( config.isBuild && (config.inlineJSON === false || name.indexOf(CACHE_BUST_QUERY_PARAM +'=') !== -1)) || (req.toUrl(name).indexOf('empty:') === 0)) {
|
|
||||||
//avoid inlining cache busted JSON or if inlineJSON:false
|
|
||||||
//and don't inline files marked as empty!
|
|
||||||
onLoad(null);
|
|
||||||
} else {
|
|
||||||
text.get(req.toUrl(name), function(data){
|
|
||||||
var parsed;
|
|
||||||
if (config.isBuild) {
|
|
||||||
buildMap[name] = data;
|
|
||||||
onLoad(data);
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
parsed = jsonParse(data);
|
|
||||||
} catch (e) {
|
|
||||||
onLoad.error(e);
|
|
||||||
}
|
|
||||||
onLoad(parsed);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onLoad.error, {
|
|
||||||
accept: 'application/json'
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
normalize : function (name, normalize) {
|
|
||||||
// used normalize to avoid caching references to a "cache busted" request
|
|
||||||
if (name.indexOf(CACHE_BUST_FLAG) !== -1) {
|
|
||||||
name = cacheBust(name);
|
|
||||||
}
|
|
||||||
// resolve any relative paths
|
|
||||||
return normalize(name);
|
|
||||||
},
|
|
||||||
|
|
||||||
//write method based on RequireJS official text plugin by James Burke
|
|
||||||
//https://github.com/jrburke/requirejs/blob/master/text.js
|
|
||||||
write : function(pluginName, moduleName, write){
|
|
||||||
if(moduleName in buildMap){
|
|
||||||
var content = buildMap[moduleName];
|
|
||||||
write('define("'+ pluginName +'!'+ moduleName +'", function(){ return '+ content +';});\n');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
});
|
|
||||||
391
app/Lib/Vendor/RequireJs/Plugin/Text.js
vendored
|
|
@ -1,391 +0,0 @@
|
||||||
/**
|
|
||||||
* @license RequireJS text 2.0.14 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved.
|
|
||||||
* Available via the MIT or new BSD license.
|
|
||||||
* see: http://github.com/requirejs/text for details
|
|
||||||
*/
|
|
||||||
/*jslint regexp: true */
|
|
||||||
/*global require, XMLHttpRequest, ActiveXObject,
|
|
||||||
define, window, process, Packages,
|
|
||||||
java, location, Components, FileUtils */
|
|
||||||
|
|
||||||
define(['module'], function (module) {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var text, fs, Cc, Ci, xpcIsWindows,
|
|
||||||
progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'],
|
|
||||||
xmlRegExp = /^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im,
|
|
||||||
bodyRegExp = /<body[^>]*>\s*([\s\S]+)\s*<\/body>/im,
|
|
||||||
hasLocation = typeof location !== 'undefined' && location.href,
|
|
||||||
defaultProtocol = hasLocation && location.protocol && location.protocol.replace(/\:/, ''),
|
|
||||||
defaultHostName = hasLocation && location.hostname,
|
|
||||||
defaultPort = hasLocation && (location.port || undefined),
|
|
||||||
buildMap = {},
|
|
||||||
masterConfig = (module.config && module.config()) || {};
|
|
||||||
|
|
||||||
text = {
|
|
||||||
version: '2.0.14',
|
|
||||||
|
|
||||||
strip: function (content) {
|
|
||||||
//Strips <?xml ...?> declarations so that external SVG and XML
|
|
||||||
//documents can be added to a document without worry. Also, if the string
|
|
||||||
//is an HTML document, only the part inside the body tag is returned.
|
|
||||||
if (content) {
|
|
||||||
content = content.replace(xmlRegExp, "");
|
|
||||||
var matches = content.match(bodyRegExp);
|
|
||||||
if (matches) {
|
|
||||||
content = matches[1];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
content = "";
|
|
||||||
}
|
|
||||||
return content;
|
|
||||||
},
|
|
||||||
|
|
||||||
jsEscape: function (content) {
|
|
||||||
return content.replace(/(['\\])/g, '\\$1')
|
|
||||||
.replace(/[\f]/g, "\\f")
|
|
||||||
.replace(/[\b]/g, "\\b")
|
|
||||||
.replace(/[\n]/g, "\\n")
|
|
||||||
.replace(/[\t]/g, "\\t")
|
|
||||||
.replace(/[\r]/g, "\\r")
|
|
||||||
.replace(/[\u2028]/g, "\\u2028")
|
|
||||||
.replace(/[\u2029]/g, "\\u2029");
|
|
||||||
},
|
|
||||||
|
|
||||||
createXhr: masterConfig.createXhr || function () {
|
|
||||||
//Would love to dump the ActiveX crap in here. Need IE 6 to die first.
|
|
||||||
var xhr, i, progId;
|
|
||||||
if (typeof XMLHttpRequest !== "undefined") {
|
|
||||||
return new XMLHttpRequest();
|
|
||||||
} else if (typeof ActiveXObject !== "undefined") {
|
|
||||||
for (i = 0; i < 3; i += 1) {
|
|
||||||
progId = progIds[i];
|
|
||||||
try {
|
|
||||||
xhr = new ActiveXObject(progId);
|
|
||||||
} catch (e) {}
|
|
||||||
|
|
||||||
if (xhr) {
|
|
||||||
progIds = [progId]; // so faster next time
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return xhr;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parses a resource name into its component parts. Resource names
|
|
||||||
* look like: module/name.ext!strip, where the !strip part is
|
|
||||||
* optional.
|
|
||||||
* @param {String} name the resource name
|
|
||||||
* @returns {Object} with properties "moduleName", "ext" and "strip"
|
|
||||||
* where strip is a boolean.
|
|
||||||
*/
|
|
||||||
parseName: function (name) {
|
|
||||||
var modName, ext, temp,
|
|
||||||
strip = false,
|
|
||||||
index = name.lastIndexOf("."),
|
|
||||||
isRelative = name.indexOf('./') === 0 ||
|
|
||||||
name.indexOf('../') === 0;
|
|
||||||
|
|
||||||
if (index !== -1 && (!isRelative || index > 1)) {
|
|
||||||
modName = name.substring(0, index);
|
|
||||||
ext = name.substring(index + 1);
|
|
||||||
} else {
|
|
||||||
modName = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
temp = ext || modName;
|
|
||||||
index = temp.indexOf("!");
|
|
||||||
if (index !== -1) {
|
|
||||||
//Pull off the strip arg.
|
|
||||||
strip = temp.substring(index + 1) === "strip";
|
|
||||||
temp = temp.substring(0, index);
|
|
||||||
if (ext) {
|
|
||||||
ext = temp;
|
|
||||||
} else {
|
|
||||||
modName = temp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
moduleName: modName,
|
|
||||||
ext: ext,
|
|
||||||
strip: strip
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
xdRegExp: /^((\w+)\:)?\/\/([^\/\\]+)/,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Is an URL on another domain. Only works for browser use, returns
|
|
||||||
* false in non-browser environments. Only used to know if an
|
|
||||||
* optimized .js version of a text resource should be loaded
|
|
||||||
* instead.
|
|
||||||
* @param {String} url
|
|
||||||
* @returns Boolean
|
|
||||||
*/
|
|
||||||
useXhr: function (url, protocol, hostname, port) {
|
|
||||||
var uProtocol, uHostName, uPort,
|
|
||||||
match = text.xdRegExp.exec(url);
|
|
||||||
if (!match) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
uProtocol = match[2];
|
|
||||||
uHostName = match[3];
|
|
||||||
|
|
||||||
uHostName = uHostName.split(':');
|
|
||||||
uPort = uHostName[1];
|
|
||||||
uHostName = uHostName[0];
|
|
||||||
|
|
||||||
return (!uProtocol || uProtocol === protocol) &&
|
|
||||||
(!uHostName || uHostName.toLowerCase() === hostname.toLowerCase()) &&
|
|
||||||
((!uPort && !uHostName) || uPort === port);
|
|
||||||
},
|
|
||||||
|
|
||||||
finishLoad: function (name, strip, content, onLoad) {
|
|
||||||
content = strip ? text.strip(content) : content;
|
|
||||||
if (masterConfig.isBuild) {
|
|
||||||
buildMap[name] = content;
|
|
||||||
}
|
|
||||||
onLoad(content);
|
|
||||||
},
|
|
||||||
|
|
||||||
load: function (name, req, onLoad, config) {
|
|
||||||
//Name has format: some.module.filext!strip
|
|
||||||
//The strip part is optional.
|
|
||||||
//if strip is present, then that means only get the string contents
|
|
||||||
//inside a body tag in an HTML string. For XML/SVG content it means
|
|
||||||
//removing the <?xml ...?> declarations so the content can be inserted
|
|
||||||
//into the current doc without problems.
|
|
||||||
|
|
||||||
// Do not bother with the work if a build and text will
|
|
||||||
// not be inlined.
|
|
||||||
if (config && config.isBuild && !config.inlineText) {
|
|
||||||
onLoad();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
masterConfig.isBuild = config && config.isBuild;
|
|
||||||
|
|
||||||
var parsed = text.parseName(name),
|
|
||||||
nonStripName = parsed.moduleName +
|
|
||||||
(parsed.ext ? '.' + parsed.ext : ''),
|
|
||||||
url = req.toUrl(nonStripName),
|
|
||||||
useXhr = (masterConfig.useXhr) ||
|
|
||||||
text.useXhr;
|
|
||||||
|
|
||||||
// Do not load if it is an empty: url
|
|
||||||
if (url.indexOf('empty:') === 0) {
|
|
||||||
onLoad();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Load the text. Use XHR if possible and in a browser.
|
|
||||||
if (!hasLocation || useXhr(url, defaultProtocol, defaultHostName, defaultPort)) {
|
|
||||||
text.get(url, function (content) {
|
|
||||||
text.finishLoad(name, parsed.strip, content, onLoad);
|
|
||||||
}, function (err) {
|
|
||||||
if (onLoad.error) {
|
|
||||||
onLoad.error(err);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
//Need to fetch the resource across domains. Assume
|
|
||||||
//the resource has been optimized into a JS module. Fetch
|
|
||||||
//by the module name + extension, but do not include the
|
|
||||||
//!strip part to avoid file system issues.
|
|
||||||
req([nonStripName], function (content) {
|
|
||||||
text.finishLoad(parsed.moduleName + '.' + parsed.ext,
|
|
||||||
parsed.strip, content, onLoad);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
write: function (pluginName, moduleName, write, config) {
|
|
||||||
if (buildMap.hasOwnProperty(moduleName)) {
|
|
||||||
var content = text.jsEscape(buildMap[moduleName]);
|
|
||||||
write.asModule(pluginName + "!" + moduleName,
|
|
||||||
"define(function () { return '" +
|
|
||||||
content +
|
|
||||||
"';});\n");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
writeFile: function (pluginName, moduleName, req, write, config) {
|
|
||||||
var parsed = text.parseName(moduleName),
|
|
||||||
extPart = parsed.ext ? '.' + parsed.ext : '',
|
|
||||||
nonStripName = parsed.moduleName + extPart,
|
|
||||||
//Use a '.js' file name so that it indicates it is a
|
|
||||||
//script that can be loaded across domains.
|
|
||||||
fileName = req.toUrl(parsed.moduleName + extPart) + '.js';
|
|
||||||
|
|
||||||
//Leverage own load() method to load plugin value, but only
|
|
||||||
//write out values that do not have the strip argument,
|
|
||||||
//to avoid any potential issues with ! in file names.
|
|
||||||
text.load(nonStripName, req, function (value) {
|
|
||||||
//Use own write() method to construct full module value.
|
|
||||||
//But need to create shell that translates writeFile's
|
|
||||||
//write() to the right interface.
|
|
||||||
var textWrite = function (contents) {
|
|
||||||
return write(fileName, contents);
|
|
||||||
};
|
|
||||||
textWrite.asModule = function (moduleName, contents) {
|
|
||||||
return write.asModule(moduleName, fileName, contents);
|
|
||||||
};
|
|
||||||
|
|
||||||
text.write(pluginName, nonStripName, textWrite, config);
|
|
||||||
}, config);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (masterConfig.env === 'node' || (!masterConfig.env &&
|
|
||||||
typeof process !== "undefined" &&
|
|
||||||
process.versions &&
|
|
||||||
!!process.versions.node &&
|
|
||||||
!process.versions['node-webkit'] &&
|
|
||||||
!process.versions['atom-shell'])) {
|
|
||||||
//Using special require.nodeRequire, something added by r.js.
|
|
||||||
fs = require.nodeRequire('fs');
|
|
||||||
|
|
||||||
text.get = function (url, callback, errback) {
|
|
||||||
try {
|
|
||||||
var file = fs.readFileSync(url, 'utf8');
|
|
||||||
//Remove BOM (Byte Mark Order) from utf8 files if it is there.
|
|
||||||
if (file[0] === '\uFEFF') {
|
|
||||||
file = file.substring(1);
|
|
||||||
}
|
|
||||||
callback(file);
|
|
||||||
} catch (e) {
|
|
||||||
if (errback) {
|
|
||||||
errback(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else if (masterConfig.env === 'xhr' || (!masterConfig.env &&
|
|
||||||
text.createXhr())) {
|
|
||||||
text.get = function (url, callback, errback, headers) {
|
|
||||||
var xhr = text.createXhr(), header;
|
|
||||||
xhr.open('GET', url, true);
|
|
||||||
|
|
||||||
//Allow plugins direct access to xhr headers
|
|
||||||
if (headers) {
|
|
||||||
for (header in headers) {
|
|
||||||
if (headers.hasOwnProperty(header)) {
|
|
||||||
xhr.setRequestHeader(header.toLowerCase(), headers[header]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Allow overrides specified in config
|
|
||||||
if (masterConfig.onXhr) {
|
|
||||||
masterConfig.onXhr(xhr, url);
|
|
||||||
}
|
|
||||||
|
|
||||||
xhr.onreadystatechange = function (evt) {
|
|
||||||
var status, err;
|
|
||||||
//Do not explicitly handle errors, those should be
|
|
||||||
//visible via console output in the browser.
|
|
||||||
if (xhr.readyState === 4) {
|
|
||||||
status = xhr.status || 0;
|
|
||||||
if (status > 399 && status < 600) {
|
|
||||||
//An http 4xx or 5xx error. Signal an error.
|
|
||||||
err = new Error(url + ' HTTP status: ' + status);
|
|
||||||
err.xhr = xhr;
|
|
||||||
if (errback) {
|
|
||||||
errback(err);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
callback(xhr.responseText);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (masterConfig.onXhrComplete) {
|
|
||||||
masterConfig.onXhrComplete(xhr, url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
xhr.send(null);
|
|
||||||
};
|
|
||||||
} else if (masterConfig.env === 'rhino' || (!masterConfig.env &&
|
|
||||||
typeof Packages !== 'undefined' && typeof java !== 'undefined')) {
|
|
||||||
//Why Java, why is this so awkward?
|
|
||||||
text.get = function (url, callback) {
|
|
||||||
var stringBuffer, line,
|
|
||||||
encoding = "utf-8",
|
|
||||||
file = new java.io.File(url),
|
|
||||||
lineSeparator = java.lang.System.getProperty("line.separator"),
|
|
||||||
input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(file), encoding)),
|
|
||||||
content = '';
|
|
||||||
try {
|
|
||||||
stringBuffer = new java.lang.StringBuffer();
|
|
||||||
line = input.readLine();
|
|
||||||
|
|
||||||
// Byte Order Mark (BOM) - The Unicode Standard, version 3.0, page 324
|
|
||||||
// http://www.unicode.org/faq/utf_bom.html
|
|
||||||
|
|
||||||
// Note that when we use utf-8, the BOM should appear as "EF BB BF", but it doesn't due to this bug in the JDK:
|
|
||||||
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4508058
|
|
||||||
if (line && line.length() && line.charAt(0) === 0xfeff) {
|
|
||||||
// Eat the BOM, since we've already found the encoding on this file,
|
|
||||||
// and we plan to concatenating this buffer with others; the BOM should
|
|
||||||
// only appear at the top of a file.
|
|
||||||
line = line.substring(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (line !== null) {
|
|
||||||
stringBuffer.append(line);
|
|
||||||
}
|
|
||||||
|
|
||||||
while ((line = input.readLine()) !== null) {
|
|
||||||
stringBuffer.append(lineSeparator);
|
|
||||||
stringBuffer.append(line);
|
|
||||||
}
|
|
||||||
//Make sure we return a JavaScript string and not a Java string.
|
|
||||||
content = String(stringBuffer.toString()); //String
|
|
||||||
} finally {
|
|
||||||
input.close();
|
|
||||||
}
|
|
||||||
callback(content);
|
|
||||||
};
|
|
||||||
} else if (masterConfig.env === 'xpconnect' || (!masterConfig.env &&
|
|
||||||
typeof Components !== 'undefined' && Components.classes &&
|
|
||||||
Components.interfaces)) {
|
|
||||||
//Avert your gaze!
|
|
||||||
Cc = Components.classes;
|
|
||||||
Ci = Components.interfaces;
|
|
||||||
Components.utils['import']('resource://gre/modules/FileUtils.jsm');
|
|
||||||
xpcIsWindows = ('@mozilla.org/windows-registry-key;1' in Cc);
|
|
||||||
|
|
||||||
text.get = function (url, callback) {
|
|
||||||
var inStream, convertStream, fileObj,
|
|
||||||
readData = {};
|
|
||||||
|
|
||||||
if (xpcIsWindows) {
|
|
||||||
url = url.replace(/\//g, '\\');
|
|
||||||
}
|
|
||||||
|
|
||||||
fileObj = new FileUtils.File(url);
|
|
||||||
|
|
||||||
//XPCOM, you so crazy
|
|
||||||
try {
|
|
||||||
inStream = Cc['@mozilla.org/network/file-input-stream;1']
|
|
||||||
.createInstance(Ci.nsIFileInputStream);
|
|
||||||
inStream.init(fileObj, 1, 0, false);
|
|
||||||
|
|
||||||
convertStream = Cc['@mozilla.org/intl/converter-input-stream;1']
|
|
||||||
.createInstance(Ci.nsIConverterInputStream);
|
|
||||||
convertStream.init(inStream, "utf-8", inStream.available(),
|
|
||||||
Ci.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER);
|
|
||||||
|
|
||||||
convertStream.readString(inStream.available(), readData);
|
|
||||||
convertStream.close();
|
|
||||||
inStream.close();
|
|
||||||
callback(readData.value);
|
|
||||||
} catch (e) {
|
|
||||||
throw new Error((fileObj && fileObj.path || '') + ': ' + e);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return text;
|
|
||||||
});
|
|
||||||
9
app/Lib/Vendor/RubeLoader.js
vendored
|
|
@ -152,7 +152,8 @@ function (Box2D) {
|
||||||
if ( bodyJson.hasOwnProperty('linearVelocity') && bodyJson.linearVelocity instanceof Object )
|
if ( bodyJson.hasOwnProperty('linearVelocity') && bodyJson.linearVelocity instanceof Object )
|
||||||
bd.linearVelocity.SetV( bodyJson.linearVelocity );
|
bd.linearVelocity.SetV( bodyJson.linearVelocity );
|
||||||
if ( bodyJson.hasOwnProperty('position') && bodyJson.position instanceof Object )
|
if ( bodyJson.hasOwnProperty('position') && bodyJson.position instanceof Object )
|
||||||
bd.position.SetV( this.getVectorValue(bodyJson.position) );
|
bodyJson.position.y *= -1;
|
||||||
|
bd.position.SetV( bodyJson.position );
|
||||||
if ( bodyJson.hasOwnProperty('awake') )
|
if ( bodyJson.hasOwnProperty('awake') )
|
||||||
bd.awake = bodyJson.awake;
|
bd.awake = bodyJson.awake;
|
||||||
else
|
else
|
||||||
|
|
@ -168,7 +169,6 @@ function (Box2D) {
|
||||||
body.name = bodyJson.name;
|
body.name = bodyJson.name;
|
||||||
if ( bodyJson.hasOwnProperty('customProperties') )
|
if ( bodyJson.hasOwnProperty('customProperties') )
|
||||||
body.customProperties = bodyJson.customProperties;
|
body.customProperties = bodyJson.customProperties;
|
||||||
|
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -231,7 +231,8 @@ function (Box2D) {
|
||||||
|
|
||||||
RubeLoader.prototype.getVectorValue = function (val) {
|
RubeLoader.prototype.getVectorValue = function (val) {
|
||||||
if ( val instanceof Object ) {
|
if ( val instanceof Object ) {
|
||||||
return { x: val.x, y: val.y * -1 };
|
val.y *= -1;
|
||||||
|
return val;
|
||||||
} else {
|
} else {
|
||||||
return { x:0, y:0 };
|
return { x:0, y:0 };
|
||||||
}
|
}
|
||||||
|
|
@ -426,7 +427,7 @@ function (Box2D) {
|
||||||
|
|
||||||
var scene = {
|
var scene = {
|
||||||
bodies: loadedBodies,
|
bodies: loadedBodies,
|
||||||
joints: loadedJoints
|
// joints: loadedJoints
|
||||||
};
|
};
|
||||||
|
|
||||||
return scene;
|
return scene;
|
||||||
|
|
|
||||||
2
app/Lib/Vendor/SocketIO.js
vendored
|
|
@ -1,3 +1,3 @@
|
||||||
define(["socketio"], function(io) {
|
define(["socketio"], function() {
|
||||||
return io;
|
return io;
|
||||||
});
|
});
|
||||||
|
|
@ -1,12 +1,11 @@
|
||||||
define([
|
define([
|
||||||
"Game/Config/Settings",
|
|
||||||
"Lib/Utilities/ColorConverter",
|
"Lib/Utilities/ColorConverter",
|
||||||
"Lib/Utilities/Exception",
|
"Lib/Utilities/Exception",
|
||||||
"Game/Client/PointerLockManager",
|
"Game/Client/PointerLockManager",
|
||||||
"Lib/Utilities/QuerySelector"
|
"Lib/Utilities/QuerySelector"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Settings, ColorConverter, Exception, pointerLockManager, qs) {
|
function (ColorConverter, Exception, PointerLockManager, Qs) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -23,30 +22,28 @@ function (Settings, ColorConverter, Exception, pointerLockManager, qs) {
|
||||||
if(localStorage["player"]) {
|
if(localStorage["player"]) {
|
||||||
var player = JSON.parse(localStorage["player"]);
|
var player = JSON.parse(localStorage["player"]);
|
||||||
if(player.nickname) {
|
if(player.nickname) {
|
||||||
qs.$("#nick").value = player.nickname;
|
Qs.$("#nick").value = player.nickname;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(localStorage["customname"]) {
|
if(localStorage["customname"]) {
|
||||||
qs.$("#customname").value = localStorage["customname"];
|
Qs.$("#customname").value = localStorage["customname"];
|
||||||
}
|
}
|
||||||
qs.$("#scoreLimit").value = Settings.CHANNEL_DEFAULT_SCORE_LIMIT;
|
|
||||||
qs.$("#userLimit").value = Settings.CHANNEL_DEFAULT_MAX_USERS;
|
|
||||||
|
|
||||||
|
|
||||||
qs.$("#refresh").onclick = refresh;
|
Qs.$("#refresh").onclick = refresh;
|
||||||
refresh();
|
refresh();
|
||||||
populateMaps();
|
populateMaps();
|
||||||
this.channelDestructionTimeout = null;
|
this.channelDestructionTimeout = null;
|
||||||
this.refreshInterval = setInterval(refresh, 5000);
|
this.refreshInterval = setInterval(refresh, 5000);
|
||||||
|
|
||||||
qs.$("#createbutton").onclick = function() {
|
Qs.$("#createbutton").onclick = function() {
|
||||||
show('#createform');
|
show('#createform');
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
qs.$("#quickstartbutton").onclick = quickstart;
|
Qs.$("#quickstartbutton").onclick = quickstart;
|
||||||
|
|
||||||
var cancelButtons = qs.$$(".cancel");
|
var cancelButtons = Qs.$$(".cancel");
|
||||||
for (var i = 0; i < cancelButtons.length; i++) {
|
for (var i = 0; i < cancelButtons.length; i++) {
|
||||||
cancelButtons[i].onclick = function() {
|
cancelButtons[i].onclick = function() {
|
||||||
show('#listform');
|
show('#listform');
|
||||||
|
|
@ -55,13 +52,13 @@ function (Settings, ColorConverter, Exception, pointerLockManager, qs) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.colorConverter = new ColorConverter();
|
this.colorConverter = new ColorConverter();
|
||||||
var c = qs.$("#nick");
|
var c = Qs.$("#nick");
|
||||||
c.onchange = c.onkeyup = c.onblur = c.onclick = this.updatePrimaryColor.bind(this);
|
c.onchange = c.onkeyup = c.onblur = c.onclick = this.updatePrimaryColor.bind(this);
|
||||||
this.updatePrimaryColor({target:c});
|
this.updatePrimaryColor({target:c});
|
||||||
};
|
};
|
||||||
|
|
||||||
Menu.prototype.updatePrimaryColor = function(e) {
|
Menu.prototype.updatePrimaryColor = function(e) {
|
||||||
qs.$("#primarycolor").style.backgroundColor = "#" + this.colorConverter.getColorByName(e.target.value).toString(16);
|
Qs.$("#primarycolor").style.backgroundColor = "#" + this.colorConverter.getColorByName(e.target.value).toString(16);
|
||||||
};
|
};
|
||||||
|
|
||||||
Menu.prototype.onRun = function(channelName, nickname) {
|
Menu.prototype.onRun = function(channelName, nickname) {
|
||||||
|
|
@ -70,7 +67,7 @@ function (Settings, ColorConverter, Exception, pointerLockManager, qs) {
|
||||||
|
|
||||||
window.onhashchange = function() {
|
window.onhashchange = function() {
|
||||||
if(window.location.hash) {
|
if(window.location.hash) {
|
||||||
if(qs.$("#game").style.display == "block") {
|
if(Qs.$("#game").style.display == "block") {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
refresh(function(list) {
|
refresh(function(list) {
|
||||||
|
|
@ -128,7 +125,7 @@ function (Settings, ColorConverter, Exception, pointerLockManager, qs) {
|
||||||
errorCallback(xhr.status, xhr.responseText);
|
errorCallback(xhr.status, xhr.responseText);
|
||||||
} else {
|
} else {
|
||||||
console.error("Ajax error: " + xhr.status + " " + xhr.responseText)
|
console.error("Ajax error: " + xhr.status + " " + xhr.responseText)
|
||||||
qs.$("#list").innerHTML = "";
|
Qs.$("#list").innerHTML = "";
|
||||||
document.body.className = "offline";
|
document.body.className = "offline";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -166,7 +163,7 @@ function (Settings, ColorConverter, Exception, pointerLockManager, qs) {
|
||||||
html += "<tr><td colspan='3'>No channels found.</td></tr>";
|
html += "<tr><td colspan='3'>No channels found.</td></tr>";
|
||||||
}
|
}
|
||||||
|
|
||||||
qs.$("#list").innerHTML = html;
|
Qs.$("#list").innerHTML = html;
|
||||||
}
|
}
|
||||||
|
|
||||||
function populateMaps() {
|
function populateMaps() {
|
||||||
|
|
@ -181,15 +178,15 @@ function (Settings, ColorConverter, Exception, pointerLockManager, qs) {
|
||||||
html += "</label></li>";
|
html += "</label></li>";
|
||||||
};
|
};
|
||||||
|
|
||||||
qs.$("#maps").innerHTML = html;
|
Qs.$("#maps").innerHTML = html;
|
||||||
}, function(status, responseText) {
|
}, function(status, responseText) {
|
||||||
console.error("getMaps error:", status, responseText);
|
console.error("getMaps error:", status, responseText);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
qs.$("form#listform").onsubmit = function(e) {
|
Qs.$("form#listform").onsubmit = function(e) {
|
||||||
try {
|
try {
|
||||||
var nickname = qs.$("#nick").value;
|
var nickname = Qs.$("#nick").value;
|
||||||
var channelName = getSelectedChannel();
|
var channelName = getSelectedChannel();
|
||||||
join(nickname, channelName);
|
join(nickname, channelName);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
|
@ -199,14 +196,14 @@ function (Settings, ColorConverter, Exception, pointerLockManager, qs) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
qs.$("form#createform").onsubmit = function(e) {
|
Qs.$("form#createform").onsubmit = function(e) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
var options = {
|
var options = {
|
||||||
channelName: qs.$("#customname").value,
|
channelName: Qs.$("#customname").value,
|
||||||
levelUids: getSelectedMaps(),
|
levelUids: getSelectedMaps(),
|
||||||
maxUsers: parseInt(qs.$("#userLimit").value, 10),
|
maxUsers: parseInt(Qs.$("#userLimit").value, 10),
|
||||||
scoreLimit: parseInt(qs.$("#scoreLimit").value, 10)
|
scoreLimit: parseInt(Qs.$("#scoreLimit").value, 10)
|
||||||
};
|
};
|
||||||
|
|
||||||
create(options, onCreateSuccess);
|
create(options, onCreateSuccess);
|
||||||
|
|
@ -217,10 +214,10 @@ function (Settings, ColorConverter, Exception, pointerLockManager, qs) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
qs.$("form#customjoinform").onsubmit = function(e) {
|
Qs.$("form#customjoinform").onsubmit = function(e) {
|
||||||
try {
|
try {
|
||||||
var nickname = qs.$("#nick").value;
|
var nickname = Qs.$("#nick").value;
|
||||||
var channelName = qs.$("#customname").value;
|
var channelName = Qs.$("#customname").value;
|
||||||
join(nickname, channelName);
|
join(nickname, channelName);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
|
@ -235,29 +232,29 @@ function (Settings, ColorConverter, Exception, pointerLockManager, qs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function showCustomJoinForm() {
|
function showCustomJoinForm() {
|
||||||
qs.$("#customname").value = unescape(window.location.hash.substr(1));
|
Qs.$("#customname").value = unescape(window.location.hash.substr(1));
|
||||||
qs.$("#link").value = window.location.href;
|
Qs.$("#link").value = window.location.href;
|
||||||
show("#customjoinform");
|
show("#customjoinform");
|
||||||
}
|
}
|
||||||
|
|
||||||
function show(id) {
|
function show(id) {
|
||||||
qs.$("#createform").style.display = "none";
|
Qs.$("#createform").style.display = "none";
|
||||||
qs.$("#listform").style.display = "none";
|
Qs.$("#listform").style.display = "none";
|
||||||
qs.$("#customjoinform").style.display = "none";
|
Qs.$("#customjoinform").style.display = "none";
|
||||||
qs.$("#game").style.display = "none";
|
Qs.$("#game").style.display = "none";
|
||||||
|
|
||||||
if(id != "#customjoinform") {
|
if(id != "#customjoinform") {
|
||||||
history.pushState("", document.title, window.location.pathname);
|
history.pushState("", document.title, window.location.pathname);
|
||||||
}
|
}
|
||||||
|
|
||||||
qs.$(id).style.display = "block";
|
Qs.$(id).style.display = "block";
|
||||||
}
|
}
|
||||||
|
|
||||||
function quickstart() {
|
function quickstart() {
|
||||||
refresh(function(list){
|
refresh(function(list){
|
||||||
var defaultChannelName = quickstartChannelName;
|
var defaultChannelName = quickstartChannelName;
|
||||||
history.pushState("", document.title, window.location.pathname + "#" + defaultChannelName);
|
history.pushState("", document.title, window.location.pathname + "#" + defaultChannelName);
|
||||||
var nickname = qs.$("#nick").value;
|
var nickname = Qs.$("#nick").value;
|
||||||
|
|
||||||
if(!nickname) {
|
if(!nickname) {
|
||||||
nickname = "Guest" + (Math.floor(Math.random() * 899) + 100)
|
nickname = "Guest" + (Math.floor(Math.random() * 899) + 100)
|
||||||
|
|
@ -268,8 +265,8 @@ function (Settings, ColorConverter, Exception, pointerLockManager, qs) {
|
||||||
var options = {
|
var options = {
|
||||||
channelName: defaultChannelName,
|
channelName: defaultChannelName,
|
||||||
levelUids: getSelectedMaps(),
|
levelUids: getSelectedMaps(),
|
||||||
maxUsers: parseInt(qs.$("#userLimit").value, 10),
|
maxUsers: parseInt(Qs.$("#userLimit").value, 10),
|
||||||
scoreLimit: parseInt(qs.$("#scoreLimit").value, 10)
|
scoreLimit: parseInt(Qs.$("#scoreLimit").value, 10)
|
||||||
};
|
};
|
||||||
|
|
||||||
create(options, function() {
|
create(options, function() {
|
||||||
|
|
@ -292,7 +289,7 @@ function (Settings, ColorConverter, Exception, pointerLockManager, qs) {
|
||||||
alert("Your channel has timed out.");
|
alert("Your channel has timed out.");
|
||||||
window.location.href = "/";
|
window.location.href = "/";
|
||||||
} else {
|
} else {
|
||||||
qs.$("#timeout").innerHTML = " within " + formatDate(diff) + " minutes";
|
Qs.$("#timeout").innerHTML = " within " + formatDate(diff) + " minutes";
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
@ -392,8 +389,8 @@ function (Settings, ColorConverter, Exception, pointerLockManager, qs) {
|
||||||
});
|
});
|
||||||
|
|
||||||
//window.location.href = "/game.html";
|
//window.location.href = "/game.html";
|
||||||
qs.$("#menu").style.display = "none";
|
Qs.$("#menu").style.display = "none";
|
||||||
qs.$("#game").style.display = "block";
|
Qs.$("#game").style.display = "block";
|
||||||
instance.onRun(channelName, nickname); // Dumm und dümmer
|
instance.onRun(channelName, nickname); // Dumm und dümmer
|
||||||
|
|
||||||
if(instance.refreshInterval) {
|
if(instance.refreshInterval) {
|
||||||
|
|
@ -404,7 +401,7 @@ function (Settings, ColorConverter, Exception, pointerLockManager, qs) {
|
||||||
clearInterval(instance.channelDestructionTimeout);
|
clearInterval(instance.channelDestructionTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
pointerLockManager.request();
|
PointerLockManager.request();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -426,8 +423,8 @@ function (Settings, ColorConverter, Exception, pointerLockManager, qs) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qs.$("#canvas").onclick = function(){
|
Qs.$("#canvas").onclick = function(){
|
||||||
pointerLockManager.request();
|
PointerLockManager.request();
|
||||||
};
|
};
|
||||||
|
|
||||||
return Menu;
|
return Menu;
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,12 @@ define([
|
||||||
"Lib/Utilities/NotificationCenter",
|
"Lib/Utilities/NotificationCenter",
|
||||||
"Lib/Utilities/Protocol/Helper",
|
"Lib/Utilities/Protocol/Helper",
|
||||||
"Lib/Utilities/Validate",
|
"Lib/Utilities/Validate",
|
||||||
"Lib/Utilities/OptionsHelper",
|
"Lib/Utilities/Options",
|
||||||
"Game/Config/Settings",
|
"Game/Config/Settings",
|
||||||
"fs"
|
"fs"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (nc, ProtocolHelper, validate, optionsHelper, Settings, FileSystem) {
|
function (Nc, ProtocolHelper, validate, Options, Settings, FileSystem) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -121,7 +121,7 @@ function (nc, ProtocolHelper, validate, optionsHelper, Settings, FileSystem) {
|
||||||
scoreLimit: Settings.CHANNEL_DEFAULT_SCORE_LIMIT
|
scoreLimit: Settings.CHANNEL_DEFAULT_SCORE_LIMIT
|
||||||
};
|
};
|
||||||
|
|
||||||
options = optionsHelper.merge(options, defaultOptions);
|
options = Options.merge(options, defaultOptions);
|
||||||
|
|
||||||
var result = this.coordinator.createChannel(options);
|
var result = this.coordinator.createChannel(options);
|
||||||
if(result !== false) {
|
if(result !== false) {
|
||||||
|
|
|
||||||
|
|
@ -5,14 +5,14 @@ define([
|
||||||
"Game/Config/Settings"
|
"Game/Config/Settings"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (User, PipeToChannel, nc, Settings) {
|
function (User, PipeToChannel, Nc, Settings) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function Coordinator() {
|
function Coordinator() {
|
||||||
this.channelPipes = {};
|
this.channelPipes = {};
|
||||||
|
|
||||||
nc.on(nc.ns.server.events.controlCommand.coordinator, this.onMessage, this);
|
Nc.on(Nc.ns.server.events.controlCommand.coordinator, this.onMessage, this);
|
||||||
|
|
||||||
console.checkpoint('create Coordinator');
|
console.checkpoint('create Coordinator');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ define([
|
||||||
"child_process"
|
"child_process"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (nc, childProcess) {
|
function (Nc, childProcess) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -57,10 +57,10 @@ function (nc, childProcess) {
|
||||||
PipeToChannel.prototype.onMessage = function (message) {
|
PipeToChannel.prototype.onMessage = function (message) {
|
||||||
switch(message.recipient) {
|
switch(message.recipient) {
|
||||||
case 'coordinator':
|
case 'coordinator':
|
||||||
nc.trigger(nc.ns.server.events.controlCommand.coordinator, message.data);
|
Nc.trigger(Nc.ns.server.events.controlCommand.coordinator, message.data);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
nc.trigger(nc.ns.server.events.controlCommand.user + message.recipient, message.data);
|
Nc.trigger(Nc.ns.server.events.controlCommand.user + message.recipient, message.data);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ define([
|
||||||
"Lib/Utilities/NotificationCenter"
|
"Lib/Utilities/NotificationCenter"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, ProtocolHelper, nc) {
|
function (Parent, ProtocolHelper, Nc) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -19,7 +19,7 @@ function (Parent, ProtocolHelper, nc) {
|
||||||
socketLink.on('message', this.onMessage.bind(this));
|
socketLink.on('message', this.onMessage.bind(this));
|
||||||
socketLink.on('disconnect', this.onDisconnect.bind(this));
|
socketLink.on('disconnect', this.onDisconnect.bind(this));
|
||||||
|
|
||||||
nc.on(nc.ns.server.events.controlCommand.user + this.id, this.socketLink.send, this.socketLink);
|
Nc.on(Nc.ns.server.events.controlCommand.user + this.id, this.socketLink.send, this.socketLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
User.prototype = Object.create(Parent.prototype);
|
User.prototype = Object.create(Parent.prototype);
|
||||||
|
|
@ -97,7 +97,7 @@ function (Parent, ProtocolHelper, nc) {
|
||||||
|
|
||||||
User.prototype.onPing = function(timestamp) {
|
User.prototype.onPing = function(timestamp) {
|
||||||
var message = ProtocolHelper.encodeCommand("pong", timestamp);
|
var message = ProtocolHelper.encodeCommand("pong", timestamp);
|
||||||
nc.trigger(nc.ns.server.events.controlCommand.user + this.id, message);
|
Nc.trigger(Nc.ns.server.events.controlCommand.user + this.id, message);
|
||||||
};
|
};
|
||||||
|
|
||||||
return User;
|
return User;
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,7 @@ var requirejs = require('requirejs');
|
||||||
requirejs.config({
|
requirejs.config({
|
||||||
nodeRequire: require,
|
nodeRequire: require,
|
||||||
baseUrl: 'app',
|
baseUrl: 'app',
|
||||||
deps: ['Lib/Utilities/Channel/Extensions'],
|
deps: ['Lib/Utilities/Channel/Extensions']
|
||||||
paths: {
|
|
||||||
text: 'Lib/Vendor/RequireJs/Plugin/Text',
|
|
||||||
json: 'Lib/Vendor/RequireJs/Plugin/Json',
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var inspector = {};
|
var inspector = {};
|
||||||
|
|
|
||||||
16
client.js
|
|
@ -7,8 +7,6 @@ requirejs.config({
|
||||||
deps: ['Lib/Utilities/Client/Extensions'],
|
deps: ['Lib/Utilities/Client/Extensions'],
|
||||||
waitSeconds: 0,
|
waitSeconds: 0,
|
||||||
paths: {
|
paths: {
|
||||||
text: 'Lib/Vendor/RequireJs/Plugin/Text',
|
|
||||||
json: 'Lib/Vendor/RequireJs/Plugin/Json',
|
|
||||||
screenfull: "/screenfull",
|
screenfull: "/screenfull",
|
||||||
chart: "/chart",
|
chart: "/chart",
|
||||||
socketio: "/socket.io/socket.io"
|
socketio: "/socket.io/socket.io"
|
||||||
|
|
@ -27,18 +25,24 @@ requirejs([
|
||||||
"Menu/Menu"
|
"Menu/Menu"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Networker, io, Settings, Exception, nc, Menu) {
|
function (Networker, SocketIO, Settings, Exception, Nc, Menu) {
|
||||||
|
|
||||||
var menu = new Menu();
|
var menu = new Menu();
|
||||||
menu.onRun = function(channelName, nickname) {
|
menu.onRun = function(channelName, nickname) {
|
||||||
var options = {
|
var options = {
|
||||||
transports: ["websocket"] // v4: only use websocket, flashsocket is gone
|
"reconnect": false,
|
||||||
|
"reconnection delay": 500,
|
||||||
|
"max reconnection attempts": 10,
|
||||||
|
"transports": [
|
||||||
|
"websocket",
|
||||||
|
"flashsocket"
|
||||||
|
]
|
||||||
};
|
};
|
||||||
var socket = io("/", options);
|
var socket = SocketIO.connect("/", options);
|
||||||
var networker = new Networker(socket, channelName, nickname);
|
var networker = new Networker(socket, channelName, nickname);
|
||||||
Chuck.inspector.networker = networker;
|
Chuck.inspector.networker = networker;
|
||||||
Chuck.inspector.settings = Settings;
|
Chuck.inspector.settings = Settings;
|
||||||
Chuck.inspector.nc = nc;
|
Chuck.inspector.nc = Nc;
|
||||||
Chuck.inspector.resetLevel = function() { networker.sendGameCommand("resetLevel"); }
|
Chuck.inspector.resetLevel = function() { networker.sendGameCommand("resetLevel"); }
|
||||||
}
|
}
|
||||||
menu.init();
|
menu.init();
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
({
|
({
|
||||||
baseUrl: "../app",
|
baseUrl: "../app",
|
||||||
paths: {
|
paths: {
|
||||||
"text": 'Lib/Vendor/RequireJs/Plugin/Text',
|
|
||||||
"json": 'Lib/Vendor/RequireJs/Plugin/Json',
|
|
||||||
"screenfull": "../node_modules/screenfull/dist/screenfull",
|
"screenfull": "../node_modules/screenfull/dist/screenfull",
|
||||||
"socketio": "../node_modules/socket.io/node_modules/socket.io-client/dist/socket.io",
|
"socketio": "../node_modules/socket.io/node_modules/socket.io-client/dist/socket.io",
|
||||||
"chart": "../node_modules/chart.js/Chart"
|
"chart": "../node_modules/chart.js/Chart"
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ define([
|
||||||
"Lib/Utilities/NotificationCenter"
|
"Lib/Utilities/NotificationCenter"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, ProtocolHelper, GameController, User) {
|
function (Parent, ProtocolHelper, GameController, User, Nc) {
|
||||||
|
|
||||||
function Worker () {
|
function Worker () {
|
||||||
//this.socketLink = socketLink;
|
//this.socketLink = socketLink;
|
||||||
|
|
@ -40,7 +40,7 @@ function (Parent, ProtocolHelper, GameController, User) {
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
nc.on(nc.ns.client.to.server.gameCommand.send, this.sendGameCommand, this);
|
Nc.on(Nc.ns.client.to.server.gameCommand.send, this.sendGameCommand, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Worker.prototype.sendCommand = function (command, options) {
|
Worker.prototype.sendCommand = function (command, options) {
|
||||||
|
|
|
||||||
2352
package-lock.json
generated
31
package.json
|
|
@ -1,9 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "chuck.js",
|
"name": "chuck.js",
|
||||||
"author": "logsol <fartman@gmx.de>",
|
"author": "logsol <fartman@gmx.de>",
|
||||||
"contributors": [
|
"contributors": ["Jeena Paradies <spam@jeenaparadies.net> (https://jeena.net)"],
|
||||||
"Jeena Paradies <spam@jeenaparadies.net> (https://jeena.net)"
|
|
||||||
],
|
|
||||||
"description": "Multiplayer browser jump and run game",
|
"description": "Multiplayer browser jump and run game",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"homepage": "http://chuck-game.tumblr.com/",
|
"homepage": "http://chuck-game.tumblr.com/",
|
||||||
|
|
@ -15,28 +13,21 @@
|
||||||
"url": "https://github.com/logsol/chuck.js/issues",
|
"url": "https://github.com/logsol/chuck.js/issues",
|
||||||
"email": "fartman@gmx.de"
|
"email": "fartman@gmx.de"
|
||||||
},
|
},
|
||||||
"main": "server.js",
|
"main": "",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"socket.io": "^4.7.4",
|
"socket.io": "= 0.9.6",
|
||||||
"express": "^4.18.2",
|
"node-static": ">= 0.6.0",
|
||||||
"requirejs": "^2.3.6",
|
"requirejs": "= 2.0.4",
|
||||||
"screenfull": "^6.0.2",
|
"node-fork": ">= 0.4.2",
|
||||||
"chart.js": "^4.4.0"
|
"screenfull": ">= 1.0.4",
|
||||||
},
|
"chart.js": ">= 1.0.1"
|
||||||
"devDependencies": {
|
|
||||||
"nodemon": "^3.0.2"
|
|
||||||
},
|
},
|
||||||
|
"devDependencies": {},
|
||||||
"optionalDependencies": {},
|
"optionalDependencies": {},
|
||||||
"engines": {
|
"engine": "node >= 0.8.4",
|
||||||
"node": ">=16.0.0"
|
"config": { "port": "1234" },
|
||||||
},
|
|
||||||
"config": {
|
|
||||||
"port": "1234"
|
|
||||||
},
|
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node server.js",
|
|
||||||
"dev": "nodemon server.js",
|
|
||||||
"prestart": "scripts/build.sh"
|
"prestart": "scripts/build.sh"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,98 @@
|
||||||
|
m1426446028547{"recipient":"channel","data":{"addUser":{"id":"7389285181034131943","nickname":"Bot1"}}}
|
||||||
|
m1426446029119{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"clientReady\\\":null}\"}"}
|
||||||
|
w1426446029547{"doll-7389285181034131943":{"p":{"x":26.757009396292265,"y":2.8537988666369247},"a":0,"lv":{"x":0,"y":3.686287386450715e-18},"av":0,"as":"stand","laxy":{"x":0,"y":0}},"item-6":{"p":{"x":17.676190476190477,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-5":{"p":{"x":20.68034223796989,"y":14.27172409912905},"a":0.05645956288623199,"lv":{"x":-0.3822032971313994,"y":0.10581586623357915},"av":-0.9131901027366345},"item-4":{"p":{"x":20.210667860242594,"y":14.23713937029844},"a":0.2172662762511257,"lv":{"x":-0.4539838684349691,"y":0.056447865910879066},"av":-0.8171646189887583},"item-3":{"p":{"x":22.4,"y":14.277445638095237},"a":0,"lv":{"x":0,"y":0},"av":0},"item-2":{"p":{"x":9.013612698412686,"y":18.087738095238098},"a":0,"lv":{"x":0,"y":0},"av":0},"item-1":{"p":{"x":19.642184126984116,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-0":{"p":{"x":19.14632479802086,"y":14.27055244283271},"a":-0.030402669209750526,"lv":{"x":0.36764627338079947,"y":0.11541986576858798},"av":0.6858739292935763}}
|
||||||
|
w1426446030548{"doll-7389285181034131943":{"p":{"x":26.757009396292265,"y":2.8537988666369247},"a":0,"lv":{"x":0,"y":0},"av":0,"as":"stand","laxy":{"x":0,"y":0}},"item-6":{"p":{"x":17.676190476190477,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-5":{"p":{"x":20.676956793943322,"y":14.27693273489722},"a":-0.006893630787064592,"lv":{"x":0,"y":0},"av":0},"item-4":{"p":{"x":20.200040618322713,"y":14.276203443653712},"a":-0.0004911852214511643,"lv":{"x":-0.0017410956075321858,"y":8.552005003579723e-7},"av":3.946495907847236e-17},"item-3":{"p":{"x":22.4,"y":14.277445638095237},"a":0,"lv":{"x":0,"y":0},"av":0},"item-2":{"p":{"x":9.013612698412686,"y":18.087738095238098},"a":0,"lv":{"x":0,"y":0},"av":0},"item-1":{"p":{"x":19.642184126984116,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-0":{"p":{"x":19.147450032657666,"y":14.276009262801196},"a":0.0025201794161469693,"lv":{"x":0,"y":0},"av":0}}
|
||||||
|
m1426446031024{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"lookAt\\\":{\\\"x\\\":-0.1,\\\"y\\\":0}}\"}"}
|
||||||
|
m1426446031024{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"moveLeft\\\":null}\"}"}
|
||||||
|
w1426446031550{"doll-7389285181034131943":{"p":{"x":23.369073130763105,"y":5.155903892632974},"a":0,"lv":{"x":-6.2,"y":10.122520758193609},"av":0,"as":"run","laxy":{"x":-0.1,"y":0}},"item-6":{"p":{"x":17.676190476190477,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-5":{"p":{"x":20.676956793943322,"y":14.27693273489722},"a":-0.006893630787064592,"lv":{"x":0,"y":0},"av":0},"item-4":{"p":{"x":20.200046042197616,"y":14.276203440989589},"a":-0.0004911852214511747,"lv":{"x":0,"y":0},"av":0},"item-3":{"p":{"x":22.4,"y":14.277445638095237},"a":0,"lv":{"x":0,"y":0},"av":0},"item-2":{"p":{"x":9.013612698412686,"y":18.087738095238098},"a":0,"lv":{"x":0,"y":0},"av":0},"item-1":{"p":{"x":19.642184126984116,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-0":{"p":{"x":19.147450032657666,"y":14.276009262801196},"a":0.0025201794161469693,"lv":{"x":0,"y":0},"av":0}}
|
||||||
|
m1426446031695{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"mePositionStateUpdate\\\":{\\\"p\\\":{\\\"x\\\":22.546741092148903,\\\"y\\\":6.945440200409302},\\\"lv\\\":{\\\"x\\\":-6.2,\\\"y\\\":13.302715397413536}}}\"}"}
|
||||||
|
m1426446031704{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"mePositionStateUpdate\\\":{\\\"p\\\":{\\\"x\\\":22.484989092148904,\\\"y\\\":7.080524845767541},\\\"lv\\\":{\\\"x\\\":-6.2,\\\"y\\\":13.508464535823881}}}\"}"}
|
||||||
|
m1426446031782{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"stop\\\":null}\"}"}
|
||||||
|
m1426446031912{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"mePositionStateUpdate\\\":{\\\"p\\\":{\\\"x\\\":21.73476374575245,\\\"y\\\":10.32390717922336},\\\"lv\\\":{\\\"x\\\":-2.3463161980324543,\\\"y\\\":17.55729589350694}}}\"}"}
|
||||||
|
m1426446032042{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"mePositionStateUpdate\\\":{\\\"p\\\":{\\\"x\\\":21.44100843193758,\\\"y\\\":12.7671303982799},\\\"lv\\\":{\\\"x\\\":-2.227842551800874,\\\"y\\\":19.92590130886559}}}\"}"}
|
||||||
|
m1426446032126{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"mePositionStateUpdate\\\":{\\\"p\\\":{\\\"x\\\":21.2807959597357,\\\"y\\\":14.271291852124465},\\\"lv\\\":{\\\"x\\\":0,\\\"y\\\":-2.133620078919897}}}\"}"}
|
||||||
|
m1426446032164{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"handActionRequest\\\":{\\\"x\\\":-0.1,\\\"y\\\":0,\\\"av\\\":0}}\"}"}
|
||||||
|
w1426446032551{"doll-7389285181034131943":{"p":{"x":21.2807959597357,"y":14.2827540733478},"a":0,"lv":{"x":0,"y":2.0808241610672144e-17},"av":0,"as":"stand","laxy":{"x":-0.1,"y":0}},"item-6":{"p":{"x":17.676190476190477,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-5":{"p":{"x":20.92365310259284,"y":13.401801692395418},"a":-0.3,"lv":{"x":1.1578834351175484e-60,"y":1.9012546152460842e-16},"av":6.564623608182231e-48},"item-4":{"p":{"x":20.200046042197616,"y":14.276203440989589},"a":-0.0004911852214511747,"lv":{"x":0,"y":0},"av":0},"item-3":{"p":{"x":22.4,"y":14.277445638095237},"a":0,"lv":{"x":0,"y":0},"av":0},"item-2":{"p":{"x":9.013612698412686,"y":18.087738095238098},"a":0,"lv":{"x":0,"y":0},"av":0},"item-1":{"p":{"x":19.642184126984116,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-0":{"p":{"x":19.147450032657666,"y":14.276009262801196},"a":0.0025201794161469693,"lv":{"x":0,"y":0},"av":0}}
|
||||||
|
m1426446032607{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"jump\\\":null}\"}"}
|
||||||
|
m1426446032783{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"lookAt\\\":{\\\"x\\\":-0.1,\\\"y\\\":0}}\"}"}
|
||||||
|
m1426446032783{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"moveLeft\\\":null}\"}"}
|
||||||
|
m1426446033408{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"handActionRequest\\\":{\\\"x\\\":-2,\\\"y\\\":1.1616379503624417,\\\"av\\\":-0.33531939942689776}}\"}"}
|
||||||
|
w1426446033552{"doll-7389285181034131943":{"p":{"x":16.557991085576948,"y":12.476641521631196},"a":0,"lv":{"x":-6.2,"y":9.458269369609303},"av":0,"as":"jump","laxy":{"x":-0.1,"y":0}},"item-6":{"p":{"x":17.676190476190477,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-5":{"p":{"x":12.048335711507379,"y":9.27107894546859},"a":-0.15313010305101882,"lv":{"x":-34.2,"y":-6.332771923395663},"av":1.0059581982806933},"item-4":{"p":{"x":20.200046042197616,"y":14.276203440989589},"a":-0.0004911852214511747,"lv":{"x":0,"y":0},"av":0},"item-3":{"p":{"x":22.4,"y":14.277445638095237},"a":0,"lv":{"x":0,"y":0},"av":0},"item-2":{"p":{"x":9.013612698412686,"y":18.087738095238098},"a":0,"lv":{"x":0,"y":0},"av":0},"item-1":{"p":{"x":19.642184126984116,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-0":{"p":{"x":19.147450032657666,"y":14.276009262801196},"a":0.0025201794161469693,"lv":{"x":0,"y":0},"av":0}}
|
||||||
|
m1426446033620{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"jumpStop\\\":null}\"}"}
|
||||||
|
m1426446033708{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"stop\\\":null}\"}"}
|
||||||
|
m1426446033764{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"mePositionStateUpdate\\\":{\\\"p\\\":{\\\"x\\\":15.545509158762231,\\\"y\\\":14.939529946319917},\\\"lv\\\":{\\\"x\\\":-2.411280442117325,\\\"y\\\":13.851923076171733}}}\"}"}
|
||||||
|
m1426446033823{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"mePositionStateUpdate\\\":{\\\"p\\\":{\\\"x\\\":15.407720608611541,\\\"y\\\":15.786375605059586},\\\"lv\\\":{\\\"x\\\":-2.355804291795286,\\\"y\\\":15.018971297630832}}}\"}"}
|
||||||
|
m1426446033890{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"mePositionStateUpdate\\\":{\\\"p\\\":{\\\"x\\\":15.252508070805703,\\\"y\\\":16.84788590944936},\\\"lv\\\":{\\\"x\\\":-2.2933002802534532,\\\"y\\\":16.333499883787308}}}\"}"}
|
||||||
|
m1426446033906{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"mePositionStateUpdate\\\":{\\\"p\\\":{\\\"x\\\":15.216050100270346,\\\"y\\\":17.114162758801857},\\\"lv\\\":{\\\"x\\\":-2.278623158459831,\\\"y\\\":16.642303084531072}}}\"}"}
|
||||||
|
m1426446034032{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"lookAt\\\":{\\\"x\\\":-0.1,\\\"y\\\":0}}\"}"}
|
||||||
|
m1426446034032{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"moveLeft\\\":null}\"}"}
|
||||||
|
w1426446034554{"doll-7389285181034131943":{"p":{"x":11.194618169931237,"y":18.075345972889064},"a":0,"lv":{"x":-8,"y":-0.3919449863882458},"av":0,"as":"run","laxy":{"x":-0.1,"y":0}},"item-6":{"p":{"x":17.676190476190477,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-5":{"p":{"x":3.5543134118221587,"y":18.08462667589248},"a":25.09946829820324,"lv":{"x":-0.19007540236753293,"y":-0.061006264861284215},"av":-0.46231125937975326},"item-4":{"p":{"x":20.200046042197616,"y":14.276203440989589},"a":-0.0004911852214511747,"lv":{"x":0,"y":0},"av":0},"item-3":{"p":{"x":22.4,"y":14.277445638095237},"a":0,"lv":{"x":0,"y":0},"av":0},"item-2":{"p":{"x":9.013612698412686,"y":18.087738095238098},"a":0,"lv":{"x":0,"y":0},"av":0},"item-1":{"p":{"x":19.642184126984116,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-0":{"p":{"x":19.147450032657666,"y":14.276009262801196},"a":0.0025201794161469693,"lv":{"x":0,"y":0},"av":0}}
|
||||||
|
m1426446034796{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"handActionRequest\\\":{\\\"x\\\":-0.1,\\\"y\\\":0,\\\"av\\\":0}}\"}"}
|
||||||
|
m1426446034797{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"stop\\\":null}\"}"}
|
||||||
|
m1426446035284{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"lookAt\\\":{\\\"x\\\":0.1,\\\"y\\\":0}}\"}"}
|
||||||
|
m1426446035284{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"moveRight\\\":null}\"}"}
|
||||||
|
m1426446035395{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"jump\\\":null}\"}"}
|
||||||
|
w1426446035556{"doll-7389285181034131943":{"p":{"x":10.491286858763196,"y":16.009696234603773},"a":0,"lv":{"x":6.2,"y":-10.887028542012015},"av":0,"as":"jump","laxy":{"x":0.1,"y":0}},"item-6":{"p":{"x":17.676190476190477,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-5":{"p":{"x":3.551564486509986,"y":18.086205519078288},"a":25.13402937147234,"lv":{"x":0,"y":0},"av":0},"item-4":{"p":{"x":20.200046042197616,"y":14.276203440989589},"a":-0.0004911852214511747,"lv":{"x":0,"y":0},"av":0},"item-3":{"p":{"x":22.4,"y":14.277445638095237},"a":0,"lv":{"x":0,"y":0},"av":0},"item-2":{"p":{"x":10.824620192096528,"y":15.128743853651395},"a":0.5,"lv":{"x":6.1577922291668665,"y":-10.887028542012015},"av":-1.4981364335015035e-95},"item-1":{"p":{"x":19.642184126984116,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-0":{"p":{"x":19.147450032657666,"y":14.276009262801196},"a":0.0025201794161469693,"lv":{"x":0,"y":0},"av":0}}
|
||||||
|
m1426446035619{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"jumpStop\\\":null}\"}"}
|
||||||
|
m1426446035622{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"handActionRequest\\\":{\\\"x\\\":2,\\\"y\\\":1.0402407501042503,\\\"av\\\":0.4762204811665006}}\"}"}
|
||||||
|
m1426446035669{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"stop\\\":null}\"}"}
|
||||||
|
m1426446036222{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"lookAt\\\":{\\\"x\\\":0.1,\\\"y\\\":0}}\"}"}
|
||||||
|
m1426446036222{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"moveRight\\\":null}\"}"}
|
||||||
|
w1426446036557{"doll-7389285181034131943":{"p":{"x":14.892865112434567,"y":18.093198012571065},"a":0,"lv":{"x":8,"y":1.1357017756785659e-17},"av":0,"as":"run","laxy":{"x":0.1,"y":0}},"item-6":{"p":{"x":17.676190476190477,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-5":{"p":{"x":3.551564486509986,"y":18.086205519078288},"a":25.13402937147234,"lv":{"x":0,"y":0},"av":0},"item-4":{"p":{"x":20.200046042197616,"y":14.276203440989589},"a":-0.0004911852214511747,"lv":{"x":0,"y":0},"av":0},"item-3":{"p":{"x":22.4,"y":14.277445638095237},"a":0,"lv":{"x":0,"y":0},"av":0},"item-2":{"p":{"x":25.67263575288429,"y":9.396029900844805},"a":1.5453100773100037,"lv":{"x":1.2141986028185257,"y":1.5118096406061725},"av":7.842891058848907},"item-1":{"p":{"x":19.642184126984116,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-0":{"p":{"x":19.147450032657666,"y":14.276009262801196},"a":0.0025201794161469693,"lv":{"x":0,"y":0},"av":0}}
|
||||||
|
m1426446036597{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"jump\\\":null}\"}"}
|
||||||
|
m1426446037146{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"jumpStop\\\":null}\"}"}
|
||||||
|
m1426446037146{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"stop\\\":null}\"}"}
|
||||||
|
m1426446037233{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"lookAt\\\":{\\\"x\\\":-0.1,\\\"y\\\":0}}\"}"}
|
||||||
|
m1426446037233{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"moveLeft\\\":null}\"}"}
|
||||||
|
w1426446037559{"doll-7389285181034131943":{"p":{"x":16.315888057006195,"y":18.09351694650934},"a":0,"lv":{"x":-8,"y":0},"av":0,"as":"run","laxy":{"x":-0.1,"y":0}},"item-6":{"p":{"x":17.676190476190477,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-5":{"p":{"x":3.551564486509986,"y":18.086205519078288},"a":25.13402937147234,"lv":{"x":0,"y":0},"av":0},"item-4":{"p":{"x":20.200046042197616,"y":14.276203440989589},"a":-0.0004911852214511747,"lv":{"x":0,"y":0},"av":0},"item-3":{"p":{"x":22.4,"y":14.277445638095237},"a":0,"lv":{"x":0,"y":0},"av":0},"item-2":{"p":{"x":25.676240547787568,"y":9.396188210902643},"a":1.5696221500784544,"lv":{"x":0,"y":0},"av":0},"item-1":{"p":{"x":19.642184126984116,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-0":{"p":{"x":19.147450032657666,"y":14.276009262801196},"a":0.0025201794161469693,"lv":{"x":0,"y":0},"av":0}}
|
||||||
|
m1426446037870{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"jump\\\":null}\"}"}
|
||||||
|
m1426446037907{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"stop\\\":null}\"}"}
|
||||||
|
m1426446037932{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"lookAt\\\":{\\\"x\\\":0.1,\\\"y\\\":0}}\"}"}
|
||||||
|
m1426446037933{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"moveRight\\\":null}\"}"}
|
||||||
|
m1426446038419{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"jumpStop\\\":null}\"}"}
|
||||||
|
m1426446038432{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"stop\\\":null}\"}"}
|
||||||
|
m1426446038538{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"handActionRequest\\\":{\\\"x\\\":0.1,\\\"y\\\":0,\\\"av\\\":0}}\"}"}
|
||||||
|
w1426446038561{"doll-7389285181034131943":{"p":{"x":17.1826631025223,"y":14.213702272433377},"a":0,"lv":{"x":2.316415665762817,"y":3.1852767893487735},"av":0,"as":"stand","laxy":{"x":0.1,"y":0}},"item-6":{"p":{"x":17.49218691204611,"y":13.332749891480995},"a":0.3,"lv":{"x":2.316415665762817,"y":3.1852767893487735},"av":0},"item-5":{"p":{"x":3.551564486509986,"y":18.086205519078288},"a":25.13402937147234,"lv":{"x":0,"y":0},"av":0},"item-4":{"p":{"x":20.200046042197616,"y":14.276203440989589},"a":-0.0004911852214511747,"lv":{"x":0,"y":0},"av":0},"item-3":{"p":{"x":22.4,"y":14.277445638095237},"a":0,"lv":{"x":0,"y":0},"av":0},"item-2":{"p":{"x":25.676240547787568,"y":9.396188210902643},"a":1.5696221500784544,"lv":{"x":0,"y":0},"av":0},"item-1":{"p":{"x":19.642184126984116,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-0":{"p":{"x":19.147450032657666,"y":14.276009262801196},"a":0.0025201794161469693,"lv":{"x":0,"y":0},"av":0}}
|
||||||
|
m1426446038958{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"lookAt\\\":{\\\"x\\\":-0.1,\\\"y\\\":0}}\"}"}
|
||||||
|
m1426446038958{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"moveLeft\\\":null}\"}"}
|
||||||
|
m1426446038996{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"jump\\\":null}\"}"}
|
||||||
|
m1426446039345{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"stop\\\":null}\"}"}
|
||||||
|
m1426446039357{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"jumpStop\\\":null}\"}"}
|
||||||
|
w1426446039562{"doll-7389285181034131943":{"p":{"x":14.373155722224688,"y":10.923172851093172},"a":0,"lv":{"x":-2.3491405651705346,"y":3.215539708036451},"av":0,"as":"jump","laxy":{"x":-0.1,"y":0}},"item-6":{"p":{"x":14.063631912700878,"y":10.04222047014079},"a":-0.3,"lv":{"x":-2.3491405651705346,"y":3.215539708036451},"av":1.4981364335015035e-95},"item-5":{"p":{"x":3.551564486509986,"y":18.086205519078288},"a":25.13402937147234,"lv":{"x":0,"y":0},"av":0},"item-4":{"p":{"x":20.200046042197616,"y":14.276203440989589},"a":-0.0004911852214511747,"lv":{"x":0,"y":0},"av":0},"item-3":{"p":{"x":22.4,"y":14.277445638095237},"a":0,"lv":{"x":0,"y":0},"av":0},"item-2":{"p":{"x":25.676240547787568,"y":9.396188210902643},"a":1.5696221500784544,"lv":{"x":0,"y":0},"av":0},"item-1":{"p":{"x":19.642184126984116,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-0":{"p":{"x":19.147450032657666,"y":14.276009262801196},"a":0.0025201794161469693,"lv":{"x":0,"y":0},"av":0}}
|
||||||
|
m1426446039848{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"jump\\\":null}\"}"}
|
||||||
|
m1426446039870{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"lookAt\\\":{\\\"x\\\":-0.1,\\\"y\\\":0}}\"}"}
|
||||||
|
m1426446039870{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"moveLeft\\\":null}\"}"}
|
||||||
|
m1426446039961{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"mePositionStateUpdate\\\":{\\\"p\\\":{\\\"x\\\":13.763554582654288,\\\"y\\\":9.91021111614182},\\\"lv\\\":{\\\"x\\\":-6.2,\\\"y\\\":-12.214568104301154}}}\"}"}
|
||||||
|
m1426446040457{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"jumpStop\\\":null}\"}"}
|
||||||
|
m1426446040491{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"stop\\\":null}\"}"}
|
||||||
|
w1426446040564{"doll-7389285181034131943":{"p":{"x":9.827992197957391,"y":7.616287969672424},"a":0,"lv":{"x":-0.0000010315612595218654,"y":-0.3467108761433166},"av":0,"as":"stand","laxy":{"x":-0.1,"y":0}},"item-6":{"p":{"x":9.51846838843358,"y":6.735335588720043},"a":-0.3,"lv":{"x":-0.0000010315612595218745,"y":-0.3467108761433166},"av":-3.237869826367756e-34},"item-5":{"p":{"x":3.551564486509986,"y":18.086205519078288},"a":25.13402937147234,"lv":{"x":0,"y":0},"av":0},"item-4":{"p":{"x":20.200046042197616,"y":14.276203440989589},"a":-0.0004911852214511747,"lv":{"x":0,"y":0},"av":0},"item-3":{"p":{"x":22.4,"y":14.277445638095237},"a":0,"lv":{"x":0,"y":0},"av":0},"item-2":{"p":{"x":25.676240547787568,"y":9.396188210902643},"a":1.5696221500784544,"lv":{"x":0,"y":0},"av":0},"item-1":{"p":{"x":19.642184126984116,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-0":{"p":{"x":19.147450032657666,"y":14.276009262801196},"a":0.0025201794161469693,"lv":{"x":0,"y":0},"av":0}}
|
||||||
|
m1426446040814{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"handActionRequest\\\":{\\\"x\\\":null,\\\"y\\\":null,\\\"av\\\":0}}\"}"}
|
||||||
|
m1426446041546{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"lookAt\\\":{\\\"x\\\":-0.1,\\\"y\\\":0}}\"}"}
|
||||||
|
m1426446041546{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"moveLeft\\\":null}\"}"}
|
||||||
|
w1426446041565{"doll-7389285181034131943":{"p":{"x":9.695420727381228,"y":7.6162879696953505},"a":0,"lv":{"x":-8,"y":0},"av":0,"as":"run","laxy":{"x":-0.1,"y":0}},"item-6":{"p":{"x":9.401617976491387,"y":7.516140983169705},"a":-1.564982640581702,"lv":{"x":0.0015602824631008733,"y":-0.0055646575139384315},"av":0.0151800309605853},"item-5":{"p":{"x":3.551564486509986,"y":18.086205519078288},"a":25.13402937147234,"lv":{"x":0,"y":0},"av":0},"item-4":{"p":{"x":20.200046042197616,"y":14.276203440989589},"a":-0.0004911852214511747,"lv":{"x":0,"y":0},"av":0},"item-3":{"p":{"x":22.4,"y":14.277445638095237},"a":0,"lv":{"x":0,"y":0},"av":0},"item-2":{"p":{"x":25.676240547787568,"y":9.396188210902643},"a":1.5696221500784544,"lv":{"x":0,"y":0},"av":0},"item-1":{"p":{"x":19.642184126984116,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-0":{"p":{"x":19.147450032657666,"y":14.276009262801196},"a":0.0025201794161469693,"lv":{"x":0,"y":0},"av":0}}
|
||||||
|
m1426446041708{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"stop\\\":null}\"}"}
|
||||||
|
m1426446042118{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"handActionRequest\\\":{\\\"x\\\":-0.1,\\\"y\\\":0,\\\"av\\\":0}}\"}"}
|
||||||
|
m1426446042420{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"lookAt\\\":{\\\"x\\\":-0.1,\\\"y\\\":0}}\"}"}
|
||||||
|
m1426446042420{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"moveLeft\\\":null}\"}"}
|
||||||
|
w1426446042568{"doll-7389285181034131943":{"p":{"x":7.146502745202811,"y":7.6190476190527345},"a":0,"lv":{"x":-8,"y":1.8167431059639174e-9},"av":0,"as":"run","laxy":{"x":-0.1,"y":0}},"item-6":{"p":{"x":6.836978935679003,"y":6.738095238100354},"a":-0.3,"lv":{"x":-7.710315253398224,"y":1.816743105963944e-9},"av":-1.2647929009154966e-36},"item-5":{"p":{"x":3.551564486509986,"y":18.086205519078288},"a":25.13402937147234,"lv":{"x":0,"y":0},"av":0},"item-4":{"p":{"x":20.200046042197616,"y":14.276203440989589},"a":-0.0004911852214511747,"lv":{"x":0,"y":0},"av":0},"item-3":{"p":{"x":22.4,"y":14.277445638095237},"a":0,"lv":{"x":0,"y":0},"av":0},"item-2":{"p":{"x":25.676240547787568,"y":9.396188210902643},"a":1.5696221500784544,"lv":{"x":0,"y":0},"av":0},"item-1":{"p":{"x":19.642184126984116,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-0":{"p":{"x":19.147450032657666,"y":14.276009262801196},"a":0.0025201794161469693,"lv":{"x":0,"y":0},"av":0}}
|
||||||
|
m1426446042873{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"stop\\\":null}\"}"}
|
||||||
|
m1426446042996{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"lookAt\\\":{\\\"x\\\":0.1,\\\"y\\\":0}}\"}"}
|
||||||
|
m1426446042996{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"moveRight\\\":null}\"}"}
|
||||||
|
m1426446043102{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"handActionRequest\\\":{\\\"x\\\":2,\\\"y\\\":0.24735158698021256,\\\"av\\\":-0.506800103937166}}\"}"}
|
||||||
|
m1426446043149{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"stop\\\":null}\"}"}
|
||||||
|
w1426446043570{"doll-7389285181034131943":{"p":{"x":6.717469927715379,"y":18.026718836374023},"a":0,"lv":{"x":0,"y":-1.5933058441069676},"av":0,"as":"stand","laxy":{"x":0.1,"y":0}},"item-6":{"p":{"x":15.346920374111809,"y":8.242346533188677},"a":13.745544723304238,"lv":{"x":8.865053038008881,"y":-6.948476024418163},"av":40.16880149763361},"item-5":{"p":{"x":3.551564486509986,"y":18.086205519078288},"a":25.13402937147234,"lv":{"x":0,"y":0},"av":0},"item-4":{"p":{"x":20.200046042197616,"y":14.276203440989589},"a":-0.0004911852214511747,"lv":{"x":0,"y":0},"av":0},"item-3":{"p":{"x":22.4,"y":14.277445638095237},"a":0,"lv":{"x":0,"y":0},"av":0},"item-2":{"p":{"x":25.676240547787568,"y":9.396188210902643},"a":1.5696221500784544,"lv":{"x":0,"y":0},"av":0},"item-1":{"p":{"x":19.642184126984116,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-0":{"p":{"x":19.147450032657666,"y":14.276009262801196},"a":0.0025201794161469693,"lv":{"x":0,"y":0},"av":0}}
|
||||||
|
w1426446044571{"doll-7389285181034131943":{"p":{"x":6.717469927715379,"y":18.094932218730197},"a":0,"lv":{"x":0,"y":0},"av":0,"as":"stand","laxy":{"x":0.1,"y":0}},"item-6":{"p":{"x":24.736836349036146,"y":14.105602828936636},"a":53.954515022435494,"lv":{"x":8.865053038008881,"y":19.077523975581837},"av":40.16880149763361},"item-5":{"p":{"x":3.551564486509986,"y":18.086205519078288},"a":25.13402937147234,"lv":{"x":0,"y":0},"av":0},"item-4":{"p":{"x":20.200046042197616,"y":14.276203440989589},"a":-0.0004911852214511747,"lv":{"x":0,"y":0},"av":0},"item-3":{"p":{"x":22.4,"y":14.277445638095237},"a":0,"lv":{"x":0,"y":0},"av":0},"item-2":{"p":{"x":25.676240547787568,"y":9.396188210902643},"a":1.5696221500784544,"lv":{"x":0,"y":0},"av":0},"item-1":{"p":{"x":19.642184126984116,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-0":{"p":{"x":19.147450032657666,"y":14.276009262801196},"a":0.0025201794161469693,"lv":{"x":0,"y":0},"av":0}}
|
||||||
|
w1426446045571{"doll-7389285181034131943":{"p":{"x":6.717469927715379,"y":18.094932218730197},"a":0,"lv":{"x":0,"y":0},"av":0,"as":"stand","laxy":{"x":0.1,"y":0}},"item-6":{"p":{"x":25.484252760088392,"y":17.1308518892069},"a":56.5833675581005,"lv":{"x":0.04489757650580847,"y":-0.010299028060006578},"av":0.12321006381376746},"item-5":{"p":{"x":3.551564486509986,"y":18.086205519078288},"a":25.13402937147234,"lv":{"x":0,"y":0},"av":0},"item-4":{"p":{"x":20.200046042197616,"y":14.276203440989589},"a":-0.0004911852214511747,"lv":{"x":0,"y":0},"av":0},"item-3":{"p":{"x":22.4,"y":14.277445638095237},"a":0,"lv":{"x":0,"y":0},"av":0},"item-2":{"p":{"x":25.676240547787568,"y":9.396188210902643},"a":1.5696221500784544,"lv":{"x":0,"y":0},"av":0},"item-1":{"p":{"x":19.642184126984116,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-0":{"p":{"x":19.147450032657666,"y":14.276009262801196},"a":0.0025201794161469693,"lv":{"x":0,"y":0},"av":0}}
|
||||||
|
w1426446046572{"doll-7389285181034131943":{"p":{"x":6.717469927715379,"y":18.094932218730197},"a":0,"lv":{"x":0,"y":0},"av":0,"as":"stand","laxy":{"x":0.1,"y":0}},"item-6":{"p":{"x":25.484809555865787,"y":17.13345683956885},"a":56.55108306250028,"lv":{"x":0,"y":0},"av":0},"item-5":{"p":{"x":3.551564486509986,"y":18.086205519078288},"a":25.13402937147234,"lv":{"x":0,"y":0},"av":0},"item-4":{"p":{"x":20.200046042197616,"y":14.276203440989589},"a":-0.0004911852214511747,"lv":{"x":0,"y":0},"av":0},"item-3":{"p":{"x":22.4,"y":14.277445638095237},"a":0,"lv":{"x":0,"y":0},"av":0},"item-2":{"p":{"x":25.676240547787568,"y":9.396188210902643},"a":1.5696221500784544,"lv":{"x":0,"y":0},"av":0},"item-1":{"p":{"x":19.642184126984116,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-0":{"p":{"x":19.147450032657666,"y":14.276009262801196},"a":0.0025201794161469693,"lv":{"x":0,"y":0},"av":0}}
|
||||||
|
w1426446047573{"doll-7389285181034131943":{"p":{"x":6.717469927715379,"y":18.094932218730197},"a":0,"lv":{"x":0,"y":0},"av":0,"as":"stand","laxy":{"x":0.1,"y":0}},"item-6":{"p":{"x":25.484809555865787,"y":17.13345683956885},"a":56.55108306250028,"lv":{"x":0,"y":0},"av":0},"item-5":{"p":{"x":3.551564486509986,"y":18.086205519078288},"a":25.13402937147234,"lv":{"x":0,"y":0},"av":0},"item-4":{"p":{"x":20.200046042197616,"y":14.276203440989589},"a":-0.0004911852214511747,"lv":{"x":0,"y":0},"av":0},"item-3":{"p":{"x":22.4,"y":14.277445638095237},"a":0,"lv":{"x":0,"y":0},"av":0},"item-2":{"p":{"x":25.676240547787568,"y":9.396188210902643},"a":1.5696221500784544,"lv":{"x":0,"y":0},"av":0},"item-1":{"p":{"x":19.642184126984116,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-0":{"p":{"x":19.147450032657666,"y":14.276009262801196},"a":0.0025201794161469693,"lv":{"x":0,"y":0},"av":0}}
|
||||||
|
w1426446048574{"doll-7389285181034131943":{"p":{"x":6.717469927715379,"y":18.094932218730197},"a":0,"lv":{"x":0,"y":0},"av":0,"as":"stand","laxy":{"x":0.1,"y":0}},"item-6":{"p":{"x":25.484809555865787,"y":17.13345683956885},"a":56.55108306250028,"lv":{"x":0,"y":0},"av":0},"item-5":{"p":{"x":3.551564486509986,"y":18.086205519078288},"a":25.13402937147234,"lv":{"x":0,"y":0},"av":0},"item-4":{"p":{"x":20.200046042197616,"y":14.276203440989589},"a":-0.0004911852214511747,"lv":{"x":0,"y":0},"av":0},"item-3":{"p":{"x":22.4,"y":14.277445638095237},"a":0,"lv":{"x":0,"y":0},"av":0},"item-2":{"p":{"x":25.676240547787568,"y":9.396188210902643},"a":1.5696221500784544,"lv":{"x":0,"y":0},"av":0},"item-1":{"p":{"x":19.642184126984116,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-0":{"p":{"x":19.147450032657666,"y":14.276009262801196},"a":0.0025201794161469693,"lv":{"x":0,"y":0},"av":0}}
|
||||||
|
w1426446049575{"doll-7389285181034131943":{"p":{"x":6.717469927715379,"y":18.094932218730197},"a":0,"lv":{"x":0,"y":0},"av":0,"as":"stand","laxy":{"x":0.1,"y":0}},"item-6":{"p":{"x":25.484809555865787,"y":17.13345683956885},"a":56.55108306250028,"lv":{"x":0,"y":0},"av":0},"item-5":{"p":{"x":3.551564486509986,"y":18.086205519078288},"a":25.13402937147234,"lv":{"x":0,"y":0},"av":0},"item-4":{"p":{"x":20.200046042197616,"y":14.276203440989589},"a":-0.0004911852214511747,"lv":{"x":0,"y":0},"av":0},"item-3":{"p":{"x":22.4,"y":14.277445638095237},"a":0,"lv":{"x":0,"y":0},"av":0},"item-2":{"p":{"x":25.676240547787568,"y":9.396188210902643},"a":1.5696221500784544,"lv":{"x":0,"y":0},"av":0},"item-1":{"p":{"x":19.642184126984116,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-0":{"p":{"x":19.147450032657666,"y":14.276009262801196},"a":0.0025201794161469693,"lv":{"x":0,"y":0},"av":0}}
|
||||||
|
w1426446050576{"doll-7389285181034131943":{"p":{"x":6.717469927715379,"y":18.094932218730197},"a":0,"lv":{"x":0,"y":0},"av":0,"as":"stand","laxy":{"x":0.1,"y":0}},"item-6":{"p":{"x":25.484809555865787,"y":17.13345683956885},"a":56.55108306250028,"lv":{"x":0,"y":0},"av":0},"item-5":{"p":{"x":3.551564486509986,"y":18.086205519078288},"a":25.13402937147234,"lv":{"x":0,"y":0},"av":0},"item-4":{"p":{"x":20.200046042197616,"y":14.276203440989589},"a":-0.0004911852214511747,"lv":{"x":0,"y":0},"av":0},"item-3":{"p":{"x":22.4,"y":14.277445638095237},"a":0,"lv":{"x":0,"y":0},"av":0},"item-2":{"p":{"x":25.676240547787568,"y":9.396188210902643},"a":1.5696221500784544,"lv":{"x":0,"y":0},"av":0},"item-1":{"p":{"x":19.642184126984116,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-0":{"p":{"x":19.147450032657666,"y":14.276009262801196},"a":0.0025201794161469693,"lv":{"x":0,"y":0},"av":0}}
|
||||||
|
m1426446051478{"recipient":"channel","data":{"releaseUser":"7389285181034131943"}}
|
||||||
|
w1426446051575{"item-6":{"p":{"x":25.484809555865787,"y":17.13345683956885},"a":56.55108306250028,"lv":{"x":0,"y":0},"av":0},"item-5":{"p":{"x":3.551564486509986,"y":18.086205519078288},"a":25.13402937147234,"lv":{"x":0,"y":0},"av":0},"item-4":{"p":{"x":20.200046042197616,"y":14.276203440989589},"a":-0.0004911852214511747,"lv":{"x":0,"y":0},"av":0},"item-3":{"p":{"x":22.4,"y":14.277445638095237},"a":0,"lv":{"x":0,"y":0},"av":0},"item-2":{"p":{"x":25.676240547787568,"y":9.396188210902643},"a":1.5696221500784544,"lv":{"x":0,"y":0},"av":0},"item-1":{"p":{"x":19.642184126984116,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-0":{"p":{"x":19.147450032657666,"y":14.276009262801196},"a":0.0025201794161469693,"lv":{"x":0,"y":0},"av":0}}
|
||||||
|
w1426446052576{"item-6":{"p":{"x":25.484809555865787,"y":17.13345683956885},"a":56.55108306250028,"lv":{"x":0,"y":0},"av":0},"item-5":{"p":{"x":3.551564486509986,"y":18.086205519078288},"a":25.13402937147234,"lv":{"x":0,"y":0},"av":0},"item-4":{"p":{"x":20.200046042197616,"y":14.276203440989589},"a":-0.0004911852214511747,"lv":{"x":0,"y":0},"av":0},"item-3":{"p":{"x":22.4,"y":14.277445638095237},"a":0,"lv":{"x":0,"y":0},"av":0},"item-2":{"p":{"x":25.676240547787568,"y":9.396188210902643},"a":1.5696221500784544,"lv":{"x":0,"y":0},"av":0},"item-1":{"p":{"x":19.642184126984116,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-0":{"p":{"x":19.147450032657666,"y":14.276009262801196},"a":0.0025201794161469693,"lv":{"x":0,"y":0},"av":0}}
|
||||||
|
w1426446053576{"item-6":{"p":{"x":25.484809555865787,"y":17.13345683956885},"a":56.55108306250028,"lv":{"x":0,"y":0},"av":0},"item-5":{"p":{"x":3.551564486509986,"y":18.086205519078288},"a":25.13402937147234,"lv":{"x":0,"y":0},"av":0},"item-4":{"p":{"x":20.200046042197616,"y":14.276203440989589},"a":-0.0004911852214511747,"lv":{"x":0,"y":0},"av":0},"item-3":{"p":{"x":22.4,"y":14.277445638095237},"a":0,"lv":{"x":0,"y":0},"av":0},"item-2":{"p":{"x":25.676240547787568,"y":9.396188210902643},"a":1.5696221500784544,"lv":{"x":0,"y":0},"av":0},"item-1":{"p":{"x":19.642184126984116,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-0":{"p":{"x":19.147450032657666,"y":14.276009262801196},"a":0.0025201794161469693,"lv":{"x":0,"y":0},"av":0}}
|
||||||
|
w1426446054579{"item-6":{"p":{"x":25.484809555865787,"y":17.13345683956885},"a":56.55108306250028,"lv":{"x":0,"y":0},"av":0},"item-5":{"p":{"x":3.551564486509986,"y":18.086205519078288},"a":25.13402937147234,"lv":{"x":0,"y":0},"av":0},"item-4":{"p":{"x":20.200046042197616,"y":14.276203440989589},"a":-0.0004911852214511747,"lv":{"x":0,"y":0},"av":0},"item-3":{"p":{"x":22.4,"y":14.277445638095237},"a":0,"lv":{"x":0,"y":0},"av":0},"item-2":{"p":{"x":25.676240547787568,"y":9.396188210902643},"a":1.5696221500784544,"lv":{"x":0,"y":0},"av":0},"item-1":{"p":{"x":19.642184126984116,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-0":{"p":{"x":19.147450032657666,"y":14.276009262801196},"a":0.0025201794161469693,"lv":{"x":0,"y":0},"av":0}}
|
||||||
|
w1426446055579{"item-6":{"p":{"x":25.484809555865787,"y":17.13345683956885},"a":56.55108306250028,"lv":{"x":0,"y":0},"av":0},"item-5":{"p":{"x":3.551564486509986,"y":18.086205519078288},"a":25.13402937147234,"lv":{"x":0,"y":0},"av":0},"item-4":{"p":{"x":20.200046042197616,"y":14.276203440989589},"a":-0.0004911852214511747,"lv":{"x":0,"y":0},"av":0},"item-3":{"p":{"x":22.4,"y":14.277445638095237},"a":0,"lv":{"x":0,"y":0},"av":0},"item-2":{"p":{"x":25.676240547787568,"y":9.396188210902643},"a":1.5696221500784544,"lv":{"x":0,"y":0},"av":0},"item-1":{"p":{"x":19.642184126984116,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-0":{"p":{"x":19.147450032657666,"y":14.276009262801196},"a":0.0025201794161469693,"lv":{"x":0,"y":0},"av":0}}
|
||||||
|
w1426446056580{"item-6":{"p":{"x":25.484809555865787,"y":17.13345683956885},"a":56.55108306250028,"lv":{"x":0,"y":0},"av":0},"item-5":{"p":{"x":3.551564486509986,"y":18.086205519078288},"a":25.13402937147234,"lv":{"x":0,"y":0},"av":0},"item-4":{"p":{"x":20.200046042197616,"y":14.276203440989589},"a":-0.0004911852214511747,"lv":{"x":0,"y":0},"av":0},"item-3":{"p":{"x":22.4,"y":14.277445638095237},"a":0,"lv":{"x":0,"y":0},"av":0},"item-2":{"p":{"x":25.676240547787568,"y":9.396188210902643},"a":1.5696221500784544,"lv":{"x":0,"y":0},"av":0},"item-1":{"p":{"x":19.642184126984116,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-0":{"p":{"x":19.147450032657666,"y":14.276009262801196},"a":0.0025201794161469693,"lv":{"x":0,"y":0},"av":0}}
|
||||||
|
w1426446057580{"item-6":{"p":{"x":25.484809555865787,"y":17.13345683956885},"a":56.55108306250028,"lv":{"x":0,"y":0},"av":0},"item-5":{"p":{"x":3.551564486509986,"y":18.086205519078288},"a":25.13402937147234,"lv":{"x":0,"y":0},"av":0},"item-4":{"p":{"x":20.200046042197616,"y":14.276203440989589},"a":-0.0004911852214511747,"lv":{"x":0,"y":0},"av":0},"item-3":{"p":{"x":22.4,"y":14.277445638095237},"a":0,"lv":{"x":0,"y":0},"av":0},"item-2":{"p":{"x":25.676240547787568,"y":9.396188210902643},"a":1.5696221500784544,"lv":{"x":0,"y":0},"av":0},"item-1":{"p":{"x":19.642184126984116,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-0":{"p":{"x":19.147450032657666,"y":14.276009262801196},"a":0.0025201794161469693,"lv":{"x":0,"y":0},"av":0}}
|
||||||
|
|
@ -1,247 +0,0 @@
|
||||||
/*
|
|
||||||
* This will generate a core/channel/client overview of a class
|
|
||||||
*
|
|
||||||
* usage:
|
|
||||||
* node scripts/core_analyzer.js [relative/path/class.js] -> relative path from core/client/channel split
|
|
||||||
*
|
|
||||||
* example:
|
|
||||||
* node scripts/core_analyzer.js GameObjects/Item.js
|
|
||||||
*
|
|
||||||
* example result:
|
|
||||||
*
|
|
||||||
* | CHANNEL | CORE | CLIENT
|
|
||||||
* |---------------------------------------|---------------------------------------|--------------------------------
|
|
||||||
* | | getBodyDef |
|
|
||||||
* | | getFixtureDef |
|
|
||||||
* | | createFixture |
|
|
||||||
* | | flip | flip
|
|
||||||
* | beingGrabbed | beingGrabbed |
|
|
||||||
* | beingReleased | beingReleased |
|
|
||||||
* | onCollisionChange | onCollisionChange |
|
|
||||||
* | | reposition |
|
|
||||||
* | | getGrabPoint |
|
|
||||||
* | | throw |
|
|
||||||
* | | accelerateBody |
|
|
||||||
* | | destroy | destroy
|
|
||||||
* | | | createMesh
|
|
||||||
* | | | render
|
|
||||||
* | getLastMovedBy | |
|
|
||||||
* | setLastMovedBy | |
|
|
||||||
* | isGrabbingAllowed | |
|
|
||||||
* | isReleasingAllowed | |
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
var fs = require('fs');
|
|
||||||
var util = require('util');
|
|
||||||
var esprima = require('esprima');
|
|
||||||
var escodegen = require('escodegen');
|
|
||||||
|
|
||||||
var info = [];
|
|
||||||
var overview = {};
|
|
||||||
|
|
||||||
var generatorOption = {
|
|
||||||
format: {
|
|
||||||
indent: {
|
|
||||||
style: ' ',
|
|
||||||
base: 0,
|
|
||||||
adjustMultilineComment: true//false
|
|
||||||
},
|
|
||||||
newline: '\n',
|
|
||||||
space: ' ',
|
|
||||||
json: false,
|
|
||||||
renumber: false,
|
|
||||||
hexadecimal: false,
|
|
||||||
quotes: 'single',
|
|
||||||
escapeless: false,
|
|
||||||
compact: false,
|
|
||||||
parentheses: true,
|
|
||||||
semicolons: true,
|
|
||||||
safeConcatenation: true
|
|
||||||
},
|
|
||||||
moz: {
|
|
||||||
starlessGenerator: false,
|
|
||||||
parenthesizedComprehensionBlock: false,
|
|
||||||
comprehensionExpressionStartsWithAssignment: false
|
|
||||||
},
|
|
||||||
parse: null,
|
|
||||||
comment: true,
|
|
||||||
sourceMap: undefined,
|
|
||||||
sourceMapRoot: null,
|
|
||||||
sourceMapWithCode: false,
|
|
||||||
file: undefined,
|
|
||||||
directive: false,
|
|
||||||
verbatim: undefined
|
|
||||||
};
|
|
||||||
|
|
||||||
function readFile (path, category, fileName) {
|
|
||||||
//console.log("+++++ " + moduleName + " ++++++");
|
|
||||||
var contents = fs.readFileSync(path + "/" + category + "/" + fileName);
|
|
||||||
contents = contents.toString();
|
|
||||||
|
|
||||||
getMethods(path, fileName, contents, category);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getMethods (path, fileName, contents, category) {
|
|
||||||
|
|
||||||
category = category.toLowerCase();
|
|
||||||
|
|
||||||
overview[category] = [];
|
|
||||||
|
|
||||||
var fullPath = path + "/" + fileName;
|
|
||||||
var moduleName = fileName.split(".js").join("");
|
|
||||||
var tree = esprima.parse(contents);
|
|
||||||
|
|
||||||
// find moduleId from return statement on module level
|
|
||||||
var module = tree.body[0].expression.arguments[1].body.body;
|
|
||||||
var moduleId = findModuleId(module);
|
|
||||||
|
|
||||||
if (!moduleId) {
|
|
||||||
info.push("could not find moduleId in: " + fullPath);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (moduleId == "Parent") {
|
|
||||||
info.push("not optimizing empty module (returning Parent) in: " + fullPath);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// find constructor
|
|
||||||
var constructorPosition = findConstructorPosition(module, moduleId);
|
|
||||||
if (constructorPosition === false) {
|
|
||||||
info.push("could not find constructor in: " + fileName)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var constructor = module[constructorPosition];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (var j = 0; j < module.length; j++) {
|
|
||||||
var expression = module[j];
|
|
||||||
|
|
||||||
if (expression.type == "ExpressionStatement") {
|
|
||||||
if(expression.expression && expression.expression.right) {
|
|
||||||
if(expression.expression.right.type == "FunctionExpression") {
|
|
||||||
overview[category].push(expression.expression.left.property.name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//console.log(escodegen.generate(tree, generatorOption));
|
|
||||||
}
|
|
||||||
|
|
||||||
function findModuleId (module) {
|
|
||||||
var moduleId = false;
|
|
||||||
for (var j = 0; j < module.length; j++) {
|
|
||||||
var expression = module[j];
|
|
||||||
|
|
||||||
//console.log(util.inspect(expression, { showHidden: true, depth: 4 }));
|
|
||||||
|
|
||||||
if (expression.type == "ReturnStatement") {
|
|
||||||
|
|
||||||
if(expression.argument.type == "Identifier") {
|
|
||||||
|
|
||||||
// for return Module;
|
|
||||||
moduleId = expression.argument.name;
|
|
||||||
break;
|
|
||||||
|
|
||||||
} else if (expression.argument.type == "NewExpression") {
|
|
||||||
|
|
||||||
// for return new Module;
|
|
||||||
moduleId = expression.argument.callee.name;
|
|
||||||
break;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
info.push("Unexpected return type at module level. " + fullPath)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return moduleId;
|
|
||||||
};
|
|
||||||
|
|
||||||
function findConstructorPosition (module, moduleId) {
|
|
||||||
|
|
||||||
for (var j = 0; j < module.length; j++) {
|
|
||||||
var expression = module[j];
|
|
||||||
|
|
||||||
if (expression.type == "FunctionDeclaration" && expression.id.name == moduleId) {
|
|
||||||
return j;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
var superOverview = {};
|
|
||||||
function display (category) {
|
|
||||||
|
|
||||||
var all = ["core", "client", "channel"];
|
|
||||||
var removeIndex = all.indexOf(category);
|
|
||||||
all.splice(removeIndex, 1);
|
|
||||||
|
|
||||||
for (var k in overview[category]) {
|
|
||||||
|
|
||||||
var name = overview[category][k];
|
|
||||||
|
|
||||||
if(superOverview.hasOwnProperty(name)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
var first = all[0];
|
|
||||||
var second = all[1];
|
|
||||||
|
|
||||||
fv = 0 + (overview[first].indexOf(name) !== -1);
|
|
||||||
sv = 0 + (overview[second].indexOf(name) !== -1);
|
|
||||||
|
|
||||||
superOverview[name] = {};
|
|
||||||
|
|
||||||
superOverview[name][category] = 1;
|
|
||||||
superOverview[name][first] = fv;
|
|
||||||
superOverview[name][second] = sv;
|
|
||||||
superOverview[name]['count'] = 1 + fv + sv;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function show(){
|
|
||||||
var alle = ['channel', 'core', 'client'];
|
|
||||||
console.log("| CHANNEL | CORE | CLIENT");
|
|
||||||
console.log("|---------------------------------------|---------------------------------------|--------------------------------");
|
|
||||||
for (var method in superOverview) {
|
|
||||||
var line = "";
|
|
||||||
|
|
||||||
for (var i = 0; i < alle.length; i++) {
|
|
||||||
if (superOverview[method] && superOverview[method].hasOwnProperty(alle[i])) {
|
|
||||||
|
|
||||||
line += "| " ;
|
|
||||||
|
|
||||||
if(superOverview[method][alle[i]] === 1) {
|
|
||||||
line += method;
|
|
||||||
line += Array(39 - method.length).join(" ");
|
|
||||||
} else {
|
|
||||||
line += Array(39).join(" ");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
console.log(line)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
readFile("app/Game", "Core", process.argv[2]);
|
|
||||||
readFile("app/Game", "Channel", process.argv[2]);
|
|
||||||
readFile("app/Game", "Client", process.argv[2]);
|
|
||||||
|
|
||||||
display("core")
|
|
||||||
display("client")
|
|
||||||
display("channel")
|
|
||||||
|
|
||||||
console.log("\n")
|
|
||||||
show()
|
|
||||||
console.log("\n")
|
|
||||||
12
server.js
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
var GLOBALS = { context: "Channel" };
|
var GLOBALS = { context: "Channel" };
|
||||||
var requirejs = require('requirejs');
|
var requirejs = require('requirejs');
|
||||||
var fs = require('fs');
|
|
||||||
|
|
||||||
var inspector;
|
var inspector;
|
||||||
|
|
||||||
|
|
@ -26,17 +25,10 @@ var options = {
|
||||||
requirejs([
|
requirejs([
|
||||||
"Bootstrap/HttpServer",
|
"Bootstrap/HttpServer",
|
||||||
"Bootstrap/Socket",
|
"Bootstrap/Socket",
|
||||||
"Server/Coordinator",
|
"Server/Coordinator"
|
||||||
"Game/Config/Settings"
|
|
||||||
],
|
],
|
||||||
|
|
||||||
function (HttpServer, Socket, Coordinator, Settings) {
|
function (HttpServer, Socket, Coordinator) {
|
||||||
|
|
||||||
var records = fs.readdirSync(Settings.CHANNEL_RECORDING_PATH);
|
|
||||||
if (records.length > 200) {
|
|
||||||
console.warn('Too many recordings!');
|
|
||||||
}
|
|
||||||
|
|
||||||
var coordinator = new Coordinator();
|
var coordinator = new Coordinator();
|
||||||
var httpServer = new HttpServer(options, coordinator);
|
var httpServer = new HttpServer(options, coordinator);
|
||||||
var socket = new Socket(httpServer.getServer(), options, coordinator);
|
var socket = new Socket(httpServer.getServer(), options, coordinator);
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,17 @@
|
||||||
<div>
|
<div>
|
||||||
<h2>Create your own!</h2>
|
<h2>Create your own!</h2>
|
||||||
<p><label>Name:<br> <input id="customname"></label></p>
|
<p><label>Name:<br> <input id="customname"></label></p>
|
||||||
<p><label>Score limit:<br> <input id="scoreLimit" type="number" value=""></label></p>
|
<p><label>Score limit:<br> <input id="scoreLimit" type="number" value="5"></label></p>
|
||||||
<p><label>User limit:<br> <input id="userLimit" type="number" value=""></label></p>
|
<p><label>User limit:<br> <input id="userLimit" type="number" value="10"></label></p>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Maps</legend>
|
<legend>Maps</legend>
|
||||||
<ul id="maps">
|
<ul id="maps">
|
||||||
|
<li>
|
||||||
|
<label><input name="maps" value="debug" type="checkbox" checked> Debug</label>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<label><input name="maps" value="stones" type="checkbox" checked> Stones</label>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ a {
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
var url = "https://api.github.com/repos/logsol/chuck.js/milestones?access_token=ce6b0623328e3733e160fe362d262a6b65e9cf27";
|
var url = "https://api.github.com/repos/logsol/chuck.js/milestones?access_token=e54ce2084dcca03983780524fad234296cbc640a";
|
||||||
var lookingFor = "Alpha-";
|
var lookingFor = "Alpha-";
|
||||||
|
|
||||||
$.get(url, function( data ) {
|
$.get(url, function( data ) {
|
||||||
|
|
@ -75,7 +75,7 @@ $.get(url, function( data ) {
|
||||||
var progress = parseInt(milestone.closed_issues) / (parseInt(milestone.open_issues)+parseInt(milestone.closed_issues));
|
var progress = parseInt(milestone.closed_issues) / (parseInt(milestone.open_issues)+parseInt(milestone.closed_issues));
|
||||||
progress = Math.round(progress * 100);
|
progress = Math.round(progress * 100);
|
||||||
|
|
||||||
$("#m-title").html('<a href="' + milestone.html_url + '">' + milestone.title + '</a>');
|
$("#m-title").text(milestone.title);
|
||||||
$("#m-open").text(milestone.open_issues);
|
$("#m-open").text(milestone.open_issues);
|
||||||
$("#m-closed").text(milestone.closed_issues);
|
$("#m-closed").text(milestone.closed_issues);
|
||||||
$("#m-progress").text(progress + "%");
|
$("#m-progress").text(progress + "%");
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 148 B |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 158 B |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 148 B |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 158 B |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 145 B |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 170 B |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
|
|
@ -60,8 +60,8 @@
|
||||||
"type":"",
|
"type":"",
|
||||||
"visible":true,
|
"visible":true,
|
||||||
"width":0,
|
"width":0,
|
||||||
"x":247.535368857004,
|
"x":222.535368857004,
|
||||||
"y":177.525492560429
|
"y":170.525492560429
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ellipse":true,
|
"ellipse":true,
|
||||||
|
|
@ -108,8 +108,8 @@
|
||||||
"type":"",
|
"type":"",
|
||||||
"visible":true,
|
"visible":true,
|
||||||
"width":0,
|
"width":0,
|
||||||
"x":548.282764098491,
|
"x":516.282764098491,
|
||||||
"y":130.219675479405
|
"y":128.219675479405
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ellipse":true,
|
"ellipse":true,
|
||||||
|
|
@ -215,7 +215,7 @@
|
||||||
{
|
{
|
||||||
"height":0,
|
"height":0,
|
||||||
"id":10,
|
"id":10,
|
||||||
"name":"RubeDoll",
|
"name":"Rube",
|
||||||
"properties":
|
"properties":
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -224,8 +224,8 @@
|
||||||
"type":"",
|
"type":"",
|
||||||
"visible":true,
|
"visible":true,
|
||||||
"width":0,
|
"width":0,
|
||||||
"x":504.607333333333,
|
"x":236.607333333333,
|
||||||
"y":433.26
|
"y":471.255333333333
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"height":0,
|
"height":0,
|
||||||
|
|
@ -290,7 +290,7 @@
|
||||||
{
|
{
|
||||||
"height":0,
|
"height":0,
|
||||||
"id":15,
|
"id":15,
|
||||||
"name":"Skateboard",
|
"name":"Piano",
|
||||||
"properties":
|
"properties":
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
||||||