From 2fdc7af240e4dac3fdc2c3aab850aea3664762e2 Mon Sep 17 00:00:00 2001 From: -=yb4f310 Date: Mon, 28 May 2018 18:58:55 +0200 Subject: [PATCH] Update: CC - Entity Loaded - AR Football 3 (ff0fsum4zx.js) 42 bytes modified --- ff0fsum4zx.js | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/ff0fsum4zx.js b/ff0fsum4zx.js index 522120e..1407516 100644 --- a/ff0fsum4zx.js +++ b/ff0fsum4zx.js @@ -10,6 +10,8 @@ if (data.entity === this.parentEntity) { this.mouseMove = R3.EntityManager.Instance.findComponentById('dwxvtxzrun'); this.touchMove = R3.EntityManager.Instance.findComponentById('p49pad0i7l'); this.beforeRender = R3.EntityManager.Instance.findComponentById('7l8ar325qf'); +this.keyDown = R3.EntityManager.Instance.findComponentById('905x4c8pna'); +this.keyUp = R3.EntityManager.Instance.findComponentById('r5kzahijoq'); /** * Meshes @@ -83,6 +85,8 @@ this.invertY = true; this.invertX = true; +this.shooting = false; + if (this.debug) { this.arrowHelper = new THREE.ArrowHelper( new THREE.Vector3(0,0,-1), @@ -118,7 +122,22 @@ R3.CustomCode.prototype.render = function(delta) { type : 'timer', time : this.totalTime } - ) + ); + + if (this.shooting === true) { + + this.move( + { + x : 0, + y : 10 * delta + } + ); + + if (this.playerRotation.y < 0) { + this.playerRotation.y = 0; + this.shooting = false; + } + } if (this.totalTime <= 0) { @@ -497,6 +516,52 @@ 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') { + + console.log('shoot'); + + this.shooting = false; + + this.move( + { + x : 0, + y : -10 + } + ); + } + + if (data.type === 'shoot_release') { + console.log('shoot release'); + this.shooting = true; + } + + if (data.type === 'look_left') { + this.move( + { + x : -10, + y : 0 + } + ); + } + + if (data.type === 'look_right') { + this.move( + { + x : 10, + y : 0 + } + ); + } }.bind(this) ); @@ -586,6 +651,8 @@ 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) );