Compare commits

...

4 Commits

Author SHA1 Message Date
Stedd 93f83c121c WIP Turret tests 2024-10-15 23:45:51 +02:00
Stedd 0969be4955 Submodule updates 2024-10-15 23:45:40 +02:00
Stedd 13fcafa4fc Turret only draws power while active 2024-10-15 23:45:23 +02:00
Stedd bed0fabc4e Changed kill and damage dealt stats to ints 2024-10-15 23:45:03 +02:00
9 changed files with 2109 additions and 4 deletions

@ -1 +1 @@
Subproject commit cf3cf65b068d861d5bd65db2fbbb53a55f5bbf4d
Subproject commit ea2119913ae05cb512b9e5bc3b28b88e50ade9af

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 35a6473e8e64e19c69b5a2aa7cf193d3
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,22 @@
{
"name": "Turret",
"rootNamespace": "",
"references": [
"UnityEngine.TestRunner",
"UnityEditor.TestRunner",
"Entities"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [
"nunit.framework.dll"
],
"autoReferenced": false,
"defineConstraints": [
"UNITY_INCLUDE_TESTS"
],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 3ab67724d349675b1a6a9081eb70e62a
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f6189f795d25322fa93a6fcde3bd4b2a
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,70 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using AsteroidGame.Entities;
using NUnit.Framework;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.Serialization;
using UnityEngine.TestTools;
using Assert = UnityEngine.Assertions.Assert;
public class TurretTestScript : MonoBehaviour
{
[SerializeField] private List<Turret> _turrets;
[SerializeField] private EnemyBase _enemy;
[UnitySetUp]
public IEnumerator LoadScene()
{
// Load the scene asynchronously and wait until it's fully loaded
var asyncLoad = SceneManager.LoadSceneAsync("TurretTestScene");
while (!asyncLoad.isDone)
{
yield return null;
}
_turrets = new();
_turrets = FindObjectsOfType<Turret>().ToList();
_enemy = new();
_enemy = FindObjectOfType<EnemyBase>();
}
// // A Test behaves as an ordinary method
// [Test]
// public void NewTestScriptSimplePasses()
// {
// // Use the Assert class to test conditions
// }
//
// // A UnityTest behaves like a coroutine in Play Mode. In Edit Mode you can use
// // `yield return null;` to skip a frame.
// [UnityTest]
// public IEnumerator NewTestScriptWithEnumeratorPasses()
// {
// // Use the Assert class to test conditions.
// // Use yield to skip a frame.
// yield return null;
// }
[UnityTest]
public IEnumerator OnlyOneTurretGetsTheKill()
{
var totalKillCount = 0;
if (_enemy != null)
{
yield return null;
}
else
{
foreach (var turret in _turrets)
{
totalKillCount += turret.Kills;
}
}
Assert.IsTrue(totalKillCount == 1);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 565b0512bfe5540aebdda54c45668c3c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -12,9 +12,9 @@ namespace AsteroidGame.Entities
[SerializeField] private float _projectileSpeed = 5;
[field: Header("Stats")]
[field: SerializeField] public float Kills { get; set; }
[field: SerializeField] public int Kills { get; set; }
[field: SerializeField] public float DamageDealt { get; set; }
[field: SerializeField] public int DamageDealt { get; set; }
[field: Header("Weapon")]
[field: SerializeField] public List<Weapon> Weapons { get; set; }
@ -73,7 +73,7 @@ namespace AsteroidGame.Entities
private void TurnOffWeapons()
{
//powerSystem.SetCurrentPower(0);
powerSystem.SetCurrentPower(0);
foreach (var weapon in Weapons)
{
weapon.FireWeapon = false;