-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMoveToTargetTest.cs
More file actions
70 lines (65 loc) · 1.52 KB
/
MoveToTargetTest.cs
File metadata and controls
70 lines (65 loc) · 1.52 KB
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
using UnityEngine;
using System.Collections;
public class MoveToTargetTest : MonoBehaviour {
public float speed = 15f;
public Transform wayPoint;
public Transform[] wayPointArray;
private int wayPointIndex_=0;
private int health_ = 100;
//for the bullet class and calling up damage
Bullet myBullet = new Bullet();
//private int damage = bulletDamage.damage;
// Use this for initialization
void Start ()
{
wayPoint = wayPointArray [wayPointIndex_];
}
// Update is called once per frame
void Update () {
if (wayPointIndex_ < wayPointArray.Length)
{
ChangePosition ();
}
else
{
Destroy(gameObject);
}
//TEST
//Assert (wayPointIndex_ <= wayPointArray.Length);
//Assert (rigidbody.velocity.x == speed || rigidbody.velocity.y == speed);
}
void ChangePosition()
{
if (wayPoint)
{
transform.position = Vector3.MoveTowards (transform.position, wayPoint.transform.position, speed * Time.deltaTime);
}
}
void OnTriggerEnter (Collider collider)
{
myBullet.Damage = 50;
int damage = myBullet.Damage;
if (collider.gameObject.tag == "Turn") {
Debug.Log("EnterTurn");
wayPointIndex_++;
wayPoint = wayPointArray [wayPointIndex_];
}
if (collider.gameObject.tag == "Bullet") {
Debug.Log("Entered!Bullet");
//for testing we will set bullet dmg at 50 so two shots should do it
if (health_ > 50 ){
health_ = health_ - damage;
}
else{
Destroy(gameObject);
}
}
}
void Assert(bool condition)
{
if(!condition)
{
Debug.LogError("Error");
}
}
}