Relentless Attack
This is the new game inspiration The Army - Idle Strategy Game.
Scriptable Objects
For this project rather than creating the spawning grid each time the game starts, I thought I would rather create a Scriptable Object. This way I was able to draw the grid out side of play time which was helpful for scaling to fit the screen. This was mostly done without tutorials which I am really proud of.
Unit Testing
Following this tutorial Unit Tests in Unity I set up very basic unit testing. Currently just checking if the init()
function of my EnemyBase
class is behaving as expected. But is has gotten me thinking more about what I should and shouldn’t be testing.
With the help of Chat, I have further expanded the Unit tests to include the following:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
public class GameManagerTesting
{
[UnityTest]
public IEnumerator ASoldierSetup_Test()
{
GameObject mGameObject = new GameObject();
GameManager mGameManager = new GameManager();
SceneManager.LoadScene("Soldier");
yield return new WaitForSeconds(2);
Assert.IsTrue(mGameManager.SetUpGameScene(), "Failed to set up the scene correctly");
}
}
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
public class EnemyBaseTesting
{
[Test]
[TestCase(10, true, 10)]
[TestCase(28, true, 100)]
[TestCase(1, false, 1)]
public void AInit_Test(int setHealth, bool isEnemy, int setSpeed)
{
GameObject mGameObject = new GameObject();
EnemyBase mEnemy = mGameObject.AddComponent<EnemyBase>();
Assert.IsNotNull(mEnemy, "Failed to create soldier");
mEnemy.Init(setHealth, isEnemy, setSpeed);
Assert.AreEqual(setHealth, mEnemy.HitPoints, "Failed to set health");
Assert.AreEqual(isEnemy, mEnemy.IsEnemy, "Failed to set enemy");
Assert.AreEqual(setSpeed, mEnemy.Speed, "Failed to set speed");
}
[Test]
[TestCase(10)]
[TestCase(-50)]
public void BAttacked_Test(int attackAmount)
{
GameObject mGameObject = new GameObject();
EnemyBase mEnemy = mGameObject.AddComponent<EnemyBase>();
mEnemy.Init(100, true, 5.0f);
mEnemy.Attacked(attackAmount);
if (attackAmount > 0)
{
Assert.AreEqual(100 - attackAmount, mEnemy.HitPoints, "Failed to reduce hitpoint by accacking amount");
}
else
{
Assert.AreEqual(100, mEnemy.HitPoints, "Failed to filter incorrect attack amounts");
}
}
}
This Medium Article was a fantastic resource I found to add the [TestCase(X,X)]
which just allows you to pass in variables to the testing functions. Even more than one! So far this has successfully found 2 issues with code changes I have made. This was really cool! The tests only pass on as much information as you give them, so the more detail the better!
Commits | Message |
---|---|
1 | Initial commit |
2 | Adding the game |
3 | Continue working on enemy class Implemented simple movement and fixed sprites not colliding. To do: Stop jittering when the enemies bunch up Implement attacking |
4 | Code clean up |
5 | Adding Boundaries Boundaries and continue work on enemy movement. |
6 | Cont. work on enemies |
7 | Trying a character controller for movement |
8 | IT WAS CHARACTER CONTROLLER |
9 | Player spawn and improved code |
10 | Adding player movement |
11 | ATTACKING Implemented a very simple attack! But needs lots of work! |
12 | Fixed attacking |
13 | Building and fixed editor scripts |
14 | Create main.yml |
15 | Testing updated actions |
16 | Fix Ui and implement score |
17 | Added a very simple game loop |
18 | Testing Android build method |
19 | Merge branch ‘build’ |
20 | Closing untiy |
21 | Removing Android as it broke |
22 | Local Android build |
23 | Update main.yml |
24 | Merge branch ‘main’ of https://github.com/ConnorY97/RelentlessAttack |
25 | Merge branch ‘main’ into build |
26 | Cleaning up the workflow |
27 | Setting up Unit Testing Created a simple test for enemy set up. Making sure all the member variables are being set correctly. Currently only testing the attack func. I need to look into how I can make sure editor variables are being set as well. Very cool! |
28 | Adding test runner action |
29 | Merge branch ‘main’ into build |
30 | Testing as a project not as a package, duh |
31 | Purposely failing unity test |
32 | Merge branch ‘main’ into build |
33 | Trying to improve logs |
34 | Fixing test break |
35 | Lots of work! 1. Fixed the Game over UI 2. Improved attack: there is now a delay between each attach so it doesn’t seem so funky 3. Added some more tests |
36 | Merge branch ‘main’ into build |
37 | Fixing hanging test |
38 | Merge branch ‘main’ into build |
39 | Trying to fix itch upload and android build |
40 | Trying to solve windows build |
41 | Maybe missing the matrix? |
42 | Improving Testing and code clean up |
43 | Changed sprites to circles So the sprites should have been circles the whole time. Lol |
44 | Merge branch ‘build’ |
45 | Merge branch ‘main’ into build |
46 | Alex and Chat suggested code improvement |
47 | Merge branch ‘build’ |
48 | Fixing issue found but tests |
49 | Lots of work! 1. Cleaned up the EnemyBase class more. Trying to encapsulate everything all of it inheritors may need.2. Added the Sniper class. This is just a ranged enemy but it will be difficult to work this into the game play.3. Improved on the unit testing but have not set any up for the sniper yet |
50 | Creating a Main menu and levels Removed some magic numbers and continued to work on different enemies |
51 | Main menu main issues Need to figure out how to assign all the required variables when the required scene loads. Lots of work to do. |
52 | Fixed scene loading and added test UI will still be broken on some resolutions though |
53 | Closing Unity |
54 | Updated readme and did some work |
55 | Bullet improvements and colours Added Alex’s suggested changes to the bullet and changed the background colour for the main camera to get rid of the terrible blue. |
56 | Fixing UI and Scaling issues… Hopefully |
57 | Build action set resolution |
58 | Trying a different template |
59 | Trying to copy more settings |
60 | Removing hard code resolution |
61 | Downgrading Unity version |
62 | Removing test runs for the time being |
63 | Stop publishing to itch and just run tests |
64 | Adding bullet tests and improving movment |
65 | You can now spawn snipers |