Initial commit: Tiny Tackle Heroes Unity project
This commit is contained in:
@@ -0,0 +1,183 @@
|
||||
using System.Collections;
|
||||
using BumpCombat.Combat;
|
||||
using NUnit.Framework;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
|
||||
namespace BumpCombat.PlayModeTests
|
||||
{
|
||||
public sealed class InteractionFeedbackPlayModeTests
|
||||
{
|
||||
private GameObject feedbackObject;
|
||||
private GameObject targetObject;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
Time.timeScale = 1f;
|
||||
feedbackObject = new GameObject("Feedback Test Host");
|
||||
feedbackObject.AddComponent<SpriteRenderer>();
|
||||
feedbackObject.AddComponent<CombatFeedback>();
|
||||
targetObject = new GameObject("Feedback Test Target");
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
if (targetObject != null)
|
||||
{
|
||||
Object.Destroy(targetObject);
|
||||
}
|
||||
if (feedbackObject != null)
|
||||
{
|
||||
Object.Destroy(feedbackObject);
|
||||
}
|
||||
Time.timeScale = 1f;
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator BreakStatusText_CreatesTextMeshWithoutException()
|
||||
{
|
||||
CombatEvents.RaiseEnemyStagger(targetObject, 1, 1, true);
|
||||
yield return null;
|
||||
|
||||
TextMesh status = FindStatusText("BREAK");
|
||||
Assert.That(status, Is.Not.Null);
|
||||
Assert.That(status.text, Is.EqualTo("BREAK"));
|
||||
Assert.That(status.font, Is.SameAs(Resources.Load<Font>(
|
||||
"Presentation/Fonts/Galmuri9")));
|
||||
Assert.That(status.fontStyle, Is.EqualTo(FontStyle.Normal));
|
||||
LogAssert.NoUnexpectedReceived();
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator ResistStatusText_CreatesTextMeshWithoutException()
|
||||
{
|
||||
CombatEvents.RaiseLaunchResisted(targetObject);
|
||||
yield return null;
|
||||
|
||||
TextMesh status = FindStatusText("RESIST");
|
||||
Assert.That(status, Is.Not.Null);
|
||||
Assert.That(status.text, Is.EqualTo("RESIST"));
|
||||
Assert.That(status.font, Is.SameAs(Resources.Load<Font>(
|
||||
"Presentation/Fonts/Galmuri9")));
|
||||
Assert.That(status.fontStyle, Is.EqualTo(FontStyle.Normal));
|
||||
LogAssert.NoUnexpectedReceived();
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator StatusTextBurst_StaysWithinHeavyLimitAndCleansUp()
|
||||
{
|
||||
CombatFeedback feedback = feedbackObject.GetComponent<CombatFeedback>();
|
||||
for (int i = 0; i < CombatFeedback.MaxConcurrentHeavyEffects + 4; i++)
|
||||
{
|
||||
CombatEvents.RaiseEnemyStagger(targetObject, 1, 1, true);
|
||||
CombatEvents.RaiseLaunchResisted(targetObject);
|
||||
}
|
||||
|
||||
Assert.That(
|
||||
feedback.ActiveHeavyEffectCount,
|
||||
Is.LessThanOrEqualTo(CombatFeedback.MaxConcurrentHeavyEffects));
|
||||
|
||||
yield return new WaitForSecondsRealtime(0.5f);
|
||||
|
||||
Assert.That(FindStatusText("BREAK"), Is.Null);
|
||||
Assert.That(FindStatusText("RESIST"), Is.Null);
|
||||
Assert.That(
|
||||
feedback.ActiveHeavyEffectCount,
|
||||
Is.LessThanOrEqualTo(CombatFeedback.MaxConcurrentHeavyEffects));
|
||||
LogAssert.NoUnexpectedReceived();
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator BumpImpactSheets_ExpireAndRemoveEveryTransientRoot()
|
||||
{
|
||||
CombatFeedback feedback = feedbackObject.GetComponent<CombatFeedback>();
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
CombatEvents.RaiseValidHit(new CombatHitResult(
|
||||
feedbackObject,
|
||||
targetObject,
|
||||
false,
|
||||
HitSide.Side,
|
||||
10f,
|
||||
Vector2.right,
|
||||
1f,
|
||||
new Vector2(i, 0f)));
|
||||
}
|
||||
|
||||
Assert.That(feedback.ActiveBumpImpactVisualCount, Is.EqualTo(8));
|
||||
yield return new WaitForSecondsRealtime(0.08f);
|
||||
|
||||
Time.timeScale = 0f;
|
||||
int pausedCount = feedback.ActiveBumpImpactVisualCount;
|
||||
yield return new WaitForSecondsRealtime(0.1f);
|
||||
Assert.That(feedback.ActiveBumpImpactVisualCount, Is.EqualTo(pausedCount));
|
||||
|
||||
Time.timeScale = 1f;
|
||||
yield return new WaitForSecondsRealtime(0.25f);
|
||||
Assert.That(feedback.ActiveBumpImpactVisualCount, Is.Zero);
|
||||
LogAssert.NoUnexpectedReceived();
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator OrdinaryBumpUsesGradeSheet_ArtifactHitKeepsProceduralFeedback()
|
||||
{
|
||||
CombatFeedback feedback = feedbackObject.GetComponent<CombatFeedback>();
|
||||
CombatEvents.RaiseValidHit(new CombatHitResult(
|
||||
feedbackObject,
|
||||
targetObject,
|
||||
false,
|
||||
HitSide.Back,
|
||||
15f,
|
||||
Vector2.up,
|
||||
1f,
|
||||
new Vector2(0.5f, 0.75f)));
|
||||
|
||||
GameObject bump = GameObject.Find("Bump Impact Strong");
|
||||
Assert.That(bump, Is.Not.Null);
|
||||
Assert.That(bump.transform.position, Is.EqualTo(new Vector3(0.5f, 0.75f, 0f)));
|
||||
Assert.That(bump.transform.eulerAngles.z, Is.EqualTo(90f).Within(0.001f));
|
||||
Assert.That(bump.GetComponent<SpriteRenderer>().color, Is.EqualTo(Color.white));
|
||||
Assert.That(GameObject.Find("Hit Impact"), Is.Null);
|
||||
Assert.That(GameObject.Find("Attack Slash"), Is.Null);
|
||||
|
||||
yield return new WaitForSecondsRealtime(0.2f);
|
||||
Time.timeScale = 1f;
|
||||
CombatEvents.RaiseValidHit(new CombatHitResult(
|
||||
feedbackObject,
|
||||
targetObject,
|
||||
false,
|
||||
HitSide.Front,
|
||||
10f,
|
||||
Vector2.right,
|
||||
1f,
|
||||
Vector2.zero,
|
||||
false,
|
||||
false,
|
||||
DamageTag.Collision,
|
||||
"Pulse"));
|
||||
|
||||
Assert.That(GameObject.Find("Hit Impact"), Is.Not.Null);
|
||||
Assert.That(GameObject.Find("Attack Slash"), Is.Not.Null);
|
||||
Assert.That(GameObject.Find("Bump Impact Weak"), Is.Null);
|
||||
LogAssert.NoUnexpectedReceived();
|
||||
}
|
||||
|
||||
private static TextMesh FindStatusText(string status)
|
||||
{
|
||||
TextMesh[] meshes = Object.FindObjectsByType<TextMesh>(
|
||||
FindObjectsInactive.Include,
|
||||
FindObjectsSortMode.None);
|
||||
foreach (TextMesh mesh in meshes)
|
||||
{
|
||||
if (mesh != null && mesh.gameObject.name == $"Status {status}")
|
||||
{
|
||||
return mesh;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user