2.5d test
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
using System.Reflection;
|
||||
using BumpCombat.Combat;
|
||||
using BumpCombat.Defense.Comparison;
|
||||
using BumpCombat.Player;
|
||||
using NUnit.Framework;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BumpCombat.Tests
|
||||
{
|
||||
public sealed class Defense25DComparisonTests
|
||||
{
|
||||
[Test]
|
||||
public void IndependentSceneExists()
|
||||
{
|
||||
Assert.That(AssetDatabase.LoadAssetAtPath<SceneAsset>(
|
||||
"Assets/_Project/Scenes/Defense25DComparison.unity"), Is.Not.Null);
|
||||
}
|
||||
|
||||
[TestCase(false, .85f, 38.0625f / 32f, 15.03125f / 32f, 3)]
|
||||
[TestCase(true, 1.25f, 46f / 32f, 18f / 32f, 5)]
|
||||
public void CyclonePreservesAuthoredEllipseAndTickSchedule(
|
||||
bool charged, float range, float radiusX, float radiusZ, int count)
|
||||
{
|
||||
Vector2 radii = CycloneGeometry.Radii(range, charged);
|
||||
Assert.That(radii.x, Is.EqualTo(radiusX).Within(.00001f));
|
||||
Assert.That(radii.y, Is.EqualTo(radiusZ).Within(.00001f));
|
||||
Assert.That(CycloneGeometry.ScheduledHitCount(charged ? .65f : .36f, .14f), Is.EqualTo(count));
|
||||
MethodInfo original = typeof(ActiveArtifactController).GetMethod(
|
||||
"GetCycloneHitRadii", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
Assert.That(original.Invoke(null, new object[] { range, charged }), Is.EqualTo(radii));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EllipseUsesBodyEdgeRatherThanGroundCenterOrSphere()
|
||||
{
|
||||
Vector2 radii = CycloneGeometry.Radii(.85f, false);
|
||||
Vector2 bodyCenter = new(0f, radii.y + .2f);
|
||||
Vector2 Closest(Vector2 point) => bodyCenter + Vector2.ClampMagnitude(point - bodyCenter, .24f);
|
||||
Assert.That(CycloneGeometry.Overlaps(Vector2.zero, radii, Closest), Is.True);
|
||||
bodyCenter.y = radii.y + .3f;
|
||||
Assert.That(CycloneGeometry.Overlaps(Vector2.zero, radii, Closest), Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ViewportCentersIntegerUpscaleAndRejectsLetterbox()
|
||||
{
|
||||
Rect rect = Defense25DView.GetViewport(1920, 1080);
|
||||
Assert.That(rect, Is.EqualTo(new Rect(0, 0, 1920, 1080)));
|
||||
rect = Defense25DView.GetViewport(1399, 799);
|
||||
Assert.That(rect.width, Is.EqualTo(1280));
|
||||
Assert.That(rect.height, Is.EqualTo(720));
|
||||
Assert.That(rect.Contains(Vector2.zero), Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SharedBumpDamageStillFloorsOnlyAtFinalBoundary()
|
||||
{
|
||||
Assert.That(DamageCalculator.FinalizeDamage(
|
||||
BumpCombatMath.ApplySideMultiplier(10.9f, HitSide.Side)), Is.EqualTo(13));
|
||||
Assert.That(DamageCalculator.FinalizeDamage(
|
||||
BumpCombatMath.ApplySideMultiplier(10f, HitSide.Back)), Is.EqualTo(15));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2b42d4c49df64f999778421ebe6a83e3
|
||||
@@ -0,0 +1,55 @@
|
||||
using BumpCombat.Defense.Comparison;
|
||||
using BumpCombat.Enemies;
|
||||
using NUnit.Framework;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BumpCombat.Tests
|
||||
{
|
||||
public sealed class Defense25DSkeletonCombatTests
|
||||
{
|
||||
[Test]
|
||||
public void SkeletonSlashUsesSourceBoxFootprintAndRejectsTargetsBehindOrigin()
|
||||
{
|
||||
Assert.That(Defense25DEnemy.SkeletonSlashIntersectsCircle(Vector2.zero, Vector2.right, 1f, .75f,
|
||||
new Vector2(.5f, .49f), .1f), Is.False,
|
||||
"A hurtbox beyond the authored half-width must not be hit.");
|
||||
Assert.That(Defense25DEnemy.SkeletonSlashIntersectsCircle(Vector2.zero, Vector2.right, 1f, .75f,
|
||||
new Vector2(.5f, .45f), .1f), Is.True,
|
||||
"A circular hurtbox overlapping the authored box edge must be hit.");
|
||||
Assert.That(Defense25DEnemy.SkeletonSlashIntersectsCircle(Vector2.zero, Vector2.right, 1f, .75f,
|
||||
new Vector2(-.01f, 0f), .5f), Is.False,
|
||||
"The source attack rejects a target whose collider center is behind the slash origin.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SkeletonAttackAnimationUsesDefinitionLeadTime()
|
||||
{
|
||||
EnemyDefinition skeleton = AssetDatabase.LoadAssetAtPath<EnemyDefinition>(
|
||||
"Assets/_Project/Constants/Enemies/Skeleton.asset");
|
||||
Assert.That(skeleton, Is.Not.Null);
|
||||
EnemyAttackPattern pattern = skeleton.GetAttackPattern(0);
|
||||
|
||||
Assert.That(Defense25DEnemy.SkeletonAttackAnimationShouldStart(pattern, .324f), Is.False);
|
||||
Assert.That(Defense25DEnemy.SkeletonAttackAnimationShouldStart(pattern, .326f), Is.True);
|
||||
Assert.That(pattern.WarningDuration, Is.EqualTo(.7f).Within(.0001f));
|
||||
Assert.That(pattern.AnimationLeadTime, Is.EqualTo(.375f).Within(.0001f));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SkeletonAttackFramesFollowTheNonLoopingSourceClip()
|
||||
{
|
||||
AnimationClip clip = AssetDatabase.LoadAssetAtPath<AnimationClip>(
|
||||
"Assets/_Project/Art/Characters/Skeleton/Animations/Skeleton_Attack.anim");
|
||||
Assert.That(clip, Is.Not.Null);
|
||||
Assert.That(clip.frameRate, Is.EqualTo(8f).Within(.001f));
|
||||
Assert.That(clip.length, Is.EqualTo(.75f).Within(.001f));
|
||||
Assert.That(clip.isLooping, Is.False);
|
||||
Assert.That(Defense25DEnemy.SkeletonAttackFrameAt(clip, .124f, 6), Is.EqualTo(0));
|
||||
Assert.That(Defense25DEnemy.SkeletonAttackFrameAt(clip, .126f, 6), Is.EqualTo(1));
|
||||
Assert.That(Defense25DEnemy.SkeletonAttackFrameAt(clip, 1f, 6), Is.EqualTo(5),
|
||||
"A non-looping source attack holds its last authored frame through recovery.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 799325f1d64440fd8f07e757025dff0e
|
||||
Reference in New Issue
Block a user