-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAttackSamu.js
74 lines (57 loc) · 1.97 KB
/
AttackSamu.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import * as THREE from './libs/three.module.js'
import { MTLLoader } from './libs/MTLLoader.js'
import { OBJLoader } from './libs/OBJLoader.js'
class AttackSamu extends THREE.Object3D{
constructor(samu){
super();
var that = this;
var materiaLoader = new MTLLoader();
var objectLoader = new OBJLoader();
materiaLoader.load('models/attack_samu/attack_samu.mtl',
function(materials){
objectLoader.setMaterials(materials);
objectLoader.load('models/attack_samu/attack_samu.obj',
function(object){
var modelo = object;
var modelo = object
modelo.scale.set(120,120,120)
that.add(modelo);
},null,null);
});
var geometry = new THREE.BoxGeometry( 2, 10, 2 );
var material = new THREE.MeshBasicMaterial( {color: 0x00ff00} );
this.cube = new THREE.Mesh( geometry, material );
this.cube.visible = false
this.add(this.cube)
this.muerto = false
this.factor_aleatorio = 0
this.aux = true
this.ref_samu = samu;
this.name = "Attack"
}
paraAtaque(){
this.muerto = true
this.visible = false
}
ataque(){
if(!this.muerto){
if(this.position.x > 20 ){
this.visible = true
this.position.x = this.ref_samu.position.x + this.factor_aleatorio
this.position.y = this.ref_samu.position.y + this.factor_aleatorio
this.position.z = this.ref_samu.position.z + this.factor_aleatorio
}
else if(this.position.x > 20){
this.visible = false
}
else{
this.position.x += 0.5
}
}
}
}
AttackSamu.LOOK_AT_UP = 5;
AttackSamu.LOOK_AT_DOWN = 6;
AttackSamu.LOOK_AT_RIGHT = 7;
AttackSamu.LOOK_AT_LEFT = 8;
export { AttackSamu };