Update: CC - Snake FS - Entity Loaded (21g30t1e75.js) 2143 bytes modified
parent
cfdba955d2
commit
e308e52b63
|
@ -27,6 +27,12 @@ GameLib.CustomCode.ORIENTATION_RIGHT = 3;
|
|||
GameLib.CustomCode.FOOD_SPEED_INITIAL = 3;
|
||||
GameLib.CustomCode.MAX_FOOD_ITEMS = 6;
|
||||
|
||||
GameLib.CustomCode.FOOD_BACON = 0;
|
||||
GameLib.CustomCode.FOOD_CHEESE = 1;
|
||||
GameLib.CustomCode.FOOD_ONION = 2;
|
||||
GameLib.CustomCode.FOOD_ONION_RING = 3;
|
||||
GameLib.CustomCode.FOOD_PATTY = 4;
|
||||
GameLib.CustomCode.FOOD_TOMATO = 5;
|
||||
|
||||
/**
|
||||
* Get runtime
|
||||
|
@ -51,7 +57,13 @@ this.imageBreadHead = GameLib.EntityManager.Instance.findComponentById('swkla3w
|
|||
this.imageBreadTail = GameLib.EntityManager.Instance.findComponentById('se6qlnmojd');
|
||||
this.imageBreadPatty = GameLib.EntityManager.Instance.findComponentById('01r51k9ptr');
|
||||
this.imageBreadCorner = GameLib.EntityManager.Instance.findComponentById('iljpuouaok');
|
||||
|
||||
this.imageBacon = GameLib.EntityManager.Instance.findComponentById('t4lb4hr4ue');
|
||||
this.imageCheese = GameLib.EntityManager.Instance.findComponentById('y2611hx41r');
|
||||
this.imageOnion = GameLib.EntityManager.Instance.findComponentById('g3z1wg2vt8');
|
||||
this.imageOnionRing = GameLib.EntityManager.Instance.findComponentById('ztcyy0bgk5');
|
||||
this.imagePatty = GameLib.EntityManager.Instance.findComponentById('4lf0fw24su');
|
||||
this.imageTomato = GameLib.EntityManager.Instance.findComponentById('ptvwmo8l38');
|
||||
|
||||
/**
|
||||
* Other Objects (Scene)
|
||||
|
@ -135,13 +147,18 @@ GameLib.CustomCode.prototype.createMaterial = function(image) {
|
|||
);
|
||||
}.bind(this);
|
||||
|
||||
GameLib.CustomCode.prototype.createGameMesh = function(image) {
|
||||
GameLib.CustomCode.prototype.createGameMesh = function(image, visible) {
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(visible)) {
|
||||
visible = true;
|
||||
}
|
||||
|
||||
var mesh = new GameLib.D3.Mesh(
|
||||
this.runtime.graphics,
|
||||
{
|
||||
geometry : this.geometryBody,
|
||||
materials : [this.createMaterial(image)]
|
||||
materials : [this.createMaterial(image)],
|
||||
visible : visible
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -166,7 +183,12 @@ this.meshBreadPatty.useQuaternion = false;
|
|||
this.meshBreadCorner = this.createGameMesh(this.imageBreadCorner);
|
||||
this.meshBreadCorner.useQuaternion = false;
|
||||
|
||||
this.meshPatty = this.createGameMesh(this.imagePatty);
|
||||
this.meshBacon = this.createGameMesh(this.imageBacon, false);
|
||||
this.meshCheese = this.createGameMesh(this.imageCheese, false);
|
||||
this.meshOnion = this.createGameMesh(this.imageOnion, false);
|
||||
this.meshOnionRing = this.createGameMesh(this.imageOnionRing, false);
|
||||
this.meshPatty = this.createGameMesh(this.imagePatty, false);
|
||||
this.meshTomato = this.createGameMesh(this.imageTomato, false);
|
||||
|
||||
GameLib.CustomCode.prototype.createFood = function(delta) {
|
||||
|
||||
|
@ -178,8 +200,44 @@ GameLib.CustomCode.prototype.createFood = function(delta) {
|
|||
return;
|
||||
}
|
||||
|
||||
var foodType = GameLib.Utils.GetRandomIntInclusive(0, 5);
|
||||
|
||||
var mesh = null;
|
||||
|
||||
switch (foodType) {
|
||||
case GameLib.CustomCode.FOOD_BACON :
|
||||
mesh = this.meshBacon.clone();
|
||||
break;
|
||||
case GameLib.CustomCode.FOOD_CHEESE :
|
||||
mesh = this.meshCheese.clone();
|
||||
break;
|
||||
case GameLib.CustomCode.FOOD_ONION :
|
||||
mesh = this.meshOnion.clone();
|
||||
break;
|
||||
case GameLib.CustomCode.FOOD_ONION_RING :
|
||||
mesh = this.meshOnionRing.clone();
|
||||
break;
|
||||
case GameLib.CustomCode.FOOD_PATTY :
|
||||
mesh = this.meshPatty.clone();
|
||||
break;
|
||||
case GameLib.CustomCode.FOOD_TOMATO :
|
||||
mesh = this.meshTomato.clone();
|
||||
break;
|
||||
default :
|
||||
console.warn('unhandled food type');
|
||||
break;
|
||||
}
|
||||
|
||||
var positionX = GameLib.Utils.GetRandomInt(0, GameLib.CustomCode.GRID_WIDTH);
|
||||
var positionY = GameLib.Utils.GetRandomInt(0, GameLib.CustomCode.GRID_HEIGHT);
|
||||
|
||||
mesh.position.x = positionX + GameLib.CustomCode.GRID_OFFSET_X;
|
||||
mesh.position.y = positionY + GameLib.CustomCode.GRID_OFFSET_Y;
|
||||
|
||||
mesh.visible = true;
|
||||
|
||||
mesh.updateInstance('position');
|
||||
mesh.updateInstance('visible');
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue