forked from GCSShatteredSpace/Week-2-Code-Reading
-
Notifications
You must be signed in to change notification settings - Fork 0
/
turret.cs
48 lines (40 loc) · 1.27 KB
/
turret.cs
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
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class turret : MonoBehaviour {
public Vector2 turretPosition;
public Vector2 playerPosition;
public GameObject gameController;
private actionController actrl;
public GameObject actionController;
public GameObject statsCtrl;
public statsController dataBase;
public weaponProperties hitWeapon;
public int moveindex;
public int maxAction;
public Vector3 positionOffset;
public Vector2[,] toInstantiate;
public weaponProperties[,] weapons;
public List<int> attackWeapon = new List <int> ();
public int energy;
public int exp;
void Start () {
gameController = GameObject.Find ("GameController(Clone)");
actionController = GameObject.Find ("actionController");
statsCtrl = GameObject.Find("gameData");
dataBase = statsCtrl.GetComponent<statsController> ();
actrl = actionController.GetComponent<actionController> ();
energy = dataBase.turretHealth;
}
void OnTriggerEnter(Collider other) {
GameObject otherObject = other.gameObject;
if (otherObject.tag == "damage") {
hitWeapon = otherObject.GetComponent<weaponProperties> ();
energy = energy - hitWeapon.damage;
if (energy<=0){
actrl.destoryTurret(turretPosition);
Destroy (this.gameObject);
}
}
}
}