Update: CC - Entity Loaded - AR Football 4 (6aae13w4xh.js) 881 bytes modified
parent
343f2ca31f
commit
80794de999
167
6aae13w4xh.js
167
6aae13w4xh.js
|
@ -10,8 +10,6 @@ if (data.entity === this.parentEntity) {
|
|||
this.mouseMove = R3.EntityManager.Instance.findComponentById('5d3rqq75xi');
|
||||
this.touchMove = R3.EntityManager.Instance.findComponentById('7w3d7hfzal');
|
||||
this.beforeRender = R3.EntityManager.Instance.findComponentById('8l80lykq42');
|
||||
this.keyDown = R3.EntityManager.Instance.findComponentById('70v12hvjrw');
|
||||
this.keyUp = R3.EntityManager.Instance.findComponentById('xlq24tbwpo');
|
||||
|
||||
/**
|
||||
* Meshes
|
||||
|
@ -85,10 +83,6 @@ this.invertY = true;
|
|||
|
||||
this.invertX = true;
|
||||
|
||||
this.preparing = false;
|
||||
|
||||
this.looking = null;
|
||||
|
||||
if (this.debug) {
|
||||
this.arrowHelper = new THREE.ArrowHelper(
|
||||
new THREE.Vector3(0,0,-1),
|
||||
|
@ -124,47 +118,7 @@ R3.CustomCode.prototype.render = function(delta) {
|
|||
type : 'timer',
|
||||
time : this.totalTime
|
||||
}
|
||||
);
|
||||
|
||||
if (this.preparing === true) {
|
||||
this.move(
|
||||
{
|
||||
x : 0,
|
||||
y : delta * -200
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (this.preparing === false && this.playerRotation.y < 0) {
|
||||
this.move(
|
||||
{
|
||||
x : 0,
|
||||
y : delta * 1000
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
if (this.looking === 'left') {
|
||||
this.move(
|
||||
{
|
||||
x : delta * -700,
|
||||
y : 0
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (this.looking === 'right') {
|
||||
this.move(
|
||||
{
|
||||
x : delta * 700,
|
||||
y : 0
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (this.activeBall === null) {
|
||||
this.createActiveBall();
|
||||
}
|
||||
)
|
||||
|
||||
if (this.totalTime <= 0) {
|
||||
|
||||
|
@ -386,9 +340,8 @@ R3.CustomCode.prototype.move = function(data) {
|
|||
/**
|
||||
* Clamp player rotation to values between 0 and Math.PI * 2
|
||||
*/
|
||||
if (this.playerRotation.y > 0) {
|
||||
this.playerRotation.y = 0;
|
||||
this.kick = true;
|
||||
if (this.playerRotation.y > Math.PI) {
|
||||
this.playerRotation.y = Math.PI;
|
||||
}
|
||||
|
||||
if (this.playerRotation.y < -Math.PI) {
|
||||
|
@ -403,39 +356,41 @@ R3.CustomCode.prototype.move = function(data) {
|
|||
this.playerRotation.x = -Math.PI / 2;
|
||||
}
|
||||
|
||||
// if (this.playerRotation.y <= 0) {
|
||||
// this.canKick = true;
|
||||
// }
|
||||
if (this.playerRotation.y <= 0) {
|
||||
this.canKick = true;
|
||||
}
|
||||
|
||||
//if (this.canKick && this.playerRotation.y === 0) {
|
||||
// this.canKick = false;
|
||||
// this.kick = true;
|
||||
// }
|
||||
if (this.canKick && this.playerRotation.y > 0) {
|
||||
this.canKick = false;
|
||||
this.kick = true;
|
||||
}
|
||||
|
||||
// if (y > 0 && this.canKick) {
|
||||
//
|
||||
// /**
|
||||
// * Moving down, initialize start time and record the distance travelled
|
||||
// */
|
||||
// if (this.startTime === null) {
|
||||
// this.startTime = Date.now();
|
||||
// }
|
||||
//
|
||||
// //this.kickDistance += Math.abs(y);
|
||||
//
|
||||
// }
|
||||
|
||||
// if (y < 0) {
|
||||
// /**
|
||||
// * We are no longer moving down, also reset our Y distance counter
|
||||
// * @type {boolean}
|
||||
// */
|
||||
// //this.kickDistance = 0;
|
||||
// this.startTime = null;
|
||||
// }
|
||||
if (y > 0 && this.canKick) {
|
||||
|
||||
/**
|
||||
* Moving down, initialize start time and record the distance travelled
|
||||
*/
|
||||
if (this.startTime === null) {
|
||||
this.startTime = Date.now();
|
||||
}
|
||||
|
||||
this.kickDistance += Math.abs(y);
|
||||
|
||||
}
|
||||
|
||||
if (y < 0) {
|
||||
/**
|
||||
* We are no longer moving down, also reset our Y distance counter
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.kickDistance = 0;
|
||||
this.startTime = null;
|
||||
}
|
||||
|
||||
|
||||
if (this.canKick && this.activeBall === null) {
|
||||
this.createActiveBall();
|
||||
}
|
||||
|
||||
this.footballPlayer.instance.matrix = new THREE.Matrix4();
|
||||
this.footballPlayer.instance.matrix.decompose(
|
||||
|
@ -456,12 +411,10 @@ R3.CustomCode.prototype.move = function(data) {
|
|||
|
||||
this.kick = false;
|
||||
|
||||
//this.shooting = false;
|
||||
|
||||
// if (this.startTime === null) {
|
||||
// console.warn('no kick start time');
|
||||
// return;
|
||||
// }
|
||||
if (this.startTime === null) {
|
||||
console.warn('no kick start time');
|
||||
return;
|
||||
}
|
||||
|
||||
R3.Event.Emit(
|
||||
R3.Event.PLAY_AUDIO,
|
||||
|
@ -470,11 +423,9 @@ R3.CustomCode.prototype.move = function(data) {
|
|||
}
|
||||
);
|
||||
|
||||
//var kickDuration = 1;//Date.now() - this.startTime;
|
||||
var kickDuration = Date.now() - this.startTime;
|
||||
|
||||
var speed = this.kickDistance;
|
||||
|
||||
console.log('speed = ' + speed);
|
||||
var speed = this.kickDistance / kickDuration * 20;
|
||||
|
||||
// if (speed > 1.5) {
|
||||
// speed = 1.5;
|
||||
|
@ -506,7 +457,7 @@ R3.CustomCode.prototype.move = function(data) {
|
|||
kickDuration : this.kickDuration,
|
||||
kickDistance : this.kickDistance,
|
||||
kickSpeed : speed,
|
||||
upAngle : speed,
|
||||
upAngle : Math.PI * speed,
|
||||
v : v,
|
||||
vRotationAxis : vRotationAxis,
|
||||
t : 0,
|
||||
|
@ -522,7 +473,7 @@ R3.CustomCode.prototype.move = function(data) {
|
|||
this.activeBall = null;
|
||||
}
|
||||
|
||||
}.bind(this);
|
||||
}.bind(this)
|
||||
|
||||
|
||||
R3.Event.Subscribe(
|
||||
|
@ -546,40 +497,6 @@ R3.Event.Subscribe(
|
|||
this.mouseMove.entityLoaded = null;
|
||||
this.touchMove.entityLoaded = null;
|
||||
this.beforeRender.entityLoaded = null;
|
||||
this.keyDown.entityLoaded = null;
|
||||
this.keyUp.entityLoaded = null;
|
||||
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
R3.Event.Subscribe(
|
||||
R3.Event.GAME_DATA,
|
||||
function(data) {
|
||||
|
||||
if (data.type === 'shoot') {
|
||||
this.preparing = true;
|
||||
}
|
||||
|
||||
if (data.type === 'shoot_release') {
|
||||
this.preparing = false;
|
||||
this.kickDistance = Math.abs(this.playerRotation.y);
|
||||
}
|
||||
|
||||
if (data.type === 'left') {
|
||||
this.looking = 'left';
|
||||
}
|
||||
|
||||
if (data.type === 'right') {
|
||||
this.looking = 'right';
|
||||
}
|
||||
|
||||
if (data.type === 'right_release') {
|
||||
this.looking = null;
|
||||
}
|
||||
|
||||
if (data.type === 'left_release') {
|
||||
this.looking = null;
|
||||
}
|
||||
|
||||
}.bind(this)
|
||||
);
|
||||
|
@ -669,8 +586,6 @@ R3.Event.Subscribe(
|
|||
this.mouseMove.entityLoaded = this;
|
||||
this.touchMove.entityLoaded = this;
|
||||
this.beforeRender.entityLoaded = this;
|
||||
this.keyDown.entityLoaded = this;
|
||||
this.keyUp.entityLoaded = this;
|
||||
|
||||
}.bind(this)
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue