2.5d test
This commit is contained in:
@@ -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.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user