-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAttackController.gd
35 lines (27 loc) · 973 Bytes
/
AttackController.gd
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
extends Node
# Const and enum variable declarations:
const Curve_Dive = preload("res://Curve-Dive.tscn")
# Member variable declarations:
var attackList = [] #populated by EnemyController
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func attackRandom():
if(not attackList.empty()):
for j in range(0,round(attackList.size()/2)):
#Select a random attacker
var i = randi() % attackList.size()
var enemy = attackList[i]
#Get
var currentPos = enemy.get_global_transform().get_origin()
enemy.get_parent().remove_child(enemy)
var curveInst = Curve_Dive.instance()
curveInst.get_child(0).add_child(enemy)
enemy.position = Vector2(0,0)
add_child(curveInst)
curveInst.position = currentPos
enemy.state = enemy.STATE.RAIL
#print("A random attacks ")