-
Notifications
You must be signed in to change notification settings - Fork 0
/
enemy.js
148 lines (126 loc) · 3.63 KB
/
enemy.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
const enemy_right_create = function(x, y) {
enemies_right.create(x, y,'Archerer')
enemies_right.forEach(_enemy_right =>{
_enemy_right.scale.setTo(-0.6, 0.6)
_enemy_right.anchor.setTo(0.5, 0)
_enemy_right.health = 50
_enemy_right.frame = 13
Game.physics.arcade.enable(_enemy_right)
_enemy_right.body.gravity.y = 500
_enemy_right.body.collideWorldBounds = true
_enemy_right.body.setSize(90, 162, 60)
})
}
const enemy_right_phys = function() {
}
const enemy_right_movement = function () {
}
const enemy_right_shot = function() {
enemies_right.forEach(_enemy_right => {
if (_enemy_right.visible === true){
shooting_right()
}
})
}
const enemy_right_dying = function() {
enemies_right.forEach(_enemy_right => {
if (_enemy_right.health < 0){
_enemy_right.kill()
enemies_right.remove(_enemy_right)
}
})
}
const enemy_right_damage = function() {
enemies_right.forEach(_enemy_right => {
if (pl.visible && _enemy_right.visible){
if (Phaser.Rectangle.intersects(pl.body, _enemy_right.body)){
pl.health -= 1
}}
})
}
const enemy_right_hit = function() {
enemies_right.forEach(_enemy_right => {
if (pl.visible && _enemy_right.visible){
if (Phaser.Rectangle.intersects(attacker.body, _enemy_right.body)){
_enemy_right.health -= 5
pl.health += 5.5
}
if (Phaser.Rectangle.intersects(attacker1.body, _enemy_right.body)){
_enemy_right.health -= 5
pl.health += 5.5
}
}
})
}
const enemy_right_collision = function() {
enemies_right.forEach(_enemy_right => {
Game.physics.arcade.collide(_enemy_right, ground)
})
}
const enemy_right_revive = function() {
enemy_right.revive()
enemy_right.health = 50
}
const enemy_create = function(x, y) {
enemies.create(x, y,'Archerer')
enemies.forEach(_enemy =>{
_enemy.scale.setTo(0.6)
_enemy.anchor.setTo(0.5, 0)
_enemy.health = 50
_enemy.frame = 13
Game.physics.arcade.enable(_enemy)
_enemy.body.gravity.y = 500
_enemy.body.collideWorldBounds = true
_enemy.body.setSize(90, 162, 60)
})
}
const enemy_phys = function() {
}
const enemy_movment = function () {
}
const enemy_shot = function() {
enemies.forEach(_enemy => {
if (_enemy.visible === true){
shooting()
}
})
}
const enemy_dying = function() {
enemies.forEach(_enemy => {
if (_enemy.health < 0){
_enemy.kill()
enemies.remove(_enemy)
}
})
}
const enemy_damage = function() {
enemies.forEach(_enemy => {
if (pl.visible && _enemy.visible){
if (Phaser.Rectangle.intersects(pl.body, _enemy.body)){
pl.health -= 1
}}
})
}
const enemy_hit = function() {
enemies.forEach(_enemy => {
if (pl.visible && _enemy.visible){
if (Phaser.Rectangle.intersects(attacker.body, _enemy.body)){
_enemy.health -= 5
pl.health += 5.5
}
if (Phaser.Rectangle.intersects(attacker1.body, _enemy.body)){
_enemy.health -= 5
pl.health += 5.5
}
}
})
}
const enemy_collision = function() {
enemies.forEach(_enemy => {
Game.physics.arcade.collide(_enemy, ground)
})
}
const enemy_revive = function() {
enemy.revive()
enemy.health = 50
}