2018-03-12 14:11:01 +01:00
|
|
|
if (this.parentEntity === data.entity) {
|
|
|
|
console.log('snake entity loaded');
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.runtime = GameLib.Utils.GetRuntime();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Geometries
|
|
|
|
*/
|
2018-03-12 14:12:20 +01:00
|
|
|
this.geometryBody = GameLib.EntityManager.Instance.findComponentById('8f5q7k5ozp');
|
2018-03-12 14:11:01 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Images
|
|
|
|
*/
|
|
|
|
this.imageEnd = GameLib.EntityManager.Instance.findComponentById('swkla3wpp');
|
|
|
|
this.imageBodyPatty = GameLib.EntityManager.Instance.findComponentById('01r51k9ptr');
|
|
|
|
this.imagePatty = GameLib.EntityManager.Instance.findComponentById('4lf0fw24su');
|
|
|
|
|
|
|
|
GameLib.CustomCode.prototype.createMaterial = function(image) {
|
|
|
|
var diffuseMap = new GameLib.D3.Texture.Image(
|
|
|
|
this.runtime.graphics,
|
|
|
|
{
|
|
|
|
image : image
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
return new GameLib.D3.Material.Phong(
|
|
|
|
this.runtime.graphics,
|
|
|
|
{
|
|
|
|
diffuseMap : diffuseMap
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}.bind(this);
|
|
|
|
|
|
|
|
GameLib.CustomCode.prototype.createGameMesh = function(image) {
|
|
|
|
return new GameLib.D3.Mesh(
|
2018-03-12 14:13:06 +01:00
|
|
|
this.runtime.graphics,
|
2018-03-12 14:11:01 +01:00
|
|
|
{
|
|
|
|
geometry : this.geometryBody,
|
|
|
|
materials : this.createMaterial(image)
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
}.bind(this)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create our objects
|
|
|
|
*/
|
|
|
|
this.meshHead = this.createGameMesh(this.imageEnd);
|
|
|
|
|
|
|
|
GameLib.Event.Subscribe(
|
|
|
|
GameLib.Event.GAME_START,
|
|
|
|
function() {
|
|
|
|
console.log('starting game snake');
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
GameLib.Event.Emit(GameLib.Event.GAME_LOADED);
|
|
|
|
|
|
|
|
//@ sourceURL=entityLoaded.js
|