-
Notifications
You must be signed in to change notification settings - Fork 2
/
Program.cs
146 lines (120 loc) · 4.31 KB
/
Program.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
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
using UnityEngine;
namespace TowerDefenseGame
{
[TestFixture]
public class TestSomethign
{
//static void Main(string[] args)
//{
//}
[Test]
public void AutoaimInitialize()
{
Autoaim testAuto = new Autoaim();
//Vector3 position1 = new Vector3(0, 0, 0);
//testAuto.target_.position = position1;
Assert.IsTrue(testAuto.initialized_);
}
[Test]
public void AutoaimPositions()
{
Autoaim testAuto = new Autoaim();
Vector3 position1 = new Vector3(0f, 0f, 0f);
Vector3 position2 = new Vector3(2f, 0f, 0f);
testAuto.SetPositions(position1, position2);
Assert.True(testAuto.targetPosition1_ == position1 && testAuto.targetPosition2_ == position2);
}
[Test]
public void CalculateTargetVelocity()
{
Autoaim testAuto = new Autoaim();
Vector3 returnVelocity;
Vector3 trueVelocity = new Vector3(2f, 0f, 0f);
Vector3 position1 = new Vector3(0f, 0f, 0f);
Vector3 position2 = new Vector3(2f, 0f, 0f);
testAuto.SetPositions(position1, position2);
returnVelocity = testAuto.CalculateTargetVelocity();
Assert.True(returnVelocity == trueVelocity);
}
[Test]
public void CalculateBulletVelocity()
{
float force = 1000f;
float answerVelocity = 20.0f;
Autoaim testAuto = new Autoaim();
testAuto.SetBulletForce(force);
testAuto.CalculateBulletVelocity();
Assert.True(testAuto.bulletVelocity_ == answerVelocity);
}
[Test]
public void CalculateDistance()
{
Autoaim testAuto = new Autoaim();
Vector3 targetPosition = new Vector3(0f, 0f, 0f);
Vector3 turretPosition = new Vector3(2f, 2f, 0f);
float distance;
float answerDistanceman = (float)Math.Sqrt(Math.Pow(2, 2) + Math.Pow(2, 2));
double answerDistance = (double)Vector3.Distance(targetPosition, turretPosition);
testAuto.SetPositions(targetPosition, targetPosition);
testAuto.SetTurretPosition(turretPosition);
distance = testAuto.CalculateDistance();
Assert.True(distance == answerDistanceman);
}
[Test]
public void CalculateTargetSpeed()
{
Autoaim testAuto = new Autoaim();
Vector3 targetPosition = new Vector3(0f, 0f, 0f);
Vector3 turretPosition = new Vector3(2f, 2f, 0f);
testAuto.SetPositions(targetPosition, targetPosition);
testAuto.SetTurretPosition(turretPosition);
float test = (float)Math.Sqrt(Math.Pow(2, 2) + Math.Pow(2, 2));
Assert.True(testAuto.CalculateTargetSpeed() == test);
}
[Test]
public void CalculatePositionToShoot()
{
Autoaim testAuto = new Autoaim();
Vector3 targetPosition1 = new Vector3(0f, 0f, 0f);
Vector3 targetPosition2 = new Vector3(2f, 2f, 0f);
Vector3 turretPosition = new Vector3(3f, 3f, 0f);
testAuto.SetPositions(targetPosition1, targetPosition2);
testAuto.SetTurretPosition(turretPosition);
testAuto.SetBulletForce(1000.0f);
}
[Test]
public void FirstWave()
{
MainGame testMain = new MainGame();
Assert.True(testMain.balloonsInWave_ == 5 && testMain.timeBetweenBalloons_ == 1.0f);
}
[Test]
public void Wave5()
{
MainGame testMain = new MainGame();
for (int i = 0; i < 5; i++)
{
testMain.makeNextWave();
}
Assert.True(testMain.balloonsInWave_ == 20 && testMain.timeBetweenBalloons_ == .9f);
}
[Test]
public void instancesOfMainGame()
{
MainGame testMain = new MainGame();
MainGame copy = new MainGame();
Assert.IsNotNull(copy);
}
}
class Program
{
static int Main()
{ return 0; }
}
}